Socket
Socket
Sign inDemoInstall

@nextgis/webmap

Package Overview
Dependencies
Maintainers
3
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nextgis/webmap - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

16

lib/index.d.ts

@@ -70,3 +70,3 @@ /**

*/
export declare interface AdapterOptions<A extends Record<string, any> = Record<string, any>, N extends Record<string, any> = Record<string, any>> {
export declare interface AdapterOptions<ANYPROPS extends Record<string, any> = Record<string, any>, NATIVE extends Record<string, any> = Record<string, any>> {
/**

@@ -155,5 +155,9 @@ * Unique Layer ID.

*/
props?: A;
/** Map and layer adapter base options */
nativeOptions?: N;
props?: ANYPROPS;
/**
* Map and layer adapter base options
* Use with care.
* There may be a conflict in the addLayer method by the adapter of the NextGIS Frontend library
*/
nativeOptions?: NATIVE;
ratio?: number;

@@ -982,3 +986,3 @@ /** Experimental only for Ol yet */

export declare interface VectorAdapterOptions<F extends Feature = Feature, L = any, A = Record<string, any>, N = Record<string, any>, P = F['properties']> extends _VectorAdapterOptionsToExtend<A, N> {
export declare interface VectorAdapterOptions<F extends Feature = Feature, L = any, A = Record<string, any>, N = Record<string, any>, P = F['properties']> extends _VectorAdapterOptionsToExtend<P, A, N> {
/** Type for geometries painting, for each layer may be only one of: `point`, `polygon` or `line`. */

@@ -1099,3 +1103,3 @@ type?: VectorAdapterLayerType;

declare type _VectorAdapterOptionsToExtend<A extends Record<string, any> = Record<string, any>, N extends Record<string, any> = Record<string, any>> = AdapterOptions<A, N> & FilterOptions;
declare type _VectorAdapterOptionsToExtend<P extends Record<string, any> = Record<string, any>, A extends Record<string, any> = Record<string, any>, N extends Record<string, any> = Record<string, any>> = AdapterOptions<A, N> & FilterOptions<P>;

@@ -1102,0 +1106,0 @@ /**

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@nextgis/paint"),e=require("@nextgis/properties-filter"),s=require("events"),i=require("@nextgis/utils");function r(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var o=r(require("@nextgis/cancelable-promise"));function a(t){const e={};for(let s=0;s<t.length;s++)e[t[s]]=1+(e[t[s]]||0);let s;for(const t in e){e[t]>((void 0!==s?e[s]:0)||0)&&(s=t)}return s}function n(t){let e;if("FeatureCollection"===t.type){e=a(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=a(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const d={polygon:"path",line:"path",point:"circle"},h={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function l(e){if(e.data){const s=h[n(e.data)],i=e.paint;i&&t.isPaint(i)&&(i.type=i.type?i.type:"polygon"===s||"line"===s?"path":"html"in i||"className"in i?"icon":d[s]),e.type=e.type||s}return e}class p{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class c{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class y extends c{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class m extends c{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let u=0;const f={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class L{constructor(t){this.options=f,this.emitter=new s.EventEmitter,this.keys=L.keys,this.runtimeParams=[],this.getPaintFunctions=L.getPaintFunctions,this.mapState=[y,m],this.id=u++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=i.deepmerge(f||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const s of this.runtimeParams){const i=s.get(e.name);if(void 0!==i){t[e.name]=e.parse(i);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return i.getBoundsFeature(t)}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){return this.mapAdapter.getZoom()}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(t){this.setZoom(t-1)}}}setView(t,e){this.mapAdapter.setView&&t&&i.defined(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),i.defined(e)&&this.mapAdapter.setZoom(e))}fitBounds(t,e){return t.every((t=>i.defined(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var s;const i=()=>{const s=this.mapAdapter;t&&t(s),s&&e(s)},r=null===(s=this.mapAdapter.isLoaded)||void 0===s||s;this.mapAdapter.map&&r?i():this.mapAdapter.emitter.once("create",(()=>{i()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new o(((t,e,s)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const o=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",a),this._coordFromMapClickPromise=void 0},a=e=>{o(),i.deprecatedMapClick(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",a),s(o)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const s=t;this._eventsStatus[s]=!0,this.emitter.emit(s,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),i.defined(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),i.defined(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),i.defined(t.maxzoom)&&i.defined(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:s}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):s&&this.fitBounds(s)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const s=e.get(t.name);if(void 0!==s){const e=t.parse(s);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((s=>{s.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}L.keys=new class{constructor(){this.keyCodeAlias=new p,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class g extends L{constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const s=this.getLayer(t),i=s&&(s.getBounds||s.getExtent);if(i){const t=await i.call(s);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const s=this._layers[e];s&&t.push(s)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const s=this._layers[e];if(t(s))return s}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},s){var r,o;const a=this._layersIdCounter++,n=i.defined(s)?s:void 0!==e.order?e.order:this.reserveOrder();let d;"string"==typeof t?d=this.getLayerAdapter(t):"function"==typeof t?d=t:"then"in t&&(d=await t);const h=e;this._updateGeoJsonOptions(h);const{maxZoom:l,minZoom:p}=this.options,c=null===(r=(e={id:String(a),order:n,maxZoom:l,minZoom:p,...e}).visibility)||void 0===r||r;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:d});t&&(t.options&&(e=t.options),t.adapter&&(d=t.adapter))}if(void 0!==d){const t=new d(this.mapAdapter.map,e);let s;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(s=String(t.options.id),this._layers[s]=t),this._emitLayerEvent("layer:preadd",s||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const i=await t.addLayer(t.options);if(t.layer=i,t.id=t.options.id||String(a),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(o=t.options.order)&&void 0!==o?o:n,s&&delete this._layers[s],s=String(t.id),this._layers[s])throw Error(`layer with id '${s}' already exist`);s&&(this._layers[s]=t,h.filter&&this.filterLayer(t,h.filter),e.baselayer&&this._baselayers.push(s),c&&await this.showLayer(s));const r=e.opacity;void 0!==r&&r<=1&&this.setLayerOpacity(t,r);const l=i&&(t.getBounds||t.getExtent);if(e.fit&&l){const e=await l.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",s,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,s){const i=s||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,i):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let s=!0;t&&(s=t(e,this._layers[e])),s&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),s=e&&this.getLayerId(e);if(e&&s){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(s);t&&this._baselayers.splice(t,1)}delete this._layers[s],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=l(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,s={}){const i=this.getLayer(t),r=void 0!==e?e:!(i&&i.options.visibility),o=void 0!==s.silent&&s.silent,a=async t=>{const e=String(t.id),s=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.find((e=>e!==t.id&&this.isLayerVisible(e)));e&&await this.hideLayer(e)}t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer);o||(this._emitLayerEvent(s,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=r};return i&&i.options.visibility!==r?this.onMapLoad().then((()=>a(i))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))}setLayerOpacity(t,e){const s=this.getLayer(t);s&&(s.setOpacity?s.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(s.layer,e))}selectLayer(t,e){const s=this.getLayer(t);if(s){const t=s;t&&t.select&&t.select(e);const i=this.getLayerId(s);i&&this._selectedLayers.push(i)}}unSelectLayer(t,e){const s=this.getLayer(t);if(s){const t=s&&s;t.unselect&&t.unselect(e);const i=this.getLayerId(s);if(i){const t=this._selectedLayers.indexOf(i);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const s=this.getLayer(t);return s.filter?s.filter(e):[]}propertiesFilter(t,s,i){const r=this.getLayer(t);if(!r)return;const o=r;o.propertiesFilter?o.propertiesFilter(s,i):o.filter&&this.filterLayer(o,(t=>!t.feature||!t.feature.properties||e.propertiesFilter(t.feature.properties,s)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const s=this.getLayer(t);if(s){if(s.setData)return s.setData(e);if(s.clearLayer&&s.addData)return s.clearLayer(),s.addData(e)}return Promise.resolve()}addLayerData(t,e){const s=this.getLayer(t);s.addData&&s.addData(e)}clearLayerData(t,e){const s=this.getLayer(t);s&&s.clearLayer&&s.clearLayer(e)}getAttributions(t){const e=[];for(const s in this._layers){const i=this._layers[s];let r=!(void 0===t.onlyVisible||t.onlyVisible)||i.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(s)),r){const t=i.options&&i.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(e){const{onSelect:s,onLayerSelect:r,onClick:o,onLayerClick:a,onMouseOut:n,onMouseOver:d}=e,h=o||a;e.onClick=t=>(h&&h(t),this._onLayerClick(t)),e.onMouseOut=t=>{const e=t.layer.id;n&&n(t),i.defined(e)&&this._emitLayerEvent("layer:mouseout",e,t)},e.onMouseOver=t=>{const e=t.layer.id;d&&d(t),i.defined(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const l=s||r;e.onSelect=t=>(l&&l(t),this._onLayerSelect(t)),e.nativePaint||(this.options.paint&&(e.paint=t.preparePaint(e.paint||{},this.options.paint,this.getPaintFunctions)),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=t.preparePaint(e.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}_emitLayerEvent(t,e,s){if(i.defined(e)&&t.startsWith("layer:")){const i=t.replace("layer:","layer-"+e+":");this.emitter.emit(i,s)}this.emitter.emit(t,s)}}function _(t,e){const s=document.createElement("div");let i=!1;e.getStatus?i=e.getStatus():e.status&&(i=e.status);const r=e.title||"",o=e.html;function a(){r&&(s.title="string"==typeof r?r:i?r.on:r.off,s.setAttribute("aria-label",s.title))}function n(t){t instanceof HTMLElement?(s.innerHTML="",s.appendChild(t)):"string"==typeof t&&(s.innerHTML=t)}function d(){o&&("string"==typeof o||o instanceof HTMLElement?n(o):n(i?o.on:o.off),s.setAttribute("aria-label",s.title))}function h(t,e){t.split(" ").forEach((t=>{e?s.classList.add(t):s.classList.remove(t)}))}function l(){e.addClassOn&&h(e.addClassOn,i),e.addClassOff&&h(e.addClassOff,!i)}a(),d(),e.addClass&&h(e.addClass,!0),l();const p=t=>{void 0!==t&&(i=t),d(),a(),l()},c=t=>{if(i=void 0!==t?t:!i,e.onClick){const t=e.onClick(i);Promise.resolve(t).then((()=>p())).catch((()=>i=!i))}else p()},y=t({html:s,onClick:c});return y.onClick=c,y.changeStatus=p,y}class v extends g{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,s){let i;if(e=null!=e?e:"top-left",i="string"==typeof t?this.getControl(t,s):t,i)return new Promise((t=>{this._setControlQueue(e,(async()=>{const s=await i,r=this.mapAdapter.addControl(s,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?_(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const s=this.mapAdapter.controlAdapters[t];if(s)return new s(e);{const s=v.controls[t];if(s)return s(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}v.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const C={};function w(t){return C[t]}class b extends v{constructor(t){super(t),this._addControls(),C[this.id]=this}static get(t){return w(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const t of this._starterKits)if(t.onLoadSync)try{await t.onLoadSync.call(t,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,s={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(s=this.options.controlsOptions[t],void 0!==s.control&&(e=s.control));const{position:i,...r}=s;this.addControl(e,i||"top-left",r)})),this._emitStatusEvent("controls:create")}}exports.WebMap=b,exports.WebMapControls=v,exports.WebMapLayers=g,exports.WebMapMain=L,exports.createToggleControl=_,exports.createWebMap=async function(t){return new b(t).onLoad()},exports.detectGeometryType=n,exports.findMostFrequentGeomType=a,exports.getWebMap=w,exports.updateGeoJsonAdapterOptions=l;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@nextgis/paint"),e=require("@nextgis/properties-filter"),s=require("events"),i=require("@nextgis/utils");function r(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var o=r(require("@nextgis/cancelable-promise"));function a(t){const e={};for(let s=0;s<t.length;s++)e[t[s]]=1+(e[t[s]]||0);let s;for(const t in e){e[t]>((void 0!==s?e[s]:0)||0)&&(s=t)}return s}function n(t){let e;if("FeatureCollection"===t.type){e=a(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=a(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const d={polygon:"path",line:"path",point:"circle"},h={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function l(e){if(e.data){const s=h[n(e.data)],i=e.paint;i&&t.isPaint(i)&&(i.type=i.type?i.type:"polygon"===s||"line"===s?"path":"html"in i||"className"in i?"icon":d[s]),e.type=e.type||s}return e}class p{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class c{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class y extends c{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class m extends c{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let u=0;const f={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class L{constructor(t){this.options=f,this.emitter=new s.EventEmitter,this.keys=L.keys,this.runtimeParams=[],this.getPaintFunctions=L.getPaintFunctions,this.mapState=[y,m],this.id=u++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=i.deepmerge(f||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const s of this.runtimeParams){const i=s.get(e.name);if(void 0!==i){t[e.name]=e.parse(i);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return i.getBoundsFeature(t)}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){return this.mapAdapter.getZoom()}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(t){this.setZoom(t-1)}}}setView(t,e){this.mapAdapter.setView&&t&&i.defined(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),i.defined(e)&&this.mapAdapter.setZoom(e))}fitBounds(t,e){return t.every((t=>i.defined(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var s;const i=()=>{const s=this.mapAdapter;t&&t(s),s&&e(s)},r=null===(s=this.mapAdapter.isLoaded)||void 0===s||s;this.mapAdapter.map&&r?i():this.mapAdapter.emitter.once("create",(()=>{i()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new o(((t,e,s)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const o=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",a),this._coordFromMapClickPromise=void 0},a=e=>{o(),i.deprecatedMapClick(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",a),s(o)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const s=t;this._eventsStatus[s]=!0,this.emitter.emit(s,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),i.defined(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),i.defined(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),i.defined(t.maxzoom)&&i.defined(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:s}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):s&&this.fitBounds(s)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const s=e.get(t.name);if(void 0!==s){const e=t.parse(s);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((s=>{s.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}L.keys=new class{constructor(){this.keyCodeAlias=new p,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class g extends L{constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const s=this.getLayer(t),i=s&&(s.getBounds||s.getExtent);if(i){const t=await i.call(s);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const s=this._layers[e];s&&t.push(s)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const s=this._layers[e];if(t(s))return s}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},s){var r,o;const a=this._layersIdCounter++,n=i.defined(s)?s:void 0!==e.order?e.order:this.reserveOrder();let d;"string"==typeof t?d=this.getLayerAdapter(t):"function"==typeof t?d=t:"then"in t&&(d=await t);const h=e;this._updateGeoJsonOptions(h);const{maxZoom:l,minZoom:p}=this.options,c=null===(r=(e={id:String(a),order:n,maxZoom:l,minZoom:p,...e}).visibility)||void 0===r||r;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:d});t&&(t.options&&(e=t.options),t.adapter&&(d=t.adapter))}if(void 0!==d){const t=new d(this.mapAdapter.map,e);let s;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(s=String(t.options.id),this._layers[s]=t),this._emitLayerEvent("layer:preadd",s||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const i=await t.addLayer(t.options);if(t.layer=i,t.id=t.options.id||String(a),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(o=t.options.order)&&void 0!==o?o:n,s&&delete this._layers[s],s=String(t.id),this._layers[s])throw Error(`layer with id '${s}' already exist`);s&&(this._layers[s]=t,h.filter&&this.filterLayer(t,h.filter),e.baselayer&&this._baselayers.push(s),c&&await this.showLayer(s));const r=e.opacity;void 0!==r&&r<=1&&this.setLayerOpacity(t,r);const l=i&&(t.getBounds||t.getExtent);if(e.fit&&l){const e=await l.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",s,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,s){const i=s||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,i):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let s=!0;t&&(s=t(e,this._layers[e])),s&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),s=e&&this.getLayerId(e);if(e&&s){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(s);t&&this._baselayers.splice(t,1)}delete this._layers[s],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=l(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,s={}){const i=this.getLayer(t),r=void 0!==e?e:!(i&&i.options.visibility),o=void 0!==s.silent&&s.silent,a=async t=>{const e=String(t.id),s=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.filter((e=>e!==t.id&&this.isLayerVisible(e)));for(const t of e)await this.hideLayer(t)}t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer);o||(this._emitLayerEvent(s,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=r};return i&&i.options.visibility!==r?this.onMapLoad().then((()=>a(i))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))}setLayerOpacity(t,e){const s=this.getLayer(t);s&&(s.setOpacity?s.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(s.layer,e))}selectLayer(t,e){const s=this.getLayer(t);if(s){const t=s;t&&t.select&&t.select(e);const i=this.getLayerId(s);i&&this._selectedLayers.push(i)}}unSelectLayer(t,e){const s=this.getLayer(t);if(s){const t=s&&s;t.unselect&&t.unselect(e);const i=this.getLayerId(s);if(i){const t=this._selectedLayers.indexOf(i);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const s=this.getLayer(t);return s.filter?s.filter(e):[]}propertiesFilter(t,s,i){const r=this.getLayer(t);if(!r)return;const o=r;o.propertiesFilter?o.propertiesFilter(s,i):o.filter&&this.filterLayer(o,(t=>!t.feature||!t.feature.properties||e.propertiesFilter(t.feature.properties,s)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const s=this.getLayer(t);if(s){if(s.setData)return s.setData(e);if(s.clearLayer&&s.addData)return s.clearLayer(),s.addData(e)}return Promise.resolve()}addLayerData(t,e){const s=this.getLayer(t);s.addData&&s.addData(e)}clearLayerData(t,e){const s=this.getLayer(t);s&&s.clearLayer&&s.clearLayer(e)}getAttributions(t){const e=[];for(const s in this._layers){const i=this._layers[s];let r=!(void 0===t.onlyVisible||t.onlyVisible)||i.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(s)),r){const t=i.options&&i.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(e){const{onSelect:s,onLayerSelect:r,onClick:o,onLayerClick:a,onMouseOut:n,onMouseOver:d}=e,h=o||a;e.onClick=t=>(h&&h(t),this._onLayerClick(t)),e.onMouseOut=t=>{const e=t.layer.id;n&&n(t),i.defined(e)&&this._emitLayerEvent("layer:mouseout",e,t)},e.onMouseOver=t=>{const e=t.layer.id;d&&d(t),i.defined(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const l=s||r;e.onSelect=t=>(l&&l(t),this._onLayerSelect(t)),e.nativePaint||(this.options.paint&&(e.paint=t.preparePaint(e.paint||{},this.options.paint,this.getPaintFunctions)),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=t.preparePaint(e.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}_emitLayerEvent(t,e,s){if(i.defined(e)&&t.startsWith("layer:")){const i=t.replace("layer:","layer-"+e+":");this.emitter.emit(i,s)}this.emitter.emit(t,s)}}function _(t,e){const s=document.createElement("div");let i=!1;e.getStatus?i=e.getStatus():e.status&&(i=e.status);const r=e.title||"",o=e.html;function a(){r&&(s.title="string"==typeof r?r:i?r.on:r.off,s.setAttribute("aria-label",s.title))}function n(t){t instanceof HTMLElement?(s.innerHTML="",s.appendChild(t)):"string"==typeof t&&(s.innerHTML=t)}function d(){o&&("string"==typeof o||o instanceof HTMLElement?n(o):n(i?o.on:o.off),s.setAttribute("aria-label",s.title))}function h(t,e){t.split(" ").forEach((t=>{e?s.classList.add(t):s.classList.remove(t)}))}function l(){e.addClassOn&&h(e.addClassOn,i),e.addClassOff&&h(e.addClassOff,!i)}a(),d(),e.addClass&&h(e.addClass,!0),l();const p=t=>{void 0!==t&&(i=t),d(),a(),l()},c=t=>{if(i=void 0!==t?t:!i,e.onClick){const t=e.onClick(i);Promise.resolve(t).then((()=>p())).catch((()=>i=!i))}else p()},y=t({html:s,onClick:c});return y.onClick=c,y.changeStatus=p,y}class v extends g{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,s){let i;if(e=null!=e?e:"top-left",i="string"==typeof t?this.getControl(t,s):t,i)return new Promise((t=>{this._setControlQueue(e,(async()=>{const s=await i,r=this.mapAdapter.addControl(s,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?_(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const s=this.mapAdapter.controlAdapters[t];if(s)return new s(e);{const s=v.controls[t];if(s)return s(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}v.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const C={};function w(t){return C[t]}class b extends v{constructor(t){super(t),this._addControls(),C[this.id]=this}static get(t){return w(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const t of this._starterKits)if(t.onLoadSync)try{await t.onLoadSync.call(t,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,s={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(s=this.options.controlsOptions[t],void 0!==s.control&&(e=s.control));const{position:i,...r}=s;this.addControl(e,i||"top-left",r)})),this._emitStatusEvent("controls:create")}}exports.WebMap=b,exports.WebMapControls=v,exports.WebMapLayers=g,exports.WebMapMain=L,exports.createToggleControl=_,exports.createWebMap=async function(t){return new b(t).onLoad()},exports.detectGeometryType=n,exports.findMostFrequentGeomType=a,exports.getWebMap=w,exports.updateGeoJsonAdapterOptions=l;
//# sourceMappingURL=webmap.cjs.prod.js.map

@@ -1,2 +0,2 @@

function t(t){return"function"==typeof t}const e={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){const[s,...r]=e;let o=s;Array.isArray(s)&&(o=i(t,s));const n=r.splice(-1,r.length%2)[0];for(let t=0;t<r.length-1;t+=2){if(r[t]===o)return r[t+1]}return n}};function i(t,i){const[s,...r]=i,o=e[s];if(o)return o(t,r)}function s(t){return e=>i(e,t)}const r=["iconSize","iconAnchor"];function o(t,e,i){if((e=String(e))===(t=String(t)))return!0;if(i&&e.toUpperCase()===t.toUpperCase())return!0;const s=`^${r=e,r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var r;return null!==new RegExp(s,i?"i":"").exec(t)}const n={gt:(t,e)=>t>e,lt:(t,e)=>t<e,ge:(t,e)=>t>=e,le:(t,e)=>t<=e,eq:(t,e)=>t===e,ne:(t,e)=>t!==e,in:(t,e)=>-1!==e.indexOf(t),notin:(t,e)=>-1===e.indexOf(t),like:(t,e)=>o(t,e),ilike:(t,e)=>o(t,e,!0)};function a(t,e){const i="string"==typeof e[0]?e[0]:"all",s=e=>{if(3===(i=e).length&&"string"==typeof i[0]&&"string"==typeof i[1]){const[i,s,r]=e,o=n[s];if(o){if(("like"===s||"ilike"===s)&&"string"==typeof i){let e="";const s=i.replace(/^%?(\w+)%?$/,((s,o)=>(e=t[o],i.replace(o,r))));return o(e,s)}return o(t[i],r)}return!1}return a(t,e);var i},r=e.filter((t=>Array.isArray(t)));return"any"===i?r.some(s):r.every(s)}function l(t){let e={};const i=[];return t.forEach((t=>{t&&(Array.isArray(t)?i.push(t):e=t)})),t=>{const s=i.find((e=>function(t,e){const i={...t.properties};return!!i&&(i.$id=t.id,a(i,e))}(t,e[0])));return s?{...e,...s[1]}:e}}function c(e,i,o){if(!e)throw new Error("paint is empty");let n={...i};if(t(e)){const t=t=>{const s=c(e(t),i,o);return s.type=e.type,s};return t.type=e.type,t}if(function(t){return!!Array.isArray(t)}(e))return t=>c(l(e)(t),i,o);if("get-paint"===e.type){const t=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){const i=e[t.from];if(i)return i(t.options)}}(e,o);t&&(n=c(t,i,o))}else{if("icon"===e.type)return e;{const t=function(t){let e=!1;const i={};for(const o in t)if(-1===r.indexOf(o)){const r=o,n=t[r];Array.isArray(n)&&(e=!0,i[r]=s(n))}if(e)return e=>{const s={};for(const t in i)s[t]=i[t](e);return{...t,...s}}}(e);if(t)return e=>c(t(e),i,o);n={...n,...e},n.fill=void 0===n.fill||n.fill,n.stroke=void 0!==n.stroke?n.stroke:!n.fill||!(!n.strokeColor&&!n.strokeOpacity)}}return t(n)||("color"in n&&(n.strokeColor||(n.strokeColor=n.color),n.fillColor||(n.fillColor=n.color)),"opacity"in n&&(void 0===n.strokeOpacity&&(n.strokeOpacity=n.opacity),void 0===n.fillOpacity&&(n.fillOpacity=n.opacity))),n}function h(t){const e={};for(let i=0;i<t.length;i++)e[t[i]]=1+(e[t[i]]||0);let i;for(const t in e){e[t]>((void 0!==i?e[i]:0)||0)&&(i=t)}return i}function p(t){let e;if("FeatureCollection"===t.type){e=h(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=h(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const d={polygon:"path",line:"path",point:"circle"},u={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function y(t){if(t.data){const e=u[p(t.data)],i=t.paint;i&&"[object Object]"===Object.prototype.toString.call(i)&&(i.type=i.type?i.type:"polygon"===e||"line"===e?"path":"html"in i||"className"in i?"icon":d[e]),t.type=t.type||e}return t}var m,f={exports:{}},v="object"==typeof Reflect?Reflect:null,_=v&&"function"==typeof v.apply?v.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};m=v&&"function"==typeof v.ownKeys?v.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var g=Number.isNaN||function(t){return t!=t};function L(){L.init.call(this)}f.exports=L,f.exports.once=function(t,e){return new Promise((function(i,s){function r(i){t.removeListener(e,o),s(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",r),i([].slice.call(arguments))}x(t,e,o,{once:!0}),"error"!==e&&function(t,e,i){"function"==typeof t.on&&x(t,"error",e,i)}(t,r,{once:!0})}))},L.EventEmitter=L,L.prototype._events=void 0,L.prototype._eventsCount=0,L.prototype._maxListeners=void 0;var w=10;function C(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function b(t){return void 0===t._maxListeners?L.defaultMaxListeners:t._maxListeners}function A(t,e,i,s){var r,o,n,a;if(C(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),n=o[e]),void 0===n)n=o[e]=i,++t._eventsCount;else if("function"==typeof n?n=o[e]=s?[i,n]:[n,i]:s?n.unshift(i):n.push(i),(r=b(t))>0&&n.length>r&&!n.warned){n.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=n.length,a=l,console&&console.warn&&console.warn(a)}return t}function E(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function k(t,e,i){var s={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},r=E.bind(s);return r.listener=i,s.wrapFn=r,r}function O(t,e,i){var s=t._events;if(void 0===s)return[];var r=s[e];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(r):S(r,r.length)}function P(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function S(t,e){for(var i=new Array(e),s=0;s<e;++s)i[s]=t[s];return i}function x(t,e,i,s){if("function"==typeof t.on)s.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function r(o){s.once&&t.removeEventListener(e,r),i(o)}))}}function M(t){return null!=t}function F(t,e,i=!1){let s=t;const r=e,o=Array.isArray(r);let n=o&&[]||{};return o&&Array.isArray(r)?i?(s=s||[],n=n.concat(s),r.forEach(((t,e)=>{void 0===n[e]?n[e]=t:"object"==typeof t?n[e]=F(s[e],t,i):-1===s.indexOf(t)&&n.push(t)}))):n=r:(s&&"object"==typeof s&&Object.keys(s).forEach((function(t){n[t]=s[t]})),Object.keys(r).forEach((function(t){n[t]="object"==typeof r[t]&&r[t]&&"object"==typeof s[t]&&"object"==typeof r[t]?F(s[t],r[t],i):r[t]}))),n}function j(t){return{type:"Polygon",coordinates:[T(t)]}}function T(t){const e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}Object.defineProperty(L,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(t){if("number"!=typeof t||t<0||g(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");w=t}}),L.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},L.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||g(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},L.prototype.getMaxListeners=function(){return b(this)},L.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var s="error"===t,r=this._events;if(void 0!==r)s=s&&void 0===r.error;else if(!s)return!1;if(s){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var n=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw n.context=o,n}var a=r[t];if(void 0===a)return!1;if("function"==typeof a)_(a,this,e);else{var l=a.length,c=S(a,l);for(i=0;i<l;++i)_(c[i],this,e)}return!0},L.prototype.on=L.prototype.addListener=function(t,e){return A(this,t,e,!1)},L.prototype.prependListener=function(t,e){return A(this,t,e,!0)},L.prototype.once=function(t,e){return C(e),this.on(t,k(this,t,e)),this},L.prototype.prependOnceListener=function(t,e){return C(e),this.prependListener(t,k(this,t,e)),this},L.prototype.off=L.prototype.removeListener=function(t,e){var i,s,r,o,n;if(C(e),void 0===(s=this._events))return this;if(void 0===(i=s[t]))return this;if(i===e||i.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete s[t],s.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){n=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,r),1===i.length&&(s[t]=i[0]),void 0!==s.removeListener&&this.emit("removeListener",t,n||e)}return this},L.prototype.removeAllListeners=function(t){var e,i,s;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var r,o=Object.keys(i);for(s=0;s<o.length;++s)"removeListener"!==(r=o[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(s=e.length-1;s>=0;s--)this.removeListener(t,e[s]);return this},L.prototype.listeners=function(t){return O(this,t,!0)},L.prototype.rawListeners=function(t){return O(this,t,!1)},L.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):P.call(t,e)},L.prototype.listenerCount=P,L.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]};class z extends Error{constructor(){super(),this.name="CancelError",Object.setPrototypeOf(this,z.prototype)}}class B{constructor(t={}){this.options=t,this._promises=new Map}get isLoaded(){return this._promises.size>0}remove(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())}get(t){return this._promises.get(t)}add(t,e){const i=e||t,s=this._promises.get(i);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),s||(this._promises.set(i,t),t.finally((()=>{this.remove(i)})),t)}abort(){this.isLoaded&&(this._promises.forEach((t=>{t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())}waitFunc(t,e=""){const i=this.get(e=e||t.name);return i||this.add(t(),e)}WaitForMe(t=""){const e=this.get.bind(this),i=this.add.bind(this);return function(s,r,o){const n=o.value;return t=t||r,o.value=function(...s){const r=e(t);if(r)return r;return i(n.apply(this,s),t)},o}}GetOrCreateDecorator(t=""){return this.WaitForMe(t)}_onStop(){this.options.onStop&&!this.isLoaded&&this.options.onStop()}}class I extends Error{constructor(){super(),this.name="TimeoutError",Object.setPrototypeOf(this,I.prototype)}}const Z=(t,e,i,s)=>{try{t(i(s))}catch(t){e(t)}};let R=0;class V{constructor(t,e){this.id=R++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise(((t,e)=>{this._setCanceledCallback=e=>t(e||new z)}));const i=[this._cancelPromise,new Promise(((e,i)=>t((t=>{t instanceof V?this.attach(t):this._isPending=!1,e(t)}),(t=>{this._isPending=!1,i(t)}),(t=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(t)}))))];e&&i.push(new Promise(((t,i)=>{setTimeout((()=>{if(this._isPending)try{this.cancel()}finally{i(new I)}}),e)}))),this._promise=Promise.race(i)}static createControl(t){return new B(t)}static resolve(t){return new V((e=>e(t)))}static reject(t){return new V(((e,i)=>i(t)))}static all(t){return new V(((e,i)=>{Promise.all(t).then(e).catch(i)})).catch((e=>{if(e instanceof this.CancelError)for(const e of t)"cancel"in e&&e.cancel();throw e}))}attach(t){this._isCanceled?t.cancel():this._children.push(t)}then(t,e){const i=new V(((i,s)=>{if(this._promise){const r=t=>{e?Z(i,s,e,t):s(t)};this._promise.then((e=>{this._isCanceled?r(e):t?Z(i,s,t,e):i(e)}),r)}}));return i._parentPromise=this,this._children.push(i),i}catch(t){return this._isCanceled&&t&&t(new z),this.then(void 0,t)}finally(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new z:t)}cancel(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;const t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((t=>t.cancel())),this._isPending){if(this._cancelHandlers.length)try{for(const t of this._cancelHandlers)t()}catch(t){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this}_getTopParent(){let t=this._parentPromise,e=!!t;for(;e;)t&&t._parentPromise?(t=t._parentPromise,e=!!t):e=!1;return t}_destroy(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0}}V.CancelError=z,V.TimeoutError=I,V.PromiseControl=B,Object.setPrototypeOf(V.prototype,Promise.prototype);var N=V;class J{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class G{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class D extends G{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class H extends G{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let K=0;const Q={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class ${constructor(t){this.options=Q,this.emitter=new f.exports.EventEmitter,this.keys=$.keys,this.runtimeParams=[],this.getPaintFunctions=$.getPaintFunctions,this.mapState=[D,H],this.id=K++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=F(Q||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const i of this.runtimeParams){const s=i.get(e.name);if(void 0!==s){t[e.name]=e.parse(s);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return{type:"Feature",properties:{},geometry:j(t)}}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){return this.mapAdapter.getZoom()}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(t){this.setZoom(t-1)}}}setView(t,e){this.mapAdapter.setView&&t&&M(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),M(e)&&this.mapAdapter.setZoom(e))}fitBounds(t,e){return t.every((t=>M(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var i;const s=()=>{const i=this.mapAdapter;t&&t(i),i&&e(i)},r=null===(i=this.mapAdapter.isLoaded)||void 0===i||i;this.mapAdapter.map&&r?s():this.mapAdapter.emitter.once("create",(()=>{s()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new N(((t,e,i)=>{const s=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const r=()=>{this.setCursor(s),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=e=>{r(),function(t){!t.lngLat&&t.latLng&&(t.lngLat=[t.latLng.lng,t.latLng.lat])}(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",o),i(r)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const i=t;this._eventsStatus[i]=!0,this.emitter.emit(i,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),M(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),M(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),M(t.maxzoom)&&M(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:i}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):i&&this.fitBounds(i)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const i=e.get(t.name);if(void 0!==i){const e=t.parse(i);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((i=>{i.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}$.keys=new class{constructor(){this.keyCodeAlias=new J,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class U extends ${constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const i=this.getLayer(t),s=i&&(i.getBounds||i.getExtent);if(s){const t=await s.call(i);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const i=this._layers[e];i&&t.push(i)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const i=this._layers[e];if(t(i))return i}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},i){var s,r;const o=this._layersIdCounter++,n=M(i)?i:void 0!==e.order?e.order:this.reserveOrder();let a;"string"==typeof t?a=this.getLayerAdapter(t):"function"==typeof t?a=t:"then"in t&&(a=await t);const l=e;this._updateGeoJsonOptions(l);const{maxZoom:c,minZoom:h}=this.options,p=null===(s=(e={id:String(o),order:n,maxZoom:c,minZoom:h,...e}).visibility)||void 0===s||s;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:a});t&&(t.options&&(e=t.options),t.adapter&&(a=t.adapter))}if(void 0!==a){const t=new a(this.mapAdapter.map,e);let i;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(i=String(t.options.id),this._layers[i]=t),this._emitLayerEvent("layer:preadd",i||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const s=await t.addLayer(t.options);if(t.layer=s,t.id=t.options.id||String(o),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(r=t.options.order)&&void 0!==r?r:n,i&&delete this._layers[i],i=String(t.id),this._layers[i])throw Error(`layer with id '${i}' already exist`);i&&(this._layers[i]=t,l.filter&&this.filterLayer(t,l.filter),e.baselayer&&this._baselayers.push(i),p&&await this.showLayer(i));const c=e.opacity;void 0!==c&&c<=1&&this.setLayerOpacity(t,c);const h=s&&(t.getBounds||t.getExtent);if(e.fit&&h){const e=await h.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",i,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,i){const s=i||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,s):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let i=!0;t&&(i=t(e,this._layers[e])),i&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),i=e&&this.getLayerId(e);if(e&&i){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(i);t&&this._baselayers.splice(t,1)}delete this._layers[i],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=y(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,i={}){const s=this.getLayer(t),r=void 0!==e?e:!(s&&s.options.visibility),o=void 0!==i.silent&&i.silent,n=async t=>{const e=String(t.id),i=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.find((e=>e!==t.id&&this.isLayerVisible(e)));e&&await this.hideLayer(e)}t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer);o||(this._emitLayerEvent(i,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=r};return s&&s.options.visibility!==r?this.onMapLoad().then((()=>n(s))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))}setLayerOpacity(t,e){const i=this.getLayer(t);i&&(i.setOpacity?i.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(i.layer,e))}selectLayer(t,e){const i=this.getLayer(t);if(i){const t=i;t&&t.select&&t.select(e);const s=this.getLayerId(i);s&&this._selectedLayers.push(s)}}unSelectLayer(t,e){const i=this.getLayer(t);if(i){const t=i&&i;t.unselect&&t.unselect(e);const s=this.getLayerId(i);if(s){const t=this._selectedLayers.indexOf(s);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const i=this.getLayer(t);return i.filter?i.filter(e):[]}propertiesFilter(t,e,i){const s=this.getLayer(t);if(!s)return;const r=s;r.propertiesFilter?r.propertiesFilter(e,i):r.filter&&this.filterLayer(r,(t=>!t.feature||!t.feature.properties||a(t.feature.properties,e)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const i=this.getLayer(t);if(i){if(i.setData)return i.setData(e);if(i.clearLayer&&i.addData)return i.clearLayer(),i.addData(e)}return Promise.resolve()}addLayerData(t,e){const i=this.getLayer(t);i.addData&&i.addData(e)}clearLayerData(t,e){const i=this.getLayer(t);i&&i.clearLayer&&i.clearLayer(e)}getAttributions(t){const e=[];for(const i in this._layers){const s=this._layers[i];let r=!(void 0===t.onlyVisible||t.onlyVisible)||s.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(i)),r){const t=s.options&&s.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(t){const{onSelect:e,onLayerSelect:i,onClick:s,onLayerClick:r,onMouseOut:o,onMouseOver:n}=t,a=s||r;t.onClick=t=>(a&&a(t),this._onLayerClick(t)),t.onMouseOut=t=>{const e=t.layer.id;o&&o(t),M(e)&&this._emitLayerEvent("layer:mouseout",e,t)},t.onMouseOver=t=>{const e=t.layer.id;n&&n(t),M(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const l=e||i;t.onSelect=t=>(l&&l(t),this._onLayerSelect(t)),t.nativePaint||(this.options.paint&&(t.paint=c(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=c(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}_emitLayerEvent(t,e,i){if(M(e)&&t.startsWith("layer:")){const s=t.replace("layer:","layer-"+e+":");this.emitter.emit(s,i)}this.emitter.emit(t,i)}}function W(t,e){const i=document.createElement("div");let s=!1;e.getStatus?s=e.getStatus():e.status&&(s=e.status);const r=e.title||"",o=e.html;function n(){r&&(i.title="string"==typeof r?r:s?r.on:r.off,i.setAttribute("aria-label",i.title))}function a(t){t instanceof HTMLElement?(i.innerHTML="",i.appendChild(t)):"string"==typeof t&&(i.innerHTML=t)}function l(){o&&("string"==typeof o||o instanceof HTMLElement?a(o):a(s?o.on:o.off),i.setAttribute("aria-label",i.title))}function c(t,e){t.split(" ").forEach((t=>{e?i.classList.add(t):i.classList.remove(t)}))}function h(){e.addClassOn&&c(e.addClassOn,s),e.addClassOff&&c(e.addClassOff,!s)}n(),l(),e.addClass&&c(e.addClass,!0),h();const p=t=>{void 0!==t&&(s=t),l(),n(),h()},d=t=>{if(s=void 0!==t?t:!s,e.onClick){const t=e.onClick(s);Promise.resolve(t).then((()=>p())).catch((()=>s=!s))}else p()},u=t({html:i,onClick:d});return u.onClick=d,u.changeStatus=p,u}class q extends U{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,i){let s;if(e=null!=e?e:"top-left",s="string"==typeof t?this.getControl(t,i):t,s)return new Promise((t=>{this._setControlQueue(e,(async()=>{const i=await s,r=this.mapAdapter.addControl(i,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?W(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const i=this.mapAdapter.controlAdapters[t];if(i)return new i(e);{const i=q.controls[t];if(i)return i(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}q.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const X={};function Y(t){return X[t]}class tt extends q{constructor(t){super(t),this._addControls(),X[this.id]=this}static get(t){return Y(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const t of this._starterKits)if(t.onLoadSync)try{await t.onLoadSync.call(t,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,i={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(i=this.options.controlsOptions[t],void 0!==i.control&&(e=i.control));const{position:s,...r}=i;this.addControl(e,s||"top-left",r)})),this._emitStatusEvent("controls:create")}}async function et(t){return new tt(t).onLoad()}export{tt as WebMap,q as WebMapControls,U as WebMapLayers,$ as WebMapMain,W as createToggleControl,et as createWebMap,p as detectGeometryType,h as findMostFrequentGeomType,Y as getWebMap,y as updateGeoJsonAdapterOptions};
function t(t){return"function"==typeof t}const e={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){const[s,...r]=e;let o=s;Array.isArray(s)&&(o=i(t,s));const n=r.splice(-1,r.length%2)[0];for(let t=0;t<r.length-1;t+=2){if(r[t]===o)return r[t+1]}return n}};function i(t,i){const[s,...r]=i,o=e[s];if(o)return o(t,r)}function s(t){return e=>i(e,t)}const r=["iconSize","iconAnchor"];function o(t,e,i){if((e=String(e))===(t=String(t)))return!0;if(i&&e.toUpperCase()===t.toUpperCase())return!0;const s=`^${r=e,r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var r;return null!==new RegExp(s,i?"i":"").exec(t)}const n={gt:(t,e)=>t>e,lt:(t,e)=>t<e,ge:(t,e)=>t>=e,le:(t,e)=>t<=e,eq:(t,e)=>t===e,ne:(t,e)=>t!==e,in:(t,e)=>-1!==e.indexOf(t),notin:(t,e)=>-1===e.indexOf(t),like:(t,e)=>o(t,e),ilike:(t,e)=>o(t,e,!0)};function a(t,e){const i="string"==typeof e[0]?e[0]:"all",s=e=>{if(3===(i=e).length&&"string"==typeof i[0]&&"string"==typeof i[1]){const[i,s,r]=e,o=n[s];if(o){if(("like"===s||"ilike"===s)&&"string"==typeof i){let e="";const s=i.replace(/^%?(\w+)%?$/,((s,o)=>(e=t[o],i.replace(o,r))));return o(e,s)}return o(t[i],r)}return!1}return a(t,e);var i},r=e.filter((t=>Array.isArray(t)));return"any"===i?r.some(s):r.every(s)}function l(t){let e={};const i=[];return t.forEach((t=>{t&&(Array.isArray(t)?i.push(t):e=t)})),t=>{const s=i.find((e=>function(t,e){const i={...t.properties};return!!i&&(i.$id=t.id,a(i,e))}(t,e[0])));return s?{...e,...s[1]}:e}}function c(e,i,o){if(!e)throw new Error("paint is empty");let n={...i};if(t(e)){const t=t=>{const s=c(e(t),i,o);return s.type=e.type,s};return t.type=e.type,t}if(function(t){return!!Array.isArray(t)}(e))return t=>c(l(e)(t),i,o);if("get-paint"===e.type){const t=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){const i=e[t.from];if(i)return i(t.options)}}(e,o);t&&(n=c(t,i,o))}else{if("icon"===e.type)return e;{const t=function(t){let e=!1;const i={};for(const o in t)if(-1===r.indexOf(o)){const r=o,n=t[r];Array.isArray(n)&&(e=!0,i[r]=s(n))}if(e)return e=>{const s={};for(const t in i)s[t]=i[t](e);return{...t,...s}}}(e);if(t)return e=>c(t(e),i,o);n={...n,...e},n.fill=void 0===n.fill||n.fill,n.stroke=void 0!==n.stroke?n.stroke:!n.fill||!(!n.strokeColor&&!n.strokeOpacity)}}return t(n)||("color"in n&&(n.strokeColor||(n.strokeColor=n.color),n.fillColor||(n.fillColor=n.color)),"opacity"in n&&(void 0===n.strokeOpacity&&(n.strokeOpacity=n.opacity),void 0===n.fillOpacity&&(n.fillOpacity=n.opacity))),n}function h(t){const e={};for(let i=0;i<t.length;i++)e[t[i]]=1+(e[t[i]]||0);let i;for(const t in e){e[t]>((void 0!==i?e[i]:0)||0)&&(i=t)}return i}function p(t){let e;if("FeatureCollection"===t.type){e=h(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=h(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const d={polygon:"path",line:"path",point:"circle"},u={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function y(t){if(t.data){const e=u[p(t.data)],i=t.paint;i&&"[object Object]"===Object.prototype.toString.call(i)&&(i.type=i.type?i.type:"polygon"===e||"line"===e?"path":"html"in i||"className"in i?"icon":d[e]),t.type=t.type||e}return t}var m,f={exports:{}},v="object"==typeof Reflect?Reflect:null,_=v&&"function"==typeof v.apply?v.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};m=v&&"function"==typeof v.ownKeys?v.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var g=Number.isNaN||function(t){return t!=t};function L(){L.init.call(this)}f.exports=L,f.exports.once=function(t,e){return new Promise((function(i,s){function r(i){t.removeListener(e,o),s(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",r),i([].slice.call(arguments))}x(t,e,o,{once:!0}),"error"!==e&&function(t,e,i){"function"==typeof t.on&&x(t,"error",e,i)}(t,r,{once:!0})}))},L.EventEmitter=L,L.prototype._events=void 0,L.prototype._eventsCount=0,L.prototype._maxListeners=void 0;var w=10;function C(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function b(t){return void 0===t._maxListeners?L.defaultMaxListeners:t._maxListeners}function A(t,e,i,s){var r,o,n,a;if(C(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),n=o[e]),void 0===n)n=o[e]=i,++t._eventsCount;else if("function"==typeof n?n=o[e]=s?[i,n]:[n,i]:s?n.unshift(i):n.push(i),(r=b(t))>0&&n.length>r&&!n.warned){n.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=n.length,a=l,console&&console.warn&&console.warn(a)}return t}function E(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function k(t,e,i){var s={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},r=E.bind(s);return r.listener=i,s.wrapFn=r,r}function O(t,e,i){var s=t._events;if(void 0===s)return[];var r=s[e];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(r):S(r,r.length)}function P(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function S(t,e){for(var i=new Array(e),s=0;s<e;++s)i[s]=t[s];return i}function x(t,e,i,s){if("function"==typeof t.on)s.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function r(o){s.once&&t.removeEventListener(e,r),i(o)}))}}function M(t){return null!=t}function F(t,e,i=!1){let s=t;const r=e,o=Array.isArray(r);let n=o&&[]||{};return o&&Array.isArray(r)?i?(s=s||[],n=n.concat(s),r.forEach(((t,e)=>{void 0===n[e]?n[e]=t:"object"==typeof t?n[e]=F(s[e],t,i):-1===s.indexOf(t)&&n.push(t)}))):n=r:(s&&"object"==typeof s&&Object.keys(s).forEach((function(t){n[t]=s[t]})),Object.keys(r).forEach((function(t){n[t]="object"==typeof r[t]&&r[t]&&"object"==typeof s[t]&&"object"==typeof r[t]?F(s[t],r[t],i):r[t]}))),n}function j(t){return{type:"Polygon",coordinates:[T(t)]}}function T(t){const e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}Object.defineProperty(L,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(t){if("number"!=typeof t||t<0||g(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");w=t}}),L.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},L.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||g(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},L.prototype.getMaxListeners=function(){return b(this)},L.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var s="error"===t,r=this._events;if(void 0!==r)s=s&&void 0===r.error;else if(!s)return!1;if(s){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var n=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw n.context=o,n}var a=r[t];if(void 0===a)return!1;if("function"==typeof a)_(a,this,e);else{var l=a.length,c=S(a,l);for(i=0;i<l;++i)_(c[i],this,e)}return!0},L.prototype.on=L.prototype.addListener=function(t,e){return A(this,t,e,!1)},L.prototype.prependListener=function(t,e){return A(this,t,e,!0)},L.prototype.once=function(t,e){return C(e),this.on(t,k(this,t,e)),this},L.prototype.prependOnceListener=function(t,e){return C(e),this.prependListener(t,k(this,t,e)),this},L.prototype.off=L.prototype.removeListener=function(t,e){var i,s,r,o,n;if(C(e),void 0===(s=this._events))return this;if(void 0===(i=s[t]))return this;if(i===e||i.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete s[t],s.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){n=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,r),1===i.length&&(s[t]=i[0]),void 0!==s.removeListener&&this.emit("removeListener",t,n||e)}return this},L.prototype.removeAllListeners=function(t){var e,i,s;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var r,o=Object.keys(i);for(s=0;s<o.length;++s)"removeListener"!==(r=o[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(s=e.length-1;s>=0;s--)this.removeListener(t,e[s]);return this},L.prototype.listeners=function(t){return O(this,t,!0)},L.prototype.rawListeners=function(t){return O(this,t,!1)},L.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):P.call(t,e)},L.prototype.listenerCount=P,L.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]};class z extends Error{constructor(){super(),this.name="CancelError",Object.setPrototypeOf(this,z.prototype)}}class B{constructor(t={}){this.options=t,this._promises=new Map}get isLoaded(){return this._promises.size>0}remove(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())}get(t){return this._promises.get(t)}add(t,e){const i=e||t,s=this._promises.get(i);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),s||(this._promises.set(i,t),t.finally((()=>{this.remove(i)})),t)}abort(){this.isLoaded&&(this._promises.forEach((t=>{t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())}waitFunc(t,e=""){const i=this.get(e=e||t.name);return i||this.add(t(),e)}WaitForMe(t=""){const e=this.get.bind(this),i=this.add.bind(this);return function(s,r,o){const n=o.value;return t=t||r,o.value=function(...s){const r=e(t);if(r)return r;return i(n.apply(this,s),t)},o}}GetOrCreateDecorator(t=""){return this.WaitForMe(t)}_onStop(){this.options.onStop&&!this.isLoaded&&this.options.onStop()}}class I extends Error{constructor(){super(),this.name="TimeoutError",Object.setPrototypeOf(this,I.prototype)}}const Z=(t,e,i,s)=>{try{t(i(s))}catch(t){e(t)}};let R=0;class V{constructor(t,e){this.id=R++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise(((t,e)=>{this._setCanceledCallback=e=>t(e||new z)}));const i=[this._cancelPromise,new Promise(((e,i)=>t((t=>{t instanceof V?this.attach(t):this._isPending=!1,e(t)}),(t=>{this._isPending=!1,i(t)}),(t=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(t)}))))];e&&i.push(new Promise(((t,i)=>{setTimeout((()=>{if(this._isPending)try{this.cancel()}finally{i(new I)}}),e)}))),this._promise=Promise.race(i)}static createControl(t){return new B(t)}static resolve(t){return new V((e=>e(t)))}static reject(t){return new V(((e,i)=>i(t)))}static all(t){return new V(((e,i)=>{Promise.all(t).then(e).catch(i)})).catch((e=>{if(e instanceof this.CancelError)for(const e of t)"cancel"in e&&e.cancel();throw e}))}attach(t){this._isCanceled?t.cancel():this._children.push(t)}then(t,e){const i=new V(((i,s)=>{if(this._promise){const r=t=>{e?Z(i,s,e,t):s(t)};this._promise.then((e=>{this._isCanceled?r(e):t?Z(i,s,t,e):i(e)}),r)}}));return i._parentPromise=this,this._children.push(i),i}catch(t){return this._isCanceled&&t&&t(new z),this.then(void 0,t)}finally(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new z:t)}cancel(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;const t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((t=>t.cancel())),this._isPending){if(this._cancelHandlers.length)try{for(const t of this._cancelHandlers)t()}catch(t){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this}_getTopParent(){let t=this._parentPromise,e=!!t;for(;e;)t&&t._parentPromise?(t=t._parentPromise,e=!!t):e=!1;return t}_destroy(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0}}V.CancelError=z,V.TimeoutError=I,V.PromiseControl=B,Object.setPrototypeOf(V.prototype,Promise.prototype);var N=V;class J{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class G{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class D extends G{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class H extends G{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let K=0;const Q={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class ${constructor(t){this.options=Q,this.emitter=new f.exports.EventEmitter,this.keys=$.keys,this.runtimeParams=[],this.getPaintFunctions=$.getPaintFunctions,this.mapState=[D,H],this.id=K++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=F(Q||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const i of this.runtimeParams){const s=i.get(e.name);if(void 0!==s){t[e.name]=e.parse(s);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return{type:"Feature",properties:{},geometry:j(t)}}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){return this.mapAdapter.getZoom()}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(t){this.setZoom(t-1)}}}setView(t,e){this.mapAdapter.setView&&t&&M(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),M(e)&&this.mapAdapter.setZoom(e))}fitBounds(t,e){return t.every((t=>M(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var i;const s=()=>{const i=this.mapAdapter;t&&t(i),i&&e(i)},r=null===(i=this.mapAdapter.isLoaded)||void 0===i||i;this.mapAdapter.map&&r?s():this.mapAdapter.emitter.once("create",(()=>{s()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new N(((t,e,i)=>{const s=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const r=()=>{this.setCursor(s),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=e=>{r(),function(t){!t.lngLat&&t.latLng&&(t.lngLat=[t.latLng.lng,t.latLng.lat])}(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",o),i(r)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const i=t;this._eventsStatus[i]=!0,this.emitter.emit(i,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),M(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),M(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),M(t.maxzoom)&&M(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:i}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):i&&this.fitBounds(i)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const i=e.get(t.name);if(void 0!==i){const e=t.parse(i);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((i=>{i.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}$.keys=new class{constructor(){this.keyCodeAlias=new J,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class U extends ${constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const i=this.getLayer(t),s=i&&(i.getBounds||i.getExtent);if(s){const t=await s.call(i);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const i=this._layers[e];i&&t.push(i)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const i=this._layers[e];if(t(i))return i}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},i){var s,r;const o=this._layersIdCounter++,n=M(i)?i:void 0!==e.order?e.order:this.reserveOrder();let a;"string"==typeof t?a=this.getLayerAdapter(t):"function"==typeof t?a=t:"then"in t&&(a=await t);const l=e;this._updateGeoJsonOptions(l);const{maxZoom:c,minZoom:h}=this.options,p=null===(s=(e={id:String(o),order:n,maxZoom:c,minZoom:h,...e}).visibility)||void 0===s||s;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:a});t&&(t.options&&(e=t.options),t.adapter&&(a=t.adapter))}if(void 0!==a){const t=new a(this.mapAdapter.map,e);let i;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(i=String(t.options.id),this._layers[i]=t),this._emitLayerEvent("layer:preadd",i||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const s=await t.addLayer(t.options);if(t.layer=s,t.id=t.options.id||String(o),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(r=t.options.order)&&void 0!==r?r:n,i&&delete this._layers[i],i=String(t.id),this._layers[i])throw Error(`layer with id '${i}' already exist`);i&&(this._layers[i]=t,l.filter&&this.filterLayer(t,l.filter),e.baselayer&&this._baselayers.push(i),p&&await this.showLayer(i));const c=e.opacity;void 0!==c&&c<=1&&this.setLayerOpacity(t,c);const h=s&&(t.getBounds||t.getExtent);if(e.fit&&h){const e=await h.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",i,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,i){const s=i||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,s):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let i=!0;t&&(i=t(e,this._layers[e])),i&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),i=e&&this.getLayerId(e);if(e&&i){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(i);t&&this._baselayers.splice(t,1)}delete this._layers[i],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=y(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,i={}){const s=this.getLayer(t),r=void 0!==e?e:!(s&&s.options.visibility),o=void 0!==i.silent&&i.silent,n=async t=>{const e=String(t.id),i=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.filter((e=>e!==t.id&&this.isLayerVisible(e)));for(const t of e)await this.hideLayer(t)}t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer);o||(this._emitLayerEvent(i,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=r};return s&&s.options.visibility!==r?this.onMapLoad().then((()=>n(s))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))}setLayerOpacity(t,e){const i=this.getLayer(t);i&&(i.setOpacity?i.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(i.layer,e))}selectLayer(t,e){const i=this.getLayer(t);if(i){const t=i;t&&t.select&&t.select(e);const s=this.getLayerId(i);s&&this._selectedLayers.push(s)}}unSelectLayer(t,e){const i=this.getLayer(t);if(i){const t=i&&i;t.unselect&&t.unselect(e);const s=this.getLayerId(i);if(s){const t=this._selectedLayers.indexOf(s);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const i=this.getLayer(t);return i.filter?i.filter(e):[]}propertiesFilter(t,e,i){const s=this.getLayer(t);if(!s)return;const r=s;r.propertiesFilter?r.propertiesFilter(e,i):r.filter&&this.filterLayer(r,(t=>!t.feature||!t.feature.properties||a(t.feature.properties,e)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const i=this.getLayer(t);if(i){if(i.setData)return i.setData(e);if(i.clearLayer&&i.addData)return i.clearLayer(),i.addData(e)}return Promise.resolve()}addLayerData(t,e){const i=this.getLayer(t);i.addData&&i.addData(e)}clearLayerData(t,e){const i=this.getLayer(t);i&&i.clearLayer&&i.clearLayer(e)}getAttributions(t){const e=[];for(const i in this._layers){const s=this._layers[i];let r=!(void 0===t.onlyVisible||t.onlyVisible)||s.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(i)),r){const t=s.options&&s.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(t){const{onSelect:e,onLayerSelect:i,onClick:s,onLayerClick:r,onMouseOut:o,onMouseOver:n}=t,a=s||r;t.onClick=t=>(a&&a(t),this._onLayerClick(t)),t.onMouseOut=t=>{const e=t.layer.id;o&&o(t),M(e)&&this._emitLayerEvent("layer:mouseout",e,t)},t.onMouseOver=t=>{const e=t.layer.id;n&&n(t),M(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const l=e||i;t.onSelect=t=>(l&&l(t),this._onLayerSelect(t)),t.nativePaint||(this.options.paint&&(t.paint=c(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=c(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}_emitLayerEvent(t,e,i){if(M(e)&&t.startsWith("layer:")){const s=t.replace("layer:","layer-"+e+":");this.emitter.emit(s,i)}this.emitter.emit(t,i)}}function W(t,e){const i=document.createElement("div");let s=!1;e.getStatus?s=e.getStatus():e.status&&(s=e.status);const r=e.title||"",o=e.html;function n(){r&&(i.title="string"==typeof r?r:s?r.on:r.off,i.setAttribute("aria-label",i.title))}function a(t){t instanceof HTMLElement?(i.innerHTML="",i.appendChild(t)):"string"==typeof t&&(i.innerHTML=t)}function l(){o&&("string"==typeof o||o instanceof HTMLElement?a(o):a(s?o.on:o.off),i.setAttribute("aria-label",i.title))}function c(t,e){t.split(" ").forEach((t=>{e?i.classList.add(t):i.classList.remove(t)}))}function h(){e.addClassOn&&c(e.addClassOn,s),e.addClassOff&&c(e.addClassOff,!s)}n(),l(),e.addClass&&c(e.addClass,!0),h();const p=t=>{void 0!==t&&(s=t),l(),n(),h()},d=t=>{if(s=void 0!==t?t:!s,e.onClick){const t=e.onClick(s);Promise.resolve(t).then((()=>p())).catch((()=>s=!s))}else p()},u=t({html:i,onClick:d});return u.onClick=d,u.changeStatus=p,u}class q extends U{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,i){let s;if(e=null!=e?e:"top-left",s="string"==typeof t?this.getControl(t,i):t,s)return new Promise((t=>{this._setControlQueue(e,(async()=>{const i=await s,r=this.mapAdapter.addControl(i,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?W(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const i=this.mapAdapter.controlAdapters[t];if(i)return new i(e);{const i=q.controls[t];if(i)return i(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}q.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const X={};function Y(t){return X[t]}class tt extends q{constructor(t){super(t),this._addControls(),X[this.id]=this}static get(t){return Y(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const t of this._starterKits)if(t.onLoadSync)try{await t.onLoadSync.call(t,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,i={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(i=this.options.controlsOptions[t],void 0!==i.control&&(e=i.control));const{position:s,...r}=i;this.addControl(e,s||"top-left",r)})),this._emitStatusEvent("controls:create")}}async function et(t){return new tt(t).onLoad()}export{tt as WebMap,q as WebMapControls,U as WebMapLayers,$ as WebMapMain,W as createToggleControl,et as createWebMap,p as detectGeometryType,h as findMostFrequentGeomType,Y as getWebMap,y as updateGeoJsonAdapterOptions};
//# sourceMappingURL=webmap.esm-browser.prod.js.map

@@ -1,2 +0,2 @@

import{isPaint as t,preparePaint as e}from"@nextgis/paint";import{propertiesFilter as s}from"@nextgis/properties-filter";import{EventEmitter as i}from"events";import{deepmerge as r,getBoundsFeature as o,defined as a,deprecatedMapClick as n}from"@nextgis/utils";import h from"@nextgis/cancelable-promise";function l(t){const e={};for(let s=0;s<t.length;s++)e[t[s]]=1+(e[t[s]]||0);let s;for(const t in e){e[t]>((void 0!==s?e[s]:0)||0)&&(s=t)}return s}function d(t){let e;if("FeatureCollection"===t.type){e=l(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=l(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const p={polygon:"path",line:"path",point:"circle"},c={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function m(e){if(e.data){const s=c[d(e.data)],i=e.paint;i&&t(i)&&(i.type=i.type?i.type:"polygon"===s||"line"===s?"path":"html"in i||"className"in i?"icon":p[s]),e.type=e.type||s}return e}class y{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class u{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class f extends u{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class L extends u{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let g=0;const _={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class v{constructor(t){this.options=_,this.emitter=new i,this.keys=v.keys,this.runtimeParams=[],this.getPaintFunctions=v.getPaintFunctions,this.mapState=[f,L],this.id=g++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(_||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const s of this.runtimeParams){const i=s.get(e.name);if(void 0!==i){t[e.name]=e.parse(i);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return o(t)}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){return this.mapAdapter.getZoom()}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(t){this.setZoom(t-1)}}}setView(t,e){this.mapAdapter.setView&&t&&a(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),a(e)&&this.mapAdapter.setZoom(e))}fitBounds(t,e){return t.every((t=>a(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var s;const i=()=>{const s=this.mapAdapter;t&&t(s),s&&e(s)},r=null===(s=this.mapAdapter.isLoaded)||void 0===s||s;this.mapAdapter.map&&r?i():this.mapAdapter.emitter.once("create",(()=>{i()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new h(((t,e,s)=>{const i=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const r=()=>{this.setCursor(i),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=e=>{r(),n(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",o),s(r)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const s=t;this._eventsStatus[s]=!0,this.emitter.emit(s,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),a(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),a(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),a(t.maxzoom)&&a(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:s}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):s&&this.fitBounds(s)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const s=e.get(t.name);if(void 0!==s){const e=t.parse(s);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((s=>{s.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}v.keys=new class{constructor(){this.keyCodeAlias=new y,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class C extends v{constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const s=this.getLayer(t),i=s&&(s.getBounds||s.getExtent);if(i){const t=await i.call(s);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const s=this._layers[e];s&&t.push(s)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const s=this._layers[e];if(t(s))return s}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},s){var i,r;const o=this._layersIdCounter++,n=a(s)?s:void 0!==e.order?e.order:this.reserveOrder();let h;"string"==typeof t?h=this.getLayerAdapter(t):"function"==typeof t?h=t:"then"in t&&(h=await t);const l=e;this._updateGeoJsonOptions(l);const{maxZoom:d,minZoom:p}=this.options,c=null===(i=(e={id:String(o),order:n,maxZoom:d,minZoom:p,...e}).visibility)||void 0===i||i;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:h});t&&(t.options&&(e=t.options),t.adapter&&(h=t.adapter))}if(void 0!==h){const t=new h(this.mapAdapter.map,e);let s;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(s=String(t.options.id),this._layers[s]=t),this._emitLayerEvent("layer:preadd",s||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const i=await t.addLayer(t.options);if(t.layer=i,t.id=t.options.id||String(o),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(r=t.options.order)&&void 0!==r?r:n,s&&delete this._layers[s],s=String(t.id),this._layers[s])throw Error(`layer with id '${s}' already exist`);s&&(this._layers[s]=t,l.filter&&this.filterLayer(t,l.filter),e.baselayer&&this._baselayers.push(s),c&&await this.showLayer(s));const a=e.opacity;void 0!==a&&a<=1&&this.setLayerOpacity(t,a);const d=i&&(t.getBounds||t.getExtent);if(e.fit&&d){const e=await d.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",s,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,s){const i=s||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,i):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let s=!0;t&&(s=t(e,this._layers[e])),s&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),s=e&&this.getLayerId(e);if(e&&s){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(s);t&&this._baselayers.splice(t,1)}delete this._layers[s],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=m(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,s={}){const i=this.getLayer(t),r=void 0!==e?e:!(i&&i.options.visibility),o=void 0!==s.silent&&s.silent,a=async t=>{const e=String(t.id),s=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.find((e=>e!==t.id&&this.isLayerVisible(e)));e&&await this.hideLayer(e)}t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer);o||(this._emitLayerEvent(s,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=r};return i&&i.options.visibility!==r?this.onMapLoad().then((()=>a(i))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))}setLayerOpacity(t,e){const s=this.getLayer(t);s&&(s.setOpacity?s.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(s.layer,e))}selectLayer(t,e){const s=this.getLayer(t);if(s){const t=s;t&&t.select&&t.select(e);const i=this.getLayerId(s);i&&this._selectedLayers.push(i)}}unSelectLayer(t,e){const s=this.getLayer(t);if(s){const t=s&&s;t.unselect&&t.unselect(e);const i=this.getLayerId(s);if(i){const t=this._selectedLayers.indexOf(i);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const s=this.getLayer(t);return s.filter?s.filter(e):[]}propertiesFilter(t,e,i){const r=this.getLayer(t);if(!r)return;const o=r;o.propertiesFilter?o.propertiesFilter(e,i):o.filter&&this.filterLayer(o,(t=>!t.feature||!t.feature.properties||s(t.feature.properties,e)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const s=this.getLayer(t);if(s){if(s.setData)return s.setData(e);if(s.clearLayer&&s.addData)return s.clearLayer(),s.addData(e)}return Promise.resolve()}addLayerData(t,e){const s=this.getLayer(t);s.addData&&s.addData(e)}clearLayerData(t,e){const s=this.getLayer(t);s&&s.clearLayer&&s.clearLayer(e)}getAttributions(t){const e=[];for(const s in this._layers){const i=this._layers[s];let r=!(void 0===t.onlyVisible||t.onlyVisible)||i.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(s)),r){const t=i.options&&i.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(t){const{onSelect:s,onLayerSelect:i,onClick:r,onLayerClick:o,onMouseOut:n,onMouseOver:h}=t,l=r||o;t.onClick=t=>(l&&l(t),this._onLayerClick(t)),t.onMouseOut=t=>{const e=t.layer.id;n&&n(t),a(e)&&this._emitLayerEvent("layer:mouseout",e,t)},t.onMouseOver=t=>{const e=t.layer.id;h&&h(t),a(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const d=s||i;t.onSelect=t=>(d&&d(t),this._onLayerSelect(t)),t.nativePaint||(this.options.paint&&(t.paint=e(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=e(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}_emitLayerEvent(t,e,s){if(a(e)&&t.startsWith("layer:")){const i=t.replace("layer:","layer-"+e+":");this.emitter.emit(i,s)}this.emitter.emit(t,s)}}function w(t,e){const s=document.createElement("div");let i=!1;e.getStatus?i=e.getStatus():e.status&&(i=e.status);const r=e.title||"",o=e.html;function a(){r&&(s.title="string"==typeof r?r:i?r.on:r.off,s.setAttribute("aria-label",s.title))}function n(t){t instanceof HTMLElement?(s.innerHTML="",s.appendChild(t)):"string"==typeof t&&(s.innerHTML=t)}function h(){o&&("string"==typeof o||o instanceof HTMLElement?n(o):n(i?o.on:o.off),s.setAttribute("aria-label",s.title))}function l(t,e){t.split(" ").forEach((t=>{e?s.classList.add(t):s.classList.remove(t)}))}function d(){e.addClassOn&&l(e.addClassOn,i),e.addClassOff&&l(e.addClassOff,!i)}a(),h(),e.addClass&&l(e.addClass,!0),d();const p=t=>{void 0!==t&&(i=t),h(),a(),d()},c=t=>{if(i=void 0!==t?t:!i,e.onClick){const t=e.onClick(i);Promise.resolve(t).then((()=>p())).catch((()=>i=!i))}else p()},m=t({html:s,onClick:c});return m.onClick=c,m.changeStatus=p,m}class b extends C{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,s){let i;if(e=null!=e?e:"top-left",i="string"==typeof t?this.getControl(t,s):t,i)return new Promise((t=>{this._setControlQueue(e,(async()=>{const s=await i,r=this.mapAdapter.addControl(s,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?w(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const s=this.mapAdapter.controlAdapters[t];if(s)return new s(e);{const s=b.controls[t];if(s)return s(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}b.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const A={};function k(t){return A[t]}class E extends b{constructor(t){super(t),this._addControls(),A[this.id]=this}static get(t){return k(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const t of this._starterKits)if(t.onLoadSync)try{await t.onLoadSync.call(t,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,s={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(s=this.options.controlsOptions[t],void 0!==s.control&&(e=s.control));const{position:i,...r}=s;this.addControl(e,i||"top-left",r)})),this._emitStatusEvent("controls:create")}}async function O(t){return new E(t).onLoad()}export{E as WebMap,b as WebMapControls,C as WebMapLayers,v as WebMapMain,w as createToggleControl,O as createWebMap,d as detectGeometryType,l as findMostFrequentGeomType,k as getWebMap,m as updateGeoJsonAdapterOptions};
import{isPaint as t,preparePaint as e}from"@nextgis/paint";import{propertiesFilter as s}from"@nextgis/properties-filter";import{EventEmitter as i}from"events";import{deepmerge as r,getBoundsFeature as o,defined as a,deprecatedMapClick as n}from"@nextgis/utils";import h from"@nextgis/cancelable-promise";function l(t){const e={};for(let s=0;s<t.length;s++)e[t[s]]=1+(e[t[s]]||0);let s;for(const t in e){e[t]>((void 0!==s?e[s]:0)||0)&&(s=t)}return s}function d(t){let e;if("FeatureCollection"===t.type){e=l(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=l(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const p={polygon:"path",line:"path",point:"circle"},c={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function m(e){if(e.data){const s=c[d(e.data)],i=e.paint;i&&t(i)&&(i.type=i.type?i.type:"polygon"===s||"line"===s?"path":"html"in i||"className"in i?"icon":p[s]),e.type=e.type||s}return e}class y{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class u{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class f extends u{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class L extends u{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let g=0;const _={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class v{constructor(t){this.options=_,this.emitter=new i,this.keys=v.keys,this.runtimeParams=[],this.getPaintFunctions=v.getPaintFunctions,this.mapState=[f,L],this.id=g++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(_||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const s of this.runtimeParams){const i=s.get(e.name);if(void 0!==i){t[e.name]=e.parse(i);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return o(t)}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){return this.mapAdapter.getZoom()}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(t){this.setZoom(t-1)}}}setView(t,e){this.mapAdapter.setView&&t&&a(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),a(e)&&this.mapAdapter.setZoom(e))}fitBounds(t,e){return t.every((t=>a(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var s;const i=()=>{const s=this.mapAdapter;t&&t(s),s&&e(s)},r=null===(s=this.mapAdapter.isLoaded)||void 0===s||s;this.mapAdapter.map&&r?i():this.mapAdapter.emitter.once("create",(()=>{i()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new h(((t,e,s)=>{const i=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const r=()=>{this.setCursor(i),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=e=>{r(),n(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",o),s(r)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const s=t;this._eventsStatus[s]=!0,this.emitter.emit(s,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),a(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),a(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),a(t.maxzoom)&&a(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:s}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):s&&this.fitBounds(s)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const s=e.get(t.name);if(void 0!==s){const e=t.parse(s);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((s=>{s.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}v.keys=new class{constructor(){this.keyCodeAlias=new y,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class C extends v{constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const s=this.getLayer(t),i=s&&(s.getBounds||s.getExtent);if(i){const t=await i.call(s);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const s=this._layers[e];s&&t.push(s)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const s=this._layers[e];if(t(s))return s}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},s){var i,r;const o=this._layersIdCounter++,n=a(s)?s:void 0!==e.order?e.order:this.reserveOrder();let h;"string"==typeof t?h=this.getLayerAdapter(t):"function"==typeof t?h=t:"then"in t&&(h=await t);const l=e;this._updateGeoJsonOptions(l);const{maxZoom:d,minZoom:p}=this.options,c=null===(i=(e={id:String(o),order:n,maxZoom:d,minZoom:p,...e}).visibility)||void 0===i||i;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:h});t&&(t.options&&(e=t.options),t.adapter&&(h=t.adapter))}if(void 0!==h){const t=new h(this.mapAdapter.map,e);let s;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(s=String(t.options.id),this._layers[s]=t),this._emitLayerEvent("layer:preadd",s||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const i=await t.addLayer(t.options);if(t.layer=i,t.id=t.options.id||String(o),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(r=t.options.order)&&void 0!==r?r:n,s&&delete this._layers[s],s=String(t.id),this._layers[s])throw Error(`layer with id '${s}' already exist`);s&&(this._layers[s]=t,l.filter&&this.filterLayer(t,l.filter),e.baselayer&&this._baselayers.push(s),c&&await this.showLayer(s));const a=e.opacity;void 0!==a&&a<=1&&this.setLayerOpacity(t,a);const d=i&&(t.getBounds||t.getExtent);if(e.fit&&d){const e=await d.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",s,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,s){const i=s||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,i):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let s=!0;t&&(s=t(e,this._layers[e])),s&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),s=e&&this.getLayerId(e);if(e&&s){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(s);t&&this._baselayers.splice(t,1)}delete this._layers[s],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=m(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,s={}){const i=this.getLayer(t),r=void 0!==e?e:!(i&&i.options.visibility),o=void 0!==s.silent&&s.silent,a=async t=>{const e=String(t.id),s=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.filter((e=>e!==t.id&&this.isLayerVisible(e)));for(const t of e)await this.hideLayer(t)}t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer);o||(this._emitLayerEvent(s,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=r};return i&&i.options.visibility!==r?this.onMapLoad().then((()=>a(i))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))}setLayerOpacity(t,e){const s=this.getLayer(t);s&&(s.setOpacity?s.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(s.layer,e))}selectLayer(t,e){const s=this.getLayer(t);if(s){const t=s;t&&t.select&&t.select(e);const i=this.getLayerId(s);i&&this._selectedLayers.push(i)}}unSelectLayer(t,e){const s=this.getLayer(t);if(s){const t=s&&s;t.unselect&&t.unselect(e);const i=this.getLayerId(s);if(i){const t=this._selectedLayers.indexOf(i);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const s=this.getLayer(t);return s.filter?s.filter(e):[]}propertiesFilter(t,e,i){const r=this.getLayer(t);if(!r)return;const o=r;o.propertiesFilter?o.propertiesFilter(e,i):o.filter&&this.filterLayer(o,(t=>!t.feature||!t.feature.properties||s(t.feature.properties,e)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const s=this.getLayer(t);if(s){if(s.setData)return s.setData(e);if(s.clearLayer&&s.addData)return s.clearLayer(),s.addData(e)}return Promise.resolve()}addLayerData(t,e){const s=this.getLayer(t);s.addData&&s.addData(e)}clearLayerData(t,e){const s=this.getLayer(t);s&&s.clearLayer&&s.clearLayer(e)}getAttributions(t){const e=[];for(const s in this._layers){const i=this._layers[s];let r=!(void 0===t.onlyVisible||t.onlyVisible)||i.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(s)),r){const t=i.options&&i.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(t){const{onSelect:s,onLayerSelect:i,onClick:r,onLayerClick:o,onMouseOut:n,onMouseOver:h}=t,l=r||o;t.onClick=t=>(l&&l(t),this._onLayerClick(t)),t.onMouseOut=t=>{const e=t.layer.id;n&&n(t),a(e)&&this._emitLayerEvent("layer:mouseout",e,t)},t.onMouseOver=t=>{const e=t.layer.id;h&&h(t),a(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const d=s||i;t.onSelect=t=>(d&&d(t),this._onLayerSelect(t)),t.nativePaint||(this.options.paint&&(t.paint=e(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=e(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}_emitLayerEvent(t,e,s){if(a(e)&&t.startsWith("layer:")){const i=t.replace("layer:","layer-"+e+":");this.emitter.emit(i,s)}this.emitter.emit(t,s)}}function w(t,e){const s=document.createElement("div");let i=!1;e.getStatus?i=e.getStatus():e.status&&(i=e.status);const r=e.title||"",o=e.html;function a(){r&&(s.title="string"==typeof r?r:i?r.on:r.off,s.setAttribute("aria-label",s.title))}function n(t){t instanceof HTMLElement?(s.innerHTML="",s.appendChild(t)):"string"==typeof t&&(s.innerHTML=t)}function h(){o&&("string"==typeof o||o instanceof HTMLElement?n(o):n(i?o.on:o.off),s.setAttribute("aria-label",s.title))}function l(t,e){t.split(" ").forEach((t=>{e?s.classList.add(t):s.classList.remove(t)}))}function d(){e.addClassOn&&l(e.addClassOn,i),e.addClassOff&&l(e.addClassOff,!i)}a(),h(),e.addClass&&l(e.addClass,!0),d();const p=t=>{void 0!==t&&(i=t),h(),a(),d()},c=t=>{if(i=void 0!==t?t:!i,e.onClick){const t=e.onClick(i);Promise.resolve(t).then((()=>p())).catch((()=>i=!i))}else p()},m=t({html:s,onClick:c});return m.onClick=c,m.changeStatus=p,m}class b extends C{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,s){let i;if(e=null!=e?e:"top-left",i="string"==typeof t?this.getControl(t,s):t,i)return new Promise((t=>{this._setControlQueue(e,(async()=>{const s=await i,r=this.mapAdapter.addControl(s,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?w(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const s=this.mapAdapter.controlAdapters[t];if(s)return new s(e);{const s=b.controls[t];if(s)return s(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}b.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const A={};function k(t){return A[t]}class E extends b{constructor(t){super(t),this._addControls(),A[this.id]=this}static get(t){return k(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const t of this._starterKits)if(t.onLoadSync)try{await t.onLoadSync.call(t,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,s={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(s=this.options.controlsOptions[t],void 0!==s.control&&(e=s.control));const{position:i,...r}=s;this.addControl(e,i||"top-left",r)})),this._emitStatusEvent("controls:create")}}async function O(t){return new E(t).onLoad()}export{E as WebMap,b as WebMapControls,C as WebMapLayers,v as WebMapMain,w as createToggleControl,O as createWebMap,d as detectGeometryType,l as findMostFrequentGeomType,k as getWebMap,m as updateGeoJsonAdapterOptions};
//# sourceMappingURL=webmap.esm-bundler.prod.js.map

@@ -15,3 +15,3 @@ var WebMap=function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}function u(t){return"function"==typeof t}var c={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),o=r;Array.isArray(r)&&(o=p(t,r));for(var i=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===o)return n[s+1]}return i}};function p(t,e){var r=e[0],n=e.slice(1),o=c[r];if(o)return o(t,n)}function l(t){return function(e){return p(e,t)}}var h=["iconSize","iconAnchor"];function f(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o=("^"+(n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")+"$")).replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var d={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return f(t,e)},ilike:function(t,e){return f(t,e,!0)}};function y(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(3===(u=e).length&&"string"==typeof u[0]&&"string"==typeof u[1]){var r=e[0],n=e[1],o=e[2],i=d[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return y(t,e);var u},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function v(t){var e={},r=[];return t.forEach((function(t){t&&(Array.isArray(t)?r.push(t):e=t)})),function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,y(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function m(t,e,r){if(!t)throw new Error("paint is empty");var o=n({},e);if(u(t)){var i=function(n){var o=m(t(n),e,r);return o.type=t.type,o};return i.type=t.type,i}if(function(t){return!!Array.isArray(t)}(t))return function(n){return m(v(t)(n),e,r)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,r);s&&(o=m(s,e,r))}else{if("icon"===t.type)return t;var a=function(t){var e=!1,r={};for(var o in t)if(-1===h.indexOf(o)){var i=o,s=t[i];Array.isArray(s)&&(e=!0,r[i]=l(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(t);if(a)return function(t){return m(a(t),e,r)};(o=n(n({},o),t)).fill=void 0===o.fill||o.fill,o.stroke=void 0!==o.stroke?o.stroke:!o.fill||!(!o.strokeColor&&!o.strokeOpacity)}return u(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function g(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function _(t){var e;if("FeatureCollection"===t.type)e=g(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=g(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var L={polygon:"path",line:"path",point:"circle"},b={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function w(t){if(t.data){var e=b[_(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":L[e]),t.type=t.type||e}return t}var C,O={exports:{}},A="object"==typeof Reflect?Reflect:null,E=A&&"function"==typeof A.apply?A.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};C=A&&"function"==typeof A.ownKeys?A.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var P=Number.isNaN||function(t){return t!=t};function k(){k.init.call(this)}O.exports=k,O.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}Z(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&Z(t,"error",e,r)}(t,o,{once:!0})}))},k.EventEmitter=k,k.prototype._events=void 0,k.prototype._eventsCount=0,k.prototype._maxListeners=void 0;var S=10;function x(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function M(t){return void 0===t._maxListeners?k.defaultMaxListeners:t._maxListeners}function j(t,e,r,n){var o,i,s,a;if(x(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=M(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function T(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function F(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=T.bind(n);return o.listener=r,n.wrapFn=o,o}function z(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):I(o,o.length)}function B(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function I(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Z(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}function R(t){return null!=t}function V(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=V(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?V(n[t],o[t],r):o[t]}))),s}function G(t){return{type:"Polygon",coordinates:[N(t)]}}function N(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return S},set:function(t){if("number"!=typeof t||t<0||P(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");S=t}}),k.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||P(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},k.prototype.getMaxListeners=function(){return M(this)},k.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)E(a,this,e);else{var u=a.length,c=I(a,u);for(r=0;r<u;++r)E(c[r],this,e)}return!0},k.prototype.on=k.prototype.addListener=function(t,e){return j(this,t,e,!1)},k.prototype.prependListener=function(t,e){return j(this,t,e,!0)},k.prototype.once=function(t,e){return x(e),this.on(t,F(this,t,e)),this},k.prototype.prependOnceListener=function(t,e){return x(e),this.prependListener(t,F(this,t,e)),this},k.prototype.off=k.prototype.removeListener=function(t,e){var r,n,o,i,s;if(x(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},k.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},k.prototype.listeners=function(t){return z(this,t,!0)},k.prototype.rawListeners=function(t){return z(this,t,!1)},k.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):B.call(t,e)},k.prototype.listenerCount=B,k.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]};var J=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),W=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);if(i)return i;var a=r(s.apply(this,n),t);return a},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),D=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),H=function(t,e,r,n){try{t(r(n))}catch(t){e(t)}},K=0,Q=function(){function t(e,r){var n=this;this.id=K++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new J)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new D)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new W(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?H(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?H(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new J),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new J:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(t){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=J,t.TimeoutError=D,t.PromiseControl=W,t}();Object.setPrototypeOf(Q.prototype,Promise.prototype);var U=Q,$=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},q=function(){function t(){this.keyCodeAlias=new $,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),X=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),Y=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(X),tt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(X);var et=0,rt={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},nt=function(){function t(e){this.options=rt,this.emitter=new O.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[Y,tt],this.id=et++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=V(rt||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:G(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){return this.mapAdapter.getZoom()},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){this.mapAdapter.setView&&t&&R(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),R(e)&&this.mapAdapter.setZoom(e))},t.prototype.fitBounds=function(t,e){return t.every((function(t){return R(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new U((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){var r;i(),!(r=t).lngLat&&r.latLng&&(r.lngLat=[r.latLng.lng,r.latLng.lat]),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),R(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),R(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),R(t.maxzoom)&&R(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new q,t}(),ot=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var s,a;return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var o,u,c,p,l,h,f,d,y,v,m,g,_,L,b;return i(this,(function(i){switch(i.label){case 0:return o=this._layersIdCounter++,u=R(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(c=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(c=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:c=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(p=e),h=(l=this.options).maxZoom,f=l.minZoom,e=n({id:String(o),order:u,maxZoom:h,minZoom:f},e),d=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(y=this.options.onBeforeAddLayer({options:e,adapter:c}))&&(y.options&&(e=y.options),y.adapter&&(c=y.adapter)),void 0===c?[3,12]:((v=new c(this.mapAdapter.map,e)).options=n(n({},e),v.options),v.options.baselayer&&(e.baselayer=!0,e.order=0,v.options.order=0),m=void 0,v.options.id&&(m=String(v.options.id),this._layers[m]=v),this._emitLayerEvent("layer:preadd",m||"",v),[4,this.onMapLoad()]);case 5:return i.sent(),v.map=this.mapAdapter.map,[4,v.addLayer(v.options)];case 6:if(g=i.sent(),v.layer=g,v.id=v.options.id||String(o),v.options.id=v.id,e.baselayer&&(v.options.order=0),v.order=null!==(a=v.options.order)&&void 0!==a?a:u,m&&delete this._layers[m],m=String(v.id),this._layers[m])throw Error("layer with id '"+m+"' already exist");return m?(this._layers[m]=v,p.filter&&this.filterLayer(v,p.filter),e.baselayer&&this._baselayers.push(m),d?[4,this.showLayer(m)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(_=e.opacity)&&_<=1&&this.setLayerOpacity(v,_),L=g&&(v.getBounds||v.getExtent),e.fit&&L?[4,L.call(v)]:[3,11];case 9:return(b=i.sent())?[4,this.fitBounds(b)]:[3,11];case 10:i.sent(),i.label=11;case 11:return this._emitLayerEvent("layer:add",m,v),[2,v];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=w(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){return this.addLayer("IMAGE",n(n({},e),{url:t}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,o(n,void 0,void 0,(function(){var e,r,n,o,s,c=this;return i(this,(function(i){switch(i.label){case 0:return e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),a&&this.mapAdapter?(o=t.options.baselayer?0:t.options.order,t.options.baselayer&&this._baselayers.length&&(s=this._baselayers.find((function(e){return e!==t.id&&c.isLayerVisible(e)})))?[4,this.hideLayer(s)]:[3,2]):[3,3];case 1:i.sent(),i.label=2;case 2:return t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,4];case 3:t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer),i.label=4;case 4:return u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=a,[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||y(t.feature.properties,e)}))}},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._onLayerClick=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),R(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),R(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=m(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=m(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},e.prototype._emitLayerEvent=function(t,e,r){if(R(e)&&t.startsWith("layer:")){var n=t.replace("layer:","layer-"+e+":");this.emitter.emit(n,r)}this.emitter.emit(t,r)},e}(nt);function it(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},h=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},f=t({html:r,onClick:h});return f.onClick=h,f.changeStatus=l,f}var st=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return o(this,void 0,void 0,(function(){var n,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return o(s,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,it(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(ot),at={};function ut(t){return at[t]}var ct=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),at[r.id]=r,r}return r(e,t),e.get=function(t){return ut(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return o(this,void 0,void 0,(function(){var o,s,u,c,p,l,h,f,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),o=a(this._starterKits),i.label=1;case 1:return[4,o.next()];case 2:return(s=i.sent()).done?[3,17]:(u=s.value).getLayerAdapters?[4,u.getLayerAdapters.call(u)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=a(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(h=l.value).createAdapter(this)];case 7:(f=i.sent())&&(this.mapAdapter.layerAdapters[h.name]=f),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(n=p.return)?[4,n.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),s&&!s.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return o(this,void 0,void 0,(function(){var r,n,o,s,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=a(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return s=i.sent(),console.error(s),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return u=i.sent(),t={error:u},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(st);return t.WebMap=ct,t.WebMapControls=st,t.WebMapLayers=ot,t.WebMapMain=nt,t.createToggleControl=it,t.createWebMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new ct(t).onLoad()]}))}))},t.detectGeometryType=_,t.findMostFrequentGeomType=g,t.getWebMap=ut,t.updateGeoJsonAdapterOptions=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
***************************************************************************** */var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}function u(t){return"function"==typeof t}var c={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),o=r;Array.isArray(r)&&(o=p(t,r));for(var i=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===o)return n[s+1]}return i}};function p(t,e){var r=e[0],n=e.slice(1),o=c[r];if(o)return o(t,n)}function l(t){return function(e){return p(e,t)}}var h=["iconSize","iconAnchor"];function f(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o=("^"+(n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")+"$")).replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var d={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return f(t,e)},ilike:function(t,e){return f(t,e,!0)}};function y(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(3===(u=e).length&&"string"==typeof u[0]&&"string"==typeof u[1]){var r=e[0],n=e[1],o=e[2],i=d[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return y(t,e);var u},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function v(t){var e={},r=[];return t.forEach((function(t){t&&(Array.isArray(t)?r.push(t):e=t)})),function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,y(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function m(t,e,r){if(!t)throw new Error("paint is empty");var o=n({},e);if(u(t)){var i=function(n){var o=m(t(n),e,r);return o.type=t.type,o};return i.type=t.type,i}if(function(t){return!!Array.isArray(t)}(t))return function(n){return m(v(t)(n),e,r)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,r);s&&(o=m(s,e,r))}else{if("icon"===t.type)return t;var a=function(t){var e=!1,r={};for(var o in t)if(-1===h.indexOf(o)){var i=o,s=t[i];Array.isArray(s)&&(e=!0,r[i]=l(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(t);if(a)return function(t){return m(a(t),e,r)};(o=n(n({},o),t)).fill=void 0===o.fill||o.fill,o.stroke=void 0!==o.stroke?o.stroke:!o.fill||!(!o.strokeColor&&!o.strokeOpacity)}return u(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function g(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function _(t){var e;if("FeatureCollection"===t.type)e=g(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=g(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var L={polygon:"path",line:"path",point:"circle"},b={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function w(t){if(t.data){var e=b[_(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":L[e]),t.type=t.type||e}return t}var C,O={exports:{}},A="object"==typeof Reflect?Reflect:null,E=A&&"function"==typeof A.apply?A.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};C=A&&"function"==typeof A.ownKeys?A.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var P=Number.isNaN||function(t){return t!=t};function k(){k.init.call(this)}O.exports=k,O.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}Z(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&Z(t,"error",e,r)}(t,o,{once:!0})}))},k.EventEmitter=k,k.prototype._events=void 0,k.prototype._eventsCount=0,k.prototype._maxListeners=void 0;var S=10;function x(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function M(t){return void 0===t._maxListeners?k.defaultMaxListeners:t._maxListeners}function j(t,e,r,n){var o,i,s,a;if(x(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=M(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function T(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function F(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=T.bind(n);return o.listener=r,n.wrapFn=o,o}function z(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):I(o,o.length)}function B(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function I(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function Z(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}function R(t){return null!=t}function V(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=V(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?V(n[t],o[t],r):o[t]}))),s}function G(t){return{type:"Polygon",coordinates:[N(t)]}}function N(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return S},set:function(t){if("number"!=typeof t||t<0||P(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");S=t}}),k.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||P(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},k.prototype.getMaxListeners=function(){return M(this)},k.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)E(a,this,e);else{var u=a.length,c=I(a,u);for(r=0;r<u;++r)E(c[r],this,e)}return!0},k.prototype.on=k.prototype.addListener=function(t,e){return j(this,t,e,!1)},k.prototype.prependListener=function(t,e){return j(this,t,e,!0)},k.prototype.once=function(t,e){return x(e),this.on(t,F(this,t,e)),this},k.prototype.prependOnceListener=function(t,e){return x(e),this.prependListener(t,F(this,t,e)),this},k.prototype.off=k.prototype.removeListener=function(t,e){var r,n,o,i,s;if(x(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},k.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},k.prototype.listeners=function(t){return z(this,t,!0)},k.prototype.rawListeners=function(t){return z(this,t,!1)},k.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):B.call(t,e)},k.prototype.listenerCount=B,k.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]};var J=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),W=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);if(i)return i;var a=r(s.apply(this,n),t);return a},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),D=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),H=function(t,e,r,n){try{t(r(n))}catch(t){e(t)}},K=0,Q=function(){function t(e,r){var n=this;this.id=K++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new J)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new D)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new W(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?H(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?H(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new J),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new J:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(t){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=J,t.TimeoutError=D,t.PromiseControl=W,t}();Object.setPrototypeOf(Q.prototype,Promise.prototype);var U=Q,$=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},q=function(){function t(){this.keyCodeAlias=new $,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),X=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),Y=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(X),tt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(X);var et=0,rt={minZoom:0,maxZoom:20,paint:{color:"blue",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"darkblue",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},nt=function(){function t(e){this.options=rt,this.emitter=new O.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[Y,tt],this.id=et++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=V(rt||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:G(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){return this.mapAdapter.getZoom()},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){this.mapAdapter.setView&&t&&R(e)?this.mapAdapter.setView(t,e):(t&&this.mapAdapter.setCenter(t),R(e)&&this.mapAdapter.setZoom(e))},t.prototype.fitBounds=function(t,e){return t.every((function(t){return R(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new U((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){var r;i(),!(r=t).lngLat&&r.latLng&&(r.lngLat=[r.latLng.lng,r.latLng.lat]),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),R(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),R(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),R(t.maxzoom)&&R(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new q,t}(),ot=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e&&e.options)return e.options.id;throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var s,a;return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var o,u,c,p,l,h,f,d,y,v,m,g,_,L,b;return i(this,(function(i){switch(i.label){case 0:return o=this._layersIdCounter++,u=R(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(c=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(c=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:c=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(p=e),h=(l=this.options).maxZoom,f=l.minZoom,e=n({id:String(o),order:u,maxZoom:h,minZoom:f},e),d=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(y=this.options.onBeforeAddLayer({options:e,adapter:c}))&&(y.options&&(e=y.options),y.adapter&&(c=y.adapter)),void 0===c?[3,12]:((v=new c(this.mapAdapter.map,e)).options=n(n({},e),v.options),v.options.baselayer&&(e.baselayer=!0,e.order=0,v.options.order=0),m=void 0,v.options.id&&(m=String(v.options.id),this._layers[m]=v),this._emitLayerEvent("layer:preadd",m||"",v),[4,this.onMapLoad()]);case 5:return i.sent(),v.map=this.mapAdapter.map,[4,v.addLayer(v.options)];case 6:if(g=i.sent(),v.layer=g,v.id=v.options.id||String(o),v.options.id=v.id,e.baselayer&&(v.options.order=0),v.order=null!==(a=v.options.order)&&void 0!==a?a:u,m&&delete this._layers[m],m=String(v.id),this._layers[m])throw Error("layer with id '"+m+"' already exist");return m?(this._layers[m]=v,p.filter&&this.filterLayer(v,p.filter),e.baselayer&&this._baselayers.push(m),d?[4,this.showLayer(m)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(_=e.opacity)&&_<=1&&this.setLayerOpacity(v,_),L=g&&(v.getBounds||v.getExtent),e.fit&&L?[4,L.call(v)]:[3,11];case 9:return(b=i.sent())?[4,this.fitBounds(b)]:[3,11];case 10:i.sent(),i.label=11;case 11:return this._emitLayerEvent("layer:add",m,v),[2,v];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=w(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){return this.addLayer("IMAGE",n(n({},e),{url:t}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,o(n,void 0,void 0,(function(){var e,r,n,o,s,c,p,l=this;return i(this,(function(i){switch(i.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,5];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];s=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=s,i.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?t.showLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.showLayer(t.layer),void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,6];case 5:t.hideLayer?t.hideLayer.call(t,t.layer):void 0!==t.layer&&this.mapAdapter.hideLayer(t.layer),i.label=6;case 6:return u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),t.options.visibility=a,[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this.getLayer(t);e&&(e.updateLayer?e.updateLayer():this.isLayerVisible(e)&&(this.hideLayer(e,{silent:!0}),this.showLayer(e,{silent:!0})))},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||y(t.feature.properties,e)}))}},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._onLayerClick=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),R(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),R(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=m(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=m(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},e.prototype._emitLayerEvent=function(t,e,r){if(R(e)&&t.startsWith("layer:")){var n=t.replace("layer:","layer-"+e+":");this.emitter.emit(n,r)}this.emitter.emit(t,r)},e}(nt);function it(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},h=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},f=t({html:r,onClick:h});return f.onClick=h,f.changeStatus=l,f}var st=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return o(this,void 0,void 0,(function(){var n,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return o(s,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,it(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(ot),at={};function ut(t){return at[t]}var ct=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),at[r.id]=r,r}return r(e,t),e.get=function(t){return ut(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return o(this,void 0,void 0,(function(){var o,s,u,c,p,l,h,f,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),o=a(this._starterKits),i.label=1;case 1:return[4,o.next()];case 2:return(s=i.sent()).done?[3,17]:(u=s.value).getLayerAdapters?[4,u.getLayerAdapters.call(u)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=a(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(h=l.value).createAdapter(this)];case 7:(f=i.sent())&&(this.mapAdapter.layerAdapters[h.name]=f),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(n=p.return)?[4,n.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),s&&!s.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return o(this,void 0,void 0,(function(){var r,n,o,s,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=a(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return s=i.sent(),console.error(s),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return u=i.sent(),t={error:u},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(st);return t.WebMap=ct,t.WebMapControls=st,t.WebMapLayers=ot,t.WebMapMain=nt,t.createToggleControl=it,t.createWebMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new ct(t).onLoad()]}))}))},t.detectGeometryType=_,t.findMostFrequentGeomType=g,t.getWebMap=ut,t.updateGeoJsonAdapterOptions=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
//# sourceMappingURL=webmap.global.prod.js.map
{
"name": "@nextgis/webmap",
"version": "1.7.0",
"version": "1.8.0",
"_priority": 14,

@@ -12,3 +12,3 @@ "description": "Universal map constructor",

"dependencies": {
"@nextgis/cancelable-promise": "^1.7.0",
"@nextgis/cancelable-promise": "^1.8.0",
"@nextgis/paint": "^1.7.0",

@@ -59,3 +59,3 @@ "@nextgis/properties-filter": "^1.7.0",

},
"gitHead": "a3113b03e87540abf798c1151d3243a1e20c8607"
"gitHead": "9d65a0f80bff7c2a9fc04229bef131cec5c7e752"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc