@nextgis/ngw-map 3.0.0-alpha.3 → 3.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var NgwMap=function(e){"use strict";function t(){}function r(){r.init.call(this)}function n(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function o(e,r,o,i){var s,a,l,c;if("function"!=typeof o)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",r,o.listener?o.listener:o),a=e._events),l=a[r]):(a=e._events=new t,e._eventsCount=0),l){if("function"==typeof l?l=a[r]=i?[o,l]:[l,o]:i?l.unshift(o):l.push(o),!l.warned&&(s=n(e))&&s>0&&l.length>s){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=r,u.count=l.length,c=u,"function"==typeof console.warn?console.warn(c):console.log(c)}}else l=a[r]=o,++e._eventsCount;return e}function i(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function s(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function a(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}t.prototype=Object.create(null),r.EventEmitter=r,r.usingDomains=!1,r.prototype.domain=void 0,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.init=function(){this.domain=null,r.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new t,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return n(this)},r.prototype.emit=function(e){var t,r,n,o,i,s,l,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(l=this.domain,c){if(t=arguments[1],!l){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=l,t.domainThrown=!1,l.emit("error",t),!1}if(!(r=s[e]))return!1;var p="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=a(e,n),i=0;i<n;++i)o[i].call(r)}(r,p,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=a(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,p,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=a(e,i),l=0;l<i;++l)s[l].call(r,n,o)}(r,p,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,l=a(e,s),c=0;c<s;++c)l[c].call(r,n,o,i)}(r,p,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=a(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,p,this,o)}return!0},r.prototype.on=r.prototype.addListener=function(e,t){return o(this,e,t,!1)},r.prototype.prependListener=function(e,t){return o(this,e,t,!0)},r.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,i(this,e,t)),this},r.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,i(this,e,t)),this},r.prototype.removeListener=function(e,r){var n,o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===r||n.listener&&n.listener===r)0==--this._eventsCount?this._events=new t:(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if("function"!=typeof n){for(i=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new t,this;delete o[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(n,i);o.removeListener&&this.emit("removeListener",e,a||r)}return this},r.prototype.off=function(e,t){return this.removeListener(e,t)},r.prototype.removeAllListeners=function(e){var r,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new t,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new t:delete n[e]),this;if(0===arguments.length){for(var o,i=Object.keys(n),s=0;s<i.length;++s)"removeListener"!==(o=i[s])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new t,this._eventsCount=0,this}if("function"==typeof(r=n[e]))this.removeListener(e,r);else if(r)do{this.removeListener(e,r[r.length-1])}while(r[0]);return this},r.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):s.call(e,t)},r.prototype.listenerCount=s,r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};const l={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'},c=12;function u(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach((t=>{Object.getOwnPropertyNames(t.prototype).forEach((r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}}))}))}function p(e){return null!=e}function h(e){return"string"==typeof e?!!e:p(e)}function d(e,t,r=!1){let n=e;const o=t,i=Array.isArray(o);let s=i&&[]||{};return i&&Array.isArray(o)?r?(n=n||[],s=s.concat(n),o.forEach(((e,t)=>{void 0===s[t]?s[t]=e:"object"==typeof e?s[t]=d(n[t],e,r):-1===n.indexOf(e)&&s.push(e)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(e){s[e]=n[e]})),Object.keys(o).forEach((function(e){s[e]="object"==typeof o[e]&&o[e]&&"object"==typeof n[e]&&"object"==typeof o[e]?d(n[e],o[e],r):o[e]}))),s}function f(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}const y=6371;function m(e){return{type:"Polygon",coordinates:[g(e)]}}function g(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const b=Math.PI/180,v=180/Math.PI;function w(e,t,r=10,n=6){const o=r/y*v,i=o/Math.cos(t*b),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function _(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}function O(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:L(e,t));return e===t}function L(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!O(e[r[o]],t[n[o]],e,t))return!1}return!0}function P(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=P(e[r])})),t}function I(e){return"[object Object]"===Object.prototype.toString.call(e)}function x(e){return e.replace(/([^:]\/)\/+/g,"$1")}var E=Object.defineProperty,j=(e,t,r)=>((e,t,r)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const A=class e{constructor(t={}){var r;j(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r){return this.add(e,t,r,!0)}add(e,t,r,n){const o=this._find(e,r);if(o)return o.value;{let o;o=t instanceof Function?t():t;const i=r&&JSON.parse(JSON.stringify(P(r))),s={key:e,value:o,props:i};return n&&!h(o)?o:(this.cache.push(s),o instanceof Promise?(o.catch((t=>{this.delete(e,r)})),n&&o.then((t=>(h(t)||this.delete(e,r),t))),o):o)}}match(e,t){const r=this._find(e,t);return null==r?void 0:r.value}matchAll(e,t){return e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return L(e.props||{},P(r))}};j(A,"instance",{});let C=A;var M="3.0.0-alpha.3",k=Object.defineProperty,S=(e,t,r)=>((e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class N extends Error{constructor(e){super(),S(this,"name","NgwError"),S(this,"title"),S(this,"message"),S(this,"detail"),S(this,"exception"),S(this,"status_code"),S(this,"data"),S(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,N.prototype)}}var T=Object.defineProperty,F=(e,t,r)=>((e,t,r)=>t in e?T(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class B extends N{constructor(e){super(e),F(this,"name","ResourceNotFoundError"),F(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,B.prototype)}}function R(e){return"[object Object]"===Object.prototype.toString.call(e)}const $=["description"];function D(e,t=""){t=t?t+"__":"";const r={};for(const[n,o]of Object.entries(e))if(-1===$.indexOf(n))if(R(o))if("owner_user"===n){const e=D(o,n);Object.assign(r,e)}else"parent"===n&&"id"in o&&(r.parent_id=o.id);else p(o)&&(r[t+n]=o);return r}var q=Object.defineProperty,G=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,z=(e,t,r)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Z=(e,t)=>{for(var r in t||(t={}))V.call(t,r)&&z(e,r,t[r]);if(G)for(var r of G(t))U.call(t,r)&&z(e,r,t[r]);return e},W=(e,t,r)=>z(e,"symbol"!=typeof t?t+"":t,r);class J{constructor({connector:e,cacheId:t}){W(this,"cache"),W(this,"connector"),this.connector=e,this.cache=new C({namespace:t})}getOne(e,t){const r=Z({},t);return"string"==typeof e||"number"==typeof e||R(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):R(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new B}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||R(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then((e=>{if(void 0===e)throw new Error;return e}))}getMany(e,t){return this._resourceCacheFilter(e).then((r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,D(e)),this.connector.get("resource.search",t,Z({serialization:"full"},r)).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>e?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t,r=[]){return this.connector.get("resource.collection",t,{parent:e}).then((e=>{const n=[];for(const o of e)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(o),{id:o.resource.id}),r.push(o),(null==t?void 0:t.recursive)&&o.resource.children&&n.push(this._getChildrenOf(o.resource.id,t,r));return n.length?Promise.all(n).then((()=>r)):r}))}_cleanResourceItemCache(e){return t=this,r=null,n=function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;["resource.item","resource"].includes(o.key)&&void 0!==r&&("number"==typeof r?r===e&&n.push(o):(yield this.getId(r))===e&&n.push(o))}for(const e of n)this.cache.delete(e)},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}_fetchResourceById(e,t){return this.connector.get("resource.item",t,{id:e})}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:p(e.id)&&p(t.resource.id)?e.id===t.resource.id:L(e,t.resource)})),[])))}}const H=[];function Q(e){H.push(e)}class K extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var X=Object.defineProperty,Y=(e,t,r)=>((e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ee extends N{constructor(e){super(e),Y(this,"name","InsufficientPermissionsError"),Y(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,ee.prototype)}}const te=/\{ *([\w_-]+) *\}/g;function re(e,t){return e.replace(te,((e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var ne=Object.defineProperty,oe=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,ae=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function le(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=re(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach((([e,t])=>{r.push(`${e}=${t}`)}));for(const e in t)-1===s.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))ie.call(t,r)&&ae(e,r,t[r]);if(oe)for(var r of oe(t))se.call(t,r)&&ae(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var ce=Object.defineProperty,ue=(e,t,r)=>((e,t,r)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class pe extends Error{constructor(e){super(),ue(this,"name","NetworkError"),Object.setPrototypeOf(this,pe.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}let he;he=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new N(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new pe(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{i.abort()})),i.send(l)};var de=Object.defineProperty,fe=Object.defineProperties,ye=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t)=>{for(var r in t||(t={}))ge.call(t,r)&&ve(e,r,t[r]);if(me)for(var r of me(t))be.call(t,r)&&ve(e,r,t[r]);return e},_e=(e,t,r)=>ve(e,"symbol"!=typeof t?t+"":t,r),Oe=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let Le=0,Pe=0;class Ie{constructor(e){this.options=e,_e(this,"id",Le++),_e(this,"emitter",new r),_e(this,"user"),_e(this,"resources"),_e(this,"cache"),_e(this,"withCredentials"),_e(this,"client",`NextGIS-NGW-Connector/${M}`),_e(this,"routeStr","/api/component/pyramid/route"),_e(this,"activeRequests",{}),_e(this,"requestTransform");const t=function(e){return H.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return L(t.options.auth,e.auth)}}))}(e);if(this.cache=new C({namespace:e.cacheId}),t)return t;{const{route:t,requestTransform:r,withCredentials:n}=this.options;t&&(this.routeStr=t),r&&(this.requestTransform=r),void 0!==n&&(this.withCredentials=n),this.resources=new J({connector:this,cacheId:e.cacheId}),Q(this)}}static create(e){return new this(e)}clearCache(){this.cache.clean(),this.resources.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Q(this)}connect(){return Oe(this,null,(function*(){const e=this.options.auth;if(e){const{login:t,password:r}=e;t&&r&&(yield this._login({login:t,password:r}))}const t=`${this.routeStr}?client=${this.client}`;return yield this.makeQuery(t,{},{cacheName:"route",cache:!0,cacheProps:{id:this.id,auth:e,baseUrl:this.options.baseUrl}})}))}login(e,t){return this.logout(),Q(this),this._login(e,t)}logout(){this.abort(),function(e){const t=H.indexOf(e);-1!==t&&H.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return Oe(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=we({headers:this.getAuthorizationHeaders(e)},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);if(t)return{Authorization:`Basic ${t}`}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return we({},this.activeRequests)}apiRequest(e,t={},r={}){var n;return le({name:e,params:P(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}makeQuery(e,t){return Oe(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)ge.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&me)for(var n of me(e))t.indexOf(n)<0&&be.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=re(e,r)}e=encodeURI(x(e)),r=we({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:p}=r,h=new AbortController,d=h.signal;if(i){if(i.aborted)throw new K;i.addEventListener("abort",(()=>{h.abort()}))}r.signal=d;const f=()=>Oe(this,null,(function*(){const t=Pe++;this.activeRequests[t]=h;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if(o&&"GET"===s){const r=c||(y=we({},P({headers:a,withCredentials:p,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),fe(y,ye({params:t})));return this.cache.add(l||e,f,r,!1)}var y;return f()}))}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=we(we({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;he(e,r,t,n,(e=>{i=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==i&&i(),n(new K)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return Oe(this,null,(function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}}))}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof N){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new B(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new ee(e)}return e}}_e(Ie,"errors",{NgwError:N,ResourceNotFoundError:B});var xe=Object.defineProperty,Ee=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,Ce=(e,t,r)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Me=(e,t)=>{for(var r in t||(t={}))je.call(t,r)&&Ce(e,r,t[r]);if(Ee)for(var r of Ee(t))Ae.call(t,r)&&Ce(e,r,t[r]);return e};function ke(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const Se={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>ke(e,t),ilike:(e,t)=>ke(e,t,!0)};function Ne(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Te(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Ne(t)){const[r,n,o]=t,i=Se[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,i)=>(t=e[i],r.replace(i,o))));return i(t,n)}return i(e[r],o)}return!1}return Te(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}var Fe=Object.defineProperty,Be=Object.defineProperties,Re=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Ge=(e,t,r)=>t in e?Fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ve=(e,t)=>{for(var r in t||(t={}))De.call(t,r)&&Ge(e,r,t[r]);if($e)for(var r of $e(t))qe.call(t,r)&&Ge(e,r,t[r]);return e},Ue=(e,t)=>Be(e,Re(t)),ze=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Ze={srs:4326,geom_format:"geojson"};function We(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function Je(e,t){const{extensions:r,geom:n,fields:o,srs:i,ilike:s,like:a}=t,l=r?r.join(","):"";"*"!==l&&(e.extensions=l),null!=o&&(e.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),p(s)?e.ilike=s:p(a)&&(e.like=a),p(i)&&(e.srs=i)}function He(e){return ze(this,null,(function*(){const t=Ke(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o}))}function Qe(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,i=n,r)))}__${r}`,o+n+i]}function Ke(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===s)for(const l of a)Ne(l)?t.push(Ye(Ue(Ve({},e),{paramList:[...r,...i,Qe(l)]}))):Ke(Ue(Ve({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Ne(e)?n.push(Qe(e)):o.push(e);if(o.length)for(const i of o)Ke(Ue(Ve({},e),{filters:i}),t,[...r,...n]);else t.push(Ye(Ue(Ve({},e),{paramList:[...r,...i,...n]})))}return t}function Xe(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=_(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Ye(e){const t=Ve({},Ze),{limit:r,cache:n,signal:o,offset:i,orderBy:s,paramList:a,connector:l,geomFormat:c,intersects:u,resourceId:p}=e;if(r?r!==Number.POSITIVE_INFINITY&&(t.limit=r):t.limit=7e3,i&&(t.offset=i),c&&(t.geom_format=c),Je(t,e),s&&(t.order_by=s.join(",")),Array.isArray(u)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every((e=>"number"==typeof e))}(u)?g(u):u;t.intersects=Xe(e)}else"string"==typeof u&&(t.intersects=u);a&&(t.paramList=a);const h=Ve({id:p},t);return l.get("feature_layer.feature.collection",{cache:n,signal:o},h)}var et=Object.defineProperty,tt=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,nt=Object.getOwnPropertySymbols,ot=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable,st=(e,t,r)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,at=(e,t)=>{for(var r in t||(t={}))ot.call(t,r)&&st(e,r,t[r]);if(nt)for(var r of nt(t))it.call(t,r)&&st(e,r,t[r]);return e},lt=(e,t)=>tt(e,rt(t)),ct=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function ut(e){return ct(this,null,(function*(){const t=at({},Ze);Je(t,e);const r=at({id:e.resourceId,fid:e.featureId},t),n=yield e.connector.get("feature_layer.feature.item",e,r);return lt(at({},n),{toGeojson:()=>ct(this,null,(function*(){if(n.geom)return We(n);{const t=(yield ut(lt(at({},e),{geom:!0,fields:null,extensions:null}))).geom;return We(lt(at({},n),{geom:t}))}}))})}))}var pt=Object.defineProperty,ht=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,yt=(e,t,r)=>t in e?pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mt=(e,t,r)=>yt(e,"symbol"!=typeof t?t+"":t,r);class gt{constructor(e){this.options=e,mt(this,"name"),mt(this,"resourceId"),mt(this,"item"),mt(this,"_extent"),this.resourceId=e.resourceId;const t=e.item;this.item=t,this.name=e.labelField&&t.fields?t.fields[e.labelField]:String(t.id)}extent(e){return this._extent?Promise.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",e,{id:this.resourceId,fid:this.item.id}).then((e=>{const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}))}geoJson(e){return this.item.geom?Promise.resolve(We(this.item)):ut(((e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&yt(e,r,t[r]);if(ht)for(var r of ht(t))ft.call(t,r)&&yt(e,r,t[r]);return e})({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null},e)).then((e=>(this.item.geom=e.geom,We(this.item))))}}function bt(e,t,r,n){return!!_t(e,t,r,Ot)}function vt(e,t,r,n){return _t(e,t,r,Lt)}function wt(e,t="children"){let r=[];const n=("function"==typeof t?t:e=>e[t])(e);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function _t(e,t=(e=>!!e),r="children",n,o){return n(e,"function"==typeof t?t:e=>Te(e,t),r)}function Ot(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=wt(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=Ot(o[i],t,r,n);if(e)return e}}function Lt(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=wt(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&Lt(o[i],t,r,n);return n}function Pt(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=wt(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!Pt(o[i],t,r,n))return!1}return!0}var It=Object.defineProperty,xt=(e,t,r)=>((e,t,r)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Et{constructor(e){xt(this,"item"),xt(this,"_children",[]),xt(this,"_parent"),this.item=e}setParent(e){this._parent=e}addChild(e){this._children.push(e)}getParent(){return this._parent}getParents(e){const t=this.getParent();return t?vt(t,e,(e=>e.tree.getParent())):[]}getRoot(){let e=this.getParent(),t=e;for(;e;)e=e.tree.getParent(),e&&(t=e);return t}find(e){return _t(this._children,e,(e=>e.tree.getChildren()),Ot)}every(e){return!!_t(this._children,e,(e=>e.tree.getChildren()),Pt)}some(e){return bt(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return vt(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var jt=Object.defineProperty,At=(e,t,r)=>((e,t,r)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ct{constructor(e,t,n){At(this,"options"),At(this,"emitter",new r),At(this,"name"),At(this,"item"),At(this,"_blocked",!1),At(this,"_container"),At(this,"_value"),At(this,"_removeEventsListener"),this.item=t,this.options=Object.assign({},n),this.name=e,this._value=this.getProperty()}getProperty(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value}getParents(){return this.item.tree.getParents()||[]}getParent(){return this.item.tree.getParent()}getChildren(){return this.item.tree.getChildren()}isGroup(){return this.item.tree.getDescendants().length}isBlocked(){if(void 0!==this._blocked)return this._blocked;const e=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(e),this._blocked}set(e,t){this._value=this._prepareValue(e),this.update(this._value,t),this._fireChangeEvent(this._value,t)}get(){return this.getValue()}update(e,t){this._callOnSet(e,t)}getContainer(){return this._container}destroy(){if(this._container){const e=this._container.parentNode;e&&e.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()}getValue(){return void 0!==this._value?this._value:this.getProperty()}_prepareValue(e){return e}_callOnSet(e,t){this.options.onSet&&this.options.onSet.call(this,e,t,this.item)}_fireChangeEvent(e,t){if(this.emitter){e=void 0!==e?e:this.getValue(),this.emitter.emit("change",{value:e,options:t});this.item.tree.getParents().forEach((r=>{const n=r.properties&&r.properties.property(this.name);n&&n.emitter.emit("change-tree",{value:e,options:t,item:this.item})}))}}_calculateBlockedStatus(e){return e.some((e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()}))}}var Mt=Object.defineProperty,kt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,Tt=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ft=(e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Tt(e,r,t[r]);if(kt)for(var r of kt(t))Nt.call(t,r)&&Tt(e,r,t[r]);return e};const Bt=class e extends Ct{constructor(t,r,n){super(t,r,Ft(Ft({},e.options),n)),this.set(this.get())}update(e,t){if(e){if(t&&t.bubble||this.options.bubble){this.unBlock(t);const r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(e,Object.assign({},t,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(t)}else this._turnOff(t);(t&&t.propagation||this.options.propagation)&&this._propagation(e,t)}getHierarchyValue(){return this.get()&&this.getParents().every((e=>{const t=e.properties&&e.properties.get(this.name);return t&&t.get()}))}block(e){this._blocked=!0,this._block(e)}unBlock(e){this._blocked=!1,this.getValue()&&this._unBlock(e)}blockChild(e){this.item.tree.getDescendants().forEach((t=>this._blockChild(t,e)))}unblockChild(e){this.item.tree.getChildren().forEach((t=>this._unBlockChild(t,e)))}_prepareValue(e){return e}_turnOff(e){this.options.turnOff&&this.options.turnOff.call(this,e),this._callOnSet(!1,e),this.options.hierarchy&&this.isGroup()&&this.blockChild(e)}_turnOn(e){this.options.turnOn&&this.options.turnOn.call(this,e),this._callOnSet(!0,e),this.options.hierarchy&&this.isGroup()&&this.unblockChild(e)}_block(e){this._turnOff(e)}_unBlock(e){this._turnOn(e)}_blockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.block&&r.block(t)}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(t)}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,Ft(Ft({},t),{propagation:!0,bubble:!1}))}}}};Tt(Bt,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let Rt=Bt;var $t=Object.defineProperty,Dt=Object.getOwnPropertySymbols,qt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?$t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t,r)=>Vt(e,"symbol"!=typeof t?t+"":t,r);const zt=class e{constructor(e,t){this.item=e,Ut(this,"options",{}),Ut(this,"_properties",{}),Ut(this,"_propertiesList",[]),t&&t.forEach(this._setPropertyHandler.bind(this))}add(e){this._setPropertyHandler(e)}update(){this.list().forEach((e=>e.update()))}get(e){const t=this.property(e);return t?t.get():void 0}set(e,t,r){const n=this.property(e);n&&n.getValue()!==t&&n.set(t,r)}property(e){return this._properties[e]}list(){return this._propertiesList.map((e=>this._properties[e]))}destroy(){for(const e in this._properties){const t=this.property(e);t&&t.destroy&&t.destroy()}this._properties={},this._propertiesList=[]}_setPropertyHandler(e){const t=this._getHandler(e);if(t&&e.name){const r=((e,t)=>{for(var r in t||(t={}))qt.call(t,r)&&Vt(e,r,t[r]);if(Dt)for(var r of Dt(t))Gt.call(t,r)&&Vt(e,r,t[r]);return e})({},e);this._properties[e.name]=new t(e.name,this.item,r),this._propertiesList.push(e.name)}}_getHandler(t){const r=t.handler;return!r&&t.type?"boolean"===t.type?e.handlers.CheckProperty:e.handlers.BaseProperty:r}};Ut(zt,"handlers",{CheckProperty:Rt});let Zt=zt;var Wt=Object.defineProperty,Jt=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Kt=(e,t,r)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xt=(e,t,r)=>Kt(e,"symbol"!=typeof t?t+"":t,r);let Yt=0;class er{constructor(e){Xt(this,"options",{}),Xt(this,"properties"),Xt(this,"tree"),Xt(this,"id",Yt),Yt+=1,this.options=((e,t)=>{for(var r in t||(t={}))Ht.call(t,r)&&Kt(e,r,t[r]);if(Jt)for(var r of Jt(t))Qt.call(t,r)&&Kt(e,r,t[r]);return e})({},e),this.tree=new Et(this)}initProperties(){this.properties=new Zt(this,this.options.properties)}}var tr=Object.defineProperty,rr=Object.defineProperties,nr=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,ir=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,ar=(e,t,r)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lr=(e,t)=>{for(var r in t||(t={}))ir.call(t,r)&&ar(e,r,t[r]);if(or)for(var r of or(t))sr.call(t,r)&&ar(e,r,t[r]);return e},cr=(e,t)=>rr(e,nr(t));function ur(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function pr({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.get("layer.extent",{cache:r,signal:n},{id:e}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}function hr(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then((t=>{if(t)return dr(t,e.connector,e)}))}function dr(e,t,r){if(e.webmap)return Promise.resolve(ur(e.webmap));{const n=e.resource;return n.cls&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id,r).then((e=>{if(e)return pr(cr(lr({},r),{resourceId:e.resource.id,connector:t}))})):pr(cr(lr({},r),{resourceId:n.id,connector:t}))}}var fr=Object.defineProperty,yr=(e,t,r)=>((e,t,r)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),mr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class gr{constructor(){yr(this,"item"),yr(this,"connector"),yr(this,"_extent")}getExtent(){return mr(this,null,(function*(){return this.getBounds()}))}getBounds(e){return mr(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield dr(this.item,this.connector,e),this._extent):void 0}))}}var br=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function vr(e,t){return br(this,null,(function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield vr(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i}))}const wr={tms:"TILE"};var _r=Object.defineProperty,Or=Object.getOwnPropertySymbols,Lr=Object.prototype.hasOwnProperty,Pr=Object.prototype.propertyIsEnumerable,Ir=(e,t,r)=>t in e?_r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xr=(e,t)=>{for(var r in t||(t={}))Lr.call(t,r)&&Ir(e,r,t[r]);if(Or)for(var r of Or(t))Pr.call(t,r)&&Ir(e,r,t[r]);return e},Er=(e,t,r)=>Ir(e,"symbol"!=typeof t?t+"":t,r);const jr="https://qms.nextgis.com";function Ar(e,t=jr,r={}){let n;if("webMap"in e){const o=e,{webMap:i,url:s}=o,a=((e,t)=>{var r={};for(var n in e)Lr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Or)for(var n of Or(e))t.indexOf(n)<0&&Pr.call(e,n)&&(r[n]=e[n]);return r})(o,["webMap","url"]);n=i,s&&(t=s),a&&(r=a)}else n=e;t||(t=jr);class o{constructor(e,t){Er(this,"qms"),Er(this,"options"),Er(this,"map"),this.map=e;const n=xr(xr({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,i=null,s=function*(){if(!this.qms&&e.qmsId)try{this.qms=yield function(e){return new Promise(((t,r)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status&&n.responseText)try{t(JSON.parse(n.responseText))}catch(e){r(e)}},n.open("GET",x(e),!0),n.send()}))}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=wr[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(i=o,s=a,["showLayer","hideLayer"].forEach((e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(i.prototype,e,t)})),"TILE"===t)){if(e=xr(xr({order:0,maxZoom:n.options.maxZoom,minZoom:n.options.minZoom},this.options),function(e){const t=("https:"===location.protocol?"https":"http")+"://";let r=e.url.replace(/^(https?|ftp):\/\//,t);return e.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:e.name,attribution:e.copyright_text,maxZoom:e.z_max,minZoom:e.z_min}}(r)),r.origin_url){const[t,n]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,((e,r)=>("string"==typeof r&&r.split(",").forEach((e=>t.push(e))),"{s}"))),t]}(r.origin_url);n.length&&(e.subdomains=n,e.url=t)}return this.options=e,new a(this.map,e).addLayer(e)}}var i,s},new Promise(((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},o=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((s=s.apply(r,i)).next())}));var r,i,s}}return o}var Cr=Object.defineProperty,Mr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Nr=(e,t,r)=>t in e?Cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tr=(e,t)=>{for(var r in t||(t={}))kr.call(t,r)&&Nr(e,r,t[r]);if(Mr)for(var r of Mr(t))Sr.call(t,r)&&Nr(e,r,t[r]);return e},Fr=(e,t,r)=>Nr(e,"symbol"!=typeof t?t+"":t,r);class Br{constructor(e){Fr(this,"options",{url:"https://qms.nextgis.com"}),Fr(this,"url"),this.options=Tr(Tr({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return Ar({webMap:e,url:this.url})}}Fr(Br,"utils",{createQmsAdapter:Ar});var Rr=Object.defineProperty,$r=Object.defineProperties,Dr=Object.getOwnPropertyDescriptors,qr=Object.getOwnPropertySymbols,Gr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,zr=Reflect.get,Zr=(e,t,r)=>t in e?Rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wr=(e,t)=>{for(var r in t||(t={}))Vr.call(t,r)&&Zr(e,r,t[r]);if(qr)for(var r of qr(t))Ur.call(t,r)&&Zr(e,r,t[r]);return e},Jr=(e,t)=>$r(e,Dr(t)),Hr=(e,t,r)=>zr(Gr(e),r,t),Qr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Kr(e){let t;for(t in e){const r=e[t];if(I(r)){const n=r;if(p(n.year)&&p(n.month)&&p(n.day)){const r=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((e=>{r.push(e)})),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var Xr=Object.defineProperty,Yr=Object.defineProperties,en=Object.getOwnPropertyDescriptors,tn=Object.getOwnPropertySymbols,rn=Object.prototype.hasOwnProperty,nn=Object.prototype.propertyIsEnumerable,on=(e,t,r)=>t in e?Xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sn=(e,t)=>{for(var r in t||(t={}))rn.call(t,r)&&on(e,r,t[r]);if(tn)for(var r of tn(t))nn.call(t,r)&&on(e,r,t[r]);return e},an=(e,t)=>Yr(e,en(t)),ln=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function cn(e){return ln(this,null,(function*(){var t;const r=e.filters;if(r){let n=yield He(an(sn({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:un(r))&&(n=n.filter((e=>Te(Kr(an(sn({},e.fields),{id:e.id})),r)))),n}return Ye(e)}))}function un(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(un(r))return!0}}return!1}var pn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function hn(e){return function(e){return pn(this,null,(function*(){const t=yield cn(e),r=[];return t.forEach((e=>{r.push(We(e))})),r}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const dn=["fields","intersects","limit","orderBy","strategy"];function fn(e){const t={};return dn.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var yn=Object.defineProperty,mn=Object.defineProperties,gn=Object.getOwnPropertyDescriptors,bn=Object.getOwnPropertySymbols,vn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty,_n=Object.prototype.propertyIsEnumerable,On=Reflect.get,Ln=(e,t,r)=>t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pn=(e,t)=>{for(var r in t||(t={}))wn.call(t,r)&&Ln(e,r,t[r]);if(bn)for(var r of bn(t))_n.call(t,r)&&Ln(e,r,t[r]);return e},In=(e,t)=>mn(e,gn(t)),xn=(e,t,r)=>Ln(e,"symbol"!=typeof t?t+"":t,r),En=(e,t,r)=>On(vn(e),r,t),jn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function An(e){return jn(this,null,(function*(){var t,n;const{item:o,webMap:i,Adapter:s,connector:a,layerOptions:l,addLayerOptionsPriority:c}=e,u=null==c||c,p=l,h=s||l.Adapter||i.mapAdapter.layerAdapters.GEOJSON,d=[];let f,y,m=!1;const g=yield vr(p,a);(null==(n=null==(t=p.adapterOptions)?void 0:t.popupOptions)?void 0:n.fromProperties)&&(p.adapterOptions.popupOptions.createPopupContent=({feature:e})=>e&&function(e,t){{const r=document.createElement("div");if(t&&t.feature_layer)t.feature_layer.fields.forEach((t=>{if(t.grid_visibility){const n=e.properties&&e.properties[t.keyname];if(n){const e=document.createElement("div");r.appendChild(e),e.innerHTML=`<span>${t.display_name}</span>: ${n}<span></span>`}}}));else if(e.properties)for(const t in e.properties){const n=document.createElement("div");r.appendChild(n),n.innerHTML=`<span>${t}</span>: ${e.properties[t]}<span></span>`}return r}}(e,o));const b=(e,t)=>jn(this,null,(function*(){w(),y=new AbortController;const r=y.signal;return(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",y.abort),(t=t||{}).signal=r,f={filters:e,options:t},hn(Pn({resourceId:g,filters:e,connector:a,cache:!0},t))}));let v=!1;const w=()=>{y&&(y.abort(),y=void 0)};class _ extends h{constructor(){super(...arguments),xn(this,"emitter",new r),xn(this,"__onMapMove"),xn(this,"__onMapMoveStart"),xn(this,"__enableMapMoveListener"),xn(this,"__disableMapMoveListener")}addLayer(e){return jn(this,null,(function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==p.id&&(e.id=p.id),o&&o.vector_layer&&(e.type=po[o.vector_layer.geometry_type]),p.adapterOptions&&(e=u?Pn(Pn({},p.adapterOptions),e):Pn(Pn({},e),p.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const n=e.strategy||void 0;this.options.strategy=n;const i=En(_.prototype,this,"addLayer").call(this,e);let s;return f={filters:e.propertiesFilter,options:fn(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),n&&n.startsWith("BBOX")&&!m&&this._addBboxEventListener(),i}))}getExtent(){return this.getBounds()}getBounds(){return jn(this,null,(function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?hr({connector:a,resourceId:o.resource.id}):En(_.prototype,this,"getBounds")?En(_.prototype,this,"getBounds").call(this):void 0}))}beforeRemove(){v=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,w()}getCount(){return function({connector:e,resourceId:t,cache:r=!0,signal:n}){return e.get("feature_layer.feature.count",{cache:r,signal:n},{id:t}).then((e=>e.total_count))}({connector:a,resourceId:g,cache:!0})}updateLayer(e){return jn(this,null,(function*(){var t;if(e=e||f||{},null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield i.onLoad("create"),e.options=e.options||{},e.options.intersects=i.getBounds();const{minZoom:t,maxZoom:r}=this.options,n=i.getZoom();if(void 0!==n){if(void 0!==t&&n<t)return;if(void 0!==r&&n>r)return;if(m)return}}if(!v){try{this.emitter.emit("preupdate",e),i._emitLayerEvent("layer:preupdate",p.id||"",e);const t=yield b(e.filters,In(Pn({},e.options),{srs:this.options.srs}));let r=t;const n=yield this.getCount();if("BBOX+"===this.options.strategy){r={type:"FeatureCollection",features:[]};for(const e of t.features)-1===d.indexOf(String(e.id))&&(d.push(String(e.id)),r.features.push(e));m=void 0!==n&&d.length>=n,yield i.addLayerData(this,r)}else m=void 0!==n&&t.features.length>=n,yield i.setLayerData(this,t);this.emitter.emit("updated",t),i._emitLayerEvent("layer:updated",p.id||"",{data:t,newData:r,isFull:m})}catch(r){if(r instanceof Error&&"CancelError"!==r.name)throw r}En(_.prototype,this,"updateLayer")&&En(_.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return jn(this,null,(function*(){if(w(),this.filter&&m)this.filter((t=>{const r=t.feature&&t.feature.properties&&Kr(Pn({},t.feature.properties));return!r||Te(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,In(Pn({},t),{srs:this.options.srs}));this.setData(r)}}))}removeFilter(){f=void 0,this.propertiesFilter([]),this.filter&&this.filter((()=>!0))}_addBboxEventListener(){this.__enableMapMoveListener=e=>{e===this&&(this._removeMoveEventListener(),this.updateLayer(),this._addMoveEventListener())},this.__disableMapMoveListener=e=>{e===this&&this._removeMoveEventListener()},i.emitter.on("layer:show",this.__enableMapMoveListener),i.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&i.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&i.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...o){n.clear(),r=setTimeout((()=>{r=null,e.apply(this,o)}),t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}((()=>this.updateLayer())),this.__onMapMoveStart=w,i.emitter.on("movestart",this.__onMapMoveStart),i.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&i.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&i.emitter.removeListener("movestart",this.__onMapMoveStart)}}return _}))}var Cn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Mn({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),uo(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var kn=Object.defineProperty,Sn=Object.defineProperties,Nn=Object.getOwnPropertyDescriptors,Tn=Object.getOwnPropertySymbols,Fn=Object.prototype.hasOwnProperty,Bn=Object.prototype.propertyIsEnumerable,Rn=(e,t,r)=>t in e?kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$n=(e,t)=>{for(var r in t||(t={}))Fn.call(t,r)&&Rn(e,r,t[r]);if(Tn)for(var r of Tn(t))Bn.call(t,r)&&Rn(e,r,t[r]);return e},Dn=(e,t)=>Sn(e,Nn(t)),qn=(e,t,r)=>Rn(e,"symbol"!=typeof t?t+"":t,r),Gn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Vn(e){return Gn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.cls;let i=e.adapter||o&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[o]||"IMAGE";if(void 0!==i&&(e.adapter=i),"IMAGE"===i){const e=t.getLayerAdapters();!e||e.IMAGE||(i="TILE")}const s=t.mapAdapter.layerAdapters[i];if(s){const o=yield vr(e,r);return class extends s{constructor(i,s){super(i,s),this.map=i,qn(this,"item",n),qn(this,"resourceId",o);const a=Mn({options:e,webMap:t,baseUrl:r.options.baseUrl||""});if(a){const t=Dn($n($n({},a),e.adapterOptions),{params:{resource:o},layers:a.layers||String(o),resourceId:o});e.adapterOptions&&p(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=$n($n({},this.options),t)}}addLayer(e){return super.addLayer($n($n({},this.options),e))}getLegend(e){return Gn(this,null,(function*(){const t=yield r.get("render.legend_symbols",$n({params:{id:o},cache:!0},e)),n=this.options.id;if(void 0!==n){return[{layerId:n,legend:t.map((({display_name:e,icon:t})=>({name:e,symbol:t})))}]}return[]}))}getIdentificationIds(){return Gn(this,null,(function*(){if(this.item){if("MVT"===i)return[this.item.resource.id];const e=this.item.resource.parent.id;if(p(e))return[e]}return[]}))}}}throw new Error(i+" not supported yet. Only TILE")}))}var Un=Object.defineProperty,zn=Object.defineProperties,Zn=Object.getOwnPropertyDescriptors,Wn=Object.getOwnPropertySymbols,Jn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,Qn=(e,t,r)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kn=(e,t)=>{for(var r in t||(t={}))Jn.call(t,r)&&Qn(e,r,t[r]);if(Wn)for(var r of Wn(t))Hn.call(t,r)&&Qn(e,r,t[r]);return e},Xn=(e,t)=>zn(e,Zn(t)),Yn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const eo={},to=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function ro(e){return Yn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.id,i=yield r.getResourceChildren(o),s=i&&i[0];if(s)return no(Xn(Kn({},e),{resource:s.resource.id}),t,r)}))}function no(e,t,r){return Yn(this,null,(function*(){let n,o;const i=e.adapter,s=yield vr(e,r);if(s){const a=e.resource;if(o=a&&a.resource&&void 0!==a.resource.id?a:yield r.getResource(s),!o)throw"Resource item is not found";{const a=o.resource.cls,l={layerOptions:Xn(Kn({},e),{resource:s}),connector:r,webMap:t,item:o};if(-1!==to.indexOf(a))if("webmap"===a)n=function(e){return Cn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield vr(e,r);return class extends Wo{constructor(e){super(e,{url:"",webMap:t,resourceId:n,connector:r})}}}))}(l);else if("vector_layer"===a||"postgis_layer"===a){const t=l.layerOptions.adapterOptions||{};if(t.type=t.type||o.vector_layer&&po[o.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==i&&"GEOJSON"!==i){if("MVT"!==i)return ro(l);n=Vn(l)}else n=An(l)}else{if("raster_layer"===a)return ro(l);if("basemap_layer"===a)n=function(e){return Qr(this,arguments,(function*({webMap:e,item:t}){if(t.basemap_layer){const r=t.basemap_layer.qms,n=t.basemap_layer.url;if(r){const t=JSON.parse(r);return Promise.resolve(Br.utils.createQmsAdapter(e,void 0,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return Qr(this,null,(function*(){return Hr(e.prototype,this,"addLayer").call(this,Jr(Wr({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===i){const t=yield r.getResource(o.resource.parent.id);if(t){const r=Xn(Kn({},e),{resource:o.resource.parent.id});n=An(Xn(Kn({},l),{item:t,layerOptions:r}))}}else n=Vn(l)}else{if(!eo[a])throw`Resource class '${a}' not yet supported.`;{const e=eo[a];let t;t=i&&"function"!=typeof t?e[i]:e,t&&(n=t(l))}}}}if(n)return n.then((e=>{if(e){const t=e;return o&&(t.prototype.item=o,t.prototype.resourceId=o.resource.id,t.prototype.connector=r),u(t,[gr],{replace:!1}),t}}))}))}var oo=Object.defineProperty,io=Object.getOwnPropertySymbols,so=Object.prototype.hasOwnProperty,ao=Object.prototype.propertyIsEnumerable,lo=(e,t,r)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,co=(e,t)=>{for(var r in t||(t={}))so.call(t,r)&&lo(e,r,t[r]);if(io)for(var r of io(t))ao.call(t,r)&&lo(e,r,t[r]);return e};function uo(e,t){const{bbox:r,width:n,height:o,nd:i}=e;return{resource:Array.isArray(t)?t.join(","):t,extent:r,size:n+","+o,timestamp:Date.now(),nd:null!=i?i:200}}const po={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};let ho;function fo(e,t=0){const r=t,n=function(){if(void 0===ho){const e=document.createElement("div");e.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(e);const t=e.offsetWidth;document.body.removeChild(e),ho=t}return ho}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e,o=function(e){return Math.log(e/256)/Math.LN2}(n);return o}var yo=Object.defineProperty,mo=Object.defineProperties,go=Object.getOwnPropertyDescriptors,bo=Object.getOwnPropertySymbols,vo=Object.prototype.hasOwnProperty,wo=Object.prototype.propertyIsEnumerable,_o=(e,t,r)=>t in e?yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Oo=(e,t)=>{for(var r in t||(t={}))vo.call(t,r)&&_o(e,r,t[r]);if(bo)for(var r of bo(t))wo.call(t,r)&&_o(e,r,t[r]);return e},Lo=(e,t)=>mo(e,go(t)),Po=(e,t,r)=>_o(e,"symbol"!=typeof t?t+"":t,r),Io=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const xo=class e extends er{constructor(t,n,o,i,s,a){if(super(Oo(Oo({},e.options),o)),this.webMap=t,Po(this,"item"),Po(this,"connector"),Po(this,"layer"),Po(this,"emitter",new r),Po(this,"_rootDescendantsCount",0),i&&(this.connector=i),s&&this.tree.setParent(s),this.item=n,"root"===this.item.item_type)this._rootDescendantsCount=this._sumUp(this.item.children);else{const e=this.tree.getRoot();e&&(this._rootDescendantsCount=e._rootDescendantsCount)}this.initProperties(),a||this._init(n)}static create(t,r,n,o,i){return Io(this,null,(function*(){const s=new e(t,r,n,o,i,!0);return yield s._init(r),s}))}initItem(e){return"group"===e.item_type||"root"===e.item_type?this.initGroupItem(e):this.initLayerItem(e)}bringToFront(){}fit(){}getLayer(){return this.layer}getLegend(e){return Io(this,null,(function*(){var t;const r=null==(t=this.layer)?void 0:t.id;if(void 0!==r){const t=this.connector;if(t){return[{layerId:r,legend:(yield t.get("render.legend_symbols",Oo({params:{id:this.item.resourceId}},e))).map((({display_name:e,icon:t})=>({name:e,symbol:t})))}]}}return[]}))}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Lo(Oo({visibility:!1,name:e.display_name},this.options),{params:{resource:this.item.resourceId,item:this.item}});if(this.options.order){const t=String(this.options.drawOrderEnabled&&"draw_order_position"in e?this._rootDescendantsCount-e.draw_order_position:this.id).padStart(4,"0");n.order=Number((0|this.options.order)+"."+t)}if(this.options.popupOptions&&(n.popupOptions=this.options.popupOptions),"layer"===e.item_type){const{maxZoom:t,minZoom:r}=this._getZoomRange(e);Object.assign(n,Lo(Oo({updateWmsParams:e.updateWmsParams},this.options),{url:e.url,maxZoom:t,minZoom:r,minScale:e.layer_min_scale_denom,maxScale:e.layer_max_scale_denom,interactive:e.layer_identifiable}))}return void 0!==r&&(n.opacity=r),n}getChildren(e){return[...e.children].reverse()}_mapScaleToZoomLevel(e){return fo(e)}initGroupItem(e){if(e.children&&e.children.length){const t=this.getChildren(e);for(const e of t){const t=new this.constructor(this.webMap,e,this.options,this.connector,this);this.tree.addChild(t)}}return Promise.resolve()}initLayerItem(t){const r=this.getItemOptions(t),n=e=>{t._layer=e,this.layer=e;this.properties.get("visibility")&&this.properties.set("visibility",!0),void 0!==r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let o;if("layer"===t.item_type)o=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){o=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return o?this.webMap.addLayer(o,r).then((e=>{n(e)})):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,o=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,i=[t,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max(...i):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then((()=>{this.emitter.emit("init")}))}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};Po(xo,"GetAdapterFromLayerType",{}),Po(xo,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return bt(e.item,(e=>"layer_enabled"in e&&e.layer_enabled),(e=>e.children));if("layer"===e.item.item_type)return e.item.layer_enabled}return!1},onSet(e,t,r){r&&"layer"===r.item.item_type&&(r.layer&&(e?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=e)}},{name:"opacity",handler:class extends Ct{getProperty(){const e=this.item.layer;return e&&e&&e.options&&void 0!==e.options.opacity?e.options.opacity:1}update(e,t){if(t=t||{},this.isGroup()){this._value=this._prepareValue(e,t);const r=this.getChildren();for(const n of r){const r=n.properties.property(this.name);r&&(t.propagation?r.set(e,t):r.update(r.get(),t))}}const r=this.item.layer;if(r){const t=this.getParents().reduce(((e,t)=>{const r=t.properties.property(this.name);return e*(r?r.getValue():1)}),1);this.item.webMap.setLayerOpacity(r,this._prepareValue(e*t))}}_prepareValue(e,t){return t&&t.propagation&&this.isGroup()?1:Number(e)}}}]});let Eo=xo;var jo=Object.defineProperty,Ao=Object.getOwnPropertySymbols,Co=Object.prototype.hasOwnProperty,Mo=Object.prototype.propertyIsEnumerable,ko=(e,t,r)=>t in e?jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,So=(e,t)=>{for(var r in t||(t={}))Co.call(t,r)&&ko(e,r,t[r]);if(Ao)for(var r of Ao(t))Mo.call(t,r)&&ko(e,r,t[r]);return e},No=(e,t,r)=>ko(e,"symbol"!=typeof t?t+"":t,r),To=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Fo(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){const i=function(e){return To(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){No(this,"options",{}),No(this,"layer",[]),No(this,"_removed",!1),No(this,"_creatingInProgress",!1)}addLayer(){return this.layer}removeLayer(){this._removed=!0;for(const t of this.layer)e.removeLayer(t)}destroyed(){return this._removed}showLayer(){return To(this,null,(function*(){if(this.options.visibility=!0,this.layer.length)for(const t of this.layer)yield e.showLayer(t);else yield this.loadLayer()}))}hideLayer(){return To(this,null,(function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)}))}loadLayer(){return To(this,null,(function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const o=yield n(this);if(o){const n=new o(e.mapAdapter.map,So({},t)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer}))}}}))}({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>no({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)});return i},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var Bo=Object.defineProperty,Ro=Object.defineProperties,$o=Object.getOwnPropertyDescriptors,Do=Object.getOwnPropertySymbols,qo=Object.prototype.hasOwnProperty,Go=Object.prototype.propertyIsEnumerable,Vo=(e,t,r)=>t in e?Bo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Uo=(e,t)=>{for(var r in t||(t={}))qo.call(t,r)&&Vo(e,r,t[r]);if(Do)for(var r of Do(t))Go.call(t,r)&&Vo(e,r,t[r]);return e},zo=(e,t,r)=>Vo(e,"symbol"!=typeof t?t+"":t,r),Zo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Wo{constructor(e,t){this.map=e,this.options=t,zo(this,"layer"),zo(this,"NgwWebmapItem",Eo),zo(this,"pixelRadius",10),zo(this,"resourceId"),zo(this,"webmapClassName","webmap"),zo(this,"emitter",new r),zo(this,"_extent"),zo(this,"response"),zo(this,"_webmapLayersIds"),zo(this,"_webmapBaselayersIds",[]),zo(this,"_lastActiveBaselayer");const n=t.resourceId;if(Array.isArray(n)?(this.resourceId=n[0],this.options.id=n[1]):this.resourceId=n,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}addLayer(e){return Zo(this,null,(function*(){var t,r;this.options=Uo(Uo({},this.options),e),this.layer=yield this._getWebMapLayerItem();const n=null==(r=null==(t=this.response)?void 0:t.webmap)?void 0:r.extent_constrained;return this.options.useExtentConstrained&&this._extent&&n&&this.options.webMap.setView({maxBounds:this._extent}),this.layer}))}removeLayer(){const e=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach((t=>{"layer"in t&&e.removeLayer(t.layer.layer)})),this._webmapBaselayersIds.length){for(const e of this._webmapBaselayersIds)this.options.webMap.removeLayer(e);this._lastActiveBaselayer&&this.options.webMap.showLayer(this._lastActiveBaselayer)}this.options.useExtentConstrained&&this._extent&&this.options.webMap.setView({maxBounds:null}),delete this.layer,delete this.response,delete this._webmapLayersIds}showLayer(){return Zo(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return Zo(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return Zo(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("opacity").set(e)}))}getExtent(){return this.getBounds()}getBounds(){const e=this.response&&this.response.webmap;if(e)return ur(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.response&&this.response.webmap;if(e)return e.bookmark_resource.id}fetchBookmarks(e){const t=this.getBookmarksResourceId(),r=this.options.connector;if(t)return r.getResourceOrFail(t,e).then((n=>{var o;const i=null==(o=n.feature_layer)?void 0:o.fields.find((e=>e.label_field)),s=i&&i.keyname;return cn(Uo({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then((e=>{const n=[];for(const o of e){const e=new gt({item:o,resourceId:t,labelField:s,connector:r});n.push(e)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(e){return Zo(this,null,(function*(){const t=[];let r=this.getDependLayers();r=r.sort(((e,t)=>t.id-e.id));for(const n of r){const r=yield n.getLegend(e);t.push(...r)}return t}))}getIdentificationIds(e){return Zo(this,null,(function*(){const t=[];let r=this._webmapLayersIds;if(r||(r=yield this._getWebMapIds(e),this._webmapLayersIds=r),r&&r.length){let e=this.getDependLayers();e=e.sort(((e,t)=>t.id-e.id)),e.forEach((e=>{const r=e.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type&&r.layer_identifiable){const r=e.properties.property("visibility");r.get()&&!r.isBlocked()&&t.push(n)}}))}return t}))}_getWebMapLayerItem(){return Zo(this,null,(function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise((t=>{const r=this.options.connector,n=(null==r?void 0:r.options.auth)?r.getAuthorizationHeaders():void 0,o=r.withCredentials,i=(s=Uo({},this.options),Ro(s,$o({withCredentials:o,headers:n,drawOrderEnabled:e.draw_order_enabled})));var s;const a=new this.NgwWebmapItem(this.options.webMap,e.root_item,i,r);a.emitter.on("init",(()=>{t(a)}))})):void 0}))}getWebMapConfig(e){return Zo(this,null,(function*(){const t=yield this.options.connector.getResource(e);if(t){this.response=t;const e=t[this.webmapClassName];if(this._setupBaselayers(t),e)return this._extent=[e.extent_left,e.extent_bottom,e.extent_right,e.extent_top],this._updateItemsParams(e.root_item,this.options.webMap,t),e}}))}_setupBaselayers(e){var t;const r=this.options.webMap;if(null==(t=this.options.useBasemap)||t)if(e.basemap_webmap&&e.basemap_webmap.basemaps.length){const t=r.getActiveBaseLayer();this._lastActiveBaselayer=t?t.id:void 0,this._setBasemaps(e.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})}_setBasemaps(e){const t=this.options.webMap;let r=!1;for(const n of e.basemaps)Fo({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then((e=>{const o=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:o}).then((e=>{e.id&&this._webmapBaselayersIds.push(e.id)}))}))}_updateItemsParams(e,t,r){if(e)if("group"===e.item_type||"root"===e.item_type)e.children&&(e.children=e.children.map((e=>this._updateItemsParams(e,t,r)))),"root"===e.item_type&&(e.display_name=r.resource.display_name);else if("layer"===e.item_type){const r=x(this.options.connector.options.baseUrl+"/api/component/render/image"),n=e.layer_style_id;e.url=r,e.resourceId=n,e.updateWmsParams=e=>uo(e,n);const o=Mn({options:{adapter:e.layer_adapter.toUpperCase(),resource:n},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Uo(Uo({},e),o)}return e}_getWebMapIds(e){return Zo(this,null,(function*(){const t=this.layer;if(t&&"root"===t.item.item_type){const r=t.tree.getDescendants(),n=[];for(const t of r){const r=t.item;if("layer"===r.item_type){const t=this.options.connector.getResource(r.layer_style_id,e).then((e=>{if(e){const t=Number(e.resource.parent.id);return r.parentId=t,t}}));n.push(t)}}return(yield Promise.all(n)).filter((e=>void 0!==e))}}))}}var Jo=Object.defineProperty,Ho=Object.getOwnPropertySymbols,Qo=Object.prototype.hasOwnProperty,Ko=Object.prototype.propertyIsEnumerable,Xo=(e,t,r)=>t in e?Jo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yo=(e,t)=>{for(var r in t||(t={}))Qo.call(t,r)&&Xo(e,r,t[r]);if(Ho)for(var r of Ho(t))Ko.call(t,r)&&Xo(e,r,t[r]);return e},ei=(e,t,r)=>Xo(e,"symbol"!=typeof t?t+"":t,r);class ti{constructor(e){if(this.options=e,ei(this,"url"),ei(this,"connector"),ei(this,"webMap"),this.options.connector)this.url=this.options.connector.options.baseUrl||"",this.connector=this.options.connector;else{if(!this.options.baseUrl)throw new Error("url is not defined");this.url=this.options.baseUrl,this.connector=new Ie({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){eo[e]=t}onLoadSync(e){return t=this,r=null,n=function*(){if(this.options.resourceId&&this.url){const t=[this.options.resourceId];if(t.length)for(const r of t){const t={resourceId:r,connector:this.connector,webMap:e};return yield e.addLayer(Wo,Yo({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends Wo{constructor(e,r){super(e,r=co(co({},t),r))}};var t}}var ri=Object.defineProperty,ni=Object.getOwnPropertySymbols,oi=Object.prototype.hasOwnProperty,ii=Object.prototype.propertyIsEnumerable,si=(e,t,r)=>t in e?ri(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ai=(e,t)=>{for(var r in t||(t={}))oi.call(t,r)&&si(e,r,t[r]);if(ni)for(var r of ni(t))ii.call(t,r)&&si(e,r,t[r]);return e},li=(e,t,r)=>si(e,"symbol"!=typeof t?t+"":t,r);class ci{constructor(e){li(this,"id"),li(this,"label"),li(this,"layerId"),li(this,"parent"),li(this,"fields"),li(this,"geom"),li(this,"extensions"),li(this,"connector"),li(this,"_item"),li(this,"_geojson"),li(this,"_resource"),li(this,"_extent");const t=e.feature;this.id=t.id,this.geom=t.geom,this.label=t.label,this.parent=t.parent,this.fields=t.fields,this.layerId=t.layerId,this.connector=e.connector}identify(e={}){return this._item?Promise.resolve(this._item):ut(ai({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},e)).then((e=>(this._item=e,this.geom=e.geom,this.extensions=e.extensions,e)))}resource(e){return this._resource?Promise.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId,e).then((e=>(this._resource=e,this._resource.feature_layer)))}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.get("feature_layer.feature.item_extent",{cache:n,signal:o},{id:e,fid:t}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}(ai({connector:this.connector,featureId:this.id,resourceId:this.layerId},e))}geojson(e){return this._geojson?Promise.resolve(this._geojson):this.identify(e).then((e=>e.toGeojson().then((e=>(this._geojson=e,e)))))}}var ui=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function pi(e){return ui(this,null,(function*(){return We(yield ut(e))}))}var hi=Object.defineProperty,di=Object.defineProperties,fi=Object.getOwnPropertyDescriptors,yi=Object.getOwnPropertySymbols,mi=Object.prototype.hasOwnProperty,gi=Object.prototype.propertyIsEnumerable,bi=(e,t,r)=>t in e?hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vi=(e,t)=>{for(var r in t||(t={}))mi.call(t,r)&&bi(e,r,t[r]);if(yi)for(var r of yi(t))gi.call(t,r)&&bi(e,r,t[r]);return e},wi=(e,t)=>di(e,fi(t));function _i(e,t=!1){const r=[],n=[];for(const i in e){const e=Number(i);isNaN(e)||r.push(e)}const o=e.resources;o&&r.sort(((e,t)=>o.indexOf(e)-o.indexOf(t)));for(let i=0;i<r.length;i++){const o=r[i],s=e[o];if("features"in s){const e=Oi(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function Oi(e,t,r){const n=[];for(const o of e){if(n.push({featureId:o.id,resourceId:t,feature:o}),!r)break}return n}function Li(e){const{geom:t,signal:r,cache:n,layers:o}=e,i="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map((([e,t])=>{const[r,n]=_(e,t);return`${r} ${n}`})).join(",")}))`}(t);if(!i)throw new Error("Not valid geometry format to make intersection");return e.connector.post("feature_layer.identify",{data:{geom:i,srs:3857,layers:o},signal:r,cache:n})}function Pi(e,t){return r=this,n=null,o=function*(){var r;const n=yield e.get("pyramid.settings",null,{component:"pyramid"});if(n&&n.company_logo&&n.company_logo.enabled){const i=document.createElement("a");i.style.position="absolute",i.style.bottom="0",i.style.right="0",i.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",i.className="ngw-map-logo",t&&t.cssClass&&(i.className+=" "+t.cssClass);const s=new Image;s.style.maxHeight="100px",s.style.maxWidth="100px",s.src="";try{const t=yield e.get("pyramid.company_logo",{responseType:"blob"}),r=(window.URL||window.webkitURL).createObjectURL(t);s.src=r}catch(o){console.warn(o)}return null!==n.company_logo.link&&""!==n.company_logo.link.trim()&&(i.href=n.company_logo.link,i.target="_blank",-1!==n.company_logo.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),i.appendChild(s),i}},new Promise(((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())}));var r,n,o}function Ii(e){return"function"==typeof e}function xi(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const Ei={"!":xi((function([e]){return!e})),"!=":xi((function([e,t]){return e!==t})),"<":xi((function([e,t]){return e<t})),"<=":xi((function([e,t]){return e<=t})),"==":xi((function([e,t]){return e===t})),">":xi((function([e,t]){return e>t})),">=":xi((function([e,t]){return e>=t})),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},ji={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function Ai(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Ci(e);if("string"==typeof(t=e)&&t in ji)return function(e){return Ci(ji[e])}(e);if(function(e){return"string"==typeof e&&/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/.test(e)}(e))return function(e){const t=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;let r;if(r=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)];if(r=e.match(t))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])];throw new Error(`The '${e}' Is not valid rgb`)}(e);if(function(e){if("object"==typeof e&&null!==e)return"r"in e&&"g"in e&&"b"in e&&(!("a"in e)||"number"==typeof e.a&&e.a>=0&&e.a<=1);return!1}(e))return function({r:e,g:t,b:r,a:n}){return[e,t,r,...void 0!==n?[n]:[]]}(e);var t,r;throw new Error(`The '${e}' cannot be converted to color`)}function Ci(e){let t;if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),parseInt(t[4]+t[4],16)/255];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16)/255];throw new Error(`The '${e}' Is not valid hex`)}function Mi(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=Ai(r),s=Ai(o);return function(e){return`rgb(${e.join(",")})`}(i.map(((r,o)=>Math.ceil(Mi(e,t,r,n,s[o])))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const ki={step:e=>{const[t,r,...n]=e,o=t();if("number"!=typeof o)return r();for(let i=0;i<n.length-2;i+=2){const e=n[i](),t=n[i+1](),r=n[i+2]();if(o>=e&&o<r)return t}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const o=e();for(let i=0;i<r.length-2;i+=2){const e=r[i](),t=r[i+1](),s=r[i+2](),a=r[i+3]();if(n>=e&&n<=s&&"linear"===o[0])return Mi(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Si={get:xi((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:xi((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:xi((function([e,t]){return t[e]})),has:xi((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:xi((function([e,t]){if("string"==typeof t)return t.includes(String(e));if(Array.isArray(t))return t.includes(e);throw new Error(`Invalid input type for 'in'. Expected string or array, got ${typeof t}.`)})),"index-of":xi((function([e,t,r]){if("string"==typeof t)return t.indexOf(String(e),r);if(Array.isArray(t))return t.indexOf(e,r);throw new Error(`Invalid input type for 'index-of'. Expected string or array, got ${typeof t}.`)})),slice:xi((function(e){const[t,r,n]=e;if("string"==typeof t)return t.slice(r,n);if(Array.isArray(t))return t.slice(r,n);throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof t}.`)}))},Ni={"+":xi((e=>e.reduce(((e,t)=>e+t),0))),"-":xi((e=>e.reduce(((e,t)=>e-t)))),"*":xi((e=>e.reduce(((e,t)=>e*t),1))),"/":xi((e=>e.reduce(((e,t)=>e/t)))),"%":xi((e=>e[0]%e[1])),"^":xi((e=>Math.pow(e[0],e[1]))),abs:xi((e=>Math.abs(e[0]))),acos:xi((e=>Math.acos(e[0]))),asin:xi((e=>Math.asin(e[0]))),atan:xi((e=>Math.atan(e[0]))),ceil:xi((e=>Math.ceil(e[0]))),cos:xi((e=>Math.cos(e[0]))),e:()=>Math.E,floor:xi((e=>Math.floor(e[0]))),ln:xi((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:xi((e=>Math.log10(e[0]))),log2:xi((e=>Math.log2(e[0]))),max:xi((e=>Math.max(...e))),min:xi((e=>Math.min(...e))),pi:()=>Math.PI,round:xi((e=>Math.round(e[0]))),sin:xi((e=>Math.sin(e[0]))),sqrt:xi((e=>Math.sqrt(e[0]))),tan:xi((e=>Math.tan(e[0])))},Ti={concat:xi((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:xi((e=>String(e[0]).toLowerCase())),upcase:xi((e=>String(e[0]).toUpperCase()))},Fi=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function Bi(e){return(t,r)=>{for(const n of t){const t=Fi(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Ri={array:xi((e=>{const[t,r,n]=e;let o,i,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(o=t,"number"==typeof r?(i=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(o&&!s.every((e=>typeof e===o)))throw new Error(`Expected all items in array to be of type ${o}`);if(i&&s.length!==i)throw new Error(`Expected array of length ${i}`);return s})),boolean:xi(Bi((e=>"boolean"==typeof e?e:void 0))),literal:xi((([e])=>e)),number:xi(Bi((e=>"number"==typeof e?e:void 0))),object:xi(Bi((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:xi(Bi((e=>"string"==typeof e?e:void 0))),"to-boolean":xi(Bi(Boolean)),"to-number":xi(Bi(Number)),"to-string":xi(Bi(String)),typeof:xi((([e])=>function(e){if(null===e)return"null";switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":if(Array.isArray(e)){let t="value";return e.every((e=>"number"==typeof e))?t="number":e.every((e=>"string"==typeof e))?t="string":e.every((e=>"boolean"==typeof e))&&(t="boolean"),`array<${t}, ${e.length}>`}return"object";default:return"undefined"}}(e)))};var $i=Object.defineProperty,Di=Object.getOwnPropertySymbols,qi=Object.prototype.hasOwnProperty,Gi=Object.prototype.propertyIsEnumerable,Vi=(e,t,r)=>t in e?$i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ui=(e,t)=>{for(var r in t||(t={}))qi.call(t,r)&&Vi(e,r,t[r]);if(Di)for(var r of Di(t))Gi.call(t,r)&&Vi(e,r,t[r]);return e};function zi(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in Zi&&r.length>0}return!1}const Zi=Ui(Ui(Ui(Ui(Ui(Ui({},Ni),Ri),Ti),Si),Ei),ki);function Wi(e,t={}){const[r,...n]=e,o=Zi[r];if(o)return o(n.map((e=>()=>zi(e)?Wi(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var Ji=Object.defineProperty,Hi=Object.getOwnPropertySymbols,Qi=Object.prototype.hasOwnProperty,Ki=Object.prototype.propertyIsEnumerable,Xi=(e,t,r)=>t in e?Ji(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yi=(e,t)=>{for(var r in t||(t={}))Qi.call(t,r)&&Xi(e,r,t[r]);if(Hi)for(var r of Hi(t))Ki.call(t,r)&&Xi(e,r,t[r]);return e};function es(e){return t=>{const r=t.properties;return!!r&&Wi(e,r)}}const ts=["iconSize","iconAnchor"];var rs=Object.defineProperty,ns=Object.getOwnPropertySymbols,os=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,ss=(e,t,r)=>t in e?rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,as=(e,t)=>{for(var r in t||(t={}))os.call(t,r)&&ss(e,r,t[r]);if(ns)for(var r of ns(t))is.call(t,r)&&ss(e,r,t[r]);return e};function ls(e){let t={};const r=[];for(const n of e)n&&(Array.isArray(n)?r.push(n):t=n);return e=>{const n=r.find((t=>function(e,t){const r=Me({},e.properties);return!!r&&(r.$id=e.id,Te(r,t))}(e,t[0])));return n?as(as({},t),n[1]):t}}function cs({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===ts.indexOf(n)){const o=n,i=e[o];zi(i)&&(t=!0,r[o]=es(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return Yi(Yi({},e),n)}}(e);if(r){const n=e=>ps({paint:r(e),defaultPaint:t});return n.paint=us({paint:e,defaultPaint:t}),n}return us({paint:e,defaultPaint:t})}function us({paint:e,defaultPaint:t}){var r;let n=as({},t);return n=as(as({},n),e),n.fill=null==(r=n.fill)||r,n.stroke=void 0!==n.stroke?n.stroke:!n.fill||!(!n.strokeColor&&!n.strokeOpacity),n}function ps({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=as({},t);if(Ii(e)){const n=n=>{const o=ps({paint:e(n),defaultPaint:t,getPaintFunctions:r});return o.type=e.type,o};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>ps({paint:ls(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const o=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);o&&(n=ps({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=cs({paint:e,defaultPaint:t})}return Ii(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}var hs=Object.defineProperty,ds=(e,t,r)=>((e,t,r)=>t in e?hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class fs{constructor(){ds(this,"backspace",8),ds(this,"tab",9),ds(this,"enter",13),ds(this,"shift",16),ds(this,"ctrl",17),ds(this,"alt",18),ds(this,"pause/break",19),ds(this,"caps_lock",20),ds(this,"escape",27),ds(this,"page_up",33),ds(this,"page_down",34),ds(this,"end",35),ds(this,"home",36),ds(this,"left_arrow",37),ds(this,"up_arrow",38),ds(this,"right_arrow",39),ds(this,"down_arrow",40),ds(this,"insert",45),ds(this,"delete",46),ds(this,"left_window_key",91),ds(this,"right_window_key",92),ds(this,"select_key",93),ds(this,"numpad_0",96),ds(this,"numpad_1",97),ds(this,"numpad_2",98),ds(this,"numpad_3",99),ds(this,"numpad_4",100),ds(this,"numpad_5",101),ds(this,"numpad_6",102),ds(this,"numpad_7",103),ds(this,"numpad_8",104),ds(this,"numpad_9",105),ds(this,"multiply",106),ds(this,"add",107),ds(this,"subtract",109),ds(this,"decimal_point",110),ds(this,"divide",111),ds(this,"f1",112),ds(this,"f2",113),ds(this,"f3",114),ds(this,"f4",115),ds(this,"f5",116),ds(this,"f6",117),ds(this,"f7",118),ds(this,"f8",119),ds(this,"f9",120),ds(this,"f10",121),ds(this,"f11",122),ds(this,"f12",123),ds(this,"num_lock",144),ds(this,"scroll_lock",145),ds(this,"semi-colon",186),ds(this,"equal_sign",187),ds(this,",",188),ds(this,"-",189),ds(this,".",190),ds(this,"/",191),ds(this,"`",192),ds(this,"[",219),ds(this,"\\",220),ds(this,"]",221),ds(this,"'",222)}}var ys=Object.defineProperty,ms=(e,t,r)=>((e,t,r)=>t in e?ys(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var gs=Object.defineProperty,bs=(e,t,r)=>((e,t,r)=>t in e?gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class vs{constructor(e,t){this.webMap=e,bs(this,"name"),bs(this,"event"),bs(this,"value"),t&&(t.value&&this.setValue(t.value),t.name&&(this.name=t.name),t.event&&(this.event=t.event))}getValue(){return this.value}setValue(e){this.value=e}}var ws=Object.defineProperty,_s=(e,t,r)=>((e,t,r)=>t in e?ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Os extends vs{constructor(){super(...arguments),_s(this,"name","center"),_s(this,"event","moveend")}getValue(){return this.webMap.getCenter()}setValue(e){this.webMap.setCenter(e)}toString(e){const t=e.map((e=>e.toFixed(5)));return t[0]+"_"+t[1]}parse(e){return e.split("_").map(Number)}}var Ls=Object.defineProperty,Ps=(e,t,r)=>((e,t,r)=>t in e?Ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Is extends vs{constructor(){super(...arguments),Ps(this,"name","zoom"),Ps(this,"event","zoomend")}getValue(){const e=this.webMap.getZoom();return void 0!==e?Math.round(e):void 0}setValue(e){this.webMap.setZoom(e)}toString(e){return String(e)}parse(e){return Number(e)}}var xs=Object.defineProperty,Es=(e,t,r)=>((e,t,r)=>t in e?xs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),js=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let As=0;const Cs={minZoom:0,maxZoom:22,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},Ms=class e{constructor(t){Es(this,"options",Cs),Es(this,"emitter",new r),Es(this,"keys",e.keys),Es(this,"mapAdapter"),Es(this,"runtimeParams",[]),Es(this,"getPaintFunctions",e.getPaintFunctions),Es(this,"mapState",[Os,Is]),Es(this,"id",As++),Es(this,"_initMapState",{}),Es(this,"_starterKits"),Es(this,"_mapState",[]),Es(this,"_extent"),Es(this,"_eventsStatus",{}),Es(this,"_coordFromMapClickAbort"),Es(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=d(Cs||{},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}create(){return js(this,null,(function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapState),yield this._setupMap(),this._emitStatusEvent("create",this)),this}))}setRuntimeParams(e){this.runtimeParams.push(e)}destroy(){this._removeEventListeners(),function(e){for(const t in e)delete e[t]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const e={};return this._mapState.forEach((t=>{e[t.name]=t.getValue()})),e}getRuntimeParams(){const e={};return this._mapState.forEach((t=>{for(const r of this.runtimeParams){const n=r.get(t.name);if(void 0!==n){e[t.name]=t.parse(n);break}}})),e}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 e=document.getElementById(this.options.target);if(e)return e}}}setCursor(e){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(e)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const e=this.getContainer();return e?e.style.cursor:void 0}setCenter(e){return this.mapAdapter.setCenter(e),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const e=this.getBounds();if(e){return{type:"Feature",properties:{},geometry:m(e)}}}setZoom(e){return this.mapAdapter.setZoom(e),this}getZoom(){const e=this.mapAdapter.getZoom();if("number"==typeof e)return e}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e-1)}}}setView(e,t){if(Array.isArray(e)){const r=e;this.mapAdapter.setView&&r&&p(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),p(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,o]=e,i=t<n&&r<o;if(!i){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${o}]`);const e=[Math.min(t,n),Math.min(r,o),Math.max(t,n),Math.max(o,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&o<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every((e=>p(e)))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise((t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,(()=>{t(this)}))}))}onMapLoad(e){return new Promise((t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},o=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&o?n():this.mapAdapter.emitter.once("create",(()=>{n()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickAbort&&(this._coordFromMapClickAbort(),this._coordFromMapClickAbort=void 0)}getCoordFromMapClick(){return this._coordFromMapClickAbort?this.getCoordFromMapClick():new Promise(((e,t)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const n=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickAbort=void 0},o=t=>{n(),f(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),this._coordFromMapClickAbort=n}))}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return js(this,null,(function*(){}))}_onLoadSync(){return js(this,null,(function*(){}))}_setupMap(){return js(this,null,(function*(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return yield this.mapAdapter.create(this.options),this._zoomToInitialExtent(),yield this._addLayerProviders(),yield this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}))}_setTileJsonOptions(e){e.center&&(this.options.center=e.center),e.bounds&&(this.options.bounds=e.bounds),p(e.maxzoom)&&(this.options.zoom=e.maxzoom),p(e.minzoom)&&(this.options.zoom=e.minzoom),p(e.maxzoom)&&p(e.minzoom)&&(this.options.zoom=(e.maxzoom+e.minzoom)/2)}_zoomToInitialExtent(){const{center:e,zoom:t,bounds:r}=this.options;this._extent?this.fitBounds(this._extent):e&&t?this.setView(e,t):r&&(this.fitBounds(r),void 0!==t&&this.setZoom(t))}_setInitMapState(e){for(const t of e){const e=new t(this);this._mapState.push(e);for(const t of this.runtimeParams){const r=t.get(e.name);if(void 0!==r){const t=e.parse(r);this._initMapState[e.name]=t,Object.defineProperty(this.options,e.name,{value:t,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(e){let t=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];e&&e.include&&(t=t.filter((t=>e.include.includes(t)))),t.forEach((e=>{this._mapEvents[e]=t=>{if(this.runtimeParams.length){const t=this._mapState.find((t=>t.event===e));if(t){const e=t.toString(t.getValue());this.runtimeParams.forEach((r=>{r.set(t.name,e)}))}}this._eventsStatus&&this.emitter.emit(e,t)};const t=this._mapEvents[e];t&&this.mapAdapter.emitter.on(e,t)}))}_removeEventListeners(e){let t=Object.entries(this._mapEvents);e&&e.include&&(t=t.filter((t=>e.include.includes(t[0])))),t.forEach((([e,t])=>{t&&this.mapAdapter.emitter.removeListener(e,t)}))}};Es(Ms,"keys",new class{constructor(){ms(this,"keyCodeAlias",new fs),ms(this,"keys",{}),ms(this,"_windowOnFocus"),ms(this,"_keysPressed"),ms(this,"_keysReleased"),this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(e){const t=this.keyCodeAlias[e];return!!t&&this.keys[t]}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(e){e.stopPropagation(),this.keys[e.keyCode]||(this.keys[e.keyCode]=!0)}keysReleased(e){e.stopPropagation(),this.keys[e.keyCode]=!1}windowOnFocus(){this.keys={}}}),Es(Ms,"getPaintFunctions");let ks=Ms;function Ss(e){const t={};for(let n=0;n<e.length;n++)t[e[n]]=1+(t[e[n]]||0);let r;for(const n in t){t[n]>((void 0!==r?t[r]:0)||0)&&(r=n)}return r}function Ns(e){let t;if("FeatureCollection"===e.type){t=Ss(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=Ss(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const Ts={polygon:"path",line:"path",point:"circle"},Fs={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Bs(e){if(e.data){const t=Fs[Ns(e.data)],r=e.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===t||"line"===t?"path":"html"in r||"className"in r?"icon":Ts[t]),e.type=e.type||t}return e}var Rs=Object.defineProperty,$s=Object.defineProperties,Ds=Object.getOwnPropertyDescriptors,qs=Object.getOwnPropertySymbols,Gs=Object.prototype.hasOwnProperty,Vs=Object.prototype.propertyIsEnumerable,Us=(e,t,r)=>t in e?Rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,zs=(e,t)=>{for(var r in t||(t={}))Gs.call(t,r)&&Us(e,r,t[r]);if(qs)for(var r of qs(t))Vs.call(t,r)&&Us(e,r,t[r]);return e},Zs=(e,t)=>$s(e,Ds(t)),Ws=(e,t,r)=>Us(e,"symbol"!=typeof t?t+"":t,r),Js=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Hs extends ks{constructor(e){super(e),Ws(this,"_layersIdCounter",1),Ws(this,"_layersOrderCounter",1),Ws(this,"_baselayers",[]),Ws(this,"_layers",{}),Ws(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return Js(this,null,(function*(){const r=this.getLayer(e),n=r&&(r.getBounds||r.getExtent);if(n){const e=yield n.call(r);e&&this.fitBounds(e,t)}}))}isBaseLayer(e){const t=this.getLayer(e);if(t&&t.id)return-1!==this._baselayers.indexOf(t.id)}getBaseLayers(){const e=[];return this._baselayers.forEach((t=>{const r=this._layers[t];r&&e.push(r)})),e}getBaseLayersIds(){return this._baselayers}getLayer(e){return"string"==typeof e?this._layers[e]:e}getLayerId(e){const t=this.getLayer(e);if(t){if(t.id)return null==t?void 0:t.id;if(t&&t.options)return t.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(((e,t)=>e.order&&t.order?e.order-t.order:0))}findLayer(e){for(const t in this._layers){const r=this._layers[t];if(e(r))return r}}isLayerVisible(e){const t=this.getLayer(e);return!(!t||void 0===t.options.visibility)&&t.options.visibility}addBaseLayer(e,t){return Js(this,null,(function*(){return yield this.addLayer(e,Zs(zs({},t),{baselayer:!0}),void 0)}))}addLayer(e){return Js(this,arguments,(function*(e,t={},r){var n,o;const i=this._layersIdCounter++,s=p(r)?r:void 0!==t.order?t.order:this.reserveOrder();let a;"string"==typeof e?a=this.getLayerAdapter(e):"function"==typeof e?a=e:"then"in e&&(a=yield e);const l=t;this._updateGeoJsonOptions(l);const c=null==(n=(t=zs({id:String(i),order:s},t)).visibility)||n;if(t.visibility=!1,t.baselayer&&(t.order=0),this.options.onBeforeAddLayer){const e=this.options.onBeforeAddLayer({options:t,adapter:a});e&&(e.options&&(t=e.options),e.adapter&&(a=e.adapter))}if(void 0!==a){const e=new a(this.mapAdapter.map,t);let r;e.options=zs(zs({},t),e.options),e.options.baselayer&&(t.baselayer=!0,t.order=0,e.options.order=0),e.options.id&&(r=String(e.options.id),this._layers[r]=e),this._emitLayerEvent("layer:preadd",r||"",e),yield this.onMapLoad(),e.map=this.mapAdapter.map;const n=yield e.addLayer(e.options);if(e.layer=n,e.id=e.options.id||String(i),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(o=e.options.order)?o:s,r&&delete this._layers[r],r=String(e.id),this._layers[r])throw Error(`layer with id '${r}' already exist`);r&&(this._layers[r]=e,l.filter&&this.filterLayer(e,l.filter),t.baselayer&&this._baselayers.push(r),c&&(yield this.showLayer(r)));const u=t.opacity;void 0!==u&&u<=1&&this.setLayerOpacity(e,u);const p=n&&(e.getBounds||e.getExtent);if(t.fit&&p){const t=yield p.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")}))}addLayerFromAsyncAdapter(e,t,r){return Js(this,null,(function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),o=e(),i=yield o;return i?this.addLayer(i,t,n):Promise.reject("No adapter")}))}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return Js(this,null,(function*(){const t=[];for(const r of this.orderedLayers())r.getLegend&&t.push(r.getLegend(e));return(yield Promise.all(t)).flat()}))}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((e,t)=>!(t&&t.options&&t.options.baselayer)))}removeLayer(e){const t=this.getLayer(e),r=t&&this.getLayerId(t);if(t&&r){if(this.emitter.emit("layer:preremove",t),t.beforeRemove&&t.beforeRemove(),t.removeLayer?t.removeLayer():this.mapAdapter.removeLayer(t.layer),t.options&&t.options.baselayer){const e=this._baselayers.indexOf(r);e&&this._baselayers.splice(e,1)}delete this._layers[r],this.emitter.emit("layer:remove",t)}}addGeoJsonLayer(e={},t){return(e=e||{}).multiselect=void 0!==e.multiselect&&e.multiselect,e.unselectOnSecondClick=void 0===e.unselectOnSecondClick||e.unselectOnSecondClick,t||(e=Bs(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",Zs(zs({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",Zs(zs({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),o=void 0!==t?t:!(n&&n.options.visibility),i=void 0!==r.silent&&r.silent,s=e=>Js(this,null,(function*(){const t=String(e.id),r=o?"layer:show":"layer:hide";if(i||(this._emitLayerEvent(o?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),o&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter((t=>t!==e.id&&this.isLayerVisible(t)));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=o,i||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))}));return n?this.onMapLoad().then((()=>s(n))):Promise.resolve()}updateLayer(e){const t=this.getLayer(e);if(t){if(t.updateLayer)return Promise.resolve(t.updateLayer());if(this.isLayerVisible(t))return this.hideLayer(t,{silent:!0}).then((()=>this.showLayer(t,{silent:!0})))}return Promise.resolve()}setLayerOpacity(e,t){const r=this.getLayer(e);r&&(r.setOpacity?r.setOpacity(t):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,t))}isLayerLabelVisible(e){var t;const r=this.getLayer(e);return r.isLabelVisible?r.isLabelVisible():null==(t=r.options.labelVisibility)||t}showLayerLabel(e){this.toggleLayerLabel(e,!0)}hideLayerLabel(e){this.toggleLayerLabel(e,!1)}toggleLayerLabel(e,t){const r=this.getLayer(e);return t=null!=t?t:!this.isLayerLabelVisible(e),r&&(t?r.showLabel&&(r.options.labelVisibility=!0,r.showLabel()):r.hideLabel&&(r.options.labelVisibility=!1,r.hideLabel()),r.id&&this._emitLayerEvent("layer:label:toggle",r.id,r)),t}selectLayer(e,t){const r=this.getLayer(e);if(r){r&&r.select&&r.select(t);const e=this.getLayerId(r);e&&this._selectedLayers.push(e)}}unSelectLayer(e,t){const r=this.getLayer(e);if(r){const e=r&&r;e.unselect&&e.unselect(t);const n=this.getLayerId(r);if(n){const e=this._selectedLayers.indexOf(n);-1!==e&&this._selectedLayers.splice(e,1)}}}unSelectLayers(){const e=Object.values(this.allLayers());let t;for(t of e)t.unselect&&t.unselect()}filterLayer(e,t){const r=this.getLayer(e);return r.filter?r.filter(t):[]}propertiesFilter(e,t,r){const n=this.getLayer(e);if(n){const e=n;if(e.propertiesFilter)return e.propertiesFilter(t,r);e.filter&&this.filterLayer(e,(e=>!e.feature||!e.feature.properties||Te(e.feature.properties,t)))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter((()=>!0))}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let o=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(o&&e.onlyBaselayer&&(o=this._baselayers.includes(r)),o){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find((e=>this.isLayerVisible(e)));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const n=String(e);if(p(t)&&n.startsWith("layer:")){const e=n.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return Js(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerDoubleClick(e){return Js(this,null,(function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return Js(this,null,(function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)}))}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:n,onDoubleClick:o,onLayerClick:i,onMouseOut:s,onMouseOver:a}=e,l=n||i,c=o||i;e.onClick=e=>(l&&l(e),this._onLayerClick(e)),e.onDoubleClick=e=>(c&&c(e),this._onLayerDoubleClick(e)),e.onMouseOut=e=>{const t=e.layer.id;s&&s(e),p(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;a&&a(e),p(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const u=t||r;e.onSelect=e=>(u&&u(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=ps({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=ps({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}function Qs(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach((e=>{t?r.classList.add(e):r.classList.remove(e)}))}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const p=e=>{void 0!==e&&(n=e),l(),s(),u()},h=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then((()=>p())).catch((()=>n=!n))}else p()},d=e({html:r,onClick:h});return d.onClick=h,d.changeStatus=p,d}var Ks=Object.defineProperty,Xs=(e,t,r)=>((e,t,r)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Ys=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const ea=class e extends Hs{constructor(){super(...arguments),Xs(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),Xs(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return Ys(this,null,(function*(){let n;if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,r):e,n)return new Promise((e=>{this._setControlQueue(t,(()=>Ys(this,null,(function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))))}))}))}createControl(e,t){return Ys(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return Ys(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return Ys(this,null,(function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?Qs(this.mapAdapter.createButtonControl,e):void 0}))}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then((e=>{this.mapAdapter.removeControl(e)}))}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return Ys(this,null,(function*(){if(this._loadControlQueue[e].length){this._isControlLoading[e]=!0;const t=this._loadControlQueue[e][0];yield t(),this._loadControlQueue[e].splice(0,1),this._applyControls(e)}else this._isControlLoading[e]=!1}))}};Xs(ea,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let ta=ea;const ra={};function na(e){return ra[e]}function oa(e,t){ra[e]=t}var ia=Object.getOwnPropertySymbols,sa=Object.prototype.hasOwnProperty,aa=Object.prototype.propertyIsEnumerable,la=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ca=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())})),ua=(e,t,r)=>(t=e[la("asyncIterator")])?t.call(e):(e=e[la("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:i})),o))))),r("next"),r("return"),t);class pa extends ta{constructor(e){super(e),this._addControls(),oa(this.id,this)}static get(e){return na(e)}_addLayerProviders(){return ca(this,null,(function*(){try{for(var e,t,r,n=ua(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var o,i,s,a=ua(t);o=!(i=yield a.next()).done;o=!1){const e=i.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(i){s=[i]}finally{try{o&&(i=a.return)&&(yield i.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_onLoadSync(){return ca(this,null,(function*(){try{for(var e,t,r,n=ua(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(o){console.error(o)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_addControls(){this.options.controls&&this.options.controls.forEach((e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:o}=n,i=((e,t)=>{var r={};for(var n in e)sa.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&ia)for(var n of ia(e))t.indexOf(n)<0&&aa.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)})),this._emitStatusEvent("controls:create")}}function ha(){return["ZOOM","ATTRIBUTION"]}var da=Object.defineProperty,fa=Object.defineProperties,ya=Object.getOwnPropertyDescriptors,ma=Object.getOwnPropertySymbols,ga=Object.prototype.hasOwnProperty,ba=Object.prototype.propertyIsEnumerable,va=(e,t,r)=>t in e?da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wa=(e,t)=>{for(var r in t||(t={}))ga.call(t,r)&&va(e,r,t[r]);if(ma)for(var r of ma(t))ba.call(t,r)&&va(e,r,t[r]);return e},_a=(e,t)=>fa(e,ya(t));function Oa(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(_a(wa({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(wa(_a(wa({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(wa(wa(wa({},r),t),n))}var La=Object.defineProperty,Pa=Object.defineProperties,Ia=Object.getOwnPropertyDescriptors,xa=Object.getOwnPropertySymbols,Ea=Object.prototype.hasOwnProperty,ja=Object.prototype.propertyIsEnumerable,Aa=(e,t,r)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Ca={target:"map",baseUrl:"",whitlabel:!1,controls:["ZOOM","ATTRIBUTION"],controlsOptions:{ZOOM:{position:"top-left"},ATTRIBUTION:{position:"bottom-right",customAttribution:['<a href="https://nextgis.com" target="_blank">©NextGIS</a>']}},pixelRadius:10};function Ma(e){const t=[new Br];var r;return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new Ie({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=d(Ca,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new ti({connector:e.connector,auth:e.auth})),r=((e,t)=>{for(var r in t||(t={}))Ea.call(t,r)&&Aa(e,r,t[r]);if(xa)for(var r of xa(t))ja.call(t,r)&&Aa(e,r,t[r]);return e})({},e),e=Pa(r,Ia({starterKits:t,create:!1}))}var ka=Object.defineProperty,Sa=Object.defineProperties,Na=Object.getOwnPropertyDescriptors,Ta=Object.getOwnPropertySymbols,Fa=Object.getPrototypeOf,Ba=Object.prototype.hasOwnProperty,Ra=Object.prototype.propertyIsEnumerable,$a=Reflect.get,Da=(e,t,r)=>t in e?ka(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qa=(e,t)=>{for(var r in t||(t={}))Ba.call(t,r)&&Da(e,r,t[r]);if(Ta)for(var r of Ta(t))Ra.call(t,r)&&Da(e,r,t[r]);return e},Ga=(e,t)=>Sa(e,Na(t)),Va=(e,t,r)=>Da(e,"symbol"!=typeof t?t+"":t,r),Ua=(e,t,r)=>$a(Fa(e),r,t),za=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Za=class e extends pa{constructor(e){super(Ma(e)),Va(this,"emitter",new r),Va(this,"connector"),Va(this,"_ngwLayers",{}),Va(this,"$$selectFromNgwRaster"),Va(this,"$$selectFromNgwVector"),Va(this,"_promises",{select:[],identify:[]}),e.connector&&(this.connector=e.connector),this._createWebMap().then((()=>{const e=this.getContainer();e&&e.classList.add("ngw-map-container"),this.options.whitlabel&&this._whiteLabel()}))}addControl(t,r,n){return za(this,null,(function*(){return yield this.onLoad("controls:create"),Ua(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return za(this,null,(function*(){yield this.onMapLoad();const{keyname:t,resourceId:r}=e;(t||void 0!==r)&&console.warn(`DEPRECATED WARN: ${"set `resource` options instead of `keyname` or `resourceId`"}`);const n=e.resource;if(!t&&!r&&!n)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(p(this.options.baseUrl))try{p(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},p(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),no(e,t,r)}(e,this,this.connector),r=qa(qa({visibility:!0},e),e.adapterOptions),n=yield this.addLayer(t,r),o=n&&this.getLayerId(n);if(n&&o&&(this._ngwLayers[o]={layer:n,resourceId:n.resourceId},n.options.name=n.options.name||n.item&&n.item.resource.display_name,n.options.baselayer)){if(this.getActiveBaseLayer())return n}return n}catch(o){const e=I(n)&&"id"in n?n.id:t||r||n;console.error(`Can't add NGW layer ${e}.`,o)}}))}fit(){const{center:e,zoom:t,bounds:r}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):r&&this.fitBounds(r)}fetchNgwLayerItem(e){return ut(qa({connector:this.connector},e))}fetchNgwLayerItems(e){return cn(qa({connector:this.connector},e))}fetchNgwLayerFeature(e){return pi(qa({connector:this.connector},e))}fetchNgwLayerFeatures(e){return hn(qa({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=new AbortController,n=r.signal;(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",r.abort),(t=t||{}).signal=n;const o=function(e){const{connector:t,identify:r}=e,n=_i(r);return n&&n.length?ut(vi(vi({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",o,r),o}fetchIdentifyGeoJson(e,t=!1){const r=new AbortController,n=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const i in r){const e=Number(i);if(!isNaN(e)){const e=r[i];if("features"in e){const t=e.features.find((e=>e.geom));if(t&&t.geom){const e=t.geom;return Promise.resolve(We(wi(vi({},t),{geom:e})))}}}}const o=_i(r);return o&&o.length?pi(vi(wi(vi({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:r.signal}});return n&&"then"in n?(this._addPromise("identify",n,r),n):Promise.resolve(n)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}getNgwLayers(){return za(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return za(this,null,(function*(){for(const t in this._ngwLayers){const r=this._ngwLayers[t];if(r.resourceId===e)return r&&r.layer;if(r.layer.getIdentificationIds){const t=yield r.layer.getIdentificationIds();if(t&&t.some((t=>t===e)))return r.layer}if(r.layer.getDependLayers){const t=r.layer.getDependLayers().find((t=>t.item&&t.item.parentId===e));if(t)return t.layer}}}))}fitLayer(t,r){return za(this,null,(function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const o=n&&this._ngwLayers[n];if(o)if(o.layer.getBounds){const e=yield o.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(o.layer.item)e=o.layer.item;else{const t=o.resourceId;e=yield this.connector.getResource(t)}e&&hr({resourceId:e.resource.id,connector:this.connector}).then((e=>{e&&this.fitBounds(e,r)}))}else Ua(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}zoomToLayer(e){return za(this,null,(function*(){return this.fitLayer(e)}))}onLoad(e="ngw-map:create"){return super.onLoad(e)}removeLayer(e){const t=this.getLayer(e);if(t){const e=this.getLayerId(t);e&&delete this._ngwLayers[e],super.removeLayer(t)}}enableSelection(){this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=e=>{this._getSelectListenersCount()&&this.selectFromNgwRaster(e)},this.$$selectFromNgwVector=e=>{this._getSelectListenersCount()&&this._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))}disableSelection(){this.$$selectFromNgwRaster&&(this.emitter.removeListener("click",this.$$selectFromNgwRaster),this.$$selectFromNgwRaster=void 0),this.$$selectFromNgwVector&&(this.emitter.removeListener("layer:click",this.$$selectFromNgwVector),this.$$selectFromNgwVector=void 0)}getNgwLayerItem(e){return this.fetchNgwLayerItem(e)}getNgwLayerItems(e){return this.fetchNgwLayerItems(e)}getNgwLayerFeature(e){return this.fetchNgwLayerFeature(e)}getNgwLayerFeatures(e){return this.fetchNgwLayerFeatures(e)}cancelPromise(...e){this.cancelPromises(...e)}cancelPromises(...e){e.length||(e=Object.keys(this._promises)),e.forEach((e=>{const t=this._promises[e];t&&(t.forEach((e=>e[1].abort())),this._promises[e]=[])}))}selectFromNgwRaster(e){return za(this,null,(function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1));for(const e of n){const n=e.layer,o="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,i=null==(t=n.options.interactive)||t;o&&n.options.selectable&&i&&this.isLayerVisible(n)&&r.push(o.call(n))}const o=Promise.all(r),i=yield o,s=[];for(const e of i)e&&s.push(...e);if(!s.length)return void this._emitStatusEvent("ngw:select",null);const a=this.options.pixelRadius||10,l=this.getCenter();let c=this.getZoom();if(c=void 0!==c?c:20,!l||!c)return void this._emitStatusEvent("ngw:select",null);const u=function(e,t,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(l,c,a);let p;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;p={type:"Polygon",coordinates:[w(n,o,u)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:p}});r!==1/0&&setTimeout((()=>{this.removeLayer(i)}),r)}const h=new AbortController,d=function(e,t){f(e);const[r,n]=e.lngLat,{geom:o,radius:i}=t,s=null!=o?o:w(r,n,i);return Li(wi(vi({},t),{geom:s}))}(e,{layers:s,connector:this.connector,radius:u,geom:p,signal:h.signal}).then((t=>{const r=Ga(qa({},t),{resources:s,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n}));return this._addPromise("select",d,h),d}))}_addPromise(e,t,r){const n=this._promises[e];if(n&&-1===n.findIndex((e=>e[0]===t))){const e=()=>{const e=n.findIndex((e=>e[0]===t));-1!==e&&n.splice(e,1)};t.then(e),t.catch(e),n.push([t,r])}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return za(this,null,(function*(){yield this.create(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer();const e=[],t=this._isFitFromResource();if(this.options.webmapId&&Oa(e,this.options.webmapId,{fit:t}),this.options.resources&&Array.isArray(this.options.resources))for(const n of this.options.resources){const r={};t||(r.fit=!1),Oa(e,n,{},r)}for(const n of e)try{yield this.addNgwLayer(n)}catch(r){console.warn(r)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()}))}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const r={qmsId:e};t&&(r.id=t),this.addBaseLayer("QMS",r)}_selectFromNgwVector(e){const t=e.layer;if(!(t.options.selectable&&this.isLayerVisible(t)))return;const r=t.item&&t.item.resource.id,n=e.feature;if(void 0!==r&&n){const e=n.id;if(e){const t={featureCount:1,[r]:{featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]}};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(Ga(qa({},t),{resources:[r],sourceType:"vector"}))),t}}}_prepareToIdentify(e){return Ga(qa({},e),{getIdentifyItems:()=>_i(e,!0).map((e=>new ci({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return za(this,null,(function*(){const e=this.getContainer();if(e){const t=yield Pi(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};Va(Za,"getIcon",(function(e={}){var t,r,n,o,i,s;const a=null!=(t=e.shape)?t:"circle",u=null!=(r=e.color)?r:"blue",p=null!=(n=e.strokeColor)?n:"white",h=null!=(o=e.size)?o:c,d=null!=(i=e.rotate)?i:0,f=null!=(s=e.anchor)?s:[h/2,h/2],y=void 0!==e.stroke?Number(e.stroke):.8,m=e.p||l[a]||"circle",g="string"==typeof m?m:m(e),b=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(e.svg||function({width:e,height:t,stroke:r=0,content:n}){const o=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${o} -${o} ${c+r} ${c+r}"\n >${n}</svg>`}({width:h,height:h,stroke:y,content:g}));return b.setAttribute("width",String(h)),b.setAttribute("height",String(h)),b.setAttribute("fill",u),y&&(b.setAttribute("stroke",p),b.setAttribute("stroke-width",String(y))),{type:"icon",iconSize:[h,h],iconAnchor:f,html:(new XMLSerializer).serializeToString(b),rotate:d,svg:b}}));let Wa=Za;return e.NgwMap=Wa,e.WebMap=pa,e.WebMapControls=ta,e.WebMapLayers=Hs,e.WebMapMain=ks,e.createNgwMap=function(e){return t=this,r=null,n=function*(){return new Wa(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n},e.createToggleControl=Qs,e.createWebMap=function(e){return t=this,r=null,n=function*(){return new pa(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n},e.detectGeometryType=Ns,e.findMostFrequentGeomType=Ss,e.getDefaultControls=ha,e.getWebMap=na,e.paintTypeAlias=Ts,e.setWebMap=oa,e.typeAlias=Fs,e.updateGeoJsonAdapterOptions=Bs,e}({});
1
+ var NgwMap=function(e){"use strict";function t(){}function r(){r.init.call(this)}function n(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function o(e,r,o,i){var s,a,l,c;if("function"!=typeof o)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",r,o.listener?o.listener:o),a=e._events),l=a[r]):(a=e._events=new t,e._eventsCount=0),l){if("function"==typeof l?l=a[r]=i?[o,l]:[l,o]:i?l.unshift(o):l.push(o),!l.warned&&(s=n(e))&&s>0&&l.length>s){l.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+l.length+" "+r+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=r,u.count=l.length,c=u,"function"==typeof console.warn?console.warn(c):console.log(c)}}else l=a[r]=o,++e._eventsCount;return e}function i(e,t,r){var n=!1;function o(){e.removeListener(t,o),n||(n=!0,r.apply(e,arguments))}return o.listener=r,o}function s(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function a(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}t.prototype=Object.create(null),r.EventEmitter=r,r.usingDomains=!1,r.prototype.domain=void 0,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.init=function(){this.domain=null,r.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new t,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return n(this)},r.prototype.emit=function(e){var t,r,n,o,i,s,l,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(l=this.domain,c){if(t=arguments[1],!l){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=l,t.domainThrown=!1,l.emit("error",t),!1}if(!(r=s[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,o=a(e,n),i=0;i<n;++i)o[i].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var o=e.length,i=a(e,o),s=0;s<o;++s)i[s].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,o){if(t)e.call(r,n,o);else for(var i=e.length,s=a(e,i),l=0;l<i;++l)s[l].call(r,n,o)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,o,i){if(t)e.call(r,n,o,i);else for(var s=e.length,l=a(e,s),c=0;c<s;++c)l[c].call(r,n,o,i)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(n-1),i=1;i<n;i++)o[i-1]=arguments[i];!function(e,t,r,n){if(t)e.apply(r,n);else for(var o=e.length,i=a(e,o),s=0;s<o;++s)i[s].apply(r,n)}(r,h,this,o)}return!0},r.prototype.on=r.prototype.addListener=function(e,t){return o(this,e,t,!1)},r.prototype.prependListener=function(e,t){return o(this,e,t,!0)},r.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,i(this,e,t)),this},r.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,i(this,e,t)),this},r.prototype.removeListener=function(e,r){var n,o,i,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if(!(o=this._events))return this;if(!(n=o[e]))return this;if(n===r||n.listener&&n.listener===r)0==--this._eventsCount?this._events=new t:(delete o[e],o.removeListener&&this.emit("removeListener",e,n.listener||r));else if("function"!=typeof n){for(i=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){a=n[s].listener,i=s;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new t,this;delete o[e]}else!function(e,t){for(var r=t,n=r+1,o=e.length;n<o;r+=1,n+=1)e[r]=e[n];e.pop()}(n,i);o.removeListener&&this.emit("removeListener",e,a||r)}return this},r.prototype.off=function(e,t){return this.removeListener(e,t)},r.prototype.removeAllListeners=function(e){var r,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new t,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new t:delete n[e]),this;if(0===arguments.length){for(var o,i=Object.keys(n),s=0;s<i.length;++s)"removeListener"!==(o=i[s])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=new t,this._eventsCount=0,this}if("function"==typeof(r=n[e]))this.removeListener(e,r);else if(r)do{this.removeListener(e,r[r.length-1])}while(r[0]);return this},r.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):s.call(e,t)},r.prototype.listenerCount=s,r.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};const l={brill:'<path d="m6 0-5 6 5 6 5-6z"/>',circle:'<circle cx="6" cy="6" r="6"/>',rect:'<rect width="12" height="12"/>',marker:'<path d="m6 0c-1.85 0-4 1.19-4 4.22 0 2.05 3.08 6.59 4 7.78 0.821-1.19 4-5.62 4-7.78 0-3.03-2.15-4.22-4-4.22z"/>',cross:'<path d="M 2.4,12 6,8.4 9.6,12 12,9.6 8.4,6 12,2.4 9.6,0 6,3.6 2.4,0 0,2.4 3.6,6 0,9.6 Z"/>',star:'<path d="m6 0.25 1.71 4.18 4.29-1.04e-4 -3.43 3.14 0.857 4.18-3.43-3.14-3.43 3.14 0.857-4.18-3.43-3.14 4.29-0.209z"/>',triangle:'<path d="m12 11.7h-12l6-11.2z"/>',plus:'<path d="m7.5 12v-4.5h4.5v-3h-4.5v-4.5h-3v4.5h-4.5v3h4.5v4.5z"/>',minus:'<path d="m12 7.5v-3h-12v3z"/>',asterisk:'<path d="m7.59 12v-3.27l2.83 1.64 1.58-2.74-2.85-1.64 2.83-1.64-1.56-2.74-2.83 1.64v-3.24h-3.17v3.24l-2.85-1.64-1.57 2.74 2.84 1.64-2.84 1.64 1.57 2.74 2.85-1.64v3.27z"/>'},c=12;function u(e,t,r={}){const n=function(e,t=[]){for(;null!==e;e=Object.getPrototypeOf(e)){const r=Object.getOwnPropertyNames(e);for(let e=0;e<r.length;e++)-1==t.indexOf(r[e])&&t.push(r[e])}return t}(e.prototype);const o=void 0===r.replace||r.replace;t.forEach((t=>{Object.getOwnPropertyNames(t.prototype).forEach((r=>{const i=-1!==n.indexOf(r);if(!o&&!i||o){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}}))}))}function h(e){return null!=e}function p(e){return"string"==typeof e?!!e:h(e)}function d(e,t,r=!1){let n=e;const o=t,i=Array.isArray(o);let s=i&&[]||{};return i&&Array.isArray(o)?r?(n=n||[],s=s.concat(n),o.forEach(((e,t)=>{void 0===s[t]?s[t]=e:"object"==typeof e?s[t]=d(n[t],e,r):-1===n.indexOf(e)&&s.push(e)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(e){s[e]=n[e]})),Object.keys(o).forEach((function(e){s[e]="object"==typeof o[e]&&o[e]&&"object"==typeof n[e]&&"object"==typeof o[e]?d(n[e],o[e],r):o[e]}))),s}function f(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}const y=6371;function m(e){return{type:"Polygon",coordinates:[b(e)]}}function b(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const g=Math.PI/180,v=180/Math.PI;function w(e,t,r=10,n=6){const o=r/y*v,i=o/Math.cos(t*g),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+i*Math.cos(r),c=t+o*Math.sin(r);s.push([l,c])}return s}function _(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}function O(e,t,r,n){if(e instanceof Array)return t instanceof Array&&t.sort().join("")===e.sort().join("");if(e instanceof Date)return t instanceof Date&&""+e==""+t;if(e instanceof Function){if(!(t instanceof Function))return!1}else if(e instanceof Object)return t instanceof Object&&(e===r?t===n:L(e,t));return e===t}function L(e,t){const r=Object.keys(e).sort(),n=Object.keys(t).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(let o=0;o<r.length;o++){if(!O(e[r[o]],t[n[o]],e,t))return!1}return!0}function P(e){const t={};return Object.keys(e).forEach((r=>{e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=P(e[r])})),t}function I(e){return"[object Object]"===Object.prototype.toString.call(e)}function x(e){return e.replace(/([^:]\/)\/+/g,"$1")}var j=Object.defineProperty,A=(e,t,r)=>((e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);const E=class e{constructor(t={}){var r;A(this,"cache",[]);const n=null!=(r=t.namespace)?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}clean(){this.cache.length=0}all(){return this.cache}addFull(e,t,r){return this.add(e,t,r,!0)}add(e,t,r,n){const o=this._find(e,r);if(o)return o.value;{let o;o=t instanceof Function?t():t;const i=r&&JSON.parse(JSON.stringify(P(r))),s={key:e,value:o,props:i};return n&&!p(o)?o:(this.cache.push(s),o instanceof Promise?(o.catch((t=>{this.delete(e,r)})),n&&o.then((t=>(p(t)||this.delete(e,r),t))),o):o)}}match(e,t){const r=this._find(e,t);return null==r?void 0:r.value}matchAll(e,t){return e?this.cache.filter((r=>this._filter(r,e,t))).map((e=>e.value)):this.cache.map((e=>e.value))}delete(e,t){const r="string"==typeof e?this.cache.filter((r=>this._filter(r,e,t))):[e];for(const n of r){const e=this.cache.indexOf(n);-1!==e&&this.cache.splice(e,1)}}_find(e,t){return this.cache.find((r=>this._filter(r,e,t)))}_filter(e,t,r){if(e.key!==t)return!1;if(!r)return!0;return L(e.props||{},P(r))}};A(E,"instance",{});let C=E;var M="3.0.0-alpha.4",k=Object.defineProperty,S=(e,t,r)=>((e,t,r)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class N extends Error{constructor(e){super(),S(this,"name","NgwError"),S(this,"title"),S(this,"message"),S(this,"detail"),S(this,"exception"),S(this,"status_code"),S(this,"data"),S(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,N.prototype)}}var F=Object.defineProperty,T=(e,t,r)=>((e,t,r)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class R extends N{constructor(e){super(e),T(this,"name","ResourceNotFoundError"),T(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,R.prototype)}}function B(e){return"[object Object]"===Object.prototype.toString.call(e)}const $=["description"];function D(e,t=""){t=t?t+"__":"";const r={};for(const[n,o]of Object.entries(e))if(-1===$.indexOf(n))if(B(o))if("owner_user"===n){const e=D(o,n);Object.assign(r,e)}else"parent"===n&&"id"in o&&(r.parent_id=o.id);else h(o)&&(r[t+n]=o);return r}var V=Object.defineProperty,q=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,z=(e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Z=(e,t)=>{for(var r in t||(t={}))G.call(t,r)&&z(e,r,t[r]);if(q)for(var r of q(t))U.call(t,r)&&z(e,r,t[r]);return e},W=(e,t,r)=>z(e,"symbol"!=typeof t?t+"":t,r);class J{constructor({connector:e,cacheId:t}){W(this,"cache"),W(this,"connector"),this.connector=e,this.cache=new C({namespace:t})}getOne(e,t){const r=Z({},t);return"string"==typeof e||"number"==typeof e||B(e),"string"==typeof e?this._fetchResourceBy({keyname:e},r):"number"==typeof e?this._fetchResourceById(e,r):B(e)?this._fetchResourceBy(e,r):Promise.resolve(void 0)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new R}))}getId(e,t){return"number"==typeof e?Promise.resolve(e):"string"==typeof e||B(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):Promise.resolve(void 0)}getIdOrFail(e,t){return this.getId(e,t).then((e=>{if(void 0===e)throw new Error;return e}))}getMany(e,t){return this._resourceCacheFilter(e).then((r=>{if(!r.length){const r={};return e.keyname?r.keyname=e.keyname:Object.assign(r,D(e)),this.connector.get("resource.search",t,Z({serialization:"full"},r)).then((e=>{if((null==t?void 0:t.cache)&&e)for(const t of e)this.cache.add("resource.item",Promise.resolve(t),{id:t.resource.id});return e}))}return r}))}getParent(e,t){return this.getOne(e,t).then((e=>e?this.getOne(e.resource.parent.id,t):Promise.resolve(void 0)))}getChildrenOf(e,t){return this.getIdOrFail(e).then((e=>this._getChildrenOf(e,t)))}update(e,t){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.put("resource.item",{data:t},{id:e})}))}delete(e){return this.getId(e).then((e=>{if(void 0!==e)return this.connector.delete("resource.item",null,{id:e}).then((()=>{this._cleanResourceItemCache(e)}))}))}_getChildrenOf(e,t,r=[]){return this.connector.get("resource.collection",t,{parent:e}).then((e=>{const n=[];for(const o of e)(null==t?void 0:t.cache)&&this.cache.add("resource.item",Promise.resolve(o),{id:o.resource.id}),r.push(o),(null==t?void 0:t.recursive)&&o.resource.children&&n.push(this._getChildrenOf(o.resource.id,t,r));return n.length?Promise.all(n).then((()=>r)):r}))}_cleanResourceItemCache(e){return t=this,r=null,n=function*(){var t;const r=this.cache.all(),n=[];for(const o of r){const r=null==(t=o.props)?void 0:t.id;["resource.item","resource"].includes(o.key)&&void 0!==r&&("number"==typeof r?r===e&&n.push(o):(yield this.getId(r))===e&&n.push(o))}for(const e of n)this.cache.delete(e)},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}_fetchResourceById(e,t){return this.connector.get("resource.item",t,{id:e})}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return Promise.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:h(e.id)&&h(t.resource.id)?e.id===t.resource.id:L(e,t.resource)})),[])))}}const H=[];function Q(e){H.push(e)}class K extends Error{constructor(e="AbortError"){super(e),this.name="AbortError"}}var X=Object.defineProperty,Y=(e,t,r)=>((e,t,r)=>t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ee extends N{constructor(e){super(e),Y(this,"name","InsufficientPermissionsError"),Y(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,ee.prototype)}}const te=/\{ *([\w_-]+) *\}/g;function re(e,t){return e.replace(te,((e,r)=>{let n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var ne=Object.defineProperty,oe=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,ae=(e,t,r)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function le(e){return t=this,r=null,n=function*(){const{params:t,name:r,connector:n,requestOptions:o}=e,i=yield n.connect();let s=i&&i[r];if(s){s=[...s];let e=s.shift();if(s.length){const r={};for(let e=0;e<s.length;e++){const n=s[e];if(r[e]=`{${n}}`,void 0===t[n])throw new Error(`\`${n}\` URL API argument is not specified`)}e&&(e=re(e,r))}if(t){const r=[],n=t.paramList;Array.isArray(n)&&n.forEach((([e,t])=>{r.push(`${e}=${t}`)}));for(const e in t)-1===s.indexOf(e)&&r.push(`${e}=${t[e]}`);r.length&&(e=`${e}?${r.join("&")}`)}if(e)return n.makeQuery(e,t,((e,t)=>{for(var r in t||(t={}))ie.call(t,r)&&ae(e,r,t[r]);if(oe)for(var r of oe(t))se.call(t,r)&&ae(e,r,t[r]);return e})({cacheName:r},o));throw new Error("Request URL is not set")}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var ce=Object.defineProperty,ue=(e,t,r)=>((e,t,r)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,t+"",r);class he extends Error{constructor(e){super(),ue(this,"name","NetworkError"),Object.setPrototypeOf(this,he.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}let pe;pe=(e,t,r={},n,o)=>{r.method=r.method||"GET";const i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);const s=()=>{try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=()=>{-1!==[401,403,404,422,500].indexOf(i.status)&&n(new N(s())),((e=!1)=>{const o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})})()},i.onerror=t=>{n(0===i.status?new he(e):t)},i.upload.onprogress=function(e){if(e.lengthComputable){r.onProgress&&r.onProgress(e.loaded/e.total*100,e)}};const a=r.headers;if(a)for(const c in a){const e=a[c];"string"==typeof e&&i.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if(l=new FormData,l.append("file",r.file),r.data)for(const c in r.data)l.append(c,l[c])}else l=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((()=>{i.abort()})),i.send(l)};var de=Object.defineProperty,fe=Object.defineProperties,ye=Object.getOwnPropertyDescriptors,me=Object.getOwnPropertySymbols,be=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,ve=(e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,we=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&ve(e,r,t[r]);if(me)for(var r of me(t))ge.call(t,r)&&ve(e,r,t[r]);return e},_e=(e,t,r)=>ve(e,"symbol"!=typeof t?t+"":t,r),Oe=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let Le=0,Pe=0;class Ie{constructor(e){this.options=e,_e(this,"id",Le++),_e(this,"emitter",new r),_e(this,"user"),_e(this,"resources"),_e(this,"cache"),_e(this,"withCredentials"),_e(this,"client",`NextGIS-NGW-Connector/${M}`),_e(this,"routeStr","/api/component/pyramid/route"),_e(this,"activeRequests",{}),_e(this,"requestTransform");const t=function(e){return H.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return L(t.options.auth,e.auth)}}))}(e);if(this.cache=new C({namespace:e.cacheId}),t)return t;{const{route:t,requestTransform:r,withCredentials:n}=this.options;t&&(this.routeStr=t),r&&(this.requestTransform=r),void 0!==n&&(this.withCredentials=n),this.resources=new J({connector:this,cacheId:e.cacheId}),Q(this)}}static create(e){return new this(e)}clearCache(){this.cache.clean(),this.resources.cache.clean()}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,Q(this)}connect(){return Oe(this,null,(function*(){const e=this.options.auth;if(e){const{login:t,password:r}=e;t&&r&&(yield this._login({login:t,password:r}))}const t=`${this.routeStr}?client=${this.client}`;return yield this.makeQuery(t,{},{cacheName:"route",cache:!0,cacheProps:{id:this.id,auth:e,baseUrl:this.options.baseUrl}})}))}login(e,t){return this.logout(),Q(this),this._login(e,t)}logout(){this.abort(),function(e){const t=H.indexOf(e);-1!==t&&H.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.clearCache(),this.emitter.emit("logout")}getUserInfo(e,t){return Oe(this,null,(function*(){if(this.user&&this.user.id)return this.user;e&&(this.options.auth=e);const r=we({headers:this.getAuthorizationHeaders(e)},t);return this.makeQuery("/api/component/auth/current_user",{},r)}))}getAuthorizationHeaders(e){const t=this.makeClientId(e);if(t)return{Authorization:`Basic ${t}`}}makeClientId(e){if(e=e||this.options.auth){const{login:t,password:r}=e,n=[t,r].map(encodeURIComponent).join(":");return window.btoa(n)}}abort(){for(const e of Object.values(this.activeRequests))e.abort();this.activeRequests={}}getActiveApiRequests(){return we({},this.activeRequests)}apiRequest(e,t={},r={}){var n;return le({name:e,params:P(t=null!=(n=r.params)?n:t),requestOptions:r,connector:this})}post(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)}get(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)}patch(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)}put(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)}delete(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)}makeQuery(e,t){return Oe(this,arguments,(function*(e,t,r={}){var n;if(!(e=(this.options.baseUrl?this.options.baseUrl:"")+e))throw new Error("Empty `url` not allowed");if(t){const r=((e,t)=>{var r={};for(var n in e)be.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&me)for(var n of me(e))t.indexOf(n)<0&&ge.call(e,n)&&(r[n]=e[n]);return r})(t,["paramList"]);e=re(e,r)}e=encodeURI(x(e)),r=we({withCredentials:this.withCredentials},r);const{cache:o,signal:i,method:s="GET",headers:a,cacheName:l,cacheProps:c,responseType:u,withCredentials:h}=r,p=new AbortController,d=p.signal;if(i){if(i.aborted)throw new K;i.addEventListener("abort",(()=>{p.abort()}))}r.signal=d;const f=()=>Oe(this,null,(function*(){const t=Pe++;this.activeRequests[t]=p;try{return this._loadData(e,r)}finally{this._cleanActiveRequest(t)}}));if(o&&"GET"===s){const r=c||(y=we({},P({headers:a,withCredentials:h,responseType:u,baseUrl:this.options.baseUrl,userId:null==(n=this.user)?void 0:n.id})),fe(y,ye({params:t})));return this.cache.add(l||e,f,r,!1)}var y;return f()}))}getResource(e,t){return this.resources.getOne(e,t)}getResourceOrFail(e,t){return this.resources.getOneOrFail(e,t)}getResourceBy(e){return this.resources.getOne(e)}getResourceByKeyname(e){return this.resources.getOne(e)}getResourceById(e){return this.resources.getOne(e)}getResourceId(e,t){return this.resources.getId(e,t)}getResourceIdOrFail(e,t){return this.resources.getIdOrFail(e,t)}getResourcesBy(e,t){return this.resources.getMany(e,t)}getResourceParent(e,t){return this.resources.getParent(e,t)}getResourceChildren(e,t){return this.resources.getChildrenOf(e,t)}updateResource(e,t){return this.resources.update(e,t)}deleteResource(e){return this.resources.delete(e)}_loadData(e,t){return t.responseType=t.responseType||"json",new Promise(((r,n)=>{var o;if(this.user&&((t=t||{}).headers=we(we({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}let i;pe(e,r,t,n,(e=>{i=e})),null==(o=t.signal)||o.addEventListener("abort",(()=>{void 0!==i&&i(),n(new K)}))})).catch((e=>{if("AbortError"!==e.name){const t=this._handleHttpError(e);if(t)throw t}throw e}))}_login(e,t){return Oe(this,null,(function*(){try{const r=yield this.getUserInfo(e,t);return this.user=r,this.emitter.emit("login",r),r}catch(r){throw this.emitter.emit("login:error",r),r}}))}_cleanActiveRequest(e){delete this.activeRequests[e]}_handleHttpError(e){if(e&&e instanceof N){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new R(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new ee(e)}return e}}_e(Ie,"errors",{NgwError:N,ResourceNotFoundError:R});var xe=Object.defineProperty,je=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Ce=(e,t,r)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Me=(e,t)=>{for(var r in t||(t={}))Ae.call(t,r)&&Ce(e,r,t[r]);if(je)for(var r of je(t))Ee.call(t,r)&&Ce(e,r,t[r]);return e};function ke(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${o=t,o.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var o;return null!==new RegExp(n,r?"i":"").exec(e)}const Se={gt:(e,t)=>e>t,lt:(e,t)=>e<t,ge:(e,t)=>e>=t,le:(e,t)=>e<=t,eq:(e,t)=>e===t,ne:(e,t)=>e!==t,in:(e,t)=>-1!==t.indexOf(e),notin:(e,t)=>-1===t.indexOf(e),like:(e,t)=>ke(e,t),ilike:(e,t)=>ke(e,t,!0)};function Ne(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Fe(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Ne(t)){const[r,n,o]=t,i=Se[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,i)=>(t=e[i],r.replace(i,o))));return i(t,n)}return i(e[r],o)}return!1}return Fe(e,t)},o=t.filter((e=>Array.isArray(e)));return"any"===r?o.some(n):o.every(n)}var Te=Object.defineProperty,Re=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,qe=(e,t,r)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ge=(e,t)=>{for(var r in t||(t={}))De.call(t,r)&&qe(e,r,t[r]);if($e)for(var r of $e(t))Ve.call(t,r)&&qe(e,r,t[r]);return e},Ue=(e,t)=>Re(e,Be(t)),ze=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Ze={srs:4326,geom_format:"geojson"};function We(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function Je(e,t){const{extensions:r,geom:n,fields:o,srs:i,ilike:s,like:a}=t,l=r?r.join(","):"";"*"!==l&&(e.extensions=l),null!=o&&(e.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),h(s)?e.ilike=s:h(a)&&(e.like=a),h(i)&&(e.srs=i)}function He(e){return ze(this,null,(function*(){const t=Ke(e),r=yield Promise.all(t),n=[],o=[];for(const e of r)for(const t of e)n.includes(t.id)||(o.push(t),n.push(t.id));return e.offset||e.limit?o.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:o.length):o}))}function Qe(e){const[t,r,n]=e;let o="",i="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(o=t,i=n,r)))}__${r}`,o+n+i]}function Ke(e,t=[],r=[]){var n;const{filters:o}=e,i=null!=(n=e.paramList)?n:[],s="string"==typeof o[0]?o[0]:"all",a=o.filter((e=>Array.isArray(e)));if("any"===s)for(const l of a)Ne(l)?t.push(Ye(Ue(Ge({},e),{paramList:[...r,...i,Qe(l)]}))):Ke(Ue(Ge({},e),{filters:l}),t,[...r]);else if("all"===s){const n=[],o=[];for(const e of a)Ne(e)?n.push(Qe(e)):o.push(e);if(o.length)for(const i of o)Ke(Ue(Ge({},e),{filters:i}),t,[...r,...n]);else t.push(Ye(Ue(Ge({},e),{paramList:[...r,...i,...n]})))}return t}function Xe(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=_(e,t).map((e=>Math.round(1*(e+Number.EPSILON))/1));return r+" "+n})).join(", ")}))`}function Ye(e){const t=Ge({},Ze),{limit:r,cache:n,signal:o,offset:i,orderBy:s,paramList:a,connector:l,geomFormat:c,intersects:u,resourceId:h}=e;if(r?r!==Number.POSITIVE_INFINITY&&(t.limit=r):t.limit=7e3,i&&(t.offset=i),c&&(t.geom_format=c),Je(t,e),s&&(t.order_by=s.join(",")),Array.isArray(u)){const e=function(e){return Array.isArray(e)&&4===e.length&&e.every((e=>"number"==typeof e))}(u)?b(u):u;t.intersects=Xe(e)}else"string"==typeof u&&(t.intersects=u);a&&(t.paramList=a);const p=Ge({id:h},t);return l.get("feature_layer.feature.collection",{cache:n,signal:o},p)}var et=Object.defineProperty,tt=Object.defineProperties,rt=Object.getOwnPropertyDescriptors,nt=Object.getOwnPropertySymbols,ot=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable,st=(e,t,r)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,at=(e,t)=>{for(var r in t||(t={}))ot.call(t,r)&&st(e,r,t[r]);if(nt)for(var r of nt(t))it.call(t,r)&&st(e,r,t[r]);return e},lt=(e,t)=>tt(e,rt(t)),ct=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function ut(e){return ct(this,null,(function*(){const t=at({},Ze);Je(t,e);const r=at({id:e.resourceId,fid:e.featureId},t),n=yield e.connector.get("feature_layer.feature.item",e,r);return lt(at({},n),{toGeojson:()=>ct(this,null,(function*(){if(n.geom)return We(n);{const t=(yield ut(lt(at({},e),{geom:!0,fields:null,extensions:null}))).geom;return We(lt(at({},n),{geom:t}))}}))})}))}var ht=Object.defineProperty,pt=Object.getOwnPropertySymbols,dt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,yt=(e,t,r)=>t in e?ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mt=(e,t,r)=>yt(e,"symbol"!=typeof t?t+"":t,r);class bt{constructor(e){this.options=e,mt(this,"name"),mt(this,"resourceId"),mt(this,"item"),mt(this,"_extent"),this.resourceId=e.resourceId;const t=e.item;this.item=t,this.name=e.labelField&&t.fields?t.fields[e.labelField]:String(t.id)}extent(e){return this._extent?Promise.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",e,{id:this.resourceId,fid:this.item.id}).then((e=>{const{minLat:t,minLon:r,maxLat:n,maxLon:o}=e.extent,i=[r,t,o,n];return this._extent=i,i}))}geoJson(e){return this.item.geom?Promise.resolve(We(this.item)):ut(((e,t)=>{for(var r in t||(t={}))dt.call(t,r)&&yt(e,r,t[r]);if(pt)for(var r of pt(t))ft.call(t,r)&&yt(e,r,t[r]);return e})({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null},e)).then((e=>(this.item.geom=e.geom,We(this.item))))}}function gt(e,t,r,n){return!!_t(e,t,r,Ot)}function vt(e,t,r,n){return _t(e,t,r,Lt)}function wt(e,t="children"){let r=[];const n=("function"==typeof t?t:e=>e[t])(e);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function _t(e,t=(e=>!!e),r="children",n,o){return n(e,"function"==typeof t?t:e=>Fe(e,t),r)}function Ot(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(t(e))return e;const n=wt(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){const e=Ot(o[i],t,r,n);if(e)return e}}function Lt(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{t(e)&&n.push(e);const i=wt(e,r);i&&(o=i)}for(let i=0;i<o.length;i++)o[i]&&Lt(o[i],t,r,n);return n}function Pt(e,t=(e=>!!e),r,n=[]){let o=[];if(Array.isArray(e))o=e;else{if(!t(e))return!1;const n=wt(e,r);n&&(o=n)}for(let i=0;i<o.length;i++)if(o[i]){if(!Pt(o[i],t,r,n))return!1}return!0}var It=Object.defineProperty,xt=(e,t,r)=>((e,t,r)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class jt{constructor(e){xt(this,"item"),xt(this,"_children",[]),xt(this,"_parent"),this.item=e}setParent(e){this._parent=e}addChild(e){this._children.push(e)}getParent(){return this._parent}getParents(e){const t=this.getParent();return t?vt(t,e,(e=>e.tree.getParent())):[]}getRoot(){let e=this.getParent(),t=e;for(;e;)e=e.tree.getParent(),e&&(t=e);return t}find(e){return _t(this._children,e,(e=>e.tree.getChildren()),Ot)}every(e){return!!_t(this._children,e,(e=>e.tree.getChildren()),Pt)}some(e){return gt(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return vt(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var At=Object.defineProperty,Et=(e,t,r)=>((e,t,r)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ct{constructor(e,t,n){Et(this,"options"),Et(this,"emitter",new r),Et(this,"name"),Et(this,"item"),Et(this,"_blocked",!1),Et(this,"_container"),Et(this,"_value"),Et(this,"_removeEventsListener"),this.item=t,this.options=Object.assign({},n),this.name=e,this._value=this.getProperty()}getProperty(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value}getParents(){return this.item.tree.getParents()||[]}getParent(){return this.item.tree.getParent()}getChildren(){return this.item.tree.getChildren()}isGroup(){return this.item.tree.getDescendants().length}isBlocked(){if(void 0!==this._blocked)return this._blocked;const e=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(e),this._blocked}set(e,t){this._value=this._prepareValue(e),this.update(this._value,t),this._fireChangeEvent(this._value,t)}get(){return this.getValue()}update(e,t){this._callOnSet(e,t)}getContainer(){return this._container}destroy(){if(this._container){const e=this._container.parentNode;e&&e.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()}getValue(){return void 0!==this._value?this._value:this.getProperty()}_prepareValue(e){return e}_callOnSet(e,t){this.options.onSet&&this.options.onSet.call(this,e,t,this.item)}_fireChangeEvent(e,t){if(this.emitter){e=void 0!==e?e:this.getValue(),this.emitter.emit("change",{value:e,options:t});this.item.tree.getParents().forEach((r=>{const n=r.properties&&r.properties.property(this.name);n&&n.emitter.emit("change-tree",{value:e,options:t,item:this.item})}))}}_calculateBlockedStatus(e){return e.some((e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()}))}}var Mt=Object.defineProperty,kt=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,Nt=Object.prototype.propertyIsEnumerable,Ft=(e,t,r)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tt=(e,t)=>{for(var r in t||(t={}))St.call(t,r)&&Ft(e,r,t[r]);if(kt)for(var r of kt(t))Nt.call(t,r)&&Ft(e,r,t[r]);return e};const Rt=class e extends Ct{constructor(t,r,n){super(t,r,Tt(Tt({},e.options),n)),this.set(this.get())}update(e,t){if(e){if(t&&t.bubble||this.options.bubble){this.unBlock(t);const r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(e,Object.assign({},t,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(t)}else this._turnOff(t);(t&&t.propagation||this.options.propagation)&&this._propagation(e,t)}getHierarchyValue(){return this.get()&&this.getParents().every((e=>{const t=e.properties&&e.properties.get(this.name);return t&&t.get()}))}block(e){this._blocked=!0,this._block(e)}unBlock(e){this._blocked=!1,this.getValue()&&this._unBlock(e)}blockChild(e){this.item.tree.getDescendants().forEach((t=>this._blockChild(t,e)))}unblockChild(e){this.item.tree.getChildren().forEach((t=>this._unBlockChild(t,e)))}_prepareValue(e){return e}_turnOff(e){this.options.turnOff&&this.options.turnOff.call(this,e),this._callOnSet(!1,e),this.options.hierarchy&&this.isGroup()&&this.blockChild(e)}_turnOn(e){this.options.turnOn&&this.options.turnOn.call(this,e),this._callOnSet(!0,e),this.options.hierarchy&&this.isGroup()&&this.unblockChild(e)}_block(e){this._turnOff(e)}_unBlock(e){this._turnOn(e)}_blockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.block&&r.block(t)}_unBlockChild(e,t){const r=e.properties&&e.properties.property(this.name);r&&r.unBlock&&r.unBlock(t)}_propagation(e,t){if(this.isGroup()){const r=this.item.tree.getChildren();for(let n=0;n<r.length;n++){const o=r[n],i=o.properties&&o.properties.property(this.name);i&&i.set(e,Tt(Tt({},t),{propagation:!0,bubble:!1}))}}}};Ft(Rt,"options"+"",{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let Bt=Rt;var $t=Object.defineProperty,Dt=Object.getOwnPropertySymbols,Vt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,Gt=(e,t,r)=>t in e?$t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ut=(e,t,r)=>Gt(e,"symbol"!=typeof t?t+"":t,r);const zt=class e{constructor(e,t){this.item=e,Ut(this,"options",{}),Ut(this,"_properties",{}),Ut(this,"_propertiesList",[]),t&&t.forEach(this._setPropertyHandler.bind(this))}add(e){this._setPropertyHandler(e)}update(){this.list().forEach((e=>e.update()))}get(e){const t=this.property(e);return t?t.get():void 0}set(e,t,r){const n=this.property(e);n&&n.getValue()!==t&&n.set(t,r)}property(e){return this._properties[e]}list(){return this._propertiesList.map((e=>this._properties[e]))}destroy(){for(const e in this._properties){const t=this.property(e);t&&t.destroy&&t.destroy()}this._properties={},this._propertiesList=[]}_setPropertyHandler(e){const t=this._getHandler(e);if(t&&e.name){const r=((e,t)=>{for(var r in t||(t={}))Vt.call(t,r)&&Gt(e,r,t[r]);if(Dt)for(var r of Dt(t))qt.call(t,r)&&Gt(e,r,t[r]);return e})({},e);this._properties[e.name]=new t(e.name,this.item,r),this._propertiesList.push(e.name)}}_getHandler(t){const r=t.handler;return!r&&t.type?"boolean"===t.type?e.handlers.CheckProperty:e.handlers.BaseProperty:r}};Ut(zt,"handlers",{CheckProperty:Bt});let Zt=zt;var Wt=Object.defineProperty,Jt=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Kt=(e,t,r)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xt=(e,t,r)=>Kt(e,"symbol"!=typeof t?t+"":t,r);let Yt=0;class er{constructor(e){Xt(this,"options",{}),Xt(this,"properties"),Xt(this,"tree"),Xt(this,"id",Yt),Yt+=1,this.options=((e,t)=>{for(var r in t||(t={}))Ht.call(t,r)&&Kt(e,r,t[r]);if(Jt)for(var r of Jt(t))Qt.call(t,r)&&Kt(e,r,t[r]);return e})({},e),this.tree=new jt(this)}initProperties(){this.properties=new Zt(this,this.options.properties)}}var tr=Object.defineProperty,rr=Object.defineProperties,nr=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,ir=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,ar=(e,t,r)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lr=(e,t)=>{for(var r in t||(t={}))ir.call(t,r)&&ar(e,r,t[r]);if(or)for(var r of or(t))sr.call(t,r)&&ar(e,r,t[r]);return e},cr=(e,t)=>rr(e,nr(t));function ur(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,o=e.extent_right;if(t&&r&&n&&o){const e=[r,t,o,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function hr({resourceId:e,connector:t,cache:r=!0,signal:n}){return t.get("layer.extent",{cache:r,signal:n},{id:e}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}function pr(e){return e.connector.getResource(e.resourceId,{signal:e.signal,cache:e.cache}).then((t=>{if(t)return dr(t,e.connector,e)}))}function dr(e,t,r){if(e.webmap)return Promise.resolve(ur(e.webmap));{const n=e.resource;return n.cls&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id,r).then((e=>{if(e)return hr(cr(lr({},r),{resourceId:e.resource.id,connector:t}))})):hr(cr(lr({},r),{resourceId:n.id,connector:t}))}}var fr=Object.defineProperty,yr=(e,t,r)=>((e,t,r)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),mr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class br{constructor(){yr(this,"item"),yr(this,"connector"),yr(this,"_extent")}getExtent(){return mr(this,null,(function*(){return this.getBounds()}))}getBounds(e){return mr(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield dr(this.item,this.connector,e),this._extent):void 0}))}}var gr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function vr(e,t){return gr(this,null,(function*(){const r=e.resource,n=r;let{keyname:o,resourceId:i}=e;if(r&&("string"==typeof r?o=r:i="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield vr(r,t)),!i&&o){const e=yield t.getResource(o);e&&(i=e.resource.id)}return i}))}const wr={tms:"TILE"};var _r=Object.defineProperty,Or=Object.getOwnPropertySymbols,Lr=Object.prototype.hasOwnProperty,Pr=Object.prototype.propertyIsEnumerable,Ir=(e,t,r)=>t in e?_r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xr=(e,t)=>{for(var r in t||(t={}))Lr.call(t,r)&&Ir(e,r,t[r]);if(Or)for(var r of Or(t))Pr.call(t,r)&&Ir(e,r,t[r]);return e},jr=(e,t,r)=>Ir(e,"symbol"!=typeof t?t+"":t,r);const Ar="https://qms.nextgis.com";function Er(e,t=Ar,r={}){let n;if("webMap"in e){const o=e,{webMap:i,url:s}=o,a=((e,t)=>{var r={};for(var n in e)Lr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Or)for(var n of Or(e))t.indexOf(n)<0&&Pr.call(e,n)&&(r[n]=e[n]);return r})(o,["webMap","url"]);n=i,s&&(t=s),a&&(r=a)}else n=e;t||(t=Ar);class o{constructor(e,t){jr(this,"qms"),jr(this,"options"),jr(this,"map"),this.map=e;const n=xr(xr({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,i=null,s=function*(){if(!this.qms&&e.qmsId)try{this.qms=yield function(e){return new Promise(((t,r)=>{const n=new XMLHttpRequest;n.onreadystatechange=()=>{if(4===n.readyState&&200===n.status&&n.responseText)try{t(JSON.parse(n.responseText))}catch(e){r(e)}},n.open("GET",x(e),!0),n.send()}))}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=wr[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(i=o,s=a,["showLayer","hideLayer"].forEach((e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(i.prototype,e,t)})),"TILE"===t)){if(e=xr(xr({order:0,maxZoom:n.options.maxZoom,minZoom:n.options.minZoom},this.options),function(e){const t=("https:"===location.protocol?"https":"http")+"://";let r=e.url.replace(/^(https?|ftp):\/\//,t);return e.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:e.name,attribution:e.copyright_text,maxZoom:e.z_max,minZoom:e.z_min}}(r)),r.origin_url){const[t,n]=function(e){const t=[];return[e=e.replace(/{switch:(.*?)}/,((e,r)=>("string"==typeof r&&r.split(",").forEach((e=>t.push(e))),"{s}"))),t]}(r.origin_url);n.length&&(e.subdomains=n,e.url=t)}return this.options=e,new a(this.map,e).addLayer(e)}}var i,s},new Promise(((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},o=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,o);a((s=s.apply(r,i)).next())}));var r,i,s}}return o}var Cr=Object.defineProperty,Mr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Nr=(e,t,r)=>t in e?Cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fr=(e,t)=>{for(var r in t||(t={}))kr.call(t,r)&&Nr(e,r,t[r]);if(Mr)for(var r of Mr(t))Sr.call(t,r)&&Nr(e,r,t[r]);return e},Tr=(e,t,r)=>Nr(e,"symbol"!=typeof t?t+"":t,r);class Rr{constructor(e){Tr(this,"options",{url:"https://qms.nextgis.com"}),Tr(this,"url"),this.options=Fr(Fr({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return Er({webMap:e,url:this.url})}}Tr(Rr,"utils",{createQmsAdapter:Er});var Br=Object.defineProperty,$r=Object.defineProperties,Dr=Object.getOwnPropertyDescriptors,Vr=Object.getOwnPropertySymbols,qr=Object.getPrototypeOf,Gr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,zr=Reflect.get,Zr=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Wr=(e,t)=>{for(var r in t||(t={}))Gr.call(t,r)&&Zr(e,r,t[r]);if(Vr)for(var r of Vr(t))Ur.call(t,r)&&Zr(e,r,t[r]);return e},Jr=(e,t)=>$r(e,Dr(t)),Hr=(e,t,r)=>zr(qr(e),r,t),Qr=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Kr(e){let t;for(t in e){const r=e[t];if(I(r)){const n=r;if(h(n.year)&&h(n.month)&&h(n.day)){const r=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((e=>{r.push(e)})),e[t]=new Date(...r).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))}return e}var Xr=Object.defineProperty,Yr=Object.defineProperties,en=Object.getOwnPropertyDescriptors,tn=Object.getOwnPropertySymbols,rn=Object.prototype.hasOwnProperty,nn=Object.prototype.propertyIsEnumerable,on=(e,t,r)=>t in e?Xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sn=(e,t)=>{for(var r in t||(t={}))rn.call(t,r)&&on(e,r,t[r]);if(tn)for(var r of tn(t))nn.call(t,r)&&on(e,r,t[r]);return e},an=(e,t)=>Yr(e,en(t)),ln=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function cn(e){return ln(this,null,(function*(){var t;const r=e.filters;if(r){let n=yield He(an(sn({},e),{filters:r}));return(null!=(t=e.clientFilterValidate)?t:un(r))&&(n=n.filter((e=>Fe(Kr(an(sn({},e.fields),{id:e.id})),r)))),n}return Ye(e)}))}function un(e){if("any"===e[0])return!0;for(let t=1;t<e.length;t++){const r=e[t];if("[object Array]"===Object.prototype.toString.call(r)){if(un(r))return!0}}return!1}var hn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function pn(e){return function(e){return hn(this,null,(function*(){const t=yield cn(e),r=[];return t.forEach((e=>{r.push(We(e))})),r}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const dn=["fields","intersects","limit","orderBy","strategy"];function fn(e){const t={};return dn.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var yn=Object.defineProperty,mn=Object.defineProperties,bn=Object.getOwnPropertyDescriptors,gn=Object.getOwnPropertySymbols,vn=Object.getPrototypeOf,wn=Object.prototype.hasOwnProperty,_n=Object.prototype.propertyIsEnumerable,On=Reflect.get,Ln=(e,t,r)=>t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pn=(e,t)=>{for(var r in t||(t={}))wn.call(t,r)&&Ln(e,r,t[r]);if(gn)for(var r of gn(t))_n.call(t,r)&&Ln(e,r,t[r]);return e},In=(e,t)=>mn(e,bn(t)),xn=(e,t,r)=>Ln(e,"symbol"!=typeof t?t+"":t,r),jn=(e,t,r)=>On(vn(e),r,t),An=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function En(e){return An(this,null,(function*(){var t,n;const{item:o,webMap:i,Adapter:s,connector:a,layerOptions:l,addLayerOptionsPriority:c}=e,u=null==c||c,h=l,p=s||l.Adapter||i.mapAdapter.layerAdapters.GEOJSON,d=[];let f,y,m=!1;const b=yield vr(h,a);(null==(n=null==(t=h.adapterOptions)?void 0:t.popupOptions)?void 0:n.fromProperties)&&(h.adapterOptions.popupOptions.createPopupContent=({feature:e})=>e&&function(e,t){{const r=document.createElement("div");if(t&&t.feature_layer)t.feature_layer.fields.forEach((t=>{if(t.grid_visibility){const n=e.properties&&e.properties[t.keyname];if(n){const e=document.createElement("div");r.appendChild(e),e.innerHTML=`<span>${t.display_name}</span>: ${n}<span></span>`}}}));else if(e.properties)for(const t in e.properties){const n=document.createElement("div");r.appendChild(n),n.innerHTML=`<span>${t}</span>: ${e.properties[t]}<span></span>`}return r}}(e,o));const g=(e,t)=>An(this,null,(function*(){w(),y=new AbortController;const r=y.signal;return(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",y.abort),(t=t||{}).signal=r,f={filters:e,options:t},pn(Pn({resourceId:b,filters:e,connector:a,cache:!0},t))}));let v=!1;const w=()=>{y&&(y.abort(),y=void 0)};class _ extends p{constructor(){super(...arguments),xn(this,"emitter",new r),xn(this,"__onMapMove"),xn(this,"__onMapMoveStart"),xn(this,"__enableMapMoveListener"),xn(this,"__disableMapMoveListener")}addLayer(e){return An(this,null,(function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==h.id&&(e.id=h.id),o&&o.vector_layer&&(e.type=bo[o.vector_layer.geometry_type]),h.adapterOptions&&(e=u?Pn(Pn({},h.adapterOptions),e):Pn(Pn({},e),h.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,t=!1);const n=e.strategy||void 0;this.options.strategy=n;const i=jn(_.prototype,this,"addLayer").call(this,e);let s;return f={filters:e.propertiesFilter,options:fn(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),n&&n.startsWith("BBOX")&&!m&&this._addBboxEventListener(),i}))}getExtent(){return this.getBounds()}getBounds(){return An(this,null,(function*(){const e=this.getLayers&&this.getLayers().length,t=this.options.strategy;return(null==t?void 0:t.startsWith("BBOX"))||e?pr({connector:a,resourceId:o.resource.id}):jn(_.prototype,this,"getBounds")?jn(_.prototype,this,"getBounds").call(this):void 0}))}beforeRemove(){v=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,w()}getCount(){return function({connector:e,resourceId:t,cache:r=!0,signal:n}){return e.get("feature_layer.feature.count",{cache:r,signal:n},{id:t}).then((e=>e.total_count))}({connector:a,resourceId:b,cache:!0})}updateLayer(e){return An(this,null,(function*(){var t;const r=e||f||{};if(null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield i.onLoad("create"),r.options=r.options||{},r.options.intersects=i.getBounds();const{minZoom:e,maxZoom:t}=this.options,n=i.getZoom();if(void 0!==n){if(void 0!==e&&n<e)return;if(void 0!==t&&n>t)return;if(m)return}}if(!v){try{this.emitter.emit("preupdate",r),i._emitLayerEvent("layer:preupdate",h.id||"",r);const e=yield g(r.filters,In(Pn({},r.options),{srs:this.options.srs}));let t=e;const n=yield this.getCount();if("BBOX+"===this.options.strategy){t={type:"FeatureCollection",features:[]};for(const r of e.features)-1===d.indexOf(String(r.id))&&(d.push(String(r.id)),t.features.push(r));m=void 0!==n&&d.length>=n,yield i.addLayerData(this,t)}else m=void 0!==n&&e.features.length>=n,yield i.setLayerData(this,e);this.emitter.emit("updated",e),i._emitLayerEvent("layer:updated",h.id||"",{data:e,newData:t,isFull:m})}catch(n){if(n instanceof Error&&"CancelError"!==n.name)throw n}jn(_.prototype,this,"updateLayer")&&jn(_.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return An(this,null,(function*(){if(w(),this.filter&&m)this.filter((t=>{const r=t.feature&&t.feature.properties&&Kr(Pn({},t.feature.properties));return!r||Fe(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield g(e,In(Pn({},t),{srs:this.options.srs}));this.setData(r)}}))}removeFilter(){f=void 0,this.propertiesFilter([]),this.filter&&this.filter((()=>!0))}_addBboxEventListener(){this.__enableMapMoveListener=e=>{e===this&&(this._removeMoveEventListener(),this.updateLayer(),this._addMoveEventListener())},this.__disableMapMoveListener=e=>{e===this&&this._removeMoveEventListener()},i.emitter.on("layer:show",this.__enableMapMoveListener),i.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&i.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&i.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...o){n.clear(),r=setTimeout((()=>{r=null,e.apply(this,o)}),t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}((()=>this.updateLayer())),this.__onMapMoveStart=w,i.emitter.on("movestart",this.__onMapMoveStart),i.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&i.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&i.emitter.removeListener("movestart",this.__onMapMoveStart)}}return _}))}var Cn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Mn({options:e,webMap:t,baseUrl:r}){var n;let o,i=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===i){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const o=t+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:t=>(r&&(t.nd=r),mo(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});i="TILE"}if("WMS"===i){o=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:o,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===i)return o=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:o,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===i)return o=r+`/api/resource/${a}/terrain_provider`,{url:o,adapter:i};if("MODEL_3D"===i)return o=r+`/api/component/model_3d/${a}/data.glb`,{url:o};if("TILE"===i)return o=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:o,adapter:i}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var kn=Object.defineProperty,Sn=Object.defineProperties,Nn=Object.getOwnPropertyDescriptors,Fn=Object.getOwnPropertySymbols,Tn=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable,Bn=(e,t,r)=>t in e?kn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$n=(e,t)=>{for(var r in t||(t={}))Tn.call(t,r)&&Bn(e,r,t[r]);if(Fn)for(var r of Fn(t))Rn.call(t,r)&&Bn(e,r,t[r]);return e},Dn=(e,t)=>Sn(e,Nn(t)),Vn=(e,t,r)=>Bn(e,"symbol"!=typeof t?t+"":t,r),qn=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Gn{constructor({layerId:e,legend:t,onSymbolRenderChange:r}){Vn(this,"layerId"),Vn(this,"legend"),Vn(this,"onSymbolRenderChange"),this.layerId=e,this.legend=this.createLegend(t),this.onSymbolRenderChange=r}createLegend(e){return e.map((e=>Dn($n({},e),{name:e.display_name,symbol:e.icon})))}setSymbolRender(e,t){const r=this.legend.find((t=>t.index===e));if(r){r.render!==t&&(r.render=t,this.onSymbolRenderChange&&this.onSymbolRenderChange(this.legend.filter((e=>e.render)).map((e=>e.index))))}}}function Un(e){return qn(this,arguments,(function*({layerOptions:e,connector:t,webMap:r,item:n}){const o=n.resource.cls;let i=e.adapter||o&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[o]||"IMAGE";if(void 0!==i&&(e.adapter=i),"IMAGE"===i){const e=r.getLayerAdapters();!e||e.IMAGE||(i="TILE")}const s=r.mapAdapter.layerAdapters[i];if(s){const o=yield vr(e,t);return class extends s{constructor(i,s){super(i,s),this.map=i,Vn(this,"item",n),Vn(this,"resourceId",o),Vn(this,"_blocked",!1),Vn(this,"_layerVisibility");const a=Mn({options:e,webMap:r,baseUrl:t.options.baseUrl||""});if(a){const t=Dn($n($n({},a),e.adapterOptions),{params:{resource:o},layers:a.layers||String(o),resourceId:o});e.adapterOptions&&h(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=$n($n({},this.options),t)}}addLayer(e){return super.addLayer($n($n({},this.options),e))}showLayer(){this._layerVisibility=!0,this.layer&&(this._blocked||r.mapAdapter.showLayer(this.layer))}hideLayer(){this._layerVisibility=!1,this.layer&&r.mapAdapter.hideLayer(this.layer)}getIdentificationIds(){return qn(this,null,(function*(){if(this.item){if("MVT"===i)return[this.item.resource.id];const e=this.item.resource.parent.id;if(h(e))return[e]}return[]}))}getLegend(e){return qn(this,null,(function*(){const r=this.options.id;if(void 0!==r){const n=yield t.get("render.legend_symbols",$n({params:{id:o},cache:!0},e));return[new Gn({layerId:r,legend:n,onSymbolRenderChange:this._setLegendSymbol.bind(this)})]}return[]}))}_hideLayer(){this.options.id&&r.mapAdapter.hideLayer(this.layer)}_showLayer(){this.options.id&&this._layerVisibility&&r.showLayer(this.options.id,{silent:!0})}_setLegendSymbol(e){const t=this._consolidateIntervals(e);t.length?(this._blocked=!1,this._showLayer()):(this._hideLayer(),this._blocked=!0),this.updateLayer&&this.updateLayer({params:{[`symbols[${o}]`]:t.join(",")||void 0}})}_consolidateIntervals(e){const t=e.slice().sort(((e,t)=>e-t)),r=[];let n=t[0],o=n;for(let i=1;i<=t.length;i++)t[i]===o+1?o=t[i]:(r.push(n===o?`${n}`:`${n}-${o}`),n=t[i],o=n);return r}}}throw new Error(i+" not supported yet. Only TILE")}))}var zn=Object.defineProperty,Zn=Object.defineProperties,Wn=Object.getOwnPropertyDescriptors,Jn=Object.getOwnPropertySymbols,Hn=Object.prototype.hasOwnProperty,Qn=Object.prototype.propertyIsEnumerable,Kn=(e,t,r)=>t in e?zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xn=(e,t)=>{for(var r in t||(t={}))Hn.call(t,r)&&Kn(e,r,t[r]);if(Jn)for(var r of Jn(t))Qn.call(t,r)&&Kn(e,r,t[r]);return e},Yn=(e,t)=>Zn(e,Wn(t)),eo=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const to={},ro=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function no(e){return eo(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const o=n.resource.id,i=yield r.getResourceChildren(o),s=i&&i[0];if(s)return oo(Yn(Xn({},e),{resource:s.resource.id}),t,r)}))}function oo(e,t,r){return eo(this,null,(function*(){let n,o;const i=e.adapter,s=yield vr(e,r);if(s){const a=e.resource;if(o=a&&a.resource&&void 0!==a.resource.id?a:yield r.getResource(s),!o)throw"Resource item is not found";{const a=o.resource.cls,l={layerOptions:Yn(Xn({},e),{resource:s}),connector:r,webMap:t,item:o};if(-1!==ro.indexOf(a))if("webmap"===a)n=function(e){return Cn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield vr(e,r);return class extends Xo{constructor(e){super(e,{url:"",webMap:t,resourceId:n,connector:r})}}}))}(l);else if("vector_layer"===a||"postgis_layer"===a){const t=l.layerOptions.adapterOptions||{};if(t.type=t.type||o.vector_layer&&bo[o.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==i&&"GEOJSON"!==i){if("MVT"!==i)return no(l);n=Un(l)}else n=En(l)}else{if("raster_layer"===a)return no(l);if("basemap_layer"===a)n=function(e){return Qr(this,arguments,(function*({webMap:e,item:t}){if(t.basemap_layer){const r=t.basemap_layer.qms,n=t.basemap_layer.url;if(r){const t=JSON.parse(r);return Promise.resolve(Rr.utils.createQmsAdapter(e,void 0,{qms:t,baselayer:!0}))}if(n){const t=e.mapAdapter.layerAdapters.TILE;if(t){class e extends t{addLayer(t){return Qr(this,null,(function*(){return Hr(e.prototype,this,"addLayer").call(this,Jr(Wr({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===i){const t=yield r.getResource(o.resource.parent.id);if(t){const r=Yn(Xn({},e),{resource:o.resource.parent.id});n=En(Yn(Xn({},l),{item:t,layerOptions:r}))}}else n=Un(l)}else{if(!to[a])throw`Resource class '${a}' not yet supported.`;{const e=to[a];let t;t=i&&"function"!=typeof t?e[i]:e,t&&(n=t(l))}}}}if(n)return n.then((e=>{if(e){const t=e;return o&&(t.prototype.item=o,t.prototype.resourceId=o.resource.id,t.prototype.connector=r),u(t,[br],{replace:!1}),t}}))}))}var io=Object.defineProperty,so=Object.defineProperties,ao=Object.getOwnPropertyDescriptors,lo=Object.getOwnPropertySymbols,co=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,ho=(e,t,r)=>t in e?io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,po=(e,t)=>{for(var r in t||(t={}))co.call(t,r)&&ho(e,r,t[r]);if(lo)for(var r of lo(t))uo.call(t,r)&&ho(e,r,t[r]);return e},fo=(e,t)=>so(e,ao(t)),yo=(e,t)=>{var r={};for(var n in e)co.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&lo)for(var n of lo(e))t.indexOf(n)<0&&uo.call(e,n)&&(r[n]=e[n]);return r};function mo(e,t){const r=e,{bbox:n,width:o,height:i,nd:s}=r,a=yo(r,["bbox","width","height","nd"]);return fo(po({},a),{resource:Array.isArray(t)?t.join(","):t,extent:n,size:o+","+i,timestamp:Date.now(),nd:null!=s?s:200})}const bo={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};let go;function vo(e,t=0){const r=t,n=function(){if(void 0===go){const e=document.createElement("div");e.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(e);const t=e.offsetWidth;document.body.removeChild(e),go=t}return go}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e,o=function(e){return Math.log(e/256)/Math.LN2}(n);return o}var wo=Object.defineProperty,_o=Object.defineProperties,Oo=Object.getOwnPropertyDescriptors,Lo=Object.getOwnPropertySymbols,Po=Object.prototype.hasOwnProperty,Io=Object.prototype.propertyIsEnumerable,xo=(e,t,r)=>t in e?wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jo=(e,t)=>{for(var r in t||(t={}))Po.call(t,r)&&xo(e,r,t[r]);if(Lo)for(var r of Lo(t))Io.call(t,r)&&xo(e,r,t[r]);return e},Ao=(e,t)=>_o(e,Oo(t)),Eo=(e,t,r)=>xo(e,"symbol"!=typeof t?t+"":t,r),Co=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const Mo=class e extends er{constructor(t,n,o,i,s,a){if(super(jo(jo({},e.options),o)),this.webMap=t,Eo(this,"item"),Eo(this,"connector"),Eo(this,"layer"),Eo(this,"emitter",new r),Eo(this,"_rootDescendantsCount",0),i&&(this.connector=i),s&&this.tree.setParent(s),this.item=n,"root"===this.item.item_type)this._rootDescendantsCount=this._sumUp(this.item.children);else{const e=this.tree.getRoot();e&&(this._rootDescendantsCount=e._rootDescendantsCount)}this.initProperties(),a||this._init(n)}static create(t,r,n,o,i){return Co(this,null,(function*(){const s=new e(t,r,n,o,i,!0);return yield s._init(r),s}))}initItem(e){return"group"===e.item_type||"root"===e.item_type?this.initGroupItem(e):this.initLayerItem(e)}bringToFront(){}fit(){}getLayer(){return this.layer}getLegend(e){return Co(this,null,(function*(){var t;const r=null==(t=this.layer)?void 0:t.id;if(void 0!==r){const t=this.connector;if(t){return[{layerId:r,legend:(yield t.get("render.legend_symbols",jo({params:{id:this.item.resourceId}},e))).map((e=>jo({name:e.display_name,symbol:e.icon},e)))}]}}return[]}))}getItemOptions(e){const t="layer"===e.item_type&&e.layer_transparency,r="number"==typeof t?(100-t)/100:void 0,n=Ao(jo({visibility:!1,name:e.display_name},this.options),{params:{resource:this.item.resourceId,item:this.item}});if(this.options.order){const t=String(this.options.drawOrderEnabled&&"draw_order_position"in e?this._rootDescendantsCount-e.draw_order_position:this.id).padStart(4,"0");n.order=Number((0|this.options.order)+"."+t)}if(this.options.popupOptions&&(n.popupOptions=this.options.popupOptions),"layer"===e.item_type){const{maxZoom:t,minZoom:r}=this._getZoomRange(e);Object.assign(n,Ao(jo({updateWmsParams:e.updateWmsParams},this.options),{url:e.url,maxZoom:t,minZoom:r,minScale:e.layer_min_scale_denom,maxScale:e.layer_max_scale_denom,interactive:e.layer_identifiable}))}return void 0!==r&&(n.opacity=r),n}getChildren(e){return[...e.children].reverse()}_mapScaleToZoomLevel(e){return vo(e)}initGroupItem(e){if(e.children&&e.children.length){const t=this.getChildren(e);for(const e of t){const t=new this.constructor(this.webMap,e,this.options,this.connector,this);this.tree.addChild(t)}}return Promise.resolve()}initLayerItem(t){const r=this.getItemOptions(t),n=e=>{t._layer=e,this.layer=e;this.properties.get("visibility")&&this.properties.set("visibility",!0),void 0!==r.opacity&&this.webMap.setLayerOpacity(e,r.opacity)};let o;if("layer"===t.item_type)o=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){o=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return o?this.webMap.addLayer(o,r).then((e=>{n(e)})):t._layer?Promise.resolve(n(t._layer)):Promise.reject("No layer added")}_getZoomRange(e){const t=this.options.minZoom,r=this.options.maxZoom,n=e.layer_min_scale_denom?this._mapScaleToZoomLevel(e.layer_min_scale_denom):void 0,o=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,i=[t,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max(...i):void 0,maxZoom:s.length?Math.min(...s):void 0}}_init(e){this.initItem(e).then((()=>{this.emitter.emit("init")}))}_sumUp(e,t=0){for(const r of e)"layer"===r.item_type?(t+=1,r.draw_order_position=r.draw_order_position||t):"group"===r.item_type&&(t=this._sumUp(r.children,t));return t}};Eo(Mo,"GetAdapterFromLayerType",{}),Eo(Mo,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return gt(e.item,(e=>"layer_enabled"in e&&e.layer_enabled),(e=>e.children));if("layer"===e.item.item_type)return e.item.layer_enabled}return!1},onSet(e,t,r){r&&"layer"===r.item.item_type&&(r.layer&&(e?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=e)}},{name:"opacity",handler:class extends Ct{getProperty(){const e=this.item.layer;return e&&e&&e.options&&void 0!==e.options.opacity?e.options.opacity:1}update(e,t){if(t=t||{},this.isGroup()){this._value=this._prepareValue(e,t);const r=this.getChildren();for(const n of r){const r=n.properties.property(this.name);r&&(t.propagation?r.set(e,t):r.update(r.get(),t))}}const r=this.item.layer;if(r){const t=this.getParents().reduce(((e,t)=>{const r=t.properties.property(this.name);return e*(r?r.getValue():1)}),1);this.item.webMap.setLayerOpacity(r,this._prepareValue(e*t))}}_prepareValue(e,t){return t&&t.propagation&&this.isGroup()?1:Number(e)}}}]});let ko=Mo;var So=Object.defineProperty,No=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,To=Object.prototype.propertyIsEnumerable,Ro=(e,t,r)=>t in e?So(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bo=(e,t)=>{for(var r in t||(t={}))Fo.call(t,r)&&Ro(e,r,t[r]);if(No)for(var r of No(t))To.call(t,r)&&Ro(e,r,t[r]);return e},$o=(e,t,r)=>Ro(e,"symbol"!=typeof t?t+"":t,r),Do=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function Vo(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:o="first-show-adapter"}){const i=function(e){return Do(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){$o(this,"options",{}),$o(this,"layer",[]),$o(this,"_removed",!1),$o(this,"_creatingInProgress",!1)}addLayer(){return this.layer}removeLayer(){this._removed=!0;for(const t of this.layer)e.removeLayer(t)}destroyed(){return this._removed}showLayer(){return Do(this,null,(function*(){if(this.options.visibility=!0,this.layer.length)for(const t of this.layer)yield e.showLayer(t);else yield this.loadLayer()}))}hideLayer(){return Do(this,null,(function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)}))}loadLayer(){return Do(this,null,(function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const o=yield n(this);if(o){const n=new o(e.mapAdapter.map,Bo({},t)),i=yield n.addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer});r&&r(n),Object.assign(n.options,t),n.layer=i,this._removed&&e.removeLayer(n),this.layer.push(n),this.options.visibility&&(yield e.showLayer(n)),this._creatingInProgress=!1}}return this.layer}))}}}))}({webMap:e,adapterOptions:n,onLayerAdded:e=>{e.options.baselayer=!1,e.id=o+"-"+r.resource_id},createAdapter:()=>oo({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)});return i},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}var qo=Object.defineProperty,Go=Object.defineProperties,Uo=Object.getOwnPropertyDescriptors,zo=Object.getOwnPropertySymbols,Zo=Object.prototype.hasOwnProperty,Wo=Object.prototype.propertyIsEnumerable,Jo=(e,t,r)=>t in e?qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ho=(e,t)=>{for(var r in t||(t={}))Zo.call(t,r)&&Jo(e,r,t[r]);if(zo)for(var r of zo(t))Wo.call(t,r)&&Jo(e,r,t[r]);return e},Qo=(e,t,r)=>Jo(e,"symbol"!=typeof t?t+"":t,r),Ko=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class Xo{constructor(e,t){this.map=e,this.options=t,Qo(this,"layer"),Qo(this,"NgwWebmapItem",ko),Qo(this,"pixelRadius",10),Qo(this,"resourceId"),Qo(this,"webmapClassName","webmap"),Qo(this,"emitter",new r),Qo(this,"_extent"),Qo(this,"response"),Qo(this,"_webmapLayersIds"),Qo(this,"_webmapBaselayersIds",[]),Qo(this,"_lastActiveBaselayer");const n=t.resourceId;if(Array.isArray(n)?(this.resourceId=n[0],this.options.id=n[1]):this.resourceId=n,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}addLayer(e){return Ko(this,null,(function*(){var t,r;this.options=Ho(Ho({},this.options),e),this.layer=yield this._getWebMapLayerItem();const n=null==(r=null==(t=this.response)?void 0:t.webmap)?void 0:r.extent_constrained;return this.options.useExtentConstrained&&this._extent&&n&&this.options.webMap.setView({maxBounds:this._extent}),this.layer}))}removeLayer(){const e=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach((t=>{"layer"in t&&e.removeLayer(t.layer.layer)})),this._webmapBaselayersIds.length){for(const e of this._webmapBaselayersIds)this.options.webMap.removeLayer(e);this._lastActiveBaselayer&&this.options.webMap.showLayer(this._lastActiveBaselayer)}this.options.useExtentConstrained&&this._extent&&this.options.webMap.setView({maxBounds:null}),delete this.layer,delete this.response,delete this._webmapLayersIds}showLayer(){return Ko(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return Ko(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return Ko(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("opacity").set(e)}))}getExtent(){return this.getBounds()}getBounds(){const e=this.response&&this.response.webmap;if(e)return ur(e)}getDependLayers(){return this.layer&&this.layer.tree.getDescendants()||[]}getBookmarksResourceId(){const e=this.response&&this.response.webmap;if(e)return e.bookmark_resource.id}fetchBookmarks(e){const t=this.getBookmarksResourceId(),r=this.options.connector;if(t)return r.getResourceOrFail(t,e).then((n=>{var o;const i=null==(o=n.feature_layer)?void 0:o.fields.find((e=>e.label_field)),s=i&&i.keyname;return cn(Ho({connector:r,resourceId:t,geom:!1,fields:s?[s]:void 0},e)).then((e=>{const n=[];for(const o of e){const e=new bt({item:o,resourceId:t,labelField:s,connector:r});n.push(e)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(e){return Ko(this,null,(function*(){const t=[];let r=this.getDependLayers();r=r.sort(((e,t)=>t.id-e.id));for(const n of r){const r=yield n.getLegend(e);t.push(...r)}return t}))}getIdentificationIds(e){return Ko(this,null,(function*(){const t=[];let r=this._webmapLayersIds;if(r||(r=yield this._getWebMapIds(e),this._webmapLayersIds=r),r&&r.length){let e=this.getDependLayers();e=e.sort(((e,t)=>t.id-e.id)),e.forEach((e=>{const r=e.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type&&r.layer_identifiable){const r=e.properties.property("visibility");r.get()&&!r.isBlocked()&&t.push(n)}}))}return t}))}_getWebMapLayerItem(){return Ko(this,null,(function*(){if(!this.resourceId)return;const e=yield this.getWebMapConfig(this.resourceId);return e&&e.root_item?new Promise((t=>{const r=this.options.connector,n=(null==r?void 0:r.options.auth)?r.getAuthorizationHeaders():void 0,o=r.withCredentials,i=(s=Ho({},this.options),Go(s,Uo({withCredentials:o,headers:n,drawOrderEnabled:e.draw_order_enabled})));var s;const a=new this.NgwWebmapItem(this.options.webMap,e.root_item,i,r);a.emitter.on("init",(()=>{t(a)}))})):void 0}))}getWebMapConfig(e){return Ko(this,null,(function*(){const t=yield this.options.connector.getResource(e);if(t){this.response=t;const e=t[this.webmapClassName];if(this._setupBaselayers(t),e)return this._extent=[e.extent_left,e.extent_bottom,e.extent_right,e.extent_top],this._updateItemsParams(e.root_item,this.options.webMap,t),e}}))}_setupBaselayers(e){var t;const r=this.options.webMap;if(null==(t=this.options.useBasemap)||t)if(e.basemap_webmap&&e.basemap_webmap.basemaps.length){const t=r.getActiveBaseLayer();this._lastActiveBaselayer=t?t.id:void 0,this._setBasemaps(e.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})}_setBasemaps(e){const t=this.options.webMap;let r=!1;for(const n of e.basemaps)Vo({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then((e=>{const o=!r&&n.enabled;return n.enabled&&(r=!0),t.addBaseLayer(e,{id:"webmap-baselayer"+n.resource_id,name:n.display_name,opacity:n.opacity,visibility:o}).then((e=>{e.id&&this._webmapBaselayersIds.push(e.id)}))}))}_updateItemsParams(e,t,r){if(e)if("group"===e.item_type||"root"===e.item_type)e.children&&(e.children=e.children.map((e=>this._updateItemsParams(e,t,r)))),"root"===e.item_type&&(e.display_name=r.resource.display_name);else if("layer"===e.item_type){const r=x(this.options.connector.options.baseUrl+"/api/component/render/image"),n=e.layer_style_id;e.url=r,e.resourceId=n,e.updateWmsParams=e=>mo(e,n);const o=Mn({options:{adapter:e.layer_adapter.toUpperCase(),resource:n},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Ho(Ho({},e),o)}return e}_getWebMapIds(e){return Ko(this,null,(function*(){const t=this.layer;if(t&&"root"===t.item.item_type){const r=t.tree.getDescendants(),n=[];for(const t of r){const r=t.item;if("layer"===r.item_type){const t=this.options.connector.getResource(r.layer_style_id,e).then((e=>{if(e){const t=Number(e.resource.parent.id);return r.parentId=t,t}}));n.push(t)}}return(yield Promise.all(n)).filter((e=>void 0!==e))}}))}}var Yo=Object.defineProperty,ei=Object.getOwnPropertySymbols,ti=Object.prototype.hasOwnProperty,ri=Object.prototype.propertyIsEnumerable,ni=(e,t,r)=>t in e?Yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,oi=(e,t)=>{for(var r in t||(t={}))ti.call(t,r)&&ni(e,r,t[r]);if(ei)for(var r of ei(t))ri.call(t,r)&&ni(e,r,t[r]);return e},ii=(e,t,r)=>ni(e,"symbol"!=typeof t?t+"":t,r);class si{constructor(e){if(this.options=e,ii(this,"url"),ii(this,"connector"),ii(this,"webMap"),this.options.connector)this.url=this.options.connector.options.baseUrl||"",this.connector=this.options.connector;else{if(!this.options.baseUrl)throw new Error("url is not defined");this.url=this.options.baseUrl,this.connector=new Ie({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){to[e]=t}onLoadSync(e){return t=this,r=null,n=function*(){if(this.options.resourceId&&this.url){const t=[this.options.resourceId];if(t.length)for(const r of t){const t={resourceId:r,connector:this.connector,webMap:e};return yield e.addLayer(Xo,oi({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n}getLayerAdapters(){return Promise.resolve([this._getLayerAdapter()])}_getLayerAdapter(){return{name:"WEBMAP",createAdapter:e=>Promise.resolve(this._createAdapter(e))}}_createAdapter(e){return t={webMap:e,connector:this.connector,baseUrl:this.url},class extends Xo{constructor(e,r){super(e,r=po(po({},t),r))}};var t}}var ai=Object.defineProperty,li=Object.getOwnPropertySymbols,ci=Object.prototype.hasOwnProperty,ui=Object.prototype.propertyIsEnumerable,hi=(e,t,r)=>t in e?ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pi=(e,t)=>{for(var r in t||(t={}))ci.call(t,r)&&hi(e,r,t[r]);if(li)for(var r of li(t))ui.call(t,r)&&hi(e,r,t[r]);return e},di=(e,t,r)=>hi(e,"symbol"!=typeof t?t+"":t,r);class fi{constructor(e){di(this,"id"),di(this,"label"),di(this,"layerId"),di(this,"parent"),di(this,"fields"),di(this,"geom"),di(this,"extensions"),di(this,"connector"),di(this,"_item"),di(this,"_geojson"),di(this,"_resource"),di(this,"_extent");const t=e.feature;this.id=t.id,this.geom=t.geom,this.label=t.label,this.parent=t.parent,this.fields=t.fields,this.layerId=t.layerId,this.connector=e.connector}identify(e={}){return this._item?Promise.resolve(this._item):ut(pi({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},e)).then((e=>(this._item=e,this.geom=e.geom,this.extensions=e.extensions,e)))}resource(e){return this._resource?Promise.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId,e).then((e=>(this._resource=e,this._resource.feature_layer)))}getBounds(e){return this._extent?Promise.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0,signal:o}){return r.get("feature_layer.feature.item_extent",{cache:n,signal:o},{id:e,fid:t}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:o}=e.extent;return[o,n,r,t]}}))}(pi({connector:this.connector,featureId:this.id,resourceId:this.layerId},e))}geojson(e){return this._geojson?Promise.resolve(this._geojson):this.identify(e).then((e=>e.toGeojson().then((e=>(this._geojson=e,e)))))}}var yi=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));function mi(e){return yi(this,null,(function*(){return We(yield ut(e))}))}var bi=Object.defineProperty,gi=Object.defineProperties,vi=Object.getOwnPropertyDescriptors,wi=Object.getOwnPropertySymbols,_i=Object.prototype.hasOwnProperty,Oi=Object.prototype.propertyIsEnumerable,Li=(e,t,r)=>t in e?bi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pi=(e,t)=>{for(var r in t||(t={}))_i.call(t,r)&&Li(e,r,t[r]);if(wi)for(var r of wi(t))Oi.call(t,r)&&Li(e,r,t[r]);return e},Ii=(e,t)=>gi(e,vi(t));function xi(e,t=!1){const r=[],n=[];for(const i in e){const e=Number(i);isNaN(e)||r.push(e)}const o=e.resources;o&&r.sort(((e,t)=>o.indexOf(e)-o.indexOf(t)));for(let i=0;i<r.length;i++){const o=r[i],s=e[o];if("features"in s){const e=ji(s.features,Number(o),t);if(e.length&&(n.push(...e),!t))break}}return n}function ji(e,t,r){const n=[];for(const o of e){if(n.push({featureId:o.id,resourceId:t,feature:o}),!r)break}return n}function Ai(e){const{geom:t,signal:r,cache:n,layers:o}=e,i="string"==typeof t?t:function(e){const t=function(e){var t;if(Array.isArray(e))return e;if("Feature"===e.type)return null==(t=e.geometry)?void 0:t.coordinates[0];if("Polygon"===e.type)return e.coordinates[0];return null}(e);if(!t)return null;return`POLYGON((${t.map((([e,t])=>{const[r,n]=_(e,t);return`${r} ${n}`})).join(",")}))`}(t);if(!i)throw new Error("Not valid geometry format to make intersection");return e.connector.post("feature_layer.identify",{data:{geom:i,srs:3857,layers:o},signal:r,cache:n})}function Ei(e,t){return r=this,n=null,o=function*(){var r;const n=yield e.get("pyramid.settings",null,{component:"pyramid"});if(n&&n.company_logo&&n.company_logo.enabled){const i=document.createElement("a");i.style.position="absolute",i.style.bottom="0",i.style.right="0",i.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",i.className="ngw-map-logo",t&&t.cssClass&&(i.className+=" "+t.cssClass);const s=new Image;s.style.maxHeight="100px",s.style.maxWidth="100px",s.src="";try{const t=yield e.get("pyramid.company_logo",{responseType:"blob"}),r=(window.URL||window.webkitURL).createObjectURL(t);s.src=r}catch(o){console.warn(o)}return null!==n.company_logo.link&&""!==n.company_logo.link.trim()&&(i.href=n.company_logo.link,i.target="_blank",-1!==n.company_logo.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),i.appendChild(s),i}},new Promise(((e,t)=>{var i=e=>{try{a(o.next(e))}catch(r){t(r)}},s=e=>{try{a(o.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((o=o.apply(r,n)).next())}));var r,n,o}function Ci(e){return"function"==typeof e}function Mi(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const ki={"!":Mi((function([e]){return!e})),"!=":Mi((function([e,t]){return e!==t})),"<":Mi((function([e,t]){return e<t})),"<=":Mi((function([e,t]){return e<=t})),"==":Mi((function([e,t]){return e===t})),">":Mi((function([e,t]){return e>t})),">=":Mi((function([e,t]){return e>=t})),coalesce:e=>{for(let t=0;t<e.length;t++){const r=e[t]();if(null!=r)return r}return null},all:e=>{for(let t=0;t<e.length;t++){if(!e[t]())return!1}return!0},any:e=>{for(let t=0;t<e.length;t++){if(e[t]())return!0}return!1},case:e=>{if(e.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(e.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(let t=0;t<e.length-1;t+=2){const r=e[t](),n=e[t+1]();if(r)return n}return(0,e[e.length-1])()},match:e=>{const[t,...r]=e,n=t(),o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},Si={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function Ni(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return Fi(e);if("string"==typeof(t=e)&&t in Si)return function(e){return Fi(Si[e])}(e);if(function(e){return"string"==typeof e&&/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/.test(e)}(e))return function(e){const t=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;let r;if(r=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)];if(r=e.match(t))return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])];throw new Error(`The '${e}' Is not valid rgb`)}(e);if(function(e){if("object"==typeof e&&null!==e)return"r"in e&&"g"in e&&"b"in e&&(!("a"in e)||"number"==typeof e.a&&e.a>=0&&e.a<=1);return!1}(e))return function({r:e,g:t,b:r,a:n}){return[e,t,r,...void 0!==n?[n]:[]]}(e);var t,r;throw new Error(`The '${e}' cannot be converted to color`)}function Fi(e){let t;if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)];if(t=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(e))return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),parseInt(t[4]+t[4],16)/255];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];if(t=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(e))return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16),parseInt(t[4],16)/255];throw new Error(`The '${e}' Is not valid hex`)}function Ti(e,t,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(e-t)/(n-t)*(o-r);try{const i=Ni(r),s=Ni(o);return function(e){return`rgb(${e.join(",")})`}(i.map(((r,o)=>Math.ceil(Ti(e,t,r,n,s[o])))))}catch(i){console.log(i)}throw new Error("Unsupported output type for linear interpolation.")}const Ri={step:e=>{const[t,r,...n]=e,o=t();if("number"!=typeof o)return r();for(let i=0;i<n.length-2;i+=2){const e=n[i](),t=n[i+1](),r=n[i+2]();if(o>=e&&o<r)return t}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:([e,t,...r])=>{if(r.length<2)throw new Error("At least two stops are required");if(r.length<2||r.length%2!=0)throw new Error("Invalid stops provided.");const n=t();if("number"!=typeof n)throw new Error("Input must be a number.");const o=e();for(let i=0;i<r.length-2;i+=2){const e=r[i](),t=r[i+1](),s=r[i+2](),a=r[i+3]();if(n>=e&&n<=s&&"linear"===o[0])return Ti(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Bi={get:Mi((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:Mi((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:Mi((function([e,t]){return t[e]})),has:Mi((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:Mi((function([e,t]){if("string"==typeof t)return t.includes(String(e));if(Array.isArray(t))return t.includes(e);throw new Error(`Invalid input type for 'in'. Expected string or array, got ${typeof t}.`)})),"index-of":Mi((function([e,t,r]){if("string"==typeof t)return t.indexOf(String(e),r);if(Array.isArray(t))return t.indexOf(e,r);throw new Error(`Invalid input type for 'index-of'. Expected string or array, got ${typeof t}.`)})),slice:Mi((function(e){const[t,r,n]=e;if("string"==typeof t)return t.slice(r,n);if(Array.isArray(t))return t.slice(r,n);throw new Error(`Invalid input type for 'slice'. Expected string or array, got ${typeof t}.`)}))},$i={"+":Mi((e=>e.reduce(((e,t)=>e+t),0))),"-":Mi((e=>e.reduce(((e,t)=>e-t)))),"*":Mi((e=>e.reduce(((e,t)=>e*t),1))),"/":Mi((e=>e.reduce(((e,t)=>e/t)))),"%":Mi((e=>e[0]%e[1])),"^":Mi((e=>Math.pow(e[0],e[1]))),abs:Mi((e=>Math.abs(e[0]))),acos:Mi((e=>Math.acos(e[0]))),asin:Mi((e=>Math.asin(e[0]))),atan:Mi((e=>Math.atan(e[0]))),ceil:Mi((e=>Math.ceil(e[0]))),cos:Mi((e=>Math.cos(e[0]))),e:()=>Math.E,floor:Mi((e=>Math.floor(e[0]))),ln:Mi((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:Mi((e=>Math.log10(e[0]))),log2:Mi((e=>Math.log2(e[0]))),max:Mi((e=>Math.max(...e))),min:Mi((e=>Math.min(...e))),pi:()=>Math.PI,round:Mi((e=>Math.round(e[0]))),sin:Mi((e=>Math.sin(e[0]))),sqrt:Mi((e=>Math.sqrt(e[0]))),tan:Mi((e=>Math.tan(e[0])))},Di={concat:Mi((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:Mi((e=>String(e[0]).toLowerCase())),upcase:Mi((e=>String(e[0]).toUpperCase()))},Vi=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function qi(e){return(t,r)=>{for(const n of t){const t=Vi(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Gi={array:Mi((e=>{const[t,r,n]=e;let o,i,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(o=t,"number"==typeof r?(i=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(o&&!s.every((e=>typeof e===o)))throw new Error(`Expected all items in array to be of type ${o}`);if(i&&s.length!==i)throw new Error(`Expected array of length ${i}`);return s})),boolean:Mi(qi((e=>"boolean"==typeof e?e:void 0))),literal:Mi((([e])=>e)),number:Mi(qi((e=>"number"==typeof e?e:void 0))),object:Mi(qi((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:Mi(qi((e=>"string"==typeof e?e:void 0))),"to-boolean":Mi(qi(Boolean)),"to-number":Mi(qi(Number)),"to-string":Mi(qi(String)),typeof:Mi((([e])=>function(e){if(null===e)return"null";switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":if(Array.isArray(e)){let t="value";return e.every((e=>"number"==typeof e))?t="number":e.every((e=>"string"==typeof e))?t="string":e.every((e=>"boolean"==typeof e))&&(t="boolean"),`array<${t}, ${e.length}>`}return"object";default:return"undefined"}}(e)))};var Ui=Object.defineProperty,zi=Object.getOwnPropertySymbols,Zi=Object.prototype.hasOwnProperty,Wi=Object.prototype.propertyIsEnumerable,Ji=(e,t,r)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hi=(e,t)=>{for(var r in t||(t={}))Zi.call(t,r)&&Ji(e,r,t[r]);if(zi)for(var r of zi(t))Wi.call(t,r)&&Ji(e,r,t[r]);return e};function Qi(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in Ki&&r.length>0}return!1}const Ki=Hi(Hi(Hi(Hi(Hi(Hi({},$i),Gi),Di),Bi),ki),Ri);function Xi(e,t={}){const[r,...n]=e,o=Ki[r];if(o)return o(n.map((e=>()=>Qi(e)?Xi(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var Yi=Object.defineProperty,es=Object.getOwnPropertySymbols,ts=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable,ns=(e,t,r)=>t in e?Yi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,os=(e,t)=>{for(var r in t||(t={}))ts.call(t,r)&&ns(e,r,t[r]);if(es)for(var r of es(t))rs.call(t,r)&&ns(e,r,t[r]);return e};function is(e){return t=>{const r=t.properties;return!!r&&Xi(e,r)}}const ss=["iconSize","iconAnchor"];var as=Object.defineProperty,ls=Object.getOwnPropertySymbols,cs=Object.prototype.hasOwnProperty,us=Object.prototype.propertyIsEnumerable,hs=(e,t,r)=>t in e?as(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ps=(e,t)=>{for(var r in t||(t={}))cs.call(t,r)&&hs(e,r,t[r]);if(ls)for(var r of ls(t))us.call(t,r)&&hs(e,r,t[r]);return e};function ds(e){let t={};const r=[];for(const n of e)n&&(Array.isArray(n)?r.push(n):t=n);return e=>{const n=r.find((t=>function(e,t){const r=Me({},e.properties);return!!r&&(r.$id=e.id,Fe(r,t))}(e,t[0])));return n?ps(ps({},t),n[1]):t}}function fs({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===ss.indexOf(n)){const o=n,i=e[o];Qi(i)&&(t=!0,r[o]=is(i))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return os(os({},e),n)}}(e);if(r){const n=e=>ms({paint:r(e),defaultPaint:t});return n.paint=ys({paint:e,defaultPaint:t}),n}return ys({paint:e,defaultPaint:t})}function ys({paint:e,defaultPaint:t}){var r;let n=ps({},t);return n=ps(ps({},n),e),n.fill=null==(r=n.fill)||r,n.stroke=void 0!==n.stroke?n.stroke:!n.fill||!(!n.strokeColor&&!n.strokeOpacity),n}function ms({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=ps({},t);if(Ci(e)){const n=n=>{const o=ms({paint:e(n),defaultPaint:t,getPaintFunctions:r});return o.type=e.type,o};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>ms({paint:ds(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const o=function(e,t){if("function"==typeof e.from)return e.from(e.options);if("string"==typeof e.from&&t){const r=t[e.from];if(r)return r(e.options)}}(e,r);o&&(n=ms({paint:o,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=fs({paint:e,defaultPaint:t})}return Ci(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}var bs=Object.defineProperty,gs=(e,t,r)=>((e,t,r)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class vs{constructor(){gs(this,"backspace",8),gs(this,"tab",9),gs(this,"enter",13),gs(this,"shift",16),gs(this,"ctrl",17),gs(this,"alt",18),gs(this,"pause/break",19),gs(this,"caps_lock",20),gs(this,"escape",27),gs(this,"page_up",33),gs(this,"page_down",34),gs(this,"end",35),gs(this,"home",36),gs(this,"left_arrow",37),gs(this,"up_arrow",38),gs(this,"right_arrow",39),gs(this,"down_arrow",40),gs(this,"insert",45),gs(this,"delete",46),gs(this,"left_window_key",91),gs(this,"right_window_key",92),gs(this,"select_key",93),gs(this,"numpad_0",96),gs(this,"numpad_1",97),gs(this,"numpad_2",98),gs(this,"numpad_3",99),gs(this,"numpad_4",100),gs(this,"numpad_5",101),gs(this,"numpad_6",102),gs(this,"numpad_7",103),gs(this,"numpad_8",104),gs(this,"numpad_9",105),gs(this,"multiply",106),gs(this,"add",107),gs(this,"subtract",109),gs(this,"decimal_point",110),gs(this,"divide",111),gs(this,"f1",112),gs(this,"f2",113),gs(this,"f3",114),gs(this,"f4",115),gs(this,"f5",116),gs(this,"f6",117),gs(this,"f7",118),gs(this,"f8",119),gs(this,"f9",120),gs(this,"f10",121),gs(this,"f11",122),gs(this,"f12",123),gs(this,"num_lock",144),gs(this,"scroll_lock",145),gs(this,"semi-colon",186),gs(this,"equal_sign",187),gs(this,",",188),gs(this,"-",189),gs(this,".",190),gs(this,"/",191),gs(this,"`",192),gs(this,"[",219),gs(this,"\\",220),gs(this,"]",221),gs(this,"'",222)}}var ws=Object.defineProperty,_s=(e,t,r)=>((e,t,r)=>t in e?ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);var Os=Object.defineProperty,Ls=(e,t,r)=>((e,t,r)=>t in e?Os(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ps{constructor(e,t){this.webMap=e,Ls(this,"name"),Ls(this,"event"),Ls(this,"value"),t&&(t.value&&this.setValue(t.value),t.name&&(this.name=t.name),t.event&&(this.event="string"==typeof t.event?[t.event]:t.event))}getValue(){return this.value}setValue(e){this.value=e}}var Is=Object.defineProperty,xs=(e,t,r)=>((e,t,r)=>t in e?Is(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class js extends Ps{constructor(){super(...arguments),xs(this,"name","bounds"),xs(this,"event",["moveend"])}getValue(){return this.webMap.getBounds()}setValue(e){this.webMap.setView({bounds:e})}toString(){const e=this.getValue();if(e)return e.slice(0,4).map((e=>e.toFixed(5))).join("_")}parse(e){return e.split("_").map(Number)}}var As=Object.defineProperty,Es=(e,t,r)=>((e,t,r)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Cs extends Ps{constructor(){super(...arguments),Es(this,"name","center"),Es(this,"event",["moveend"])}getValue(){return this.webMap.getCenter()}setValue(e){this.webMap.setCenter(e)}toString(){const e=this.getValue();if(e){const t=e.map((e=>e.toFixed(5)));return t[0]+"_"+t[1]}return""}parse(e){return e.split("_").map(Number)}}var Ms=Object.defineProperty,ks=(e,t,r)=>((e,t,r)=>t in e?Ms(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Ss extends Ps{constructor(){super(...arguments),ks(this,"name","zoom"),ks(this,"event",["zoomend"])}getValue(){const e=this.webMap.getZoom();return void 0!==e?Math.round(e):void 0}setValue(e){this.webMap.setZoom(e)}toString(){return String(this.getValue())}parse(e){return Number(e)}}var Ns=Object.defineProperty,Fs=(e,t,r)=>((e,t,r)=>t in e?Ns(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),Ts=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));let Rs=0;const Bs={minZoom:0,maxZoom:22,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},$s=class e{constructor(t){Fs(this,"options",Bs),Fs(this,"emitter",new r),Fs(this,"keys",e.keys),Fs(this,"mapAdapter"),Fs(this,"runtimeParams",[]),Fs(this,"getPaintFunctions",e.getPaintFunctions),Fs(this,"mapStateItems",[Cs,Ss,js]),Fs(this,"id",Rs++),Fs(this,"mapState",[]),Fs(this,"_initMapState",{}),Fs(this,"_starterKits"),Fs(this,"_extent"),Fs(this,"_eventsStatus",{}),Fs(this,"_coordFromMapClickAbort"),Fs(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=d(Bs||{},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}create(){return Ts(this,null,(function*(){return this.getEventStatus("create")||(yield this._setInitMapState(this.mapStateItems),yield this._setupMap(),this._emitStatusEvent("create",this)),this}))}setRuntimeParams(e){this.runtimeParams.push(e)}destroy(){this._removeEventListeners(),function(e){for(const t in e)delete e[t]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}mapStateWithFunc(e){const t={};return this.mapState.forEach((r=>{t[r.name]=e(r)})),t}getStateAsString(){return this.mapStateWithFunc((e=>e.toString()))}getState(){return this.mapStateWithFunc((e=>e.getValue()))}getRuntimeParams(){const e={};return this.mapState.forEach((t=>{for(const r of this.runtimeParams){const n=r.get(t.name);if(void 0!==n){e[t.name]=t.parse(n);break}}})),e}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 e=document.getElementById(this.options.target);if(e)return e}}}setCursor(e){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(e)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const e=this.getContainer();return e?e.style.cursor:void 0}setCenter(e){return this.mapAdapter.setCenter(e),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const e=this.getBounds();if(e){return{type:"Feature",properties:{},geometry:m(e)}}}setZoom(e){return this.mapAdapter.setZoom(e),this}getZoom(){const e=this.mapAdapter.getZoom();if("number"==typeof e)return e}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const e=this.getZoom();if(void 0!==e){this.setZoom(e-1)}}}setView(e,t){if(Array.isArray(e)){const r=e;this.mapAdapter.setView&&r&&h(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),h(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return function(e){const[t,r,n,o]=e,i=t<n&&r<o;if(!i){console.log("Error: The extent coordinates are not in the correct order."),console.log(`Received extent: [${t}, ${r}, ${n}, ${o}]`);const e=[Math.min(t,n),Math.min(r,o),Math.max(t,n),Math.max(o,r)];console.log(`Expected order: [${e.join(", ")}]`)}const s=t>=-180&&n<=180,a=r>=-90&&o<=90;s&&a||console.log("Warning: The coordinates may not be within valid geographic ranges.")}(e),e.every((e=>h(e)))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,t)),this}getEventStatus(e){const t=this._eventsStatus[e];return null!=t&&t}onLoad(e="create"){return new Promise((t=>{this.getEventStatus(e)?t(this):this.emitter.once(e,(()=>{t(this)}))}))}onMapLoad(e){return new Promise((t=>{var r;const n=()=>{const r=this.mapAdapter;e&&e(r),r&&t(r)},o=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&o?n():this.mapAdapter.emitter.once("create",(()=>{n()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(e){return this.mapAdapter.layerAdapters[e]}locate(e,t){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(e,t);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickAbort&&(this._coordFromMapClickAbort(),this._coordFromMapClickAbort=void 0)}getCoordFromMapClick(){return this._coordFromMapClickAbort?this.getCoordFromMapClick():new Promise(((e,t)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const n=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickAbort=void 0},o=t=>{n(),f(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),this._coordFromMapClickAbort=n}))}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return Ts(this,null,(function*(){}))}_onLoadSync(){return Ts(this,null,(function*(){}))}_setupMap(){return Ts(this,null,(function*(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return yield this.mapAdapter.create(this.options),this._zoomToInitialExtent(),yield this._addLayerProviders(),yield this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}))}_setTileJsonOptions(e){e.center&&(this.options.center=e.center),e.bounds&&(this.options.bounds=e.bounds),h(e.maxzoom)&&(this.options.zoom=e.maxzoom),h(e.minzoom)&&(this.options.zoom=e.minzoom),h(e.maxzoom)&&h(e.minzoom)&&(this.options.zoom=(e.maxzoom+e.minzoom)/2)}_zoomToInitialExtent(){const{center:e,zoom:t,bounds:r}=this.options;this._extent?this.fitBounds(this._extent):e&&t?this.setView(e,t):r&&(this.fitBounds(r),void 0!==t&&this.setZoom(t))}_setInitMapState(e){for(const t of e){const e=new t(this);this.mapState.push(e);for(const t of this.runtimeParams){const r=t.get(e.name);if(void 0!==r){const t=e.parse(r);this._initMapState[e.name]=t,Object.defineProperty(this.options,e.name,{value:t,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(e){let t=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];e&&e.include&&(t=t.filter((t=>e.include.includes(t)))),t.forEach((e=>{this._mapEvents[e]=t=>{if(this.runtimeParams.length){this.mapState.filter((t=>t.event.includes(e))).forEach((e=>{const t=e.toString();this.runtimeParams.forEach((r=>{r.set(e.name,t)}))}))}this._eventsStatus&&this.emitter.emit(e,t)};const t=this._mapEvents[e];t&&this.mapAdapter.emitter.on(e,t)}))}_removeEventListeners(e){let t=Object.entries(this._mapEvents);e&&e.include&&(t=t.filter((t=>e.include.includes(t[0])))),t.forEach((([e,t])=>{t&&this.mapAdapter.emitter.removeListener(e,t)}))}};Fs($s,"keys",new class{constructor(){_s(this,"keyCodeAlias",new vs),_s(this,"keys",{}),_s(this,"_windowOnFocus"),_s(this,"_keysPressed"),_s(this,"_keysReleased"),this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(e){const t=this.keyCodeAlias[e];return!!t&&this.keys[t]}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(e){e.stopPropagation(),this.keys[e.keyCode]||(this.keys[e.keyCode]=!0)}keysReleased(e){e.stopPropagation(),this.keys[e.keyCode]=!1}windowOnFocus(){this.keys={}}}),Fs($s,"getPaintFunctions");let Ds=$s;function Vs(e){const t={};for(let n=0;n<e.length;n++)t[e[n]]=1+(t[e[n]]||0);let r;for(const n in t){t[n]>((void 0!==r?t[r]:0)||0)&&(r=n)}return r}function qs(e){let t;if("FeatureCollection"===e.type){t=Vs(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=Vs(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const Gs={polygon:"path",line:"path",point:"circle"},Us={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function zs(e){if(e.data){const t=Us[qs(e.data)],r=e.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===t||"line"===t?"path":"html"in r||"className"in r?"icon":Gs[t]),e.type=e.type||t}return e}var Zs=Object.defineProperty,Ws=Object.defineProperties,Js=Object.getOwnPropertyDescriptors,Hs=Object.getOwnPropertySymbols,Qs=Object.prototype.hasOwnProperty,Ks=Object.prototype.propertyIsEnumerable,Xs=(e,t,r)=>t in e?Zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ys=(e,t)=>{for(var r in t||(t={}))Qs.call(t,r)&&Xs(e,r,t[r]);if(Hs)for(var r of Hs(t))Ks.call(t,r)&&Xs(e,r,t[r]);return e},ea=(e,t)=>Ws(e,Js(t)),ta=(e,t,r)=>Xs(e,"symbol"!=typeof t?t+"":t,r),ra=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));class na extends Ds{constructor(e){super(e),ta(this,"_layersIdCounter",1),ta(this,"_layersOrderCounter",1),ta(this,"_baselayers",[]),ta(this,"_layers",{}),ta(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return ra(this,null,(function*(){const r=this.getLayer(e),n=r&&(r.getBounds||r.getExtent);if(n){const e=yield n.call(r);e&&this.fitBounds(e,t)}}))}isBaseLayer(e){const t=this.getLayer(e);if(t&&t.id)return-1!==this._baselayers.indexOf(t.id)}getBaseLayers(){const e=[];return this._baselayers.forEach((t=>{const r=this._layers[t];r&&e.push(r)})),e}getBaseLayersIds(){return this._baselayers}getLayer(e){return"string"==typeof e?this._layers[e]:e}getLayerId(e){const t=this.getLayer(e);if(t){if(t.id)return null==t?void 0:t.id;if(t&&t.options)return t.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(((e,t)=>e.order&&t.order?e.order-t.order:0))}findLayer(e){for(const t in this._layers){const r=this._layers[t];if(e(r))return r}}isLayerVisible(e){const t=this.getLayer(e);return!(!t||void 0===t.options.visibility)&&t.options.visibility}addBaseLayer(e,t){return ra(this,null,(function*(){return yield this.addLayer(e,ea(Ys({},t),{baselayer:!0}),void 0)}))}addLayer(e){return ra(this,arguments,(function*(e,t={},r){var n,o;const i=this._layersIdCounter++,s=h(r)?r:void 0!==t.order?t.order:this.reserveOrder();let a;"string"==typeof e?a=this.getLayerAdapter(e):"function"==typeof e?a=e:"then"in e&&(a=yield e);const l=t;this._updateGeoJsonOptions(l);const c=null==(n=(t=Ys({id:String(i),order:s},t)).visibility)||n;if(t.visibility=!1,t.baselayer&&(t.order=0),this.options.onBeforeAddLayer){const e=this.options.onBeforeAddLayer({options:t,adapter:a});e&&(e.options&&(t=e.options),e.adapter&&(a=e.adapter))}if(void 0!==a){const e=new a(this.mapAdapter.map,t);let r;e.options=Ys(Ys({},t),e.options),e.options.baselayer&&(t.baselayer=!0,t.order=0,e.options.order=0),e.options.id&&(r=String(e.options.id),this._layers[r]=e),this._emitLayerEvent("layer:preadd",r||"",e),yield this.onMapLoad(),e.map=this.mapAdapter.map;const n=yield e.addLayer(e.options);if(e.layer=n,e.id=e.options.id||String(i),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(o=e.options.order)?o:s,r&&delete this._layers[r],r=String(e.id),this._layers[r])throw Error(`layer with id '${r}' already exist`);r&&(this._layers[r]=e,l.filter&&this.filterLayer(e,l.filter),t.baselayer&&this._baselayers.push(r),c&&(yield this.showLayer(r)));const u=t.opacity;void 0!==u&&u<=1&&this.setLayerOpacity(e,u);const h=n&&(e.getBounds||e.getExtent);if(t.fit&&h){const t=yield h.call(e);t&&(yield this.fitBounds(t))}return t.onAdded&&t.onAdded(e),this._emitLayerEvent("layer:add",r,e),e}return Promise.reject("No adapter")}))}addLayerFromAsyncAdapter(e,t,r){return ra(this,null,(function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),o=e(),i=yield o;return i?this.addLayer(i,t,n):Promise.reject("No adapter")}))}removeLayers(e){for(const t in this._layers){let r=!0;e&&(r=e(t,this._layers[t])),r&&(this.removeLayer(t),delete this._layers[t])}}getLegend(e){return ra(this,null,(function*(){const t=[];for(const r of this.orderedLayers())r.getLegend&&t.push(r.getLegend(e));return(yield Promise.all(t)).flat()}))}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((e,t)=>!(t&&t.options&&t.options.baselayer)))}removeLayer(e){const t=this.getLayer(e),r=t&&this.getLayerId(t);if(t&&r){if(this.emitter.emit("layer:preremove",t),t.beforeRemove&&t.beforeRemove(),t.removeLayer?t.removeLayer():this.mapAdapter.removeLayer(t.layer),t.options&&t.options.baselayer){const e=this._baselayers.indexOf(r);e&&this._baselayers.splice(e,1)}delete this._layers[r],this.emitter.emit("layer:remove",t)}}addGeoJsonLayer(e={},t){return(e=e||{}).multiselect=void 0!==e.multiselect&&e.multiselect,e.unselectOnSecondClick=void 0===e.unselectOnSecondClick||e.unselectOnSecondClick,t||(e=zs(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",ea(Ys({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",ea(Ys({},t),{url:r}))}showLayer(e,t={}){return this.toggleLayer(e,!0,t)}hideLayer(e,t={}){return this.toggleLayer(e,!1,t)}toggleLayer(e,t,r={}){const n=this.getLayer(e),o=void 0!==t?t:!(n&&n.options.visibility),i=void 0!==r.silent&&r.silent,s=e=>ra(this,null,(function*(){const t=String(e.id),r=o?"layer:show":"layer:hide";if(i||(this._emitLayerEvent(o?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),o&&this.mapAdapter){const t=e.options.baselayer?0:e.options.order;if(e.options.baselayer&&this._baselayers.length){const t=this._baselayers.filter((t=>t!==e.id&&this.isLayerVisible(t)));for(const e of t)yield this.hideLayer(e)}e.showLayer?yield e.showLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.showLayer(e.layer)),void 0!==t&&this.mapAdapter.setLayerOrder(e.layer,t,this._layers)}else e.hideLayer?yield e.hideLayer.call(e,e.layer):void 0!==e.layer&&(yield this.mapAdapter.hideLayer(e.layer));e.options.visibility=o,i||(this._emitLayerEvent(r,t,e),this._emitLayerEvent("layer:toggle",t,e))}));return n?this.onMapLoad().then((()=>s(n))):Promise.resolve()}updateLayer(e,t){const r=this.getLayer(e);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer(t));if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((()=>this.showLayer(r,{silent:!0})))}return Promise.resolve()}setLayerOpacity(e,t){const r=this.getLayer(e);r&&(r.setOpacity?r.setOpacity(t):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,t))}isLayerLabelVisible(e){var t;const r=this.getLayer(e);return r.isLabelVisible?r.isLabelVisible():null==(t=r.options.labelVisibility)||t}showLayerLabel(e){this.toggleLayerLabel(e,!0)}hideLayerLabel(e){this.toggleLayerLabel(e,!1)}toggleLayerLabel(e,t){const r=this.getLayer(e);return t=null!=t?t:!this.isLayerLabelVisible(e),r&&(t?r.showLabel&&(r.options.labelVisibility=!0,r.showLabel()):r.hideLabel&&(r.options.labelVisibility=!1,r.hideLabel()),r.id&&this._emitLayerEvent("layer:label:toggle",r.id,r)),t}selectLayer(e,t){const r=this.getLayer(e);if(r){r&&r.select&&r.select(t);const e=this.getLayerId(r);e&&this._selectedLayers.push(e)}}unSelectLayer(e,t){const r=this.getLayer(e);if(r){const e=r&&r;e.unselect&&e.unselect(t);const n=this.getLayerId(r);if(n){const e=this._selectedLayers.indexOf(n);-1!==e&&this._selectedLayers.splice(e,1)}}}unSelectLayers(){const e=Object.values(this.allLayers());let t;for(t of e)t.unselect&&t.unselect()}filterLayer(e,t){const r=this.getLayer(e);return r.filter?r.filter(t):[]}propertiesFilter(e,t,r){const n=this.getLayer(e);if(n){const e=n;if(e.propertiesFilter)return e.propertiesFilter(t,r);e.filter&&this.filterLayer(e,(e=>!e.feature||!e.feature.properties||Fe(e.feature.properties,t)))}return Promise.resolve()}removeLayerFilter(e){const t=this.getLayer(e);t.removeFilter?t.removeFilter():t.filter&&t.filter((()=>!0))}setLayerData(e,t){const r=this.getLayer(e);if(r){if(r.setData)return r.setData(t);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(t)}return Promise.resolve()}addLayerData(e,t){const r=this.getLayer(e);r.addData&&r.addData(t)}clearLayerData(e,t){const r=this.getLayer(e);r&&r.clearLayer&&r.clearLayer(t)}setLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.setPaint&&r.setPaint(t)}setLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.setSelectedPaint&&r.setSelectedPaint(t)}updateLayerPaint(e,t){const r=this.getLayer(e);t&&r&&r.updatePaint&&r.updatePaint(t)}updateLayerSelectedPaint(e,t){const r=this.getLayer(e);t&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(t)}getAttributions(e){const t=[];for(const r in this._layers){const n=this._layers[r];let o=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(o&&e.onlyBaselayer&&(o=this._baselayers.includes(r)),o){const e=n.options&&n.options.attribution;e&&t.push(e)}}return t}getActiveBaseLayer(){const e=this.getBaseLayers().find((e=>this.isLayerVisible(e)));if(e)return this.getLayer(e)}addTileJsonLayer(e){return this.addLayer("TILE",{url:e.tiles[0],maxZoom:e.maxzoom,minZoom:e.minzoom,subdomains:e.scheme,attribution:e.attribution})}_emitLayerEvent(e,t,r){const n=String(e);if(h(t)&&n.startsWith("layer:")){const e=n.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return ra(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerDoubleClick(e){return ra(this,null,(function*(){return this._emitLayerEvent("layer:dblclick",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return ra(this,null,(function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)}))}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:n,onDoubleClick:o,onLayerClick:i,onMouseOut:s,onMouseOver:a}=e,l=n||i,c=o||i;e.onClick=e=>(l&&l(e),this._onLayerClick(e)),e.onDoubleClick=e=>(c&&c(e),this._onLayerDoubleClick(e)),e.onMouseOut=e=>{const t=e.layer.id;s&&s(e),h(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;a&&a(e),h(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const u=t||r;e.onSelect=e=>(u&&u(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=ms({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=ms({paint:e.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))}}function oa(e,t){const r=document.createElement("div");let n=!1;t.getStatus?n=t.getStatus():t.status&&(n=t.status);const o=t.title||"",i=t.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(e){e instanceof HTMLElement?(r.innerHTML="",r.appendChild(e)):"string"==typeof e&&(r.innerHTML=e)}function l(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(e,t){e.split(" ").forEach((e=>{t?r.classList.add(e):r.classList.remove(e)}))}function u(){t.addClassOn&&c(t.addClassOn,n),t.addClassOff&&c(t.addClassOff,!n)}s(),l(),t.addClass&&c(t.addClass,!0),u();const h=e=>{void 0!==e&&(n=e),l(),s(),u()},p=e=>{if(n=void 0!==e?e:!n,t.onClick){const e=t.onClick(n);Promise.resolve(e).then((()=>h())).catch((()=>n=!n))}else h()},d=e({html:r,onClick:p});return d.onClick=p,d.changeStatus=h,d}var ia=Object.defineProperty,sa=(e,t,r)=>((e,t,r)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r),aa=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const la=class e extends na{constructor(){super(...arguments),sa(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),sa(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return aa(this,null,(function*(){let n;if(t=null!=t?t:"top-left",n="string"==typeof e?this.getControl(e,r):e,n)return new Promise((e=>{this._setControlQueue(t,(()=>aa(this,null,(function*(){const r=yield n,o=this.mapAdapter.addControl(r,t);e(o)}))))}))}))}createControl(e,t){return aa(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return aa(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return aa(this,null,(function*(){return yield this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(e):this.mapAdapter.createButtonControl?oa(this.mapAdapter.createButtonControl,e):void 0}))}removeControl(e){"remove"in e?e.remove():this.mapAdapter.removeControl&&Promise.resolve(e).then((e=>{this.mapAdapter.removeControl(e)}))}getControl(t,r){const n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);{const n=e.controls[t];if(n)return n(this,r)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(e,t){this._loadControlQueue[e].push(t),this._isControlLoading[e]||this._applyControls(e)}_applyControls(e){return aa(this,null,(function*(){if(this._loadControlQueue[e].length){this._isControlLoading[e]=!0;const t=this._loadControlQueue[e][0];yield t(),this._loadControlQueue[e].splice(0,1),this._applyControls(e)}else this._isControlLoading[e]=!1}))}};sa(la,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let ca=la;const ua={};function ha(e){return ua[e]}function pa(e,t){ua[e]=t}var da=Object.getOwnPropertySymbols,fa=Object.prototype.hasOwnProperty,ya=Object.prototype.propertyIsEnumerable,ma=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ba=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())})),ga=(e,t,r)=>(t=e[ma("asyncIterator")])?t.call(e):(e=e[ma("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,o,i)=>(t=n.call(e,t),i=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:i})),o))))),r("next"),r("return"),t);class va extends ca{constructor(e){super(e),this._addControls(),pa(this.id,this)}static get(e){return ha(e)}_addLayerProviders(){return ba(this,null,(function*(){try{for(var e,t,r,n=ga(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.getLayerAdapters){const t=yield e.getLayerAdapters.call(e);if(t)try{for(var o,i,s,a=ga(t);o=!(i=yield a.next()).done;o=!1){const e=i.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(i){s=[i]}finally{try{o&&(i=a.return)&&(yield i.call(a))}finally{if(s)throw s[0]}}}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_onLoadSync(){return ba(this,null,(function*(){try{for(var e,t,r,n=ga(this._starterKits);e=!(t=yield n.next()).done;e=!1){const e=t.value;if(e.onLoadSync)try{yield e.onLoadSync.call(e,this)}catch(o){console.error(o)}}}catch(t){r=[t]}finally{try{e&&(t=n.return)&&(yield t.call(n))}finally{if(r)throw r[0]}}}))}_addControls(){this.options.controls&&this.options.controls.forEach((e=>{let t=e,r={};"string"==typeof e&&this.options.controlsOptions&&this.options.controlsOptions[e]&&(r=this.options.controlsOptions[e],void 0!==r.control&&(t=r.control));const n=r,{position:o}=n,i=((e,t)=>{var r={};for(var n in e)fa.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&da)for(var n of da(e))t.indexOf(n)<0&&ya.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,o||"top-left",i)})),this._emitStatusEvent("controls:create")}}function wa(){return["ZOOM","ATTRIBUTION"]}var _a=Object.defineProperty,Oa=Object.defineProperties,La=Object.getOwnPropertyDescriptors,Pa=Object.getOwnPropertySymbols,Ia=Object.prototype.hasOwnProperty,xa=Object.prototype.propertyIsEnumerable,ja=(e,t,r)=>t in e?_a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Aa=(e,t)=>{for(var r in t||(t={}))Ia.call(t,r)&&ja(e,r,t[r]);if(Pa)for(var r of Pa(t))xa.call(t,r)&&ja(e,r,t[r]);return e},Ea=(e,t)=>Oa(e,La(t));function Ca(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(Ea(Aa({},r),{resource:t}));else if(Array.isArray(t)){const[o,i]=t;e.push(Aa(Ea(Aa({},r),{resource:o,id:i}),n))}else"object"==typeof t&&e.push(Aa(Aa(Aa({},r),t),n))}var Ma=Object.defineProperty,ka=Object.defineProperties,Sa=Object.getOwnPropertyDescriptors,Na=Object.getOwnPropertySymbols,Fa=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,Ra=(e,t,r)=>t in e?Ma(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const Ba={target:"map",baseUrl:"",whitlabel:!1,controls:["ZOOM","ATTRIBUTION"],controlsOptions:{ZOOM:{position:"top-left"},ATTRIBUTION:{position:"bottom-right",customAttribution:['<a href="https://nextgis.com" target="_blank">©NextGIS</a>']}},pixelRadius:10};function $a(e){const t=[new Rr];var r;return e.starterKits&&e.starterKits.forEach((e=>{t.push(e)})),e.connector?e.connector&&(e.baseUrl=e.connector.options.baseUrl):e.connector=new Ie({baseUrl:e.baseUrl||"",auth:e.auth,withCredentials:e.withCredentials}),(e=d(Ba,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new si({connector:e.connector,auth:e.auth})),r=((e,t)=>{for(var r in t||(t={}))Fa.call(t,r)&&Ra(e,r,t[r]);if(Na)for(var r of Na(t))Ta.call(t,r)&&Ra(e,r,t[r]);return e})({},e),e=ka(r,Sa({starterKits:t,create:!1}))}var Da=Object.defineProperty,Va=Object.defineProperties,qa=Object.getOwnPropertyDescriptors,Ga=Object.getOwnPropertySymbols,Ua=Object.getPrototypeOf,za=Object.prototype.hasOwnProperty,Za=Object.prototype.propertyIsEnumerable,Wa=Reflect.get,Ja=(e,t,r)=>t in e?Da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ha=(e,t)=>{for(var r in t||(t={}))za.call(t,r)&&Ja(e,r,t[r]);if(Ga)for(var r of Ga(t))Za.call(t,r)&&Ja(e,r,t[r]);return e},Qa=(e,t)=>Va(e,qa(t)),Ka=(e,t,r)=>Ja(e,"symbol"!=typeof t?t+"":t,r),Xa=(e,t,r)=>Wa(Ua(e),r,t),Ya=(e,t,r)=>new Promise(((n,o)=>{var i=e=>{try{a(r.next(e))}catch(t){o(t)}},s=e=>{try{a(r.throw(e))}catch(t){o(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,s);a((r=r.apply(e,t)).next())}));const el=class e extends va{constructor(e){super($a(e)),Ka(this,"emitter",new r),Ka(this,"connector"),Ka(this,"_ngwLayers",{}),Ka(this,"$$selectFromNgwRaster"),Ka(this,"$$selectFromNgwVector"),Ka(this,"_promises",{select:[],identify:[]}),e.connector&&(this.connector=e.connector),this._createWebMap().then((()=>{const e=this.getContainer();e&&e.classList.add("ngw-map-container"),this.options.whitlabel&&this._whiteLabel()}))}addControl(t,r,n){return Ya(this,null,(function*(){return yield this.onLoad("controls:create"),Xa(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return Ya(this,null,(function*(){yield this.onMapLoad();const{keyname:t,resourceId:r}=e;(t||void 0!==r)&&console.warn(`DEPRECATED WARN: ${"set `resource` options instead of `keyname` or `resourceId`"}`);const n=e.resource;if(!t&&!r&&!n)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(h(this.options.baseUrl))try{h(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},h(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),void 0!==r.withCredentials&&(e.withCredentials=r.withCredentials),oo(e,t,r)}(e,this,this.connector),r=Ha(Ha({visibility:!0},e),e.adapterOptions),n=yield this.addLayer(t,r),o=n&&this.getLayerId(n);if(n&&o&&(this._ngwLayers[o]={layer:n,resourceId:n.resourceId},n.options.name=n.options.name||n.item&&n.item.resource.display_name,n.options.baselayer)){if(this.getActiveBaseLayer())return n}return n}catch(o){const e=I(n)&&"id"in n?n.id:t||r||n;console.error(`Can't add NGW layer ${e}.`,o)}}))}fit(){const{center:e,zoom:t,bounds:r}=this.options;e?(this.setCenter(e),t&&this.setZoom(t)):r&&this.fitBounds(r)}fetchNgwLayerItem(e){return ut(Ha({connector:this.connector},e))}fetchNgwLayerItems(e){return cn(Ha({connector:this.connector},e))}fetchNgwLayerFeature(e){return mi(Ha({connector:this.connector},e))}fetchNgwLayerFeatures(e){return pn(Ha({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=new AbortController,n=r.signal;(null==t?void 0:t.signal)&&t.signal.addEventListener("abort",r.abort),(t=t||{}).signal=n;const o=function(e){const{connector:t,identify:r}=e,n=xi(r);return n&&n.length?ut(Pi(Pi({connector:t},e.requestOptions),n[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",o,r),o}fetchIdentifyGeoJson(e,t=!1){const r=new AbortController,n=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const i in r){const e=Number(i);if(!isNaN(e)){const e=r[i];if("features"in e){const t=e.features.find((e=>e.geom));if(t&&t.geom){const e=t.geom;return Promise.resolve(We(Ii(Pi({},t),{geom:e})))}}}}const o=xi(r);return o&&o.length?mi(Pi(Ii(Pi({},n),{connector:t}),o[0])):Promise.resolve(void 0)}({identify:e,connector:this.connector,multiple:t,requestOptions:{signal:r.signal}});return n&&"then"in n?(this._addPromise("identify",n,r),n):Promise.resolve(n)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}getNgwLayers(){return Ya(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return Ya(this,null,(function*(){for(const t in this._ngwLayers){const r=this._ngwLayers[t];if(r.resourceId===e)return r&&r.layer;if(r.layer.getIdentificationIds){const t=yield r.layer.getIdentificationIds();if(t&&t.some((t=>t===e)))return r.layer}if(r.layer.getDependLayers){const t=r.layer.getDependLayers().find((t=>t.item&&t.item.parentId===e));if(t)return t.layer}}}))}fitLayer(t,r){return Ya(this,null,(function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const o=n&&this._ngwLayers[n];if(o)if(o.layer.getBounds){const e=yield o.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(o.layer.item)e=o.layer.item;else{const t=o.resourceId;e=yield this.connector.getResource(t)}e&&pr({resourceId:e.resource.id,connector:this.connector}).then((e=>{e&&this.fitBounds(e,r)}))}else Xa(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}zoomToLayer(e){return Ya(this,null,(function*(){return this.fitLayer(e)}))}onLoad(e="ngw-map:create"){return super.onLoad(e)}removeLayer(e){const t=this.getLayer(e);if(t){const e=this.getLayerId(t);e&&delete this._ngwLayers[e],super.removeLayer(t)}}enableSelection(){this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=e=>{this._getSelectListenersCount()&&this.selectFromNgwRaster(e)},this.$$selectFromNgwVector=e=>{this._getSelectListenersCount()&&this._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))}disableSelection(){this.$$selectFromNgwRaster&&(this.emitter.removeListener("click",this.$$selectFromNgwRaster),this.$$selectFromNgwRaster=void 0),this.$$selectFromNgwVector&&(this.emitter.removeListener("layer:click",this.$$selectFromNgwVector),this.$$selectFromNgwVector=void 0)}getNgwLayerItem(e){return this.fetchNgwLayerItem(e)}getNgwLayerItems(e){return this.fetchNgwLayerItems(e)}getNgwLayerFeature(e){return this.fetchNgwLayerFeature(e)}getNgwLayerFeatures(e){return this.fetchNgwLayerFeatures(e)}cancelPromise(...e){this.cancelPromises(...e)}cancelPromises(...e){e.length||(e=Object.keys(this._promises)),e.forEach((e=>{const t=this._promises[e];t&&(t.forEach((e=>e[1].abort())),this._promises[e]=[])}))}selectFromNgwRaster(e){return Ya(this,null,(function*(){var t;this._emitStatusEvent("ngw:preselect");const r=[],n=Object.values(this._ngwLayers);n.sort(((e,t)=>e.layer.order&&t.layer.order?t.layer.order-e.layer.order:1));for(const e of n){const n=e.layer,o="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,i=null==(t=n.options.interactive)||t;o&&n.options.selectable&&i&&this.isLayerVisible(n)&&r.push(o.call(n))}const o=Promise.all(r),i=yield o,s=[];for(const e of i)e&&s.push(...e);if(!s.length)return void this._emitStatusEvent("ngw:select",null);const a=this.options.pixelRadius||10,l=this.getCenter();let c=this.getZoom();if(c=void 0!==c?c:20,!l||!c)return void this._emitStatusEvent("ngw:select",null);const u=function(e,t,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*e[1]/Math.PI))/Math.pow(2,t+8))*5e-4}(l,c,a);let h;if(this.options.highlightIdentification){const t=this.options.highlightIdentification,r="number"==typeof t?t:1e3,[n,o]=e.lngLat;h={type:"Polygon",coordinates:[w(n,o,u)]};const i=yield this.addGeoJsonLayer({data:{type:"Feature",geometry:h}});r!==1/0&&setTimeout((()=>{this.removeLayer(i)}),r)}const p=new AbortController,d=function(e,t){f(e);const[r,n]=e.lngLat,{geom:o,radius:i}=t,s=null!=o?o:w(r,n,i);return Ai(Ii(Pi({},t),{geom:s}))}(e,{layers:s,connector:this.connector,radius:u,geom:h,signal:p.signal}).then((t=>{const r=Qa(Ha({},t),{resources:s,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n}));return this._addPromise("select",d,p),d}))}_addPromise(e,t,r){const n=this._promises[e];if(n&&-1===n.findIndex((e=>e[0]===t))){const e=()=>{const e=n.findIndex((e=>e[0]===t));-1!==e&&n.splice(e,1)};t.then(e),t.catch(e),n.push([t,r])}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return Ya(this,null,(function*(){yield this.create(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer();const e=[],t=this._isFitFromResource();if(this.options.webmapId&&Ca(e,this.options.webmapId,{fit:t}),this.options.resources&&Array.isArray(this.options.resources))for(const n of this.options.resources){const r={};t||(r.fit=!1),Ca(e,n,{},r)}for(const n of e)try{yield this.addNgwLayer(n)}catch(r){console.warn(r)}this._emitStatusEvent("ngw-map:create",this),this.enableSelection()}))}_addOsmBaseLayer(){this.addBaseLayer("OSM")}_addQmsBaseLayer(){let e,t;Array.isArray(this.options.qmsId)?(e=this.options.qmsId[0],t=this.options.qmsId[1]):e=Number(this.options.qmsId);const r={qmsId:e};t&&(r.id=t),this.addBaseLayer("QMS",r)}_selectFromNgwVector(e){const t=e.layer;if(!(t.options.selectable&&this.isLayerVisible(t)))return;const r=t.item&&t.item.resource.id,n=e.feature;if(void 0!==r&&n){const e=n.id;if(e){const t={featureCount:1,[r]:{featureCount:1,features:[{id:Number(e),fields:n.properties||{},label:`#${r}`,layerId:Number(r),parent:"",geom:n.geometry}]}};return this._emitStatusEvent("ngw:select",this._prepareToIdentify(Qa(Ha({},t),{resources:[r],sourceType:"vector"}))),t}}}_prepareToIdentify(e){return Qa(Ha({},e),{getIdentifyItems:()=>xi(e,!0).map((e=>new fi({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return Ya(this,null,(function*(){const e=this.getContainer();if(e){const t=yield Ei(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};Ka(el,"getIcon",(function(e={}){var t,r,n,o,i,s;const a=null!=(t=e.shape)?t:"circle",u=null!=(r=e.color)?r:"blue",h=null!=(n=e.strokeColor)?n:"white",p=null!=(o=e.size)?o:c,d=null!=(i=e.rotate)?i:0,f=null!=(s=e.anchor)?s:[p/2,p/2],y=void 0!==e.stroke?Number(e.stroke):.8,m=e.p||l[a]||"circle",b="string"==typeof m?m:m(e),g=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(e.svg||function({width:e,height:t,stroke:r=0,content:n}){const o=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${o} -${o} ${c+r} ${c+r}"\n >${n}</svg>`}({width:p,height:p,stroke:y,content:b}));return g.setAttribute("width",String(p)),g.setAttribute("height",String(p)),g.setAttribute("fill",u),y&&(g.setAttribute("stroke",h),g.setAttribute("stroke-width",String(y))),{type:"icon",iconSize:[p,p],iconAnchor:f,html:(new XMLSerializer).serializeToString(g),rotate:d,svg:g}}));let tl=el;return e.NgwMap=tl,e.WebMap=va,e.WebMapControls=ca,e.WebMapLayers=na,e.WebMapMain=Ds,e.createNgwMap=function(e){return t=this,r=null,n=function*(){return new tl(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n},e.createToggleControl=oa,e.createWebMap=function(e){return t=this,r=null,n=function*(){return new va(e).onLoad()},new Promise(((e,o)=>{var i=e=>{try{a(n.next(e))}catch(t){o(t)}},s=e=>{try{a(n.throw(e))}catch(t){o(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(i,s);a((n=n.apply(t,r)).next())}));var t,r,n},e.detectGeometryType=qs,e.findMostFrequentGeomType=Vs,e.getDefaultControls=wa,e.getWebMap=ha,e.paintTypeAlias=Gs,e.setWebMap=pa,e.typeAlias=Us,e.updateGeoJsonAdapterOptions=zs,e}({});
2
2
  //# sourceMappingURL=ngw-map.global.prod.js.map