@nextgis/ngw-map 1.19.2 → 2.0.0-alpha.0

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(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function s(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(u){a=[6,u],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function a(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}function c(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=a(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var p,l={exports:{}},f="object"==typeof Reflect?Reflect:null,h=f&&"function"==typeof f.apply?f.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};p=f&&"function"==typeof f.ownKeys?f.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var d=Number.isNaN||function(t){return t!=t};function y(){y.init.call(this)}l.exports=y,l.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}E(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&E(t,"error",e,r)}(t,o,{once:!0})}))},y.EventEmitter=y,y.prototype._events=void 0,y.prototype._eventsCount=0,y.prototype._maxListeners=void 0;var v=10;function m(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function g(t){return void 0===t._maxListeners?y.defaultMaxListeners:t._maxListeners}function b(t,e,r,n){var o,i,s,a;if(m(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=g(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function _(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function w(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=_.bind(n);return o.listener=r,n.wrapFn=o,o}function L(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):I(o,o.length)}function O(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function I(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function E(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(y,"defaultMaxListeners",{enumerable:!0,get:function(){return v},set:function(t){if("number"!=typeof t||t<0||d(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");v=t}}),y.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},y.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||d(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},y.prototype.getMaxListeners=function(){return g(this)},y.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)h(a,this,e);else{var u=a.length,c=I(a,u);for(r=0;r<u;++r)h(c[r],this,e)}return!0},y.prototype.on=y.prototype.addListener=function(t,e){return b(this,t,e,!1)},y.prototype.prependListener=function(t,e){return b(this,t,e,!0)},y.prototype.once=function(t,e){return m(e),this.on(t,w(this,t,e)),this},y.prototype.prependOnceListener=function(t,e){return m(e),this.prependListener(t,w(this,t,e)),this},y.prototype.removeListener=function(t,e){var r,n,o,i,s;if(m(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},y.prototype.off=y.prototype.removeListener,y.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},y.prototype.listeners=function(t){return L(this,t,!0)},y.prototype.rawListeners=function(t){return L(this,t,!1)},y.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):O.call(t,e)},y.prototype.listenerCount=O,y.prototype.eventNames=function(){return this._eventsCount>0?p(this._events):[]};var A=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),P=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);return i||r(s.apply(this,n),t)},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),C=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),M=function(t,e,r,n){try{t(r(n))}catch(o){e(o)}},k=0,x=function(){function t(e,r){var n=this;this.id=k++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new A)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new C)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new P(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?M(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?M(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new A),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new A:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=A,t.TimeoutError=C,t.PromiseControl=P,t}();Object.setPrototypeOf(x.prototype,Promise.prototype);var S=x;function N(t,e,r){void 0===r&&(r={});var n=function(t,e){for(void 0===e&&(e=[]);null!==t;t=Object.getPrototypeOf(t))for(var r=Object.getOwnPropertyNames(t),n=0;n<r.length;n++)-1==e.indexOf(r[n])&&e.push(r[n]);return e}(t.prototype),o=void 0===r.replace||r.replace;e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(r){var i=-1!==n.indexOf(r);if(!o&&!i||o){var s=Object.getOwnPropertyDescriptor(e.prototype,r);s&&Object.defineProperty(t.prototype,r,s)}}))}))}function T(t){return null!=t}function F(t){return"string"==typeof t?!!t:T(t)}function B(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=B(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?B(n[t],o[t],r):o[t]}))),s}function R(t){!t.lngLat&&t.latLng&&(t.lngLat=[t.latLng.lng,t.latLng.lat]);return t}var j=6371;function q(t){return{type:"Polygon",coordinates:[V(t)]}}function V(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}var G=Math.PI/180,D=180/Math.PI;function U(t,e){e=e>85.06?85.06:e<-85.06?-85.06:e;var r=20037508.34*t/180,n=Math.log(Math.tan((90+e)*Math.PI/360))/(Math.PI/180);return[r,n=20037508.34*n/180]}function z(t,e,r,n){if(t instanceof Array)return e instanceof Array&&e.sort().join("")===t.sort().join("");if(t instanceof Date)return e instanceof Date&&""+t==""+e;if(t instanceof Function){if(!(e instanceof Function))return!1}else if(t instanceof Object)return e instanceof Object&&(t===r?e===n:Z(t,e));return t===e}function Z(t,e){var r=Object.keys(t).sort(),n=Object.keys(e).sort();if(r.length!==n.length)return!1;if(r.join("")!==n.join(""))return!1;for(var o=0;o<r.length;o++){if(!z(t[r[o]],e[n[o]],t,e))return!1}return!0}function W(t){var e={};return Object.keys(t).forEach((function(r){t[r]instanceof Array||t[r]!==Object(t[r])?void 0!==t[r]&&(e[r]=t[r]):e[r]=W(t[r])})),e}function $(t){return"[object Object]"===Object.prototype.toString.call(t)}function H(t){return t.replace(/([^:]\/)\/+/g,"$1")}function J(t){return"function"==typeof t}function Q(t){return function(e,r){var n=e.map((function(t){return t()}));return t(n,r)}}var K={"!":Q((function(t){return!t[0]})),"!=":Q((function(t){return t[0]!==t[1]})),"<":Q((function(t){return t[0]<t[1]})),"<=":Q((function(t){return t[0]<=t[1]})),"==":Q((function(t){return t[0]===t[1]})),">":Q((function(t){return t[0]>t[1]})),">=":Q((function(t){return t[0]>=t[1]})),coalesce:function(t){for(var e=0;e<t.length;e++){var r=t[e]();if(null!=r)return r}return null},all:function(t){for(var e=0;e<t.length;e++){if(!t[e]())return!1}return!0},any:function(t){for(var e=0;e<t.length;e++){if(t[e]())return!0}return!1},case:function(t){if(t.length<2)throw new Error('The "case" function requires at least a condition and a corresponding output.');if(t.length%2==0)throw new Error("Missing a fallback value or unmatched condition-output pair.");for(var e=0;e<t.length-1;e+=2){var r=t[e](),n=t[e+1]();if(r)return n}return(0,t[t.length-1])()},match:function(t){for(var e=t[0],r=t.slice(1),n=e(),o=r.splice(-1,r.length%2)[0],i=0;i<r.length-1;i+=2){if(r[i]()===n)return r[i+1]()}return o()}},X={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 Y(t){if("string"==typeof(i=t)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(i))return tt(t);if("string"==typeof(o=t)&&o in X)return function(t){return tt(X[t])}(t);if(function(t){return"string"==typeof t&&/^rgb(a?)\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)(?:\s*,\s*([01](?:\.\d+)?))?\s*\)$/.test(t)}(t))return function(t){var e,r=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;if(e=t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10)];if(e=t.match(r))return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10),parseFloat(e[4])];throw new Error("The '".concat(t,"' Is not valid rgb"))}(t);if("object"==typeof(n=t)&&null!==n&&"r"in n&&"g"in n&&"b"in n&&(!("a"in n)||"number"==typeof n.a&&n.a>=0&&n.a<=1))return u([(e=t).r,e.g,e.b],void 0!==(r=e.a)?[r]:[],!0);var e,r,n,o,i;throw new Error("The '".concat(t,"' cannot be converted to color"))}function tt(t){var e;if(e=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(t))return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)];if(e=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/.exec(t))return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16),parseInt(e[4]+e[4],16)/255];if(e=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(t))return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)];if(e=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/.exec(t))return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16),parseInt(e[4],16)/255];throw new Error("The '".concat(t,"' Is not valid hex"))}function et(t,e,r,n,o){if("number"==typeof r&&"number"==typeof o)return r+(t-e)/(n-e)*(o-r);try{var i=Y(r),s=Y(o);return function(t){return"rgb(".concat(t.join(","),")")}(i.map((function(r,o){return Math.ceil(et(t,e,r,n,s[o]))})))}catch(a){console.log(a)}throw new Error("Unsupported output type for linear interpolation.")}var rt={step:function(t){var e=t[0],r=t[1],n=t.slice(2),o=e();if("number"!=typeof o)return r();for(var i=0;i<n.length-2;i+=2){var s=n[i](),a=n[i+1](),u=n[i+2]();if(o>=s&&o<u)return a}return o>=n[n.length-2]()?n[n.length-1]():r()},interpolate:function(t){var e=t[0],r=t[1],n=t.slice(2);if(n.length<2)throw new Error("At least two stops are required");if(n.length<2||n.length%2!=0)throw new Error("Invalid stops provided.");var o=r();if("number"!=typeof o)throw new Error("Input must be a number.");for(var i=e(),s=0;s<n.length-2;s+=2){var a=n[s](),u=n[s+1](),c=n[s+2](),p=n[s+3]();if(o>=a&&o<=c&&"linear"===i[0])return et(o,a,u,c,p)}throw new Error("Invalid interpolation type.")}};var nt={get:Q((function(t,e){var r=t[0],n=t[1]||e;return n&&"object"==typeof n&&r in n?n[r]:null})),length:Q((function(t){var e=t[0];if("string"==typeof e||Array.isArray(e))return e.length})),at:Q((function(t){return t[1][t[0]]})),has:Q((function(t,e){var r=t[1]||e;return!(!r||"object"!=typeof r||!(t[0]in r))})),in:Q((function(t){var e=t[0],r=t[1];if("string"==typeof r)return r.includes(String(e));if(Array.isArray(r))return r.includes(e);throw new Error("Invalid input type for 'in'. Expected string or array, got ".concat(typeof r,"."))})),"index-of":Q((function(t){var e=t[0],r=t[1],n=t[2];if("string"==typeof r)return r.indexOf(String(e),n);if(Array.isArray(r))return r.indexOf(e,n);throw new Error("Invalid input type for 'index-of'. Expected string or array, got ".concat(typeof r,"."))})),slice:Q((function(t){var e=t[0],r=t[1],n=t[2];if("string"==typeof e)return e.slice(r,n);if(Array.isArray(e))return e.slice(r,n);throw new Error("Invalid input type for 'slice'. Expected string or array, got ".concat(typeof e,"."))}))},ot={"+":Q((function(t){return t.reduce((function(t,e){return t+e}),0)})),"-":Q((function(t){return t.reduce((function(t,e){return t-e}))})),"*":Q((function(t){return t.reduce((function(t,e){return t*e}),1)})),"/":Q((function(t){return t.reduce((function(t,e){return t/e}))})),"%":Q((function(t){return t[0]%t[1]})),"^":Q((function(t){return Math.pow(t[0],t[1])})),abs:Q((function(t){return Math.abs(t[0])})),acos:Q((function(t){return Math.acos(t[0])})),asin:Q((function(t){return Math.asin(t[0])})),atan:Q((function(t){return Math.atan(t[0])})),ceil:Q((function(t){return Math.ceil(t[0])})),cos:Q((function(t){return Math.cos(t[0])})),e:function(){return Math.E},floor:Q((function(t){return Math.floor(t[0])})),ln:Q((function(t){return Math.log(t[0])})),ln2:function(){return Math.LN2},log10:Q((function(t){return Math.log10(t[0])})),log2:Q((function(t){return Math.log2(t[0])})),max:Q((function(t){return Math.max.apply(Math,t)})),min:Q((function(t){return Math.min.apply(Math,t)})),pi:function(){return Math.PI},round:Q((function(t){return Math.round(t[0])})),sin:Q((function(t){return Math.sin(t[0])})),sqrt:Q((function(t){return Math.sqrt(t[0])})),tan:Q((function(t){return Math.tan(t[0])}))},it={concat:Q((function(t){return t.reduce((function(t,e){return String(t)+String(e)}),"")})),downcase:Q((function(t){return String(t[0]).toLowerCase()})),upcase:Q((function(t){return String(t[0]).toUpperCase()}))},st=function(t,e,r){try{var n=t(e,r);if(void 0!==n)return n}catch(o){}};function at(t){return function(e,r){for(var n=0,o=e;n<o.length;n++){var i=st(t,o[n],r);if(void 0!==i)return i}throw new Error("Received a mismatched type")}}var ut={array:Q((function(t){var e,r=t[0],n=t[1],o=t[2],i=void 0,s=void 0;if("string"==typeof r&&["string","number","boolean"].includes(r)?(i=r,"number"==typeof n?(s=n,e=o):e=n):Array.isArray(r)&&(e=r),!Array.isArray(e))throw new Error("Expected an array");if(i&&!e.every((function(t){return typeof t===i})))throw new Error("Expected all items in array to be of type ".concat(i));if(s&&e.length!==s)throw new Error("Expected array of length ".concat(s));return e})),boolean:Q(at((function(t){return"boolean"==typeof t?t:void 0}))),literal:Q((function(t){return t[0]})),number:Q(at((function(t){return"number"==typeof t?t:void 0}))),object:Q(at((function(t){return null===t||"object"!=typeof t||Array.isArray(t)?void 0:t}))),string:Q(at((function(t){return"string"==typeof t?t:void 0}))),"to-boolean":Q(at(Boolean)),"to-number":Q(at(Number)),"to-string":Q(at(String)),typeof:Q((function(t){return function(t){if(null===t)return"null";switch(typeof t){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":if(Array.isArray(t)){var e="value";return t.every((function(t){return"number"==typeof t}))?e="number":t.every((function(t){return"string"==typeof t}))?e="string":t.every((function(t){return"boolean"==typeof t}))&&(e="boolean"),"array<".concat(e,", ").concat(t.length,">")}return"object";default:return"undefined"}}(t[0])}))};function ct(t){if(Array.isArray(t)){var e=t[0],r=t.slice(1);return"string"==typeof e&&"literal"!==e&&e in pt&&r.length>0}return!1}var pt=n(n(n(n(n(n({},ot),ut),it),nt),K),rt);function lt(t,e){void 0===e&&(e={});var r=t[0],n=t.slice(1),o=pt[r];if(o)return o(n.map((function(t){return function(){return ct(t)?lt(t,e):t}})),e);throw new Error('Expression "'.concat(r,'" is not supported.'))}function ft(t){return function(e){var r=e.properties;return!!r&&lt(t,r)}}var ht=["iconSize","iconAnchor"];function dt(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o="^".concat((n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var yt={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return dt(t,e)},ilike:function(t,e){return dt(t,e,!0)}};function vt(t){return 3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]}function mt(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(vt(e)){var r=e[0],n=e[1],o=e[2],i=yt[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return mt(t,e)},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function gt(t){for(var e={},r=[],o=0,i=t;o<i.length;o++){var s=i[o];s&&(Array.isArray(s)?r.push(s):e=s)}return function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,mt(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function bt(t){var e=t.paint,r=t.defaultPaint,o=function(t){var e=!1,r={};for(var o in t)if(-1===ht.indexOf(o)){var i=o,s=t[i];ct(s)&&(e=!0,r[i]=ft(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(e);if(o){var i=function(t){return wt({paint:o(t),defaultPaint:r})};return i.paint=_t({paint:e,defaultPaint:r}),i}return _t({paint:e,defaultPaint:r})}function _t(t){var e,r=t.paint,o=n({},t.defaultPaint);return(o=n(n({},o),r)).fill=null===(e=o.fill)||void 0===e||e,o.stroke=void 0!==o.stroke?o.stroke:!o.fill||!(!o.strokeColor&&!o.strokeOpacity),o}function wt(t){var e=t.paint,r=t.defaultPaint,o=t.getPaintFunctions;if(!e)throw new Error("paint is empty");var i=n({},r);if(J(e)){var s=function(t){var n=wt({paint:e(t),defaultPaint:r,getPaintFunctions:o});return n.type=e.type,n};return s.type=e.type,s}if(function(t){return!!Array.isArray(t)}(e))return function(t){return wt({paint:gt(e)(t),defaultPaint:r,getPaintFunctions:o})};if("get-paint"===e.type){var a=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(e,o);a&&(i=wt({paint:a,defaultPaint:r,getPaintFunctions:o}))}else{if("icon"===e.type)return e;i=bt({paint:e,defaultPaint:r})}return J(i)||("color"in i&&(i.strokeColor||(i.strokeColor=i.color),i.fillColor||(i.fillColor=i.color)),"opacity"in i&&(void 0===i.strokeOpacity&&(i.strokeOpacity=i.opacity),void 0===i.fillOpacity&&(i.fillOpacity=i.opacity))),i}var Lt=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},Ot=function(){function t(){this.keyCodeAlias=new Lt,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),It=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),Et=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(It),At=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(It);var Pt=0,Ct={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},Mt=function(){function t(e){this.options=Ct,this.emitter=new l.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[Et,At],this.id=Pt++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=B(Ct||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:q(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){if(Array.isArray(t)){var r=t;this.mapAdapter.setView&&r&&T(e)?this.mapAdapter.setView(r,e):(r&&this.mapAdapter.setCenter(r),T(e)&&this.mapAdapter.setZoom(e))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},t.prototype.fitBounds=function(t,e){return t.every((function(t){return T(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new S((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){i(),R(t),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),T(t.maxzoom)&&(this.options.zoom=t.maxzoom),T(t.minzoom)&&(this.options.zoom=t.minzoom),T(t.maxzoom)&&T(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t,e=(t=this.options).center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend","mousemove","mouseout","mouseover"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new Ot,t}();function kt(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function xt(t){var e;if("FeatureCollection"===t.type)e=kt(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=kt(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var St={polygon:"path",line:"path",point:"circle"},Nt={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function Tt(t){if(t.data){var e=Nt[xt(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":St[e]),t.type=t.type||e}return t}var Ft=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return i(this,void 0,void 0,(function(){var r,n,o;return s(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var o,a;return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var i,u,c,p,l,f,h,d,y,v,m,g;return s(this,(function(s){switch(s.label){case 0:return i=this._layersIdCounter++,u=T(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(c=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(c=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:c=s.sent(),s.label=4;case 4:return this._updateGeoJsonOptions(p=e),e=n({id:String(i),order:u},e),l=null===(o=e.visibility)||void 0===o||o,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(f=this.options.onBeforeAddLayer({options:e,adapter:c}))&&(f.options&&(e=f.options),f.adapter&&(c=f.adapter)),void 0===c?[3,12]:((h=new c(this.mapAdapter.map,e)).options=n(n({},e),h.options),h.options.baselayer&&(e.baselayer=!0,e.order=0,h.options.order=0),d=void 0,h.options.id&&(d=String(h.options.id),this._layers[d]=h),this._emitLayerEvent("layer:preadd",d||"",h),[4,this.onMapLoad()]);case 5:return s.sent(),h.map=this.mapAdapter.map,[4,h.addLayer(h.options)];case 6:if(y=s.sent(),h.layer=y,h.id=h.options.id||String(i),h.options.id=h.id,e.baselayer&&(h.options.order=0),h.order=null!==(a=h.options.order)&&void 0!==a?a:u,d&&delete this._layers[d],d=String(h.id),this._layers[d])throw Error("layer with id '".concat(d,"' already exist"));return d?(this._layers[d]=h,p.filter&&this.filterLayer(h,p.filter),e.baselayer&&this._baselayers.push(d),l?[4,this.showLayer(d)]:[3,8]):[3,8];case 7:s.sent(),s.label=8;case 8:return void 0!==(v=e.opacity)&&v<=1&&this.setLayerOpacity(h,v),m=y&&(h.getBounds||h.getExtent),e.fit&&m?[4,m.call(h)]:[3,11];case 9:return(g=s.sent())?[4,this.fitBounds(g)]:[3,11];case 10:s.sent(),s.label=11;case 11:return e.onAdded&&e.onAdded(h),this._emitLayerEvent("layer:add",d,h),[2,h];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return i(this,void 0,void 0,(function(){var n,o;return s(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.getLegend=function(t){return i(this,void 0,void 0,(function(){var e,r,n,o;return s(this,(function(i){switch(i.label){case 0:for(e=[],r=0,n=this.orderedLayers();r<n.length;r++)(o=n[r]).getLegend&&e.push(o.getLegend(t));return[4,Promise.all(e)];case 1:return[2,i.sent().flat()]}}))}))},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=Tt(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return void 0===e&&(e={}),this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){var r;return"string"==typeof t?r=t:(r=t.url,e=t),this.addLayer("IMAGE",n(n({},e),{url:r}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var o=this.getLayer(t),a=void 0!==e?e:!(o&&o.options.visibility),u=void 0!==r.silent&&r.silent;return o?this.onMapLoad().then((function(){return t=o,i(n,void 0,void 0,(function(){var e,r,n,o,i,c,p,l=this;return s(this,(function(s){switch(s.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];i=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=i,s.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:s.sent(),s.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return s.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:s.sent(),s.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return s.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:s.sent(),s.label=13;case 13:return t.options.visibility=a,u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.isLayerLabelVisible=function(t){var e,r=this.getLayer(t);return r.isLabelVisible?r.isLabelVisible():null===(e=r.options.labelVisibility)||void 0===e||e},e.prototype.showLayerLabel=function(t){this.toggleLayerLabel(t,!0)},e.prototype.hideLayerLabel=function(t){this.toggleLayerLabel(t,!1)},e.prototype.toggleLayerLabel=function(t,e){var r=this.getLayer(t);return e=null!=e?e:!this.isLayerLabelVisible(t),r&&(e?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)),e},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;if(o.propertiesFilter)return o.propertiesFilter(e,r);o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||mt(t.feature.properties,e)}))}return Promise.resolve()},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},e.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},e.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},e.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._emitLayerEvent=function(t,e,r){var n=String(t);if(T(e)&&n.startsWith("layer:")){var o=n.replace("layer:","layer-"+e+":");this.emitter.emit(o,r)}this.emitter.emit(t,r)},e.prototype._onLayerClick=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),T(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),T(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=wt({paint:t.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=wt({paint:t.selectedPaint,defaultPaint:this.options.selectedPaint,getPaintFunctions:this.getPaintFunctions})))},e}(Mt);function Bt(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},f=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},h=t({html:r,onClick:f});return h.onClick=f,h.changeStatus=l,h}var Rt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return i(this,void 0,void 0,(function(){var n,o=this;return s(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){o._setControlQueue(e,(function(){return i(o,void 0,void 0,(function(){var r,o;return s(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,Bt(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(Ft),jt={};function qt(t){return jt[t]}var Vt=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),jt[r.id]=r,r}return r(e,t),e.get=function(t){return qt(t)},e.prototype._addLayerProviders=function(){var t,e,r,n,o,a;return i(this,void 0,void 0,(function(){var i,u,p,l,f,h,d,y,v,m,g,b;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,18,19,24]),i=!0,u=c(this._starterKits),s.label=1;case 1:return[4,u.next()];case 2:return p=s.sent(),(t=p.done)?[3,17]:(i=!1,(l=p.value).getLayerAdapters?[4,l.getLayerAdapters.call(l)]:[3,16]);case 3:if(!(f=s.sent()))return[3,16];s.label=4;case 4:s.trys.push([4,10,11,16]),h=!0,o=void 0,d=c(f),s.label=5;case 5:return[4,d.next()];case 6:return y=s.sent(),(n=y.done)?[3,9]:(h=!1,[4,(v=y.value).createAdapter(this)]);case 7:(m=s.sent())&&(this.mapAdapter.layerAdapters[v.name]=m),s.label=8;case 8:return h=!0,[3,5];case 9:return[3,16];case 10:return g=s.sent(),o={error:g},[3,16];case 11:return s.trys.push([11,,14,15]),h||n||!(a=d.return)?[3,13]:[4,a.call(d)];case 12:s.sent(),s.label=13;case 13:return[3,15];case 14:if(o)throw o.error;return[7];case 15:return[7];case 16:return i=!0,[3,1];case 17:return[3,24];case 18:return b=s.sent(),e={error:b},[3,24];case 19:return s.trys.push([19,,22,23]),i||t||!(r=u.return)?[3,21]:[4,r.call(u)];case 20:s.sent(),s.label=21;case 21:return[3,23];case 22:if(e)throw e.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e,r;return i(this,void 0,void 0,(function(){var n,o,i,a,u,p;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,8,9,14]),n=!0,o=c(this._starterKits),s.label=1;case 1:return[4,o.next()];case 2:if(i=s.sent(),t=i.done)return[3,7];if(n=!1,!(a=i.value).onLoadSync)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,a.onLoadSync.call(a,this)];case 4:return s.sent(),[3,6];case 5:return u=s.sent(),console.error(u),[3,6];case 6:return n=!0,[3,1];case 7:return[3,14];case 8:return p=s.sent(),e={error:p},[3,14];case 9:return s.trys.push([9,,12,13]),n||t||!(r=o.return)?[3,11]:[4,r.call(o)];case 10:s.sent(),s.label=11;case 11:return[3,13];case 12:if(e)throw e.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var i=n.position,s=o(n,["position"]);t.addControl(r,i||"top-left",s)})),this._emitStatusEvent("controls:create")},e}(Rt);function Gt(){return["ZOOM","ATTRIBUTION"]}var Dt=function(){function t(e){var r;void 0===e&&(e={}),this.cache=[];var n=null!==(r=e.namespace)&&void 0!==r?r:"default";return t.instance[n]?t.instance[n]:(t.instance[n]=this,this)}return t.prototype.clean=function(){this.cache.length=0},t.prototype.all=function(){return this.cache},t.prototype.addFull=function(t,e,r){return this.add(t,e,r,!0)},t.prototype.add=function(t,e,r,n){var o=this,i=this._find(t,r);if(i)return i.value;var s=void 0;s=e instanceof Function?e():e;var a=r&&JSON.parse(JSON.stringify(W(r))),u={key:t,value:s,props:a,options:a};return n&&!F(s)?s:(this.cache.push(u),s instanceof Promise?(s.catch((function(e){throw o.delete(t,r),e})),n&&s.then((function(e){return F(e)||o.delete(t,r),e})),s):s)},t.prototype.match=function(t,e){var r=this._find(t,e);if(r)return r.value},t.prototype.matchAll=function(t,e){var r=this;return t?this.cache.filter((function(n){return r._filter(n,t,e)})).map((function(t){return t.value})):this.cache.map((function(t){return t.value}))},t.prototype.delete=function(t,e){var r=this,n=[];"string"==typeof t?n=this.cache.filter((function(n){return r._filter(n,t,e)})):n.push(t);for(var o=0,i=n;o<i.length;o++){var s=this.cache.indexOf(i[o]);this.cache.splice(s,1)}},t.prototype._find=function(t,e){var r=this;return this.cache.find((function(n){return r._filter(n,t,e)}))},t.prototype._filter=function(t,e,r){return t.key===e&&(!r||Z(t.props||t.options||{},W(r)))},t.instance={},t}(),Ut=Dt,zt=function(t){function e(r){var n=t.call(this)||this;return n.name="NgwError",Object.assign(n,r),Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(Error),Zt=function(t){function e(r){var n=t.call(this,r)||this;return n.name="ResourceNotFoundError",n.exception="nextgisweb.resource.exception.ResourceNotFound",Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(zt);function Wt(t){return"[object Object]"===Object.prototype.toString.call(t)}var $t=["description"];function Ht(t,e){void 0===e&&(e=""),e=e?e+"__":"";for(var r={},n=0,o=Object.entries(t);n<o.length;n++){var i=o[n],s=i[0],a=i[1];if(-1===$t.indexOf(s))if(Wt(a))if("owner_user"===s){var u=Ht(a,s);Object.assign(r,u)}else"parent"===s&&"id"in a&&(r.parent_id=a.id);else T(a)&&(r[e+s]=a)}return r}var Jt=function(){function t(t){this.connector=t,this.cache=new Ut}return t.prototype.getOne=function(t,e){var r=this,o=new Ut,i={},s=n(n({},e),{cache:!1});"string"==typeof t?i.keyname=t:"number"==typeof t?i.id=t:Wt(t)&&(void 0!==t.id?i.id=t.id:t.keyname&&(i.keyname=t.keyname));return o.addFull("resource",(function(){return"string"==typeof t?r._fetchResourceBy({keyname:t},s):"number"==typeof t?r._fetchResourceById(t,s):Wt(t)?r._fetchResourceBy(t,s):S.resolve(void 0)}),i)},t.prototype.getOneOrFail=function(t,e){return this.getOne(t,e).then((function(t){if(t)return t;throw new Zt}))},t.prototype.getId=function(t,e){return"number"==typeof t?S.resolve(t):"string"==typeof t||Wt(t)?this.getOne(t,e).then((function(t){if(t)return t.resource.id})):S.resolve(void 0)},t.prototype.getIdOrFail=function(t,e){return this.getId(t,e).then((function(t){if(void 0===t)throw new Error;return t}))},t.prototype.getMany=function(t,e){var r=this;return this._resourceCacheFilter(t).then((function(o){if(!o.length){var i={};return t.keyname?i.keyname=t.keyname:Object.assign(i,Ht(t)),r.connector.get("resource.search",e,n({serialization:"full"},i)).then((function(t){if(t)for(var e=0,n=t;e<n.length;e++){var o=n[e];r.cache.add("resource.item",S.resolve(o),{id:o.resource.id})}return t}))}return o}))},t.prototype.getParent=function(t,e){var r=this;return this.getOne(t,e).then((function(t){return t?r.getOne(t.resource.parent.id,e):S.resolve(void 0)}))},t.prototype.getChildrenOf=function(t,e){var r=this;return this.getIdOrFail(t).then((function(t){return r._getChildrenOf(t,e)}))},t.prototype.update=function(t,e){var r=this;return this.getId(t).then((function(t){if(void 0!==t)return r.connector.put("resource.item",{data:e},{id:t})}))},t.prototype.delete=function(t){var e=this;return this.getId(t).then((function(t){if(void 0!==t)return e.connector.delete("resource.item",null,{id:t}).then((function(){e._cleanResourceItemCache(t)}))}))},t.prototype._getChildrenOf=function(t,e,r){var o=this;return void 0===r&&(r=[]),this.connector.get("resource.collection",n({cache:!0},e),{parent:t}).then((function(t){for(var n=[],i=0,s=t;i<s.length;i++){var a=s[i];o.cache.add("resource.item",S.resolve(a),{id:a.resource.id}),r.push(a),(null==e?void 0:e.recursive)&&a.resource.children&&n.push(o._getChildrenOf(a.resource.id,e,r))}return n.length?S.all(n).then((function(){return r})):r}))},t.prototype._cleanResourceItemCache=function(t){return i(this,void 0,void 0,(function(){var e,r,n,o,i,a,u,c;return s(this,(function(s){switch(s.label){case 0:e=this.cache.all(),r=[],n=0,o=e,s.label=1;case 1:return n<o.length?(a=(i=o[n]).options&&i.options.id,["resource.item","resource"].includes(i.key)&&void 0!==a?"number"!=typeof a?[3,2]:(a===t&&r.push(i),[3,4]):[3,4]):[3,5];case 2:return[4,this.getId(a)];case 3:s.sent()===t&&r.push(i),s.label=4;case 4:return n++,[3,1];case 5:for(u=0,c=r;u<c.length;u++)this.cache.delete(c[u]);return[2]}}))}))},t.prototype._fetchResourceById=function(t,e){var r=this;return this.cache.add("resource.item",(function(){return r.connector.get("resource.item",e,{id:t})}),{id:t}).catch((function(t){if(!(t instanceof Zt))throw t}))},t.prototype._fetchResourceBy=function(t,e){return this.getMany(t,e).then((function(t){return t[0]}))},t.prototype._resourceCacheFilter=function(t){return S.all(this.cache.matchAll("resource.item")).then((function(e){return e.filter((function(e){if(e)return t.keyname&&e.resource.keyname?t.keyname===e.resource.keyname:T(t.id)&&T(e.resource.id)?t.id===e.resource.id:Z(t,e.resource)})),[]}))},t}(),Qt=[];function Kt(t){Qt.push(t)}var Xt=function(t){function e(r){var n=t.call(this,r)||this;return n.name="InsufficientPermissionsError",n.exception="nextgisweb.core.exception.InsufficientPermissions",Object.setPrototypeOf(n,e.prototype),n}return r(e,t),e}(zt),Yt=/\{ *([\w_-]+) *\}/g;function te(t,e){return t.replace(Yt,(function(t,r){var n=e[r];if(void 0===n)throw new Error("No value provided for letiable "+t);return"function"==typeof n&&(n=n(e)),n}))}var ee,re=function(t){function e(r){var n=t.call(this)||this;return n.name="NetworkError",Object.setPrototypeOf(n,e.prototype),n.message="Unable to request ".concat(r,".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin),n}return r(e,t),e}(Error);ee=function(t,e,r,n,o){void 0===r&&(r={}),r.method=r.method||"GET";var i=new XMLHttpRequest;i.open(r.method||"GET",t,!0),"blob"===r.responseType&&(i.responseType=r.responseType);var s=function(){try{return JSON.parse(i.responseText)}catch(t){return i.responseText}};i.onload=function(){-1!==[401,403,404,422,500].indexOf(i.status)&&n(new zt(s())),function(t){void 0===t&&(t=!1);var o=t?n:e;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})}()},i.onerror=function(e){n(0===i.status?new re(t):e)},i.upload.onprogress=function(t){t.lengthComputable&&(r.onProgress&&r.onProgress(t.loaded/t.total*100,t))};var a,u=r.headers;if(u)for(var c in u){var p=u[c];"string"==typeof p&&i.setRequestHeader(c,p)}if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if((a=new FormData).append("file",r.file),r.data)for(var l in r.data)a.append(l,a[l])}else a=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((function(){i.abort()})),i.send(a)};var ne=0,oe=function(){function t(t){this.options=t,this.id=ne++,this.emitter=new l.exports.EventEmitter,this.routeStr="/api/component/pyramid/route",this.activeRequests=[];var e=function(t){return Qt.find((function(e){if(e.options.baseUrl===t.baseUrl){if(!t.auth)return!0;if(e.options.auth)return Z(e.options.auth,t.auth)}}))}(t);if(e)return e;this.options.route&&(this.routeStr=this.options.route),this.options.requestTransform&&(this.requestTransform=this.options.requestTransform),this.resources=new Jt(this),Kt(this)}return t.create=function(t){return new this(t)},t.prototype.setRequestTransform=function(t){this.requestTransform=t},t.prototype.setNgw=function(t){this.logout(),this.options.baseUrl=t,Kt(this)},t.prototype.connect=function(){var t=this,e=new Ut,r=this.options.auth;return e.add("route",(function(){return new S((function(e,n){var o=function(){return t.makeQuery(t.routeStr,{},{}).then((function(t){e(t)})).catch((function(t){n(t)}))};if(r){var i=r.login,s=r.password;if(i&&s)return t._login({login:i,password:s}).then((function(){return o()})).catch((function(t){return n(t)}))}return o()}))}),{id:this.id,auth:r,baseUrl:this.options.baseUrl})},t.prototype.login=function(t,e){return this.logout(),Kt(this),this._login(t,e)},t.prototype.logout=function(){var t;this.abort(),-1!==(t=Qt.indexOf(this))&&Qt.splice(t,1),this.options.auth=void 0,this.user=void 0,this.emitter.emit("logout"),this.resources.cache.clean()},t.prototype.getUserInfo=function(t,e){if(this.user&&this.user.id)return S.resolve(this.user);t&&(this.options.auth=t);var r=n({headers:this.getAuthorizationHeaders(t)},e);return this.makeQuery("/api/component/auth/current_user",{},r)},t.prototype.getAuthorizationHeaders=function(t){var e=this.makeClientId(t);if(e)return{Authorization:"Basic "+e}},t.prototype.makeClientId=function(t){if(t=t||this.options.auth){var e=t.password,r=unescape(encodeURIComponent("".concat(t.login,":").concat(e)));return window.btoa(r)}},t.prototype.abort=function(){for(var t=0,e=this.activeRequests;t<e.length;t++){e[t].cancel()}this.activeRequests=[]},t.prototype.getActiveApiRequests=function(){return u([],this.activeRequests,!0)},t.prototype.apiRequest=function(t,e,r){var o,i,s=this;void 0===e&&(e={}),void 0===r&&(r={});var a=r.method,c=r.headers,p=r.withCredentials,l=r.responseType,f=W(e=null!==(o=r.params)&&void 0!==o?o:e),h=function(){return function(t){var e=t.params;return new S((function(r,n){t.connector.connect().then((function(o){var i=o&&o[t.name];if(i){var s=(i=u([],i,!0)).shift();if(i.length){for(var a={},c=0;c<i.length;c++){var p=i[c];if(a[c]="{"+p+"}",void 0===e[p])throw new Error("`"+p+"` url api argument is not specified")}s&&(s=te(s,a))}if(e){var l=[],f=e.paramList;for(var h in Array.isArray(f)&&(delete e.paramList,f.forEach((function(t){l.push("".concat(t[0],"=").concat(t[1]))}))),e)-1===i.indexOf(h)&&l.push("".concat(h,"=").concat(e[h]));l.length&&(s=s+"?"+l.join("&"))}s?r(t.connector.makeQuery(s,e,t.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((function(t){n(t)}))}))}({name:t,params:f,requestOptions:r,connector:s})};return r.cache&&"GET"===a?(new Ut).add(t,h,n({params:f},W({headers:c,withCredentials:p,responseType:l,baseUrl:this.options.baseUrl,userId:null===(i=this.user)||void 0===i?void 0:i.id}))):h()},t.prototype.post=function(t,e,r){return(e=e||{}).method="POST",this.apiRequest(t,r,e)},t.prototype.get=function(t,e,r){return(e=e||{}).method="GET",this.apiRequest(t,r,e)},t.prototype.patch=function(t,e,r){return(e=e||{}).method="PATCH",this.apiRequest(t,r,e)},t.prototype.put=function(t,e,r){return(e=e||{}).method="PUT",this.apiRequest(t,r,e)},t.prototype.delete=function(t,e,r){return(e=e||{}).method="DELETE",this.apiRequest(t,r,e)},t.prototype.makeQuery=function(t,e,r){if(void 0===r&&(r={}),t=(this.options.baseUrl?this.options.baseUrl:"")+t)return e&&(t=te(t,e)),t=encodeURI(H(t)),this._loadData(t,r);throw new Error("Empty `url` not allowed")},t.prototype.getResource=function(t,e){return this.resources.getOne(t,e)},t.prototype.getResourceOrFail=function(t,e){return this.resources.getOneOrFail(t,e)},t.prototype.getResourceBy=function(t){return this.resources.getOne(t)},t.prototype.getResourceByKeyname=function(t){return this.resources.getOne(t)},t.prototype.getResourceById=function(t){return this.resources.getOne(t)},t.prototype.getResourceId=function(t,e){return this.resources.getId(t,e)},t.prototype.getResourceIdOrFail=function(t,e){return this.resources.getIdOrFail(t,e)},t.prototype.getResourcesBy=function(t,e){return this.resources.getMany(t,e)},t.prototype.getResourceParent=function(t,e){return this.resources.getParent(t,e)},t.prototype.getResourceChildren=function(t,e){return this.resources.getChildrenOf(t,e)},t.prototype.updateResource=function(t,e){return this.resources.update(t,e)},t.prototype.deleteResource=function(t){return this.resources.delete(t)},t.prototype._loadData=function(t,e){var r=this;e.responseType=e.responseType||"json";var o=new S((function(o,i,s){if(r.user&&((e=e||{}).headers=n(n({},r.getAuthorizationHeaders()),e.headers)),r.requestTransform){var a=r.requestTransform(t,e);t=a[0],e=a[1]}ee(t,o,e,i,s)})).then((function(t){return r._cleanActiveRequests(o),t})).catch((function(t){if(r._cleanActiveRequests(o),t instanceof S.CancelError);else{var e=r._handleHttpError(t);if(e)throw e}}));return e.signal&&"function"==typeof e.signal.addEventListener&&e.signal.addEventListener("abort",(function(){o.cancel(),r._cleanActiveRequests(o)})),this.activeRequests.push(o),o},t.prototype._login=function(t,e){var r=this;return this.getUserInfo(t,e).then((function(t){return r.user=t,r.emitter.emit("login",t),t})).catch((function(t){throw r.emitter.emit("login:error",t),t}))},t.prototype._cleanActiveRequests=function(t){var e=this.activeRequests.indexOf(t);-1!==e&&this.activeRequests.splice(e,1)},t.prototype._handleHttpError=function(t){if(t&&t instanceof zt){if("nextgisweb.resource.exception.ResourceNotFound"===t.exception)throw new Zt(t);if("nextgisweb.core.exception.InsufficientPermissions"===t.exception)throw new Xt(t)}return t},t.errors={NgwError:zt,ResourceNotFoundError:Zt},t}(),ie=oe,se=function(){function t(t){this.options=t,this.resourceId=t.resourceId;var e=t.item;this.item=e,this.name=t.labelField&&e.fields?e.fields[t.labelField]:String(e.id)}return t.prototype.extent=function(){var t=this;return this._extent?S.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",null,{id:this.resourceId,fid:this.item.id}).then((function(e){var r=e.extent,n=[r.minLon,r.minLat,r.maxLon,r.maxLat];return t._extent=n,n}))},t.prototype.geoJson=function(){var t=this;return this.item.geom?S.resolve(Ne(this.item)):cr({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null}).then((function(e){return t.item.geom=e.geom,Ne(t.item)}))},t}();function ae(t,e,r,n){return!!pe(t,e,r,le,n)}function ue(t,e,r,n){return pe(t,e,r,fe,n)}function ce(t,e){void 0===e&&(e="children");var r=[],n=("function"==typeof e?e:function(t){return t[e]})(t);return n&&(Array.isArray(n)?r=n:r.push(n)),n?r:void 0}function pe(t,e,r,n,o){void 0===e&&(e=function(t){return!!t}),void 0===r&&(r="children");var i="function"==typeof e?e:function(t){return mt(t,e)};return n(t,o?function(t){return i(o(t))}:i,r)}function le(t,e,r,n){void 0===e&&(e=function(t){return!!t});var o=[];if(Array.isArray(t))o=t;else{if(e(t))return t;var i=ce(t,r);i&&(o=i)}for(var s=0;s<o.length;s++)if(o[s]){var a=le(o[s],e,r);if(a)return a}}function fe(t,e,r,n){void 0===e&&(e=function(t){return!!t}),void 0===n&&(n=[]);var o=[];if(Array.isArray(t))o=t;else{e(t)&&n.push(t);var i=ce(t,r);i&&(o=i)}for(var s=0;s<o.length;s++)o[s]&&fe(o[s],e,r,n);return n}function he(t,e,r,n){void 0===e&&(e=function(t){return!!t});var o=[];if(Array.isArray(t))o=t;else{if(!e(t))return!1;var i=ce(t,r);i&&(o=i)}for(var s=0;s<o.length;s++){if(o[s])if(!he(o[s],e,r))return!1}return!0}var de=function(){function t(t){this._children=[],this.item=t}return t.prototype.setParent=function(t){this._parent=t},t.prototype.addChild=function(t){this._children.push(t)},t.prototype.getParent=function(){return this._parent},t.prototype.getParents=function(t){var e=this.getParent();return e?ue(e,t,(function(t){return t.tree.getParent()})):[]},t.prototype.getRoot=function(){for(var t=this.getParent(),e=t;t;)(t=t.tree.getParent())&&(e=t);return e},t.prototype.find=function(t){return pe(this._children,t,(function(t){return t.tree.getChildren()}),le,e);var e},t.prototype.every=function(t){return!!pe(this._children,t,(function(t){return t.tree.getChildren()}),he,e);var e},t.prototype.some=function(t){return ae(this._children,t,(function(t){return t.tree.getChildren()}))},t.prototype.all=function(t){return this.getDescendants(t)},t.prototype.getDescendants=function(t){return ue(this._children,t,(function(t){return t.tree.getChildren()}))},t.prototype.getChildren=function(){return u([],this._children,!0)},t}(),ye=function(){function t(t,e,r){this.emitter=new l.exports.EventEmitter,this._blocked=!1,this.item=e,this.options=Object.assign({},r),this.name=t,this._value=this.getProperty()}return t.prototype.getProperty=function(){return"function"==typeof this.options.getProperty?this.options.getProperty.call(this,this.item):this.options.value},t.prototype.getParents=function(){return this.item.tree.getParents()||[]},t.prototype.getParent=function(){return this.item.tree.getParent()},t.prototype.getChildren=function(){return this.item.tree.getChildren()},t.prototype.isGroup=function(){return this.item.tree.getDescendants().length},t.prototype.isBlocked=function(){if(void 0!==this._blocked)return this._blocked;var t=this.item.tree.getParents();return this._blocked=this._calculateBlockedStatus(t),this._blocked},t.prototype.set=function(t,e){this._value=this._prepareValue(t),this.update(this._value,e),this._fireChangeEvent(this._value,e)},t.prototype.get=function(){return this.getValue()},t.prototype.update=function(t,e){this._callOnSet(t,e)},t.prototype.getContainer=function(){return this._container},t.prototype.destroy=function(){if(this._container){var t=this._container.parentNode;t&&t.removeChild(this._container)}this._removeEventsListener&&this._removeEventsListener()},t.prototype.getValue=function(){return void 0!==this._value?this._value:this.getProperty()},t.prototype._prepareValue=function(t){return t},t.prototype._callOnSet=function(t,e){this.options.onSet&&this.options.onSet.call(this,t,e,this.item)},t.prototype._fireChangeEvent=function(t,e){var r=this;this.emitter&&(t=void 0!==t?t:this.getValue(),this.emitter.emit("change",{value:t,options:e}),this.item.tree.getParents().forEach((function(n){var o=n.properties&&n.properties.property(r.name);o&&o.emitter.emit("change-tree",{value:t,options:e,item:r.item})})))},t.prototype._calculateBlockedStatus=function(t){var e=this;return t.some((function(t){var r,n=null===(r=t.properties)||void 0===r?void 0:r.property(e.name);return!!n&&!n.get()}))},t}(),ve=function(t){function e(r,o,i){var s=t.call(this,r,o,n(n({},e.options),i))||this;return s.set(s.get()),s}return r(e,t),e.prototype.update=function(t,e){if(t){if(e&&e.bubble||this.options.bubble){this.unBlock(e);var r=this.getParent(),n=r&&r.properties&&r.properties.property(this.name);n&&n.set(t,Object.assign({},e,{bubble:!0,propagation:!1}))}this.isBlocked()||this._turnOn(e)}else this._turnOff(e);(e&&e.propagation||this.options.propagation)&&this._propagation(t,e)},e.prototype.getHierarchyValue=function(){var t=this;return this.get()&&this.getParents().every((function(e){var r=e.properties&&e.properties.get(t.name);return r&&r.get()}))},e.prototype.block=function(t){this._blocked=!0,this._block(t)},e.prototype.unBlock=function(t){this._blocked=!1,this.getValue()&&this._unBlock(t)},e.prototype.blockChild=function(t){var e=this;this.item.tree.getDescendants().forEach((function(r){return e._blockChild(r,t)}))},e.prototype.unblockChild=function(t){var e=this;this.item.tree.getChildren().forEach((function(r){return e._unBlockChild(r,t)}))},e.prototype._prepareValue=function(t){return t},e.prototype._turnOff=function(t){this.options.turnOff&&this.options.turnOff.call(this,t),this._callOnSet(!1,t),this.options.hierarchy&&this.isGroup()&&this.blockChild(t)},e.prototype._turnOn=function(t){this.options.turnOn&&this.options.turnOn.call(this,t),this._callOnSet(!0,t),this.options.hierarchy&&this.isGroup()&&this.unblockChild(t)},e.prototype._block=function(t){this._turnOff(t)},e.prototype._unBlock=function(t){this._turnOn(t)},e.prototype._blockChild=function(t,e){var r=t.properties&&t.properties.property(this.name);r&&r.block&&r.block(e)},e.prototype._unBlockChild=function(t,e){var r=t.properties&&t.properties.property(this.name);r&&r.unBlock&&r.unBlock(e)},e.prototype._propagation=function(t,e){if(this.isGroup())for(var r=this.item.tree.getChildren(),o=0;o<r.length;o++){var i=r[o],s=i.properties&&i.properties.property(this.name);s&&s.set(t,n(n({},e),{propagation:!0,bubble:!1}))}},e.options={hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"},e}(ye),me=function(){function t(t,e){this.item=t,this.options={},this._properties={},this._propertiesList=[],e&&e.forEach(this._setPropertyHandler.bind(this))}return t.prototype.add=function(t){this._setPropertyHandler(t)},t.prototype.update=function(){this.list().forEach((function(t){return t.update()}))},t.prototype.get=function(t){var e=this.property(t);return e?e.get():void 0},t.prototype.set=function(t,e,r){var n=this.property(t);n&&n.getValue()!==e&&n.set(e,r)},t.prototype.property=function(t){return this._properties[t]},t.prototype.list=function(){var t=this;return this._propertiesList.map((function(e){return t._properties[e]}))},t.prototype.destroy=function(){for(var t in this._properties){var e=this.property(t);e&&e.destroy&&e.destroy()}this._properties={},this._propertiesList=[]},t.prototype._setPropertyHandler=function(t){var e=this._getHandler(t);if(e&&t.name){var r=n({},t);this._properties[t.name]=new e(t.name,this.item,r),this._propertiesList.push(t.name)}},t.prototype._getHandler=function(e){var r=e.handler;return!r&&e.type?"boolean"===e.type?t.handlers.CheckProperty:t.handlers.BaseProperty:r},t.handlers={CheckProperty:ve},t}(),ge=0,be=function(){function t(t){this.options={},this.id=ge,ge+=1,this.options=n({},t),this.tree=new de(this)}return t.prototype.initProperties=function(){this.properties=new me(this,this.options.properties)},t}(),_e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getProperty=function(){var t=this.item.layer;return t&&t&&t.options&&void 0!==t.options.opacity?t.options.opacity:1},e.prototype.update=function(t,e){var r=this;if(e=e||{},this.isGroup()){this._value=this._prepareValue(t,e);for(var n=0,o=this.getChildren();n<o.length;n++){var i=o[n].properties.property(this.name);i&&(e.propagation?i.set(t,e):i.update(i.get(),e))}}var s=this.item.layer;if(s){var a=this.getParents().reduce((function(t,e){var n=e.properties.property(r.name);return t*(n?n.getValue():1)}),1);this.item.webMap.setLayerOpacity(s,this._prepareValue(t*a))}},e.prototype._prepareValue=function(t,e){return e&&e.propagation&&this.isGroup()?1:Number(t)},e}(ye);function we(t){var e=t.extent_bottom,r=t.extent_left,n=t.extent_top,o=t.extent_right;if(e&&r&&n&&o){var i=[r,e,o,n];return i[3]>82&&(i[3]=82),i[1]<-82&&(i[1]=-82),i}}function Le(t){var e=t.cache;return t.connector.get("layer.extent",{cache:void 0===e||e},{id:t.resourceId}).then((function(t){if(t){var e=t.extent;return[e.minLon,e.minLat,e.maxLon,e.maxLat]}}))}function Oe(t){return t.connector.getResource(t.resourceId).then((function(e){if(e)return Ie(e,t.connector,t)}))}function Ie(t,e,r){if(t.webmap)return S.resolve(we(t.webmap));var o=t.resource;return o.cls&&-1!==o.cls.indexOf("style")?e.getResource(o.parent.id).then((function(t){if(t)return Le(n(n({},r),{resourceId:t.resource.id,connector:e}))})):Le(n(n({},r),{resourceId:o.id,connector:e}))}var Ee=function(){function t(){}return t.prototype.getExtent=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.getBounds()]}))}))},t.prototype.getBounds=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(r){switch(r.label){case 0:return this._extent?[2,this._extent]:this.item?(e=this,[4,Ie(this.item,this.connector,t)]):[3,2];case 1:return e._extent=r.sent(),[2,this._extent];case 2:return[2]}}))}))},t}();function Ae(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,a;return s(this,(function(s){switch(s.label){case 0:return n=r=t.resource,o=t.keyname,i=t.resourceId,r?"string"!=typeof r?[3,1]:(o=r,[3,5]):[3,5];case 1:return"number"!=typeof r?[3,2]:(i=r,[3,5]);case 2:return n.resource&&void 0!==n.resource&&"resource"in n?(i=r.resource.id,[3,5]):[3,3];case 3:return[4,Ae(r,e)];case 4:i=s.sent(),s.label=5;case 5:return i||!o?[3,7]:[4,e.getResource(o)];case 6:(a=s.sent())&&(i=a.resource.id),s.label=7;case 7:return[2,i]}}))}))}function Pe(t){return new Promise((function(e,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState&&200===n.status&&n.responseText)try{e(JSON.parse(n.responseText))}catch(t){r(t)}},n.open("GET",H(t),!0),n.send()}))}var Ce={tms:"TILE"};var Me="https://qms.nextgis.com";function ke(t,e,r){var a;if(void 0===e&&(e=Me),void 0===r&&(r={}),"webMap"in t){var u=t.webMap,c=t.url,p=o(t,["webMap","url"]);a=u,c&&(e=c),p&&(r=p)}else a=t;return e||(e=Me),function(){function t(t,e){this.map=t;var o=n(n({},r),e);this.options=o,this.options.baselayer=!0,o.qms&&(this.qms=o.qms)}return t.prototype.addLayer=function(r){return i(this,void 0,void 0,(function(){var o,i,u,c,p,l,f,h;return s(this,(function(s){switch(s.label){case 0:if(this.qms||!r.qmsId)return[3,4];s.label=1;case 1:return s.trys.push([1,3,,4]),o=this,[4,Pe(e+"/api/v1/geoservices/"+r.qmsId)];case 2:return o.qms=s.sent(),[3,4];case 3:return i=s.sent(),console.error(i),[3,4];case 4:return(u=this.qms)&&(p=a.mapAdapter.layerAdapters[c=Ce[u.type||"tms"]])&&(y=t,v=p,["showLayer","hideLayer"].forEach((function(t){var e=Object.getOwnPropertyDescriptor(v.prototype,t);e&&Object.defineProperty(y.prototype,t,e)})),"TILE"===c)?(r=n(n({order:0,maxZoom:a.options.maxZoom,minZoom:a.options.minZoom},this.options),function(t){var e=("https:"===location.protocol?"https":"http")+"://",r=t.url.replace(/^(https?|ftp):\/\//,e);return t.y_origin_top||(r=r.replace("{y}","{-y}")),{url:r,name:t.name,attribution:t.copyright_text,maxZoom:t.z_max,minZoom:t.z_min}}(u)),u.origin_url&&(d=[],l=[u.origin_url.replace(/{switch:(.*?)}/,(function(t,e){return"string"==typeof e&&e.split(",").forEach((function(t){return d.push(t)})),"{s}"})),d],f=l[0],(h=l[1]).length&&(r.subdomains=h,r.url=f)),this.options=r,[2,new p(this.map,r).addLayer(r)]):[2]}var d,y,v}))}))},t}()}var xe=function(){function t(t){this.options={url:"https://qms.nextgis.com"},this.options=n(n({},this.options),t),this.url=this.options.url}return t.prototype.getLayerAdapters=function(){var t=this;return Promise.resolve([{name:"QMS",createAdapter:function(e){return Promise.resolve(t._createAdapter(e))}}])},t.prototype._createAdapter=function(t){return ke({webMap:t,url:this.url})},t.utils={createQmsAdapter:ke},t}();var Se={srs:4326,geom_format:"geojson"};function Ne(t){return{geometry:t.geom,id:t.id,type:"Feature",properties:t.fields}}function Te(t,e){var r=e.extensions,n=e.geom,o=e.fields,i=e.srs,s=e.ilike,a=e.like,u=r?r.join(","):"";"*"!==u&&(t.extensions=u),void 0!==o&&(t.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(t.geom=n?"yes":"no",n||(delete t.srs,delete t.geom_format)),T(s)?t.ilike=s:T(a)&&(t.like=a),T(i)&&(t.srs=i)}function Fe(t){var e=Re(t);return S.all(e).then((function(e){for(var r=[],n=[],o=0,i=e;o<i.length;o++)for(var s=0,a=i[o];s<a.length;s++){var u=a[s];r.includes(u.id)||(n.push(u),r.push(u.id))}return t.offset||t.limit?n.splice(void 0!==t.offset?t.offset:0,void 0!==t.limit?t.limit:n.length):n}))}function Be(t){var e=t[0],r=t[1],n=t[2],o="id"!==e?"fld_":"",i="",s="",a=String(e).trim().replace(/^(%?)(.+?)(%?)$/,(function(t,e,r,n){return i=e,s=n,r})),u=i+n+s;return["".concat(o).concat(a,"__").concat(r),u]}function Re(t,e,r){void 0===e&&(e=[]),void 0===r&&(r=[]);var o=t.filters,i="string"==typeof o[0]?o[0]:"all",s=o.filter((function(t){return Array.isArray(t)}));if("any"===i)for(var a=0,c=s;a<c.length;a++){vt(d=c[a])?e.push(qe(n(n({},t),{paramList:u(u([],r,!0),[Be(d)],!1)}))):Re(n(n({},t),{filters:d}),e,u([],r,!0))}else if("all"===i){for(var p=[],l=[],f=0,h=s;f<h.length;f++){var d;vt(d=h[f])?p.push(Be(d)):l.push(d)}if(l.length)for(var y=0,v=l;y<v.length;y++){var m=v[y];Re(n(n({},t),{filters:m}),e,u(u([],r,!0),p,!0))}else e.push(qe(n(n({},t),{paramList:u(u([],r,!0),p,!0)})))}return e}function je(t){var e=t.map((function(t){var e=U(t[0],t[1]).map((function(t){return e=t,n=r?Number("1e+"+r):1,Math.round((e+Number.EPSILON)*n)/n;var e,r,n}));return e[0]+" "+e[1]}));return"POLYGON((".concat(e.join(", "),"))")}function qe(t){var e=n({},Se),r=t.limit,o=t.cache,i=t.signal,s=t.offset,a=t.orderBy,u=t.paramList,c=t.connector,p=t.geomFormat,l=t.intersects,f=t.resourceId;if(r?r!==Number.POSITIVE_INFINITY&&(e.limit=r):e.limit=7e3,s&&(e.offset=s),p&&(e.geom_format=p),Te(e,t),a&&(e.order_by=a.join(",")),Array.isArray(l)){var h=function(t){return Array.isArray(t)&&4===t.length&&t.every((function(t){return"number"==typeof t}))}(l)?V(l):l;e.intersects=je(h)}else"string"==typeof l&&(e.intersects=l);u&&(e.paramList=u);var d=n({id:f},e);return c.get("feature_layer.feature.collection",{cache:o,signal:i},d)}function Ve(t){var e,r=function(){var r=t[e];if($(r)){var n=r;if(T(n.year)&&T(n.month)&&T(n.day)){var o=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((function(t){o.push(t)})),t[e]=(new(Date.bind.apply(Date,u([void 0],o,!1)))).toISOString()}}else"id"===e&&"string"==typeof r&&(t[e]=r.split(",").map(Number))};for(e in t)r();return t}function Ge(t){var e=t.filters;return e?Fe(n(n({},t),{filters:e})).then((function(r){var o;return(null!==(o=t.clientFilterValidate)&&void 0!==o?o:De(e))&&(r=r.filter((function(t){return mt(Ve(n(n({},t.fields),{id:t.id})),e)}))),r})):qe(t)}function De(t){if("any"===t[0])return!0;for(var e=1;e<t.length;e++){var r=t[e];if("[object Array]"===Object.prototype.toString.call(r))if(De(r))return!0}return!1}function Ue(t){return function(t){return Ge(t).then((function(t){var e=[];return t.forEach((function(t){e.push(Ne(t))})),e}))}(t).then((function(t){return{type:"FeatureCollection",features:t}}))}var ze=["fields","intersects","limit","orderBy","strategy"];function Ze(t){var e={};return ze.forEach((function(r){var n=t[r];void 0!==n&&(e[r]=n)})),e}function We(t){var e,o;return i(this,void 0,void 0,(function(){var a,u,c,p,f,h,d,y,v,m,g,b,_,w,L,O,I=this;return s(this,(function(E){switch(E.label){case 0:return a=t.item,u=t.webMap,f=null==(p=t.addLayerOptionsPriority)||p,d=t.Adapter||u.mapAdapter.layerAdapters.GEOJSON,y=[],v=!1,[4,Ae(h=t.layerOptions,c=t.connector)];case 1:return b=E.sent(),(null===(o=null===(e=h.adapterOptions)||void 0===e?void 0:e.popupOptions)||void 0===o?void 0:o.fromProperties)&&(h.adapterOptions.popupOptions.createPopupContent=function(t){var e=t.feature;return e&&function(t,e){var r=document.createElement("div");if(e&&e.feature_layer)e.feature_layer.fields.forEach((function(e){if(e.grid_visibility){var n=t.properties&&t.properties[e.keyname];if(n){var o=document.createElement("div");r.appendChild(o),o.innerHTML="<span>".concat(e.display_name,"</span>: ").concat(n,"<span></span>")}}}));else if(t.properties)for(var n in t.properties){var o=document.createElement("div");r.appendChild(o),o.innerHTML="<span>".concat(n,"</span>: ").concat(t.properties[n],"<span></span>")}return r}(e,a)}),_=function(t,e){return i(I,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return L(),m={filters:t,options:e},[4,g=Ue(n({resourceId:b,filters:t,connector:c,cache:!0},e))];case 1:return[2,r.sent()]}}))}))},w=!1,L=function(){g&&(g.cancel(),g=void 0)},O=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.emitter=new l.exports.EventEmitter,e}return r(e,t),e.prototype.addLayer=function(e){return i(this,void 0,void 0,(function(){var r,o,i,u,c;return s(this,(function(s){switch(s.label){case 0:return r=!e.data,o=void 0===e.waitFullLoad||e.waitFullLoad,void 0!==h.id&&(e.id=h.id),a&&a.vector_layer&&(e.type=er[a.vector_layer.geometry_type]),h.adapterOptions&&(e=f?n(n({},h.adapterOptions),e):n(n({},e),h.adapterOptions)),e.data&&0===Object.keys(e.data).length&&(e.data=void 0,r=!1),this.options.strategy=i=e.strategy||void 0,u=t.prototype.addLayer.call(this,e),m={filters:e.propertiesFilter,options:Ze(e)},r&&(c=this.updateLayer()),o&&c?[4,c]:[3,2];case 1:s.sent(),s.label=2;case 2:return i&&i.startsWith("BBOX")&&!v&&this._addBboxEventListener(),[2,u]}}))}))},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){return i(this,void 0,void 0,(function(){var e,r;return s(this,(function(n){return e=this.getLayers&&this.getLayers().length,(null==(r=this.options.strategy)?void 0:r.startsWith("BBOX"))||e?[2,Oe({connector:c,resourceId:a.resource.id})]:t.prototype.getBounds?[2,t.prototype.getBounds.call(this)]:[2]}))}))},e.prototype.beforeRemove=function(){w=!0,this._removeMoveEventListener(),this._removeBboxEventListener(),this.__disableMapMoveListener=void 0,this.__enableMapMoveListener=void 0,this.__onMapMove=void 0,this.__onMapMoveStart=void 0,L()},e.prototype.getCount=function(){return function(t){var e=t.cache;return t.connector.get("feature_layer.feature.count",{cache:void 0===e||e},{id:t.resourceId}).then((function(t){return t.total_count}))}({connector:c,resourceId:b,cache:!0})},e.prototype.updateLayer=function(e){var r;return i(this,void 0,void 0,(function(){var o,i,a,c,p,l,f,d,g,b,L;return s(this,(function(s){switch(s.label){case 0:return e=e||m||{},(null===(r=this.options.strategy)||void 0===r?void 0:r.startsWith("BBOX"))?[4,u.onLoad("create")]:[3,2];case 1:if(s.sent(),e.options=e.options||{},e.options.intersects=u.getBounds(),i=(o=this.options).minZoom,a=o.maxZoom,void 0!==(c=u.getZoom())){if(void 0!==i&&c<i)return[2];if(void 0!==a&&c>a)return[2];if(v)return[2]}s.label=2;case 2:if(w)return[2];s.label=3;case 3:return s.trys.push([3,10,,11]),this.emitter.emit("preupdate",e),u._emitLayerEvent("layer:preupdate",h.id||"",e),[4,_(e.filters,n(n({},e.options),{srs:this.options.srs}))];case 4:return p=s.sent(),l=p,[4,this.getCount()];case 5:if(f=s.sent(),"BBOX+"!==this.options.strategy)return[3,7];for(l={type:"FeatureCollection",features:[]},d=0,g=p.features;d<g.length;d++)b=g[d],-1===y.indexOf(String(b.id))&&(y.push(String(b.id)),l.features.push(b));return v=void 0!==f&&y.length>=f,[4,u.addLayerData(this,l)];case 6:return s.sent(),[3,9];case 7:return v=void 0!==f&&p.features.length>=f,[4,u.setLayerData(this,p)];case 8:s.sent(),s.label=9;case 9:return this.emitter.emit("updated",p),u._emitLayerEvent("layer:updated",h.id||"",{data:p,newData:l,isFull:v}),[3,11];case 10:if((L=s.sent())instanceof Error&&"CancelError"!==L.name)throw L;return[3,11];case 11:return t.prototype.updateLayer&&t.prototype.updateLayer.call(this),[2]}}))}))},e.prototype.propertiesFilter=function(t,e){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:return L(),this.filter&&v?(this.filter((function(e){var r=e.feature&&e.feature.properties&&Ve(n({},e.feature.properties));return!r||mt(r,t)})),[3,3]):[3,1];case 1:return this.setData?(this.clearLayer&&this.clearLayer(),[4,_(t,n(n({},e),{srs:this.options.srs}))]):[3,3];case 2:r=o.sent(),this.setData(r),o.label=3;case 3:return[2]}}))}))},e.prototype.removeFilter=function(){m=void 0,this.propertiesFilter([]),this.filter&&this.filter((function(){return!0}))},e.prototype._addBboxEventListener=function(){var t=this;this.__enableMapMoveListener=function(e){e===t&&(t._removeMoveEventListener(),t.updateLayer(),t._addMoveEventListener())},this.__disableMapMoveListener=function(e){e===t&&t._removeMoveEventListener()},u.emitter.on("layer:show",this.__enableMapMoveListener),u.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)},e.prototype._removeBboxEventListener=function(){this.__enableMapMoveListener&&u.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&u.emitter.on("layer:hide",this.__disableMapMoveListener)},e.prototype._addMoveEventListener=function(){var t=this;this.__onMapMove=function(t,e){var r;function n(){for(var o=this,i=[],s=0;s<arguments.length;s++)i[s]=arguments[s];n.clear(),r=setTimeout((function(){r=null,t.apply(o,i)}),e)}return void 0===e&&(e=10),n.clear=function(){r&&(clearTimeout(r),r=null)},n}((function(){return t.updateLayer()})),this.__onMapMoveStart=L,u.emitter.on("movestart",this.__onMapMoveStart),u.emitter.on("moveend",this.__onMapMove)},e.prototype._removeMoveEventListener=function(){this.__onMapMove&&u.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&u.emitter.removeListener("movestart",this.__onMapMoveStart)},e}(d),[2,O]}}))}))}function $e(t){var e,r,n=t.options,o=t.webMap,i=t.baseUrl,s=n.adapter||"IMAGE",a=o&&o.getLayerAdapters(),u=n.resource,c=n.tileNoData?n.tileNoData:200;if("number"==typeof u){if("IMAGE"===s){if(!a||a.IMAGE)return function(t){var e=t.resourceId,r=t.nd,n=t.headers,o=t.baseUrl+"/api/component/render/image",i={resource:e};return r&&(i.nd=r),{url:o,resourceId:e,headers:n,params:i,updateWmsParams:function(t){return r&&(t.nd=r),Ye(t,e)}}}({resourceId:u,headers:n.headers,nd:c,baseUrl:i});s="TILE"}if("WMS"===s){r="".concat(i,"/api/resource/").concat(u,"/wms");var p=n.adapterOptions;return{url:r,format:"image/png",version:"1.1.1",layers:p&&p.layers,headers:n.headers}}if("MVT"===s)return{url:r=i+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+u+"&simplification="+(null!==(e=n.simplification)&&void 0!==e?e:6),sourceLayer:"ngw:"+u,featureIdName:"$id"};if("TERRAIN"===s)return{url:r=i+"/api/resource/".concat(u,"/terrain_provider"),adapter:s};if("MODEL_3D"===s)return{url:r=i+"/api/component/model_3d/".concat(u,"/data.glb")};if("TILE"===s)return{url:r=i+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+u+"&nd="+c,adapter:s}}else{if(void 0!==u)throw new Error("Option `resource` must be number, not "+typeof u);console.log("Option `resource` not set")}}function He(t){var e=t.layerOptions,o=t.webMap,a=t.connector,u=t.item;return i(this,void 0,void 0,(function(){var t,c,p,l,f,h;return s(this,(function(d){switch(d.label){case 0:return t=u.resource.cls,c={wmsserver_service:"WMS",tmsclient_layer:"IMAGE"},void 0!==(p=e.adapter||t&&c[t]||"IMAGE")&&(e.adapter=p),"IMAGE"===p&&(l=o.getLayerAdapters(),!l||l.IMAGE||(p="TILE")),(f=o.mapAdapter.layerAdapters[p])?[4,Ae(e,a)]:[3,2];case 1:return h=d.sent(),[2,function(t){function c(r,i){var s=t.call(this,r,i)||this;s.map=r,s.item=u,s.resourceId=h;var c=$e({options:e,webMap:o,baseUrl:a.options.baseUrl||""});if(c){var p=n(n(n({},c),e.adapterOptions),{params:{resource:h},layers:c.layers||String(h),resourceId:h});e.adapterOptions&&T(e.adapterOptions.setViewDelay)&&(p.setViewDelay=e.adapterOptions.setViewDelay),s.options=n(n({},s.options),p)}return s}return r(c,t),c.prototype.addLayer=function(e){return t.prototype.addLayer.call(this,n(n({},this.options),e))},c.prototype.getLegend=function(t){return i(this,void 0,void 0,(function(){var e,r,o;return s(this,(function(i){switch(i.label){case 0:return[4,a.get("render.legend_symbols",n({params:{id:h},cache:!0},t))];case 1:return e=i.sent(),void 0!==(r=this.options.id)?(o={layerId:r,legend:e.map((function(t){return{name:t.display_name,symbol:t.icon}}))},[2,[o]]):[2,[]]}}))}))},c.prototype.getIdentificationIds=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){if(this.item){if("MVT"===p)return[2,[this.item.resource.id]];if(T(t=this.item.resource.parent.id))return[2,[t]]}return[2,[]]}))}))},c}(f)];case 2:throw new Error(p+" not supported yet. Only TILE")}}))}))}var Je={},Qe=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Ke(t){var e=t.layerOptions,r=t.webMap,o=t.connector,a=t.item;return i(this,void 0,void 0,(function(){var t,i;return s(this,(function(s){switch(s.label){case 0:return[4,o.getResourceChildren(a.resource.id)];case 1:return t=s.sent(),(i=t&&t[0])?[2,Xe(n(n({},e),{resource:i.resource.id}),r,o)]:[2]}}))}))}function Xe(t,e,o){return i(this,void 0,void 0,(function(){var a,u,c,p,l,f,h,d,y,v,m,g,b,_;return s(this,(function(w){switch(w.label){case 0:return c=t.adapter,[4,Ae(t,o)];case 1:return(p=w.sent())?(l=t.resource)&&l.resource&&void 0!==l.resource.id?(u=l,[3,4]):[3,2]:[3,15];case 2:return[4,o.getResource(p)];case 3:u=w.sent(),w.label=4;case 4:return u?(f=u.resource.cls,h=n(n({},t),{resource:p}),d={layerOptions:h,webMap:e,connector:o,item:u},-1===Qe.indexOf(f)?[3,12]:"webmap"!==f?[3,5]:(a=function(t){var e=t.layerOptions,n=t.webMap,o=t.connector;return i(this,void 0,void 0,(function(){var t;return s(this,(function(i){switch(i.label){case 0:return[4,Ae(e,o)];case 1:return t=i.sent(),[2,function(e){function i(r){return e.call(this,r,{url:"",webMap:n,resourceId:t,connector:o})||this}return r(i,e),i}(ir)]}}))}))}(d),[3,11])):[3,14];case 5:if("vector_layer"!==f&&"postgis_layer"!==f)return[3,6];if(y=u.vector_layer&&er[u.vector_layer.geometry_type],(v=d.layerOptions.adapterOptions||{}).type=v.type||y,d.layerOptions.adapterOptions=v,t.adapterOptions=d,void 0!==c&&"GEOJSON"!==c){if("MVT"!==c)return[2,Ke(d)];a=He(d)}else a=We(d);return[3,11];case 6:return"raster_layer"!==f?[3,7]:[2,Ke(d)];case 7:return"basemap_layer"!==f?[3,8]:(a=function(t){var e=t.webMap,o=t.item;return i(this,void 0,void 0,(function(){var t,a,u,c,p;return s(this,(function(l){if(o.basemap_layer){if(a=o.basemap_layer.url,t=o.basemap_layer.qms)return u=JSON.parse(t),[2,Promise.resolve(xe.utils.createQmsAdapter(e,void 0,{qms:u,baselayer:!0}))];if(a&&(c=e.mapAdapter.layerAdapters.TILE))return p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.addLayer=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(r){return[2,t.prototype.addLayer.call(this,n(n({},e),{url:a}))]}))}))},e}(c),[2,p]}return[2]}))}))}(d),[3,11]);case 8:return"GEOJSON"!==c?[3,10]:[4,o.getResource(u.resource.parent.id)];case 9:return(m=w.sent())&&(g=n(n({},t),{resource:u.resource.parent.id}),a=We(n(n({},d),{item:m,layerOptions:g}))),[3,11];case 10:a=He(d),w.label=11;case 11:return[3,13];case 12:if(!Je[f])throw"Resource class '".concat(f,"' not yet supported.");b=Je[f],_=void 0,(_=c&&"function"!=typeof _?b[c]:b)&&(a=_(d)),w.label=13;case 13:return[3,15];case 14:throw"Resource item is not found";case 15:return a?[2,a.then((function(t){if(t){var e=t;return u&&(e.prototype.item=u,e.prototype.resourceId=u.resource.id,e.prototype.connector=o),N(e,[Ee],{replace:!1}),e}}))]:[2]}}))}))}function Ye(t,e){var r=t.bbox,n=t.width,o=t.height,i=t.nd;return{resource:Array.isArray(e)?e.join(","):e,extent:r,size:n+","+o,timestamp:Date.now(),nd:null!=i?i:200}}var tr,er={POINT:"point",LINESTRING:"line",POLYGON:"polygon",MULTIPOINT:"point",MULTILINESTRING:"line",MULTIPOLYGON:"polygon",POINTZ:"point",LINESTRINGZ:"line",POLYGONZ:"polygon",MULTIPOINTZ:"point",MULTILINESTRINGZ:"line",MULTIPOLYGONZ:"polygon"};function rr(t,e){void 0===e&&(e=0);var r=e,n=function(){if(void 0===tr){var t=document.createElement("div");t.style.cssText="position: absolute; left: -100%; top: -100%; width: 100cm;",document.body.appendChild(t);var e=t.offsetWidth;document.body.removeChild(t),tr=e}return tr}()*function(t){return 12756274*Math.PI*Math.cos(t*Math.PI/180)}(r)/t,o=function(t){return Math.log(t/256)/Math.LN2}(n);return o}var nr=function(t){function e(r,o,i,s,a,u){var c=t.call(this,n(n({},e.options),i))||this;if(c.webMap=r,c.emitter=new l.exports.EventEmitter,c._rootDescendantsCount=0,s&&(c.connector=s),a&&c.tree.setParent(a),c.item=o,"root"===c.item.item_type)c._rootDescendantsCount=c._sumUp(c.item.children);else{var p=c.tree.getRoot();p&&(c._rootDescendantsCount=p._rootDescendantsCount)}return c.initProperties(),u||c._init(o),c}return r(e,t),e.create=function(t,r,n,o,a){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return[4,(i=new e(t,r,n,o,a,!0))._init(r)];case 1:return s.sent(),[2,i]}}))}))},e.prototype.initItem=function(t){return"group"===t.item_type||"root"===t.item_type?this.initGroupItem(t):this.initLayerItem(t)},e.prototype.bringToFront=function(){},e.prototype.fit=function(){},e.prototype.getLayer=function(){return this.layer},e.prototype.getLegend=function(t){var e;return i(this,void 0,void 0,(function(){var r,o,i,a;return s(this,(function(s){switch(s.label){case 0:return void 0===(r=null===(e=this.layer)||void 0===e?void 0:e.id)?[3,2]:(o=this.connector)?[4,o.get("render.legend_symbols",n({params:{id:this.item.resourceId},cache:!0},t))]:[3,2];case 1:return i=s.sent(),a={layerId:r,legend:i.map((function(t){return{name:t.display_name,symbol:t.icon}}))},[2,[a]];case 2:return[2,[]]}}))}))},e.prototype.getItemOptions=function(t){var e,r="layer"===t.item_type&&t.layer_transparency,n="number"==typeof r?(100-r)/100:void 0,o={visibility:!1,name:t.display_name,headers:this.options.headers,crossOrigin:this.options.crossOrigin,setViewDelay:this.options.setViewDelay,params:{resource:this.item.resourceId,item:this.item}};if(this.options.order){var i=String(this.options.drawOrderEnabled&&"draw_order_position"in t?this._rootDescendantsCount-t.draw_order_position:this.id).padStart(4,"0");o.order=Number((0|this.options.order)+"."+i)}if(this.options.popupOptions&&(o.popupOptions=this.options.popupOptions),"layer"===t.item_type){var s=(e=this._getZoomRange(t)).maxZoom;Object.assign(o,{updateWmsParams:t.updateWmsParams,url:t.url,headers:this.options.headers,ratio:this.options.ratio,maxZoom:s,minZoom:e.minZoom,minScale:t.layer_min_scale_denom,maxScale:t.layer_max_scale_denom,interactive:t.layer_identifiable})}return void 0!==n&&(o.opacity=n),o},e.prototype.getChildren=function(t){return u([],t.children,!0).reverse()},e.prototype._mapScaleToZoomLevel=function(t){return rr(t)},e.prototype.initGroupItem=function(t){if(t.children&&t.children.length)for(var e=0,r=this.getChildren(t);e<r.length;e++){var n=new this.constructor(this.webMap,r[e],this.options,this.connector,this);this.tree.addChild(n)}return Promise.resolve()},e.prototype.initLayerItem=function(t){var r,n=this,o=this.getItemOptions(t),i=function(e){t._layer=e,n.layer=e,n.properties.get("visibility")&&n.properties.set("visibility",!0),void 0!==o.opacity&&n.webMap.setLayerOpacity(e,o.opacity)};if("layer"===t.item_type)r=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){r=(0,e.GetAdapterFromLayerType[t.item_type])(t,o,this.webMap,this.connector)}return r?this.webMap.addLayer(r,o).then((function(t){i(t)})):t._layer?Promise.resolve(i(t._layer)):Promise.reject("No layer added")},e.prototype._getZoomRange=function(t){var e=this.options.minZoom,r=this.options.maxZoom,n=t.layer_min_scale_denom?this._mapScaleToZoomLevel(t.layer_min_scale_denom):void 0,o=t.layer_max_scale_denom?this._mapScaleToZoomLevel(t.layer_max_scale_denom):void 0,i=[e,n].filter(Boolean),s=[r,o].filter(Boolean);return{minZoom:i.length?Math.max.apply(Math,i):void 0,maxZoom:s.length?Math.min.apply(Math,s):void 0}},e.prototype._init=function(t){var e=this;this.initItem(t).then((function(){e.emitter.emit("init")}))},e.prototype._sumUp=function(t,e){void 0===e&&(e=0);for(var r=0,n=t;r<n.length;r++){var o=n[r];"layer"===o.item_type?(e+=1,o.draw_order_position=o.draw_order_position||e):"group"===o.item_type&&(e=this._sumUp(o.children,e))}return e},e.GetAdapterFromLayerType={},e.options={properties:[{type:"boolean",name:"visibility",getProperty:function(t){if(t){if("group"===t.item.item_type||"root"===t.item.item_type)return ae(t.item,(function(t){return"layer_enabled"in t&&t.layer_enabled}),(function(t){return t.children}));if("layer"===t.item.item_type)return t.item.layer_enabled}return!1},onSet:function(t,e,r){r&&"layer"===r.item.item_type&&(r.layer&&(t?r.webMap.showLayer(r.layer):r.webMap.hideLayer(r.layer)),r.item.layer_enabled=t)}},{name:"opacity",handler:_e}]},e}(be);function or(t){var e=t.webMap,r=t.connector,o=t.item,a=t.adapterOptions,u=void 0===a?{}:a,c=t.idPrefix,p=void 0===c?"first-show-adapter":c;return i(this,void 0,void 0,(function(){var t;return s(this,(function(a){return t=function(t){var e=t.webMap,r=t.adapterOptions,o=void 0===r?{}:r,a=t.onLayerAdded,u=t.createAdapter;return i(this,void 0,void 0,(function(){var t;return s(this,(function(r){return t=function(){function t(){this.options={},this.layer=[],this._removed=!1,this._creatingInProgress=!1}return t.prototype.addLayer=function(){return this.layer},t.prototype.removeLayer=function(){this._removed=!0;for(var t=0,r=this.layer;t<r.length;t++)e.removeLayer(r[t])},t.prototype.destroyed=function(){return this._removed},t.prototype.showLayer=function(){return i(this,void 0,void 0,(function(){var t,r;return s(this,(function(n){switch(n.label){case 0:if(this.options.visibility=!0,!this.layer.length)return[3,5];t=0,r=this.layer,n.label=1;case 1:return t<r.length?[4,e.showLayer(r[t])]:[3,4];case 2:n.sent(),n.label=3;case 3:return t++,[3,1];case 4:return[3,7];case 5:return[4,this.loadLayer()];case 6:n.sent(),n.label=7;case 7:return[2]}}))}))},t.prototype.hideLayer=function(){return i(this,void 0,void 0,(function(){var t,r;return s(this,(function(n){switch(n.label){case 0:if(this.options.visibility=!1,!this.layer)return[3,4];t=0,r=this.layer,n.label=1;case 1:return t<r.length?[4,e.hideLayer(r[t])]:[3,4];case 2:n.sent(),n.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},t.prototype.loadLayer=function(){return i(this,void 0,void 0,(function(){var t,r,i;return s(this,(function(s){switch(s.label){case 0:return this.layer.length||this._creatingInProgress?[3,5]:(this._creatingInProgress=!0,[4,u(this)]);case 1:return(t=s.sent())?[4,(r=new t(e.mapAdapter.map,n({},o))).addLayer({order:this.options.order,headers:this.options.headers,baselayer:this.options.baselayer})]:[3,5];case 2:return i=s.sent(),a&&a(r),Object.assign(r.options,o),r.layer=i,this._removed&&e.removeLayer(r),this.layer.push(r),this.options.visibility?[4,e.showLayer(r)]:[3,4];case 3:s.sent(),s.label=4;case 4:this._creatingInProgress=!1,s.label=5;case 5:return[2,this.layer]}}))}))},t}(),[2,t]}))}))}({webMap:e,adapterOptions:u,onLayerAdded:function(t){t.options.baselayer=!1,t.id=p+"-"+o.resource_id},createAdapter:function(){return Xe({resource:o.resource_id,adapterOptions:{name:o.display_name,opacity:o.opacity}},e,r)}}),[2,t]}))}))}var ir=function(){function t(t,e){this.map=t,this.options=e,this.NgwWebmapItem=nr,this.pixelRadius=10,this.webmapClassName="webmap",this.emitter=new l.exports.EventEmitter,this._webmapBaselayersIds=[];var r=e.resourceId;if(Array.isArray(r)?(this.resourceId=r[0],this.options.id=r[1]):this.resourceId=r,!this.resourceId)throw new Error("NGW `resourceId` is not defined")}return t.prototype.addLayer=function(t){var e,r;return i(this,void 0,void 0,(function(){var o,i;return s(this,(function(s){switch(s.label){case 0:return this.options=n(n({},this.options),t),o=this,[4,this._getWebMapLayerItem()];case 1:return o.layer=s.sent(),i=null===(r=null===(e=this.response)||void 0===e?void 0:e.webmap)||void 0===r?void 0:r.extent_constrained,this.options.useExtentConstrained&&this._extent&&i&&this.options.webMap.setView({maxBounds:this._extent}),[2,this.layer]}}))}))},t.prototype.removeLayer=function(){var t=this.options.webMap.mapAdapter;if(this.getDependLayers().forEach((function(e){"layer"in e&&t.removeLayer(e.layer.layer)})),this._webmapBaselayersIds.length){for(var e=0,r=this._webmapBaselayersIds;e<r.length;e++){this.options.webMap.removeLayer(r[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},t.prototype.showLayer=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){return this.layer&&this.layer.properties?[2,this.layer.properties.property("visibility").set(!0)]:[2]}))}))},t.prototype.hideLayer=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){return this.layer&&this.layer.properties?[2,this.layer.properties.property("visibility").set(!1)]:[2]}))}))},t.prototype.setOpacity=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return this.layer&&this.layer.properties?[2,this.layer.properties.property("opacity").set(t)]:[2]}))}))},t.prototype.getExtent=function(){return this.getBounds()},t.prototype.getBounds=function(){var t=this.response&&this.response.webmap;if(t)return we(t)},t.prototype.getDependLayers=function(){return this.layer&&this.layer.tree.getDescendants()||[]},t.prototype.getBookmarksResourceId=function(){var t=this.response&&this.response.webmap;if(t)return t.bookmark_resource.id},t.prototype.fetchBookmarks=function(){var t=this.getBookmarksResourceId(),e=this.options.connector;if(t)return e.getResourceOrFail(t).then((function(r){var n,o=null===(n=r.feature_layer)||void 0===n?void 0:n.fields.find((function(t){return t.label_field})),i=o&&o.keyname;return Ge({connector:e,resourceId:t,geom:!1,fields:i?[i]:void 0}).then((function(r){for(var n=[],o=0,s=r;o<s.length;o++){var a=new se({item:s[o],resourceId:t,labelField:i,connector:e});n.push(a)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")},t.prototype.getLegend=function(){return i(this,void 0,void 0,(function(){var t,e,r,n,o;return s(this,(function(i){switch(i.label){case 0:t=[],e=(e=this.getDependLayers()).sort((function(t,e){return e.id-t.id})),r=0,n=e,i.label=1;case 1:return r<n.length?[4,n[r].getLegend()]:[3,4];case 2:o=i.sent(),t.push.apply(t,o),i.label=3;case 3:return r++,[3,1];case 4:return[2,t]}}))}))},t.prototype.getIdentificationIds=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(r){switch(r.label){case 0:return t=[],(e=this._webmapLayersIds)?[3,2]:[4,this._getWebMapIds()];case 1:e=r.sent(),this._webmapLayersIds=e,r.label=2;case 2:return e&&e.length&&this.getDependLayers().sort((function(t,e){return e.id-t.id})).forEach((function(e){var r=e.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type&&r.layer_identifiable){var o=e.properties.property("visibility");o.get()&&!o.isBlocked()&&t.push(n)}})),[2,t]}}))}))},t.prototype._getWebMapLayerItem=function(){return i(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(r){switch(r.label){case 0:return this.resourceId?[4,this.getWebMapConfig(this.resourceId)]:[3,2];case 1:if((t=r.sent())&&t.root_item)return[2,new Promise((function(r){var n={};if(e.options.connector&&e.options.connector.options.auth){var o=e.options.connector.getAuthorizationHeaders();o&&(n.headers=o)}n.setViewDelay=e.options.setViewDelay,n.order=e.options.order,n.ratio=e.options.ratio,n.crossOrigin=e.options.crossOrigin,n.minZoom=e.options.minZoom,n.maxZoom=e.options.maxZoom,n.drawOrderEnabled=t.draw_order_enabled,n.popupOptions=e.options.popupOptions;var i=new e.NgwWebmapItem(e.options.webMap,t.root_item,n,e.options.connector);i.emitter.on("init",(function(){return r(i)}))}))];r.label=2;case 2:return[2]}}))}))},t.prototype.getWebMapConfig=function(t){return i(this,void 0,void 0,(function(){var e,r;return s(this,(function(n){switch(n.label){case 0:return[4,this.options.connector.getResource(t)];case 1:return(e=n.sent())&&(this.response=e,r=e[this.webmapClassName],this._setupBaselayers(e),r)?(this._extent=[r.extent_left,r.extent_bottom,r.extent_right,r.extent_top],this._updateItemsParams(r.root_item,this.options.webMap,e),[2,r]):[2]}}))}))},t.prototype._setupBaselayers=function(t){var e,r=this.options.webMap;if(null===(e=this.options.useBasemap)||void 0===e||e)if(t.basemap_webmap&&t.basemap_webmap.basemaps.length){var n=r.getActiveBaseLayer();this._lastActiveBaselayer=n?n.id:void 0,this._setBasemaps(t.basemap_webmap)}else this.options.defaultBasemap&&r.addBaseLayer("OSM",{id:"webmap-default-baselayer",name:"OpenStreetMap"})},t.prototype._setBasemaps=function(t){for(var e=this,r=this.options.webMap,n=!1,o=function(t){or({webMap:r,connector:i.options.connector,item:t,adapterOptions:{crossOrigin:i.options.crossOrigin}}).then((function(o){var i=!n&&t.enabled;return t.enabled&&(n=!0),r.addBaseLayer(o,{id:ur+t.resource_id,name:t.display_name,opacity:t.opacity,visibility:i}).then((function(t){t.id&&e._webmapBaselayersIds.push(t.id)}))}))},i=this,s=0,a=t.basemaps;s<a.length;s++){o(a[s])}},t.prototype._updateItemsParams=function(t,e,r){var o=this;if(t)if("group"===t.item_type||"root"===t.item_type)t.children&&(t.children=t.children.map((function(t){return o._updateItemsParams(t,e,r)}))),"root"===t.item_type&&(t.display_name=r.resource.display_name);else if("layer"===t.item_type){var i=H(this.options.connector.options.baseUrl+"/api/component/render/image"),s=t.layer_style_id;t.url=i,t.resourceId=s,t.updateWmsParams=function(t){return Ye(t,s)};var a=$e({options:{adapter:t.layer_adapter.toUpperCase(),resource:s},webMap:e,baseUrl:this.options.connector.options.baseUrl||""});t=n(n({},t),a)}return t},t.prototype._getWebMapIds=function(){return i(this,void 0,void 0,(function(){var t,e,r,n,o,i,a;return s(this,(function(s){switch(s.label){case 0:if(!(t=this.layer)||"root"!==t.item.item_type)return[3,2];for(e=t.tree.getDescendants(),r=[],n=function(t){var e=t.item;if("layer"===e.item_type){var n=o.options.connector.getResource(e.layer_style_id).then((function(t){if(t){var r=Number(t.resource.parent.id);return e.parentId=r,r}}));r.push(n)}},o=this,i=0,a=e;i<a.length;i++)n(a[i]);return[4,Promise.all(r)];case 1:return[2,s.sent().filter((function(t){return void 0!==t}))];case 2:return[2]}}))}))},t}(),sr=function(){function t(t){if(this.options=t,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})}}return t.addClassAdapters=function(t,e){Je[t]=e},t.prototype.onLoadSync=function(t){return i(this,void 0,void 0,(function(){var e,r,o;return s(this,(function(i){switch(i.label){case 0:if(!this.options.resourceId||!this.url)return[3,4];if(!(e=[this.options.resourceId]).length)return[3,4];r=0,o=e,i.label=1;case 1:return r<o.length?[4,t.addLayer(ir,n({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},{resourceId:o[r],connector:this.connector,webMap:t}))]:[3,4];case 2:return[2,i.sent()];case 3:return r++,[3,1];case 4:return[2]}}))}))},t.prototype.getLayerAdapters=function(){return Promise.resolve([this._getLayerAdapter()])},t.prototype._getLayerAdapter=function(){var t=this;return{name:"WEBMAP",createAdapter:function(e){return Promise.resolve(t._createAdapter(e))}}},t.prototype._createAdapter=function(t){var e;return e={webMap:t,connector:this.connector,baseUrl:this.url},function(t){function o(r,o){return o=n(n({},e),o),t.call(this,r,o)||this}return r(o,t),o}(ir)},t}(),ar=function(){function t(t){var e=t.feature;this.id=e.id,this.geom=e.geom,this.label=e.label,this.parent=e.parent,this.fields=e.fields,this.layerId=e.layerId,this.connector=t.connector}return t.prototype.identify=function(t){var e=this;return void 0===t&&(t={}),this._item?S.resolve(this._item):cr(n({connector:this.connector,featureId:this.id,resourceId:this.layerId,fields:null,extensions:["attachment","description"]},t)).then((function(t){return e._item=t,e.geom=t.geom,e.extensions=t.extensions,t}))},t.prototype.resource=function(){var t=this;return this._resource?S.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId).then((function(e){return t._resource=e,t._resource.feature_layer}))},t.prototype.getBounds=function(){return this._extent?S.resolve(this._extent):(t={connector:this.connector,featureId:this.id,resourceId:this.layerId}).connector.get("feature_layer.feature.item_extent",{cache:void 0===(e=t.cache)||e},{id:t.resourceId,fid:t.featureId}).then((function(t){if(t){var e=t.extent;return[e.minLon,e.minLat,e.maxLon,e.maxLat]}}));var t,e},t.prototype.geojson=function(){var t=this;return this._geojson?S.resolve(this._geojson):this.identify().then((function(e){return e.toGeojson().then((function(e){return t._geojson=e,e}))}))},t}(),ur="webmap-baselayer";function cr(t){var e=n({},Se);Te(e,t);var r=n({id:t.resourceId,fid:t.featureId},e);return t.connector.get("feature_layer.feature.item",{cache:t.cache||!0},r).then((function(e){return n(n({},e),{toGeojson:function(){return e.geom?S.resolve(Ne(e)):cr(n(n({},t),{geom:!0,fields:null,extensions:null})).then((function(t){var r=t.geom;return Ne(n(n({},e),{geom:r}))}))}})}))}function pr(t){return cr(t).then((function(t){return Ne(t)}))}function lr(t,e){void 0===e&&(e=!1);var r=[],n=[];for(var o in t){var i=Number(o);isNaN(i)||r.push(i)}var s=t.resources;s&&r.sort((function(t,e){return s.indexOf(t)-s.indexOf(e)}));for(var a=0;a<r.length;a++){var u=t[o=r[a]];if("features"in u){var c=fr(u.features,Number(o),e);if(c.length&&(n.push.apply(n,c),!e))break}}return n}function fr(t,e,r){for(var n=[],o=0,i=t;o<i.length;o++){var s=i[o];if(n.push({featureId:s.id,resourceId:e,feature:s}),!r)break}return n}function hr(t){var e=t.geom,r=t.signal,n=t.cache,o=t.layers,i="string"==typeof e?e:function(t){var e=function(t){var e;if(Array.isArray(t))return t;if("Feature"===t.type)return null===(e=t.geometry)||void 0===e?void 0:e.coordinates[0];if("Polygon"===t.type)return t.coordinates[0];return null}(t);if(!e)return null;var r=e.map((function(t){var e=U(t[0],t[1]),r=e[1];return"".concat(e[0]," ").concat(r)}));return"POLYGON((".concat(r.join(","),"))")}(e);if(!i)throw new Error("Not valid geometry format to make intersection");return t.connector.post("feature_layer.identify",{data:{geom:i,srs:3857,layers:o},signal:r,cache:n})}function dr(t,e){R(t);var r=t.lngLat,o=e.geom,i=e.signal,s=e.cache,a=null!=o?o:function(t,e,r,n){void 0===r&&(r=10),void 0===n&&(n=6);for(var o=r/j*D,i=o/Math.cos(e*G),s=[],a=0;a<n+1;a++){var u=Math.PI*(a/(n/2)),c=t+i*Math.cos(u),p=e+o*Math.sin(u);s.push([c,p])}return s}(r[0],r[1],e.radius);return hr(n(n({},e),{geom:a,signal:i,cache:s}))}function yr(t,e){var r;return i(this,void 0,void 0,(function(){var n,o,i,a,u,c,p;return s(this,(function(s){switch(s.label){case 0:return[4,t.get("pyramid.settings",null,{component:"pyramid"})];case 1:if(!((n=s.sent())&&n.company_logo&&n.company_logo.enabled))return[3,6];(o=document.createElement("a")).style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding=null!==(r=null==e?void 0:e.padding)&&void 0!==r?r:"10px",o.className="ngw-map-logo",e&&e.cssClass&&(o.className+=" "+e.cssClass),(i=new Image).style.maxHeight="100px",i.style.maxWidth="100px",i.src="",s.label=2;case 2:return s.trys.push([2,4,,5]),[4,t.get("pyramid.company_logo",{responseType:"blob"})];case 3:return a=s.sent(),u=window.URL||window.webkitURL,c=u.createObjectURL(a),i.src=c,[3,5];case 4:return p=s.sent(),console.warn(p),[3,5];case 5:return null!==n.company_logo.link&&""!==n.company_logo.link.trim()&&(o.href=n.company_logo.link,o.target="_blank",-1!==n.company_logo.link.search(/:\/\/nextgis/)&&(i.alt="Get your own Web GIS at nextgis.com")),o.appendChild(i),[2,o];case 6:return[2]}}))}))}var vr={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"/>'},mr=12;function gr(t){var e,r,n,o,i,s;void 0===t&&(t={});var a=null!==(e=t.shape)&&void 0!==e?e:"circle",u=null!==(r=t.color)&&void 0!==r?r:"blue",c=null!==(n=t.strokeColor)&&void 0!==n?n:"white",p=null!==(o=t.size)&&void 0!==o?o:mr,l=null!==(i=t.rotate)&&void 0!==i?i:0,f=null!==(s=t.anchor)&&void 0!==s?s:[p/2,p/2],h=void 0!==t.stroke?Number(t.stroke):.8,d=t.p||vr[a]||"circle",y="string"==typeof d?d:d(t),v=function(t){return(new DOMParser).parseFromString(t,"image/svg+xml").documentElement}(t.svg||function(t){var e=t.height,r=t.stroke,n=void 0===r?0:r,o=t.content,i=n/2;return'<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="'.concat(t.width,'"\n height="').concat(e,'"\n viewBox="-').concat(i," -").concat(i," ").concat(mr+n," ").concat(mr+n,'"\n >').concat(o,"</svg>")}({width:p,height:p,stroke:h,content:y}));return v.setAttribute("width",String(p)),v.setAttribute("height",String(p)),v.setAttribute("fill",u),h&&(v.setAttribute("stroke",c),v.setAttribute("stroke-width",String(h))),{type:"icon",iconSize:[p,p],iconAnchor:f,html:(new XMLSerializer).serializeToString(v),rotate:l,svg:v}}function br(t,e,r,o){if("number"==typeof e||"string"==typeof e)e=Number(e),t.push(n(n({},r),{resource:e}));else if(Array.isArray(e)){var i=e[0],s=e[1];t.push(n(n(n({},r),{resource:i,id:s}),o))}else"object"==typeof e&&t.push(n(n(n({},r),e),o))}var _r={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};var wr=function(t){function e(e){var r=t.call(this,function(t){var e=[new xe];return t.starterKits&&t.starterKits.forEach((function(t){e.push(t)})),t.connector?t.connector&&(t.baseUrl=t.connector.options.baseUrl):t.connector=new ie({baseUrl:t.baseUrl||"",auth:t.auth}),(t=B(_r,t)).center||t.bounds||(t.bounds=[-179,-90,180,90]),t.connector&&e.push(new sr({connector:t.connector,auth:t.auth})),n(n({},t),{starterKits:e,create:!1})}(e))||this;return r.emitter=new l.exports.EventEmitter,r._ngwLayers={},r._promises={select:[],identify:[]},e.connector&&(r.connector=e.connector),r._createWebMap().then((function(){var t=r.getContainer();t&&t.classList.add("ngw-map-container"),r.options.whitlabel&&r._whiteLabel()})),r}return r(e,t),e.prototype.addControl=function(e,r,n){return i(this,void 0,void 0,(function(){return s(this,(function(o){switch(o.label){case 0:return[4,this.onLoad("controls:create")];case 1:return o.sent(),[2,t.prototype.addControl.call(this,e,r,n)]}}))}))},e.prototype.addNgwLayer=function(t){return i(this,void 0,void 0,(function(){var e,r,o,i,a,u,c,p,l;return s(this,(function(s){switch(s.label){case 0:return[4,this.onMapLoad()];case 1:if(s.sent(),r=t.resourceId,((e=t.keyname)||void 0!==r)&&console.warn("DEPRECATED WARN: ".concat("set `resource` options instead of `keyname` or `resourceId`")),o=t.resource,!e&&!r&&!o)throw new Error("resource, resourceId or keyname is required parameter to add NGW layer");if(!T(this.options.baseUrl))return[3,5];s.label=2;case 2:return s.trys.push([2,4,,5]),T(this.options.setViewDelay)&&(t.adapterOptions=t.adapterOptions||{},T(t.adapterOptions.setViewDelay)||(t.adapterOptions.setViewDelay=this.options.setViewDelay)),i=function(t,e,r){var n=r.getAuthorizationHeaders();return n&&(t.headers=n),Xe(t,e,r)}(t,this,this.connector),a=n(n({visibility:!0},t),t.adapterOptions),[4,this.addLayer(i,a)];case 3:return u=s.sent(),c=u&&this.getLayerId(u),u&&c&&(this._ngwLayers[c]={layer:u,resourceId:u.resourceId},u.options.name=u.options.name||u.item&&u.item.resource.display_name,u.options.baselayer&&this.getActiveBaseLayer()),[2,u];case 4:return p=s.sent(),l=$(o)&&"id"in o?o.id:e||r||o,console.error("Can't add NGW layer ".concat(l,"."),p),[3,5];case 5:return[2]}}))}))},e.prototype.fit=function(){var t,e=(t=this.options).center,r=t.zoom,n=t.bounds;e?(this.setCenter(e),r&&this.setZoom(r)):n&&this.fitBounds(n)},e.prototype.fetchNgwLayerItem=function(t){return cr(n({connector:this.connector},t))},e.prototype.fetchNgwLayerItems=function(t){return Ge(n({connector:this.connector},t))},e.prototype.fetchNgwLayerFeature=function(t){return pr(n({connector:this.connector},t))},e.prototype.fetchNgwLayerFeatures=function(t){return Ue(n({connector:this.connector},t))},e.prototype.fetchIdentifyItem=function(t,e){var r,o,i,s=(o=(r={identify:t,connector:this.connector,requestOptions:e}).connector,(i=lr(r.identify))&&i.length?cr(n(n({connector:o},r.requestOptions),i[0])):S.resolve(void 0));return this._addPromise("identify",s),s},e.prototype.fetchIdentifyGeoJson=function(t,e){void 0===e&&(e=!1);var r=function(t){var e=t.connector,r=t.identify,o=t.requestOptions;for(var i in r){var s=Number(i);if(!isNaN(s)){var a=r[i];if("features"in a){var u=a.features.find((function(t){return t.geom}));if(u&&u.geom){var c=u.geom;return S.resolve(Ne(n(n({},u),{geom:c})))}}}}var p=lr(r);return p&&p.length?pr(n(n(n({},o),{connector:e}),p[0])):S.resolve(void 0)}({identify:t,connector:this.connector,multiple:e});return r&&"then"in r?(this._addPromise("identify",r),r):S.resolve(r)},e.prototype.getIdentifyGeoJson=function(t,e){return void 0===e&&(e=!1),this.fetchIdentifyGeoJson(t,e)},e.prototype.getNgwLayers=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.onLoad()];case 1:return t.sent(),[2,this._ngwLayers]}}))}))},e.prototype.getNgwLayerByResourceId=function(t){return i(this,void 0,void 0,(function(){var e,r,n,o,i,a,u,c;return s(this,(function(s){switch(s.label){case 0:for(n in r=[],e=this._ngwLayers)r.push(n);o=0,s.label=1;case 1:return o<r.length?(n=r[o])in e?(i=this._ngwLayers[n]).resourceId!==t?[3,2]:[2,i&&i.layer]:[3,5]:[3,6];case 2:return i.layer.getIdentificationIds?[4,i.layer.getIdentificationIds()]:[3,4];case 3:if((a=s.sent())&&a.some((function(e){return e===t})))return[2,i.layer];s.label=4;case 4:if(i.layer.getDependLayers&&(u=i.layer.getDependLayers(),c=u.find((function(e){return e.item&&e.item.parentId===t}))))return[2,c.layer];s.label=5;case 5:return o++,[3,1];case 6:return[2]}}))}))},e.prototype.fitLayer=function(e,r){return i(this,void 0,void 0,(function(){var n,o,i,a,u=this;return s(this,(function(s){switch(s.label){case 0:return n="string"==typeof e||"number"==typeof e?String(n):e.id,(o=n&&this._ngwLayers[n])?o.layer.getBounds?[4,o.layer.getBounds()]:[3,2]:[3,7];case 1:return(i=s.sent())&&this.fitBounds(i,r),[3,6];case 2:return a=void 0,o.layer.item?(a=o.layer.item,[3,5]):[3,3];case 3:return[4,this.connector.getResource(o.resourceId)];case 4:a=s.sent(),s.label=5;case 5:a&&Oe({resourceId:a.resource.id,connector:this.connector}).then((function(t){t&&u.fitBounds(t,r)})),s.label=6;case 6:return[3,8];case 7:t.prototype.fitLayer.call(this,"number"==typeof e?String(e):e,r),s.label=8;case 8:return[2]}}))}))},e.prototype.zoomToLayer=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.fitLayer(t)]}))}))},e.prototype.onLoad=function(e){return void 0===e&&(e="ngw-map:create"),t.prototype.onLoad.call(this,e)},e.prototype.removeLayer=function(e){var r=this.getLayer(e);if(r){var n=this.getLayerId(r);n&&delete this._ngwLayers[n],t.prototype.removeLayer.call(this,r)}},e.prototype.enableSelection=function(){var t=this;this.$$selectFromNgwRaster||(this.$$selectFromNgwRaster=function(e){t._getSelectListenersCount()&&t.selectFromNgwRaster(e)},this.$$selectFromNgwVector=function(e){t._getSelectListenersCount()&&t._selectFromNgwVector(e)},this.emitter.on("click",this.$$selectFromNgwRaster),this.emitter.on("layer:click",this.$$selectFromNgwVector))},e.prototype.disableSelection=function(){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)},e.prototype.getNgwLayerItem=function(t){return this.fetchNgwLayerItem(t)},e.prototype.getNgwLayerItems=function(t){return this.fetchNgwLayerItems(t)},e.prototype.getNgwLayerFeature=function(t){return this.fetchNgwLayerFeature(t)},e.prototype.getNgwLayerFeatures=function(t){return this.fetchNgwLayerFeatures(t)},e.prototype.cancelPromise=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.cancelPromises.apply(this,t)},e.prototype.cancelPromises=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];e.length||(e=Object.keys(this._promises)),e.forEach((function(e){var r=t._promises[e];r&&(r.forEach((function(t){return t.cancel()})),t._promises[e]=[])}))},e.prototype.selectFromNgwRaster=function(t){var e;return i(this,void 0,void 0,(function(){var r,o,i,a,u,c,p,l,f,h,d,y,v,m,g,b,_,w=this;return s(this,(function(s){switch(s.label){case 0:for(this._emitStatusEvent("ngw:preselect"),r=[],(o=Object.values(this._ngwLayers)).sort((function(t,e){return t.layer.order&&e.layer.order?e.layer.order-t.layer.order:1})),i=0,a=o;i<a.length;i++)p=null===(e=(u=a[i].layer).options.interactive)||void 0===e||e,(c="function"==typeof u.getIdentificationIds&&u.getIdentificationIds)&&u.options.selectable&&p&&this.isLayerVisible(u)&&r.push(c.call(u));return[4,Promise.all(r)];case 1:for(l=s.sent(),f=[],h=0,d=l;h<d.length;h++)(y=d[h])&&f.push.apply(f,y);return f.length?(v=this.options.pixelRadius||10,m=this.getCenter(),g=void 0!==(g=this.getZoom())?g:20,m&&g?(b=function(t,e,r){return(r=null!=r?r:10)*(40075016.686*Math.abs(Math.cos(180*t[1]/Math.PI))/Math.pow(2,e+8))*5e-4}(m,g,v),_=dr(t,{layers:f,connector:this.connector,radius:b}).then((function(e){var r=n(n({},e),{resources:f,sourceType:"raster",event:t}),o=w._prepareToIdentify(r);return w._emitStatusEvent("ngw:select",o),o})),this._addPromise("select",_),[2,_]):(this._emitStatusEvent("ngw:select",null),[2])):(this._emitStatusEvent("ngw:select",null),[2])}}))}))},e.prototype._addPromise=function(t,e){var r=this._promises[t];if(r&&-1===r.indexOf(e)){var n=function(){var t=r.indexOf(e);-1!==t&&r.splice(t,1)};e.then(n),e.catch(n),r.push(e)}},e.prototype._isFitFromResource=function(){var t=this._initMapState;return!t.zoom||!t.center},e.prototype._createWebMap=function(){return i(this,void 0,void 0,(function(){var t,e,r,n,o,i,a,u,c,p;return s(this,(function(s){switch(s.label){case 0:return[4,this.create()];case 1:if(s.sent(),this.options.qmsId&&this._addQmsBaseLayer(),this.options.osm&&this._addOsmBaseLayer(),t=[],e=this._isFitFromResource(),this.options.webmapId&&br(t,this.options.webmapId,{fit:e}),this.options.resources&&Array.isArray(this.options.resources))for(r=0,n=this.options.resources;r<n.length;r++)o=n[r],i={},e||(i.fit=!1),br(t,o,{},i);a=0,u=t,s.label=2;case 2:if(!(a<u.length))return[3,7];c=u[a],s.label=3;case 3:return s.trys.push([3,5,,6]),[4,this.addNgwLayer(c)];case 4:return s.sent(),[3,6];case 5:return p=s.sent(),console.warn(p),[3,6];case 6:return a++,[3,2];case 7:return this._emitStatusEvent("ngw-map:create",this),this.enableSelection(),[2]}}))}))},e.prototype._addOsmBaseLayer=function(){this.addBaseLayer("OSM")},e.prototype._addQmsBaseLayer=function(){var t,e;Array.isArray(this.options.qmsId)?(t=this.options.qmsId[0],e=this.options.qmsId[1]):t=Number(this.options.qmsId);var r={qmsId:t};e&&(r.id=e),this.addBaseLayer("QMS",r)},e.prototype._selectFromNgwVector=function(t){var e,r=t.layer;if(r.options.selectable&&this.isLayerVisible(r)){var o=r.item&&r.item.resource.id,i=t.feature;if(void 0!==o&&i){var s=i.id;if(s){var a={id:Number(s),fields:i.properties||{},label:"#".concat(o),layerId:Number(o),parent:"",geom:i.geometry},u=((e={featureCount:1})[o]={featureCount:1,features:[a]},e);return this._emitStatusEvent("ngw:select",this._prepareToIdentify(n(n({},u),{resources:[o],sourceType:"vector"}))),u}}}},e.prototype._prepareToIdentify=function(t){var e=this;return n(n({},t),{getIdentifyItems:function(){return lr(t,!0).map((function(t){return new ar({feature:t.feature,connector:e.connector})}))}})},e.prototype._getSelectListenersCount=function(){return this.emitter.listenerCount("ngw:select")},e.prototype._whiteLabel=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(r){switch(r.label){case 0:return(t=this.getContainer())?[4,yr(this.connector,this.options.companyLogoOptions)]:[3,2];case 1:(e=r.sent())&&t.appendChild(e),r.label=2;case 2:return[2]}}))}))},e.getIcon=gr,e}(Vt);return t.NgwMap=wr,t.WebMap=Vt,t.WebMapControls=Rt,t.WebMapLayers=Ft,t.WebMapMain=Mt,t.createNgwMap=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new wr(t).onLoad()]}))}))},t.createToggleControl=Bt,t.createWebMap=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new Vt(t).onLoad()]}))}))},t.detectGeometryType=xt,t.findMostFrequentGeomType=kt,t.getDefaultControls=Gt,t.getWebMap=qt,t.updateGeoJsonAdapterOptions=Tt,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
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 i(e,r,i,o){var s,a,l,c;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",r,i.listener?i.listener:i),a=e._events),l=a[r]):(a=e._events=new t,e._eventsCount=0),l){if("function"==typeof l?l=a[r]=o?[i,l]:[l,i]:o?l.unshift(i):l.push(i),!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]=i,++e._eventsCount;return e}function o(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}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,i,o,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,i=a(e,n),o=0;o<n;++o)i[o].call(r)}(r,p,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,o=a(e,i),s=0;s<i;++s)o[s].call(r,n)}(r,p,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var o=e.length,s=a(e,o),l=0;l<o;++l)s[l].call(r,n,i)}(r,p,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,o){if(t)e.call(r,n,i,o);else for(var s=e.length,l=a(e,s),c=0;c<s;++c)l[c].call(r,n,i,o)}(r,p,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),o=1;o<n;o++)i[o-1]=arguments[o];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,o=a(e,i),s=0;s<i;++s)o[s].apply(r,n)}(r,p,this,i)}return!0},r.prototype.on=r.prototype.addListener=function(e,t){return i(this,e,t,!1)},r.prototype.prependListener=function(e,t){return i(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,o(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,o(this,e,t)),this},r.prototype.removeListener=function(e,r){var n,i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(n=i[e]))return this;if(n===r||n.listener&&n.listener===r)0==--this._eventsCount?this._events=new t:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if("function"!=typeof n){for(o=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){a=n[s].listener,o=s;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new t,this;delete i[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(n,o);i.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 i,o=Object.keys(n),s=0;s<o.length;++s)"removeListener"!==(i=o[s])&&this.removeAllListeners(i);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):[]};var l=Object.defineProperty,c=(e,t,r)=>(((e,t,r)=>{t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class u extends Error{constructor(){super(),c(this,"name","CancelError"),Object.setPrototypeOf(this,u.prototype)}}var p=Object.defineProperty,h=(e,t,r)=>(((e,t,r)=>{t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class d{constructor(e={}){this.options=e,h(this,"_promises",new Map)}get isLoaded(){return this._promises.size>0}remove(e){this._promises.has(e)&&(this._promises.delete(e),this._onStop())}get(e){return this._promises.get(e)}add(e,t){const r=t||e,n=this._promises.get(r);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),n||(this._promises.set(r,e),e.finally((()=>{this.remove(r)})),e)}abort(){this.isLoaded&&(this._promises.forEach((e=>{e.cancel&&e.cancel()})),this._promises.clear(),this._onStop())}waitFunc(e,t=""){const r=this.get(t=t||e.name);return r||this.add(e(),t)}WaitForMe(e=""){const t=this.get.bind(this),r=this.add.bind(this);return function(n,i,o){const s=o.value;return e=e||i,o.value=function(...n){const i=t(e);if(i)return i;return r(s.apply(this,n),e)},o}}GetOrCreateDecorator(e=""){return this.WaitForMe(e)}_onStop(){this.options.onStop&&!this.isLoaded&&this.options.onStop()}}var f=Object.defineProperty,y=(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),r);class m extends Error{constructor(){super(),y(this,"name","TimeoutError"),Object.setPrototypeOf(this,m.prototype)}}var g,b=Object.defineProperty,v=(e,t,r)=>(((e,t,r)=>{t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const _=(e,t,r,n)=>{try{e(r(n))}catch(i){t(i)}};let w=0;const O=class e{constructor(t,r){v(this,g),v(this,"id",w++),v(this,"_isCanceled",!1),v(this,"_isPending",!0),v(this,"_promise"),v(this,"_cancelPromise"),v(this,"_cancelHandlers",[]),v(this,"_setCanceledCallback"),v(this,"_parentPromise"),v(this,"_children",[]),this._cancelPromise=new Promise(((e,t)=>{this._setCanceledCallback=t=>e(t||new u)}));const n=[this._cancelPromise,new Promise(((r,n)=>t((t=>{t instanceof e?this.attach(t):this._isPending=!1,r(t)}),(e=>{this._isPending=!1,n(e)}),(e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)}))))];r&&n.push(new Promise(((e,t)=>{setTimeout((()=>{if(this._isPending)try{this.cancel()}finally{t(new m)}}),r)}))),this._promise=Promise.race(n)}static createControl(e){return new d(e)}static resolve(t){return new e((e=>e(t)))}static reject(t){return new e(((e,r)=>r(t)))}static all(t){return new e(((e,r)=>{Promise.all(t).then(e).catch(r)})).catch((e=>{if(e instanceof this.CancelError)for(const r of t){"cancel"in r&&r.cancel()}throw e}))}attach(e){this._isCanceled?e.cancel():this._children.push(e)}then(t,r){const n=new e(((e,n)=>{if(this._promise){const i=t=>{r?_(e,n,r,t):n(t)};this._promise.then((r=>{this._isCanceled?i(r):t?_(e,n,t,r):e(r)}),i)}}));return n._parentPromise=this,this._children.push(n),n}catch(e){return this._isCanceled&&e&&e(new u),this.then(void 0,e)}finally(e){return this._promise?this._promise.finally(e):Promise.reject(this._isCanceled?new u:e)}cancel(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;const e=this._getTopParent();if(e&&e.cancel(),this._children&&this._children.forEach((e=>e.cancel())),this._isPending){if(this._cancelHandlers.length)try{for(const e of this._cancelHandlers)e()}catch(t){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this}_getTopParent(){let e=this._parentPromise,t=!!e;for(;t;)e&&e._parentPromise?(e=e._parentPromise,t=!!e):t=!1;return e}_destroy(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0}};g=Symbol.toStringTag,v(O,"CancelError",u),v(O,"TimeoutError",m),v(O,"PromiseControl",d);let L=O;Object.setPrototypeOf(L.prototype,Promise.prototype);const P={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"/>'},I=12;function E(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 i=void 0===r.replace||r.replace;t.forEach((t=>{Object.getOwnPropertyNames(t.prototype).forEach((r=>{const o=-1!==n.indexOf(r);if(!i&&!o||i){const n=Object.getOwnPropertyDescriptor(t.prototype,r);n&&Object.defineProperty(e.prototype,r,n)}}))}))}function j(e){return null!=e}function x(e){return"string"==typeof e?!!e:j(e)}function A(e,t,r=!1){let n=e;const i=t,o=Array.isArray(i);let s=o&&[]||{};return o&&Array.isArray(i)?r?(n=n||[],s=s.concat(n),i.forEach(((e,t)=>{void 0===s[t]?s[t]=e:"object"==typeof e?s[t]=A(n[t],e,r):-1===n.indexOf(e)&&s.push(e)}))):s=i:(n&&"object"==typeof n&&Object.keys(n).forEach((function(e){s[e]=n[e]})),Object.keys(i).forEach((function(e){s[e]="object"==typeof i[e]&&i[e]&&"object"==typeof n[e]&&"object"==typeof i[e]?A(n[e],i[e],r):i[e]}))),s}function C(e){if(!e.lngLat&&e.latLng){e.lngLat=[e.latLng.lng,e.latLng.lat]}return e}const M=6371;function k(e){return{type:"Polygon",coordinates:[S(e)]}}function S(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}const N=Math.PI/180,T=180/Math.PI;function F(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 B(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:R(e,t));return e===t}function R(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 i=0;i<r.length;i++){if(!B(e[r[i]],t[n[i]],e,t))return!1}return!0}function $(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]=$(e[r])})),t}function D(e){return"[object Object]"===Object.prototype.toString.call(e)}function q(e){return e.replace(/([^:]\/)\/+/g,"$1")}var V=Object.defineProperty,G=(e,t,r)=>(((e,t,r)=>{t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const U=class e{constructor(t={}){var r;G(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 i=this._find(e,r);if(i)return i.value;{let i;i=t instanceof Function?t():t;const o=r&&JSON.parse(JSON.stringify($(r))),s={key:e,value:i,props:o,options:o};return n&&!x(i)?i:(this.cache.push(s),i instanceof Promise?(i.catch((t=>{throw this.delete(e,r),t})),n&&i.then((t=>(x(t)||this.delete(e,r),t))),i):i)}}match(e,t){const r=this._find(e,t);if(r)return 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){let r=[];"string"==typeof e?r=this.cache.filter((r=>this._filter(r,e,t))):r.push(e);for(const n of r){const e=this.cache.indexOf(n);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){if(r){return R(e.props||e.options||{},$(r))}return!0}return!1}};G(U,"instance",{});let z=U;var Z=Object.defineProperty,W=(e,t,r)=>(((e,t,r)=>{t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class H extends Error{constructor(e){super(),W(this,"name","NgwError"),W(this,"title"),W(this,"message"),W(this,"detail"),W(this,"exception"),W(this,"status_code"),W(this,"data"),W(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,H.prototype)}}var J=Object.defineProperty,Q=(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),r);class K extends H{constructor(e){super(e),Q(this,"name","ResourceNotFoundError"),Q(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,K.prototype)}}function X(e){return"[object Object]"===Object.prototype.toString.call(e)}const Y=["description"];function ee(e,t=""){t=t?t+"__":"";const r={};for(const[n,i]of Object.entries(e))if(-1===Y.indexOf(n))if(X(i))if("owner_user"===n){const e=ee(i,n);Object.assign(r,e)}else"parent"===n&&"id"in i&&(r.parent_id=i.id);else j(i)&&(r[t+n]=i);return r}var te=Object.defineProperty,re=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,ae=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,le=(e,t)=>{for(var r in t||(t={}))oe.call(t,r)&&ae(e,r,t[r]);if(ie)for(var r of ie(t))se.call(t,r)&&ae(e,r,t[r]);return e};class ce{constructor(e){var t,r,n;this.connector=e,t=this,r="cache",n=new z,ae(t,"symbol"!=typeof r?r+"":r,n)}getOne(e,t){const r=new z,n={},i=(o=le({},t),re(o,ne({cache:!1})));var o;"string"==typeof e?n.keyname=e:"number"==typeof e?n.id=e:X(e)&&(void 0!==e.id?n.id=e.id:(e.keyname&&(n.keyname=e.keyname),e.display_name&&(n.display_name=e.display_name)));return r.addFull("resource",(()=>"string"==typeof e?this._fetchResourceBy({keyname:e},i):"number"==typeof e?this._fetchResourceById(e,i):X(e)?this._fetchResourceBy(e,i):L.resolve(void 0)),n)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new K}))}getId(e,t){return"number"==typeof e?L.resolve(e):"string"==typeof e||X(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):L.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,ee(e)),this.connector.get("resource.search",t,le({serialization:"full"},r)).then((e=>{if(e)for(const t of e)this.cache.add("resource.item",L.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):L.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",le({cache:!0},t),{parent:e}).then((e=>{const n=[];for(const i of e)this.cache.add("resource.item",L.resolve(i),{id:i.resource.id}),r.push(i),(null==t?void 0:t.recursive)&&i.resource.children&&n.push(this._getChildrenOf(i.resource.id,t,r));return n.length?L.all(n).then((()=>r)):r}))}_cleanResourceItemCache(e){return t=this,r=null,n=function*(){const t=this.cache.all(),r=[];for(const n of t){const t=n.options&&n.options.id;["resource.item","resource"].includes(n.key)&&void 0!==t&&("number"==typeof t?t===e&&r.push(n):(yield this.getId(t))===e&&r.push(n))}for(const e of r)this.cache.delete(e)},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}_fetchResourceById(e,t){return this.cache.add("resource.item",(()=>this.connector.get("resource.item",t,{id:e})),{id:e}).catch((e=>{if(!(e instanceof K))throw e}))}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return L.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:j(e.id)&&j(t.resource.id)?e.id===t.resource.id:R(e,t.resource)})),[])))}}const ue=[];function pe(e){ue.push(e)}var he=Object.defineProperty,de=(e,t,r)=>(((e,t,r)=>{t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class fe extends H{constructor(e){super(e),de(this,"name","InsufficientPermissionsError"),de(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,fe.prototype)}}const ye=/\{ *([\w_-]+) *\}/g;function me(e,t){return e.replace(ye,((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 ge=Object.defineProperty,be=(e,t,r)=>(((e,t,r)=>{t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ve extends Error{constructor(e){super(),be(this,"name","NetworkError"),Object.setPrototypeOf(this,ve.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}let _e;_e=(e,t,r={},n,i)=>{r.method=r.method||"GET";const o=new XMLHttpRequest;o.open(r.method||"GET",e,!0),"blob"===r.responseType&&(o.responseType=r.responseType);const s=()=>{try{return JSON.parse(o.responseText)}catch(e){return o.responseText}};o.onload=()=>{-1!==[401,403,404,422,500].indexOf(o.status)&&n(new H(s())),((e=!1)=>{const i=e?n:t;"blob"===r.responseType?i(o.response):o.responseText?i(s()):n({message:""})})()},o.onerror=t=>{n(0===o.status?new ve(e):t)},o.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&&o.setRequestHeader(c,e)}let l;if(void 0!==r.withCredentials&&(o.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;i&&i((()=>{o.abort()})),o.send(l)};var we=Object.defineProperty,Oe=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Ie=(e,t,r)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ee=(e,t)=>{for(var r in t||(t={}))Le.call(t,r)&&Ie(e,r,t[r]);if(Oe)for(var r of Oe(t))Pe.call(t,r)&&Ie(e,r,t[r]);return e},je=(e,t,r)=>(Ie(e,"symbol"!=typeof t?t+"":t,r),r);let xe=0;class Ae{constructor(e){this.options=e,je(this,"id",xe++),je(this,"emitter",new r),je(this,"user"),je(this,"resources"),je(this,"routeStr","/api/component/pyramid/route"),je(this,"activeRequests",[]),je(this,"requestTransform");const t=function(e){return ue.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return R(t.options.auth,e.auth)}}))}(e);if(t)return t;this.options.route&&(this.routeStr=this.options.route),this.options.requestTransform&&(this.requestTransform=this.options.requestTransform),this.resources=new ce(this),pe(this)}static create(e){return new this(e)}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,pe(this)}connect(){const e=new z,t=this.options.auth;return e.add("route",(()=>new L(((e,r)=>{const n=()=>this.makeQuery(this.routeStr,{},{}).then((t=>{e(t)})).catch((e=>{r(e)}));if(t){const{login:e,password:i}=t;if(e&&i)return this._login({login:e,password:i}).then((()=>n())).catch((e=>r(e)))}return n()}))),{id:this.id,auth:t,baseUrl:this.options.baseUrl})}login(e,t){return this.logout(),pe(this),this._login(e,t)}logout(){this.abort(),function(e){const t=ue.indexOf(e);-1!==t&&ue.splice(t,1)}(this),this.options.auth=void 0,this.user=void 0,this.emitter.emit("logout"),this.resources.cache.clean()}getUserInfo(e,t){if(this.user&&this.user.id)return L.resolve(this.user);e&&(this.options.auth=e);const r=Ee({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=unescape(encodeURIComponent(`${t}:${r}`));return window.btoa(n)}}abort(){for(const e of this.activeRequests)e.cancel();this.activeRequests=[]}getActiveApiRequests(){return[...this.activeRequests]}apiRequest(e,t={},r={}){var n,i;const{method:o,headers:s,withCredentials:a,responseType:l}=r,c=$(t=null!=(n=r.params)?n:t),u=()=>function(e){const t=e.params;return new L(((r,n)=>{e.connector.connect().then((i=>{let o=i&&i[e.name];if(o){o=[...o];let i=o.shift();if(o.length){const e={};for(let r=0;r<o.length;r++){const n=o[r];if(e[r]="{"+n+"}",void 0===t[n])throw new Error("`"+n+"` url api argument is not specified")}i&&(i=me(i,e))}if(t){const e=[],r=t.paramList;Array.isArray(r)&&(delete t.paramList,r.forEach((t=>{e.push(`${t[0]}=${t[1]}`)})));for(const n in t)-1===o.indexOf(n)&&e.push(`${n}=${t[n]}`);e.length&&(i=i+"?"+e.join("&"))}i?r(e.connector.makeQuery(i,t,e.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((e=>{n(e)}))}))}({name:e,params:c,requestOptions:r,connector:this});if(r.cache&&"GET"===o){return(new z).add(e,u,Ee({params:c},$({headers:s,withCredentials:a,responseType:l,baseUrl:this.options.baseUrl,userId:null==(i=this.user)?void 0:i.id})))}return u()}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,r={}){if(e=(this.options.baseUrl?this.options.baseUrl:"")+e)return t&&(e=me(e,t)),e=encodeURI(q(e)),this._loadData(e,r);throw new Error("Empty `url` not allowed")}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){if(t.responseType=t.responseType||"json",t.signal&&t.signal.aborted)return L.reject(new L.CancelError);const r=new L(((r,n,i)=>{if(this.user&&((t=t||{}).headers=Ee(Ee({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}_e(e,r,t,n,i)})).then((e=>(this._cleanActiveRequests(r),e))).catch((e=>{if(this._cleanActiveRequests(r),e instanceof L.CancelError);else{const t=this._handleHttpError(e);if(t)throw t}}));return t.signal&&"function"==typeof t.signal.addEventListener&&t.signal.addEventListener("abort",(()=>{r.cancel(),this._cleanActiveRequests(r)})),this.activeRequests.push(r),r}_login(e,t){return this.getUserInfo(e,t).then((e=>(this.user=e,this.emitter.emit("login",e),e))).catch((e=>{throw this.emitter.emit("login:error",e),e}))}_cleanActiveRequests(e){const t=this.activeRequests.indexOf(e);-1!==t&&this.activeRequests.splice(t,1)}_handleHttpError(e){if(e&&e instanceof H){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new K(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new fe(e)}return e}}je(Ae,"errors",{NgwError:H,ResourceNotFoundError:K});var Ce=Object.defineProperty,Me=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,Ne=(e,t,r)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Te=(e,t)=>{for(var r in t||(t={}))ke.call(t,r)&&Ne(e,r,t[r]);if(Me)for(var r of Me(t))Se.call(t,r)&&Ne(e,r,t[r]);return e};function Fe(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${i=t,i.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var i;return null!==new RegExp(n,r?"i":"").exec(e)}const Be={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)=>Fe(e,t),ilike:(e,t)=>Fe(e,t,!0)};function Re(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function $e(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if(Re(t)){const[r,n,i]=t,o=Be[n];if(o){if(("like"===n||"ilike"===n)&&"string"==typeof r){let t="";const n=r.replace(/^%?(\w+)%?$/,((n,o)=>(t=e[o],r.replace(o,i))));return o(t,n)}return o(e[r],i)}return!1}return $e(e,t)},i=t.filter((e=>Array.isArray(e)));return"any"===r?i.some(n):i.every(n)}var De=Object.defineProperty,qe=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,Ze=(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={}))Ue.call(t,r)&&Ze(e,r,t[r]);if(Ge)for(var r of Ge(t))ze.call(t,r)&&Ze(e,r,t[r]);return e},He=(e,t)=>qe(e,Ve(t));const Je={srs:4326,geom_format:"geojson"};function Qe(e){return{geometry:e.geom,id:e.id,type:"Feature",properties:e.fields}}function Ke(e,t){const{extensions:r,geom:n,fields:i,srs:o,ilike:s,like:a}=t,l=r?r.join(","):"";"*"!==l&&(e.extensions=l),void 0!==i&&(e.fields=Array.isArray(i)?i.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),j(s)?e.ilike=s:j(a)&&(e.like=a),j(o)&&(e.srs=o)}function Xe(e){const t=et(e);return L.all(t).then((t=>{const r=[],n=[];for(const e of t)for(const t of e)r.includes(t.id)||(n.push(t),r.push(t.id));return e.offset||e.limit?n.splice(void 0!==e.offset?e.offset:0,void 0!==e.limit?e.limit:n.length):n}))}function Ye(e){const[t,r,n]=e;let i="",o="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(i=t,o=n,r)))}__${r}`,i+n+o]}function et(e,t=[],r=[]){const{filters:n}=e,i="string"==typeof n[0]?n[0]:"all",o=n.filter((e=>Array.isArray(e)));if("any"===i)for(const s of o)Re(s)?t.push(rt(He(We({},e),{paramList:[...r,Ye(s)]}))):et(He(We({},e),{filters:s}),t,[...r]);else if("all"===i){const n=[],i=[];for(const e of o)Re(e)?n.push(Ye(e)):i.push(e);if(i.length)for(const o of i)et(He(We({},e),{filters:o}),t,[...r,...n]);else t.push(rt(He(We({},e),{paramList:[...r,...n]})))}return t}function tt(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=F(e,t).map((e=>function(e,t){const r=t?Number("1e+"+t):1;return Math.round((e+Number.EPSILON)*r)/r}(e)));return r+" "+n})).join(", ")}))`}function rt(e){const t=We({},Je),{limit:r,cache:n,signal:i,offset:o,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,o&&(t.offset=o),c&&(t.geom_format=c),Ke(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)?S(u):u;t.intersects=tt(e)}else"string"==typeof u&&(t.intersects=u);a&&(t.paramList=a);const h=We({id:p},t);return l.get("feature_layer.feature.collection",{cache:n,signal:i},h)}var nt=Object.defineProperty,it=Object.defineProperties,ot=Object.getOwnPropertyDescriptors,st=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable,ct=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ut=(e,t)=>{for(var r in t||(t={}))at.call(t,r)&&ct(e,r,t[r]);if(st)for(var r of st(t))lt.call(t,r)&&ct(e,r,t[r]);return e},pt=(e,t)=>it(e,ot(t));function ht(e){const t=ut({},Je);Ke(t,e);const r=ut({id:e.resourceId,fid:e.featureId},t);return e.connector.get("feature_layer.feature.item",{cache:e.cache||!0},r).then((t=>pt(ut({},t),{toGeojson:()=>t.geom?L.resolve(Qe(t)):ht(pt(ut({},e),{geom:!0,fields:null,extensions:null})).then((e=>{const r=e.geom;return Qe(pt(ut({},t),{geom:r}))}))})))}var dt=Object.defineProperty,ft=(e,t,r)=>(((e,t,r)=>{t in e?dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class yt{constructor(e){this.options=e,ft(this,"name"),ft(this,"resourceId"),ft(this,"item"),ft(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(){return this._extent?L.resolve(this._extent):this.options.connector.get("feature_layer.feature.item_extent",null,{id:this.resourceId,fid:this.item.id}).then((e=>{const{minLat:t,minLon:r,maxLat:n,maxLon:i}=e.extent,o=[r,t,i,n];return this._extent=o,o}))}geoJson(){return this.item.geom?L.resolve(Qe(this.item)):ht({resourceId:this.resourceId,featureId:this.item.id,connector:this.options.connector,geom:!0,fields:null,extensions:null}).then((e=>(this.item.geom=e.geom,Qe(this.item))))}}function mt(e,t,r,n){return!!vt(e,t,r,_t,n)}function gt(e,t,r,n){return vt(e,t,r,wt,n)}function bt(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 vt(e,t=(e=>!!e),r="children",n,i){const o="function"==typeof t?t:e=>$e(e,t);return n(e,i?e=>o(i(e)):o,r)}function _t(e,t=(e=>!!e),r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(t(e))return e;const n=bt(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){const e=_t(i[o],t,r,n);if(e)return e}}function wt(e,t=(e=>!!e),r,n=[]){let i=[];if(Array.isArray(e))i=e;else{t(e)&&n.push(e);const o=bt(e,r);o&&(i=o)}for(let o=0;o<i.length;o++)i[o]&&wt(i[o],t,r,n);return n}function Ot(e,t=(e=>!!e),r,n=[]){let i=[];if(Array.isArray(e))i=e;else{if(!t(e))return!1;const n=bt(e,r);n&&(i=n)}for(let o=0;o<i.length;o++)if(i[o]){if(!Ot(i[o],t,r,n))return!1}return!0}var Lt=Object.defineProperty,Pt=(e,t,r)=>(((e,t,r)=>{t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class It{constructor(e){Pt(this,"item"),Pt(this,"_children",[]),Pt(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?gt(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 vt(this._children,e,(e=>e.tree.getChildren()),_t,t);var t}every(e){return!!vt(this._children,e,(e=>e.tree.getChildren()),Ot,t);var t}some(e){return mt(this._children,e,(e=>e.tree.getChildren()))}all(e){return this.getDescendants(e)}getDescendants(e){return gt(this._children,e,(e=>e.tree.getChildren()))}getChildren(){return[...this._children]}}var Et=Object.defineProperty,jt=(e,t,r)=>(((e,t,r)=>{t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class xt{constructor(e,t,n){jt(this,"options"),jt(this,"emitter",new r),jt(this,"name"),jt(this,"item"),jt(this,"_blocked",!1),jt(this,"_container"),jt(this,"_value"),jt(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){const t=e.some((e=>{var t;const r=null==(t=e.properties)?void 0:t.property(this.name);return!!r&&!r.get()}));return t}}var At=Object.defineProperty,Ct=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable,St=(e,t,r)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nt=(e,t)=>{for(var r in t||(t={}))Mt.call(t,r)&&St(e,r,t[r]);if(Ct)for(var r of Ct(t))kt.call(t,r)&&St(e,r,t[r]);return e};const Tt=class e extends xt{constructor(t,r,n){super(t,r,Nt(Nt({},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 i=r[n],o=i.properties&&i.properties.property(this.name);o&&o.set(e,Nt(Nt({},t),{propagation:!0,bubble:!1}))}}}};var Ft;St(Tt,"symbol"!=typeof(Ft="options")?Ft+"":Ft,{hierarchy:!0,bubble:!1,propagation:!1,label:"Toggle"});let Bt=Tt;var Rt=Object.defineProperty,$t=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,Vt=(e,t,r)=>t in e?Rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Gt=(e,t,r)=>(Vt(e,"symbol"!=typeof t?t+"":t,r),r);const Ut=class e{constructor(e,t){this.item=e,Gt(this,"options",{}),Gt(this,"_properties",{}),Gt(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={}))Dt.call(t,r)&&Vt(e,r,t[r]);if($t)for(var r of $t(t))qt.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}};Gt(Ut,"handlers",{CheckProperty:Bt});let zt=Ut;var Zt=Object.defineProperty,Wt=Object.getOwnPropertySymbols,Ht=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Qt=(e,t,r)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Kt=(e,t,r)=>(Qt(e,"symbol"!=typeof t?t+"":t,r),r);let Xt=0;class Yt{constructor(e){Kt(this,"options",{}),Kt(this,"properties"),Kt(this,"tree"),Kt(this,"id",Xt),Xt+=1,this.options=((e,t)=>{for(var r in t||(t={}))Ht.call(t,r)&&Qt(e,r,t[r]);if(Wt)for(var r of Wt(t))Jt.call(t,r)&&Qt(e,r,t[r]);return e})({},e),this.tree=new It(this)}initProperties(){this.properties=new zt(this,this.options.properties)}}var er=Object.defineProperty,tr=Object.defineProperties,rr=Object.getOwnPropertyDescriptors,nr=Object.getOwnPropertySymbols,ir=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable,sr=(e,t,r)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ar=(e,t)=>{for(var r in t||(t={}))ir.call(t,r)&&sr(e,r,t[r]);if(nr)for(var r of nr(t))or.call(t,r)&&sr(e,r,t[r]);return e},lr=(e,t)=>tr(e,rr(t));function cr(e){const t=e.extent_bottom,r=e.extent_left,n=e.extent_top,i=e.extent_right;if(t&&r&&n&&i){const e=[r,t,i,n];return e[3]>82&&(e[3]=82),e[1]<-82&&(e[1]=-82),e}}function ur({resourceId:e,connector:t,cache:r=!0}){return t.get("layer.extent",{cache:r},{id:e}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:i}=e.extent;return[i,n,r,t]}}))}function pr(e){return e.connector.getResource(e.resourceId).then((t=>{if(t)return hr(t,e.connector,e)}))}function hr(e,t,r){if(e.webmap)return L.resolve(cr(e.webmap));{const n=e.resource;return n.cls&&-1!==n.cls.indexOf("style")?t.getResource(n.parent.id).then((e=>{if(e)return ur(lr(ar({},r),{resourceId:e.resource.id,connector:t}))})):ur(lr(ar({},r),{resourceId:n.id,connector:t}))}}var dr=Object.defineProperty,fr=(e,t,r)=>(((e,t,r)=>{t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),yr=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));class mr{constructor(){fr(this,"item"),fr(this,"connector"),fr(this,"_extent")}getExtent(){return yr(this,null,(function*(){return this.getBounds()}))}getBounds(e){return yr(this,null,(function*(){return this._extent?this._extent:this.item?(this._extent=yield hr(this.item,this.connector,e),this._extent):void 0}))}}var gr=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function br(e,t){return gr(this,null,(function*(){const r=e.resource,n=r;let{keyname:i,resourceId:o}=e;if(r&&("string"==typeof r?i=r:o="number"==typeof r?r:n.resource&&void 0!==n.resource&&"resource"in n?r.resource.id:yield br(r,t)),!o&&i){const e=yield t.getResource(i);e&&(o=e.resource.id)}return o}))}const vr={tms:"TILE"};var _r=Object.defineProperty,wr=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable,Pr=(e,t,r)=>t in e?_r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ir=(e,t)=>{for(var r in t||(t={}))Or.call(t,r)&&Pr(e,r,t[r]);if(wr)for(var r of wr(t))Lr.call(t,r)&&Pr(e,r,t[r]);return e},Er=(e,t,r)=>(Pr(e,"symbol"!=typeof t?t+"":t,r),r);const jr="https://qms.nextgis.com";function xr(e,t=jr,r={}){let n;if("webMap"in e){const i=e,{webMap:o,url:s}=i,a=((e,t)=>{var r={};for(var n in e)Or.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&wr)for(var n of wr(e))t.indexOf(n)<0&&Lr.call(e,n)&&(r[n]=e[n]);return r})(i,["webMap","url"]);n=o,s&&(t=s),a&&(r=a)}else n=e;t||(t=jr);class i{constructor(e,t){Er(this,"qms"),Er(this,"options"),Er(this,"map"),this.map=e;const n=Ir(Ir({},r),t);this.options=n,this.options.baselayer=!0,n.qms&&(this.qms=n.qms)}addLayer(e){return r=this,o=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",q(e),!0),n.send()}))}(t+"/api/v1/geoservices/"+e.qmsId)}catch(a){console.error(a)}const r=this.qms;if(r){const t=vr[r.type||"tms"],a=n.mapAdapter.layerAdapters[t];if(a&&(o=i,s=a,["showLayer","hideLayer"].forEach((e=>{const t=Object.getOwnPropertyDescriptor(s.prototype,e);t&&Object.defineProperty(o.prototype,e,t)})),"TILE"===t)){if(e=Ir(Ir({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 o,s},new Promise(((e,t)=>{var n=e=>{try{a(s.next(e))}catch(r){t(r)}},i=e=>{try{a(s.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,i);a((s=s.apply(r,o)).next())}));var r,o,s}}return i}var Ar=Object.defineProperty,Cr=Object.getOwnPropertySymbols,Mr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Sr=(e,t,r)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nr=(e,t)=>{for(var r in t||(t={}))Mr.call(t,r)&&Sr(e,r,t[r]);if(Cr)for(var r of Cr(t))kr.call(t,r)&&Sr(e,r,t[r]);return e},Tr=(e,t,r)=>(Sr(e,"symbol"!=typeof t?t+"":t,r),r);class Fr{constructor(e){Tr(this,"options",{url:"https://qms.nextgis.com"}),Tr(this,"url"),this.options=Nr(Nr({},this.options),e),this.url=this.options.url}getLayerAdapters(){return Promise.resolve([{name:"QMS",createAdapter:e=>Promise.resolve(this._createAdapter(e))}])}_createAdapter(e){return xr({webMap:e,url:this.url})}}Tr(Fr,"utils",{createQmsAdapter:xr});var Br=Object.defineProperty,Rr=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,Dr=Object.getOwnPropertySymbols,qr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty,Gr=Object.prototype.propertyIsEnumerable,Ur=Reflect.get,zr=(e,t,r)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Zr=(e,t)=>{for(var r in t||(t={}))Vr.call(t,r)&&zr(e,r,t[r]);if(Dr)for(var r of Dr(t))Gr.call(t,r)&&zr(e,r,t[r]);return e},Wr=(e,t)=>Rr(e,$r(t)),Hr=(e,t,r)=>Ur(qr(e),r,t),Jr=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function Qr(e){let t;for(t in e){const r=e[t];if(D(r)){const n=r;if(j(n.year)&&j(n.month)&&j(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 Kr=Object.defineProperty,Xr=Object.defineProperties,Yr=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,tn=Object.prototype.hasOwnProperty,rn=Object.prototype.propertyIsEnumerable,nn=(e,t,r)=>t in e?Kr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,on=(e,t)=>{for(var r in t||(t={}))tn.call(t,r)&&nn(e,r,t[r]);if(en)for(var r of en(t))rn.call(t,r)&&nn(e,r,t[r]);return e},sn=(e,t)=>Xr(e,Yr(t));function an(e){const t=e.filters;return t?Xe(sn(on({},e),{filters:t})).then((r=>{var n;return(null!=(n=e.clientFilterValidate)?n:ln(t))&&(r=r.filter((e=>$e(Qr(sn(on({},e.fields),{id:e.id})),t)))),r})):rt(e)}function ln(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(ln(r))return!0}}return!1}function cn(e){return function(e){return an(e).then((e=>{const t=[];return e.forEach((e=>{t.push(Qe(e))})),t}))}(e).then((e=>({type:"FeatureCollection",features:e})))}const un=["fields","intersects","limit","orderBy","strategy"];function pn(e){const t={};return un.forEach((r=>{const n=e[r];void 0!==n&&(t[r]=n)})),t}var hn=Object.defineProperty,dn=Object.defineProperties,fn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertySymbols,mn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,vn=Reflect.get,_n=(e,t,r)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wn=(e,t)=>{for(var r in t||(t={}))gn.call(t,r)&&_n(e,r,t[r]);if(yn)for(var r of yn(t))bn.call(t,r)&&_n(e,r,t[r]);return e},On=(e,t)=>dn(e,fn(t)),Ln=(e,t,r)=>(_n(e,"symbol"!=typeof t?t+"":t,r),r),Pn=(e,t,r)=>vn(mn(e),r,t),In=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function En(e){return In(this,null,(function*(){var t,n;const{item:i,webMap:o,Adapter:s,connector:a,layerOptions:l,addLayerOptionsPriority:c}=e,u=null==c||c,p=l,h=s||o.mapAdapter.layerAdapters.GEOJSON,d=[];let f,y,m=!1;const g=yield br(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,i));const b=(e,t)=>In(this,null,(function*(){return _(),f={filters:e,options:t},y=cn(wn({resourceId:g,filters:e,connector:a,cache:!0},t)),yield y}));let v=!1;const _=()=>{y&&(y.cancel(),y=void 0)};class w extends h{constructor(){super(...arguments),Ln(this,"emitter",new r),Ln(this,"__onMapMove"),Ln(this,"__onMapMoveStart"),Ln(this,"__enableMapMoveListener"),Ln(this,"__disableMapMoveListener")}addLayer(e){return In(this,null,(function*(){let t=!e.data;const r=void 0===e.waitFullLoad||e.waitFullLoad;void 0!==p.id&&(e.id=p.id),i&&i.vector_layer&&(e.type=li[i.vector_layer.geometry_type]),p.adapterOptions&&(e=u?wn(wn({},p.adapterOptions),e):wn(wn({},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 o=Pn(w.prototype,this,"addLayer").call(this,e);let s;return f={filters:e.propertiesFilter,options:pn(e)},t&&(s=this.updateLayer()),r&&s&&(yield s),n&&n.startsWith("BBOX")&&!m&&this._addBboxEventListener(),o}))}getExtent(){return this.getBounds()}getBounds(){return In(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:i.resource.id}):Pn(w.prototype,this,"getBounds")?Pn(w.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,_()}getCount(){return function({connector:e,resourceId:t,cache:r=!0}){return e.get("feature_layer.feature.count",{cache:r},{id:t}).then((e=>e.total_count))}({connector:a,resourceId:g,cache:!0})}updateLayer(e){return In(this,null,(function*(){var t;if(e=e||f||{},null==(t=this.options.strategy)?void 0:t.startsWith("BBOX")){yield o.onLoad("create"),e.options=e.options||{},e.options.intersects=o.getBounds();const{minZoom:t,maxZoom:r}=this.options,n=o.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),o._emitLayerEvent("layer:preupdate",p.id||"",e);const t=yield b(e.filters,On(wn({},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 o.addLayerData(this,r)}else m=void 0!==n&&t.features.length>=n,yield o.setLayerData(this,t);this.emitter.emit("updated",t),o._emitLayerEvent("layer:updated",p.id||"",{data:t,newData:r,isFull:m})}catch(r){if(r instanceof Error&&"CancelError"!==r.name)throw r}Pn(w.prototype,this,"updateLayer")&&Pn(w.prototype,this,"updateLayer").call(this)}}))}propertiesFilter(e,t){return In(this,null,(function*(){if(_(),this.filter&&m)this.filter((t=>{const r=t.feature&&t.feature.properties&&Qr(wn({},t.feature.properties));return!r||$e(r,e)}));else if(this.setData){this.clearLayer&&this.clearLayer();const r=yield b(e,On(wn({},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()},o.emitter.on("layer:show",this.__enableMapMoveListener),o.emitter.on("layer:hide",this.__disableMapMoveListener),this.__enableMapMoveListener(this)}_removeBboxEventListener(){this.__enableMapMoveListener&&o.emitter.on("layer:show",this.__enableMapMoveListener),this.__disableMapMoveListener&&o.emitter.on("layer:hide",this.__disableMapMoveListener)}_addMoveEventListener(){this.__onMapMove=function(e,t=10){let r;function n(...i){n.clear(),r=setTimeout((()=>{r=null,e.apply(this,i)}),t)}return n.clear=function(){r&&(clearTimeout(r),r=null)},n}((()=>this.updateLayer())),this.__onMapMoveStart=_,o.emitter.on("movestart",this.__onMapMoveStart),o.emitter.on("moveend",this.__onMapMove)}_removeMoveEventListener(){this.__onMapMove&&o.emitter.removeListener("moveend",this.__onMapMove),this.__onMapMoveStart&&o.emitter.removeListener("movestart",this.__onMapMoveStart)}}return w}))}var jn=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function xn({options:e,webMap:t,baseUrl:r}){var n;let i,o=e.adapter||"IMAGE";const s=t&&t.getLayerAdapters(),a=e.resource,l=e.tileNoData?e.tileNoData:200;if("number"==typeof a){if("IMAGE"===o){if(!s||s.IMAGE)return function({resourceId:e,baseUrl:t,nd:r,headers:n}){const i=t+"/api/component/render/image",o={resource:e};return r&&(o.nd=r),{url:i,resourceId:e,headers:n,params:o,updateWmsParams:t=>(r&&(t.nd=r),ai(t,e))}}({resourceId:a,headers:e.headers,nd:l,baseUrl:r});o="TILE"}if("WMS"===o){i=`${r}/api/resource/${a}/wms`;const t=e.adapterOptions;return{url:i,format:"image/png",version:"1.1.1",layers:t&&t.layers,headers:e.headers}}if("MVT"===o)return i=r+"/api/component/feature_layer/mvt?x={x}&y={y}&z={z}&resource="+a+"&simplification="+(null!=(n=e.simplification)?n:6),{url:i,sourceLayer:"ngw:"+a,featureIdName:"$id"};if("TERRAIN"===o)return i=r+`/api/resource/${a}/terrain_provider`,{url:i,adapter:o};if("MODEL_3D"===o)return i=r+`/api/component/model_3d/${a}/data.glb`,{url:i};if("TILE"===o)return i=r+"/api/component/render/tile?z={z}&x={x}&y={y}&resource="+a+"&nd="+l,{url:i,adapter:o}}else{if(void 0!==a)throw new Error("Option `resource` must be number, not "+typeof a);console.log("Option `resource` not set")}}var An=Object.defineProperty,Cn=Object.defineProperties,Mn=Object.getOwnPropertyDescriptors,kn=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Tn=(e,t,r)=>t in e?An(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fn=(e,t)=>{for(var r in t||(t={}))Sn.call(t,r)&&Tn(e,r,t[r]);if(kn)for(var r of kn(t))Nn.call(t,r)&&Tn(e,r,t[r]);return e},Bn=(e,t)=>Cn(e,Mn(t)),Rn=(e,t,r)=>(Tn(e,"symbol"!=typeof t?t+"":t,r),r),$n=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function Dn(e){return $n(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const i=n.resource.cls;let o=e.adapter||i&&{wmsserver_service:"WMS",tmsclient_layer:"IMAGE"}[i]||"IMAGE";if(void 0!==o&&(e.adapter=o),"IMAGE"===o){const e=t.getLayerAdapters();!e||e.IMAGE||(o="TILE")}const s=t.mapAdapter.layerAdapters[o];if(s){const i=yield br(e,r);return class extends s{constructor(o,s){super(o,s),this.map=o,Rn(this,"item",n),Rn(this,"resourceId",i);const a=xn({options:e,webMap:t,baseUrl:r.options.baseUrl||""});if(a){const t=Bn(Fn(Fn({},a),e.adapterOptions),{params:{resource:i},layers:a.layers||String(i),resourceId:i});e.adapterOptions&&j(e.adapterOptions.setViewDelay)&&(t.setViewDelay=e.adapterOptions.setViewDelay),this.options=Fn(Fn({},this.options),t)}}addLayer(e){return super.addLayer(Fn(Fn({},this.options),e))}getLegend(e){return $n(this,null,(function*(){const t=yield r.get("render.legend_symbols",Fn({params:{id:i},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 $n(this,null,(function*(){if(this.item){if("MVT"===o)return[this.item.resource.id];const e=this.item.resource.parent.id;if(j(e))return[e]}return[]}))}}}throw new Error(o+" not supported yet. Only TILE")}))}var qn=Object.defineProperty,Vn=Object.defineProperties,Gn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertySymbols,zn=Object.prototype.hasOwnProperty,Zn=Object.prototype.propertyIsEnumerable,Wn=(e,t,r)=>t in e?qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Hn=(e,t)=>{for(var r in t||(t={}))zn.call(t,r)&&Wn(e,r,t[r]);if(Un)for(var r of Un(t))Zn.call(t,r)&&Wn(e,r,t[r]);return e},Jn=(e,t)=>Vn(e,Gn(t)),Qn=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const Kn={},Xn=["mapserver_style","qgis_vector_style","qgis_raster_style","wmsserver_service","raster_style","basemap_layer","vector_layer","raster_layer","postgis_layer","webmap","tmsclient_layer"];function Yn(e){return Qn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r,item:n}){const i=n.resource.id,o=yield r.getResourceChildren(i),s=o&&o[0];if(s)return ei(Jn(Hn({},e),{resource:s.resource.id}),t,r)}))}function ei(e,t,r){return Qn(this,null,(function*(){let n,i;const o=e.adapter,s=yield br(e,r);if(s){const a=e.resource;if(i=a&&a.resource&&void 0!==a.resource.id?a:yield r.getResource(s),!i)throw"Resource item is not found";{const a=i.resource.cls,l={layerOptions:Jn(Hn({},e),{resource:s}),webMap:t,connector:r,item:i};if(-1!==Xn.indexOf(a))if("webmap"===a)n=function(e){return jn(this,arguments,(function*({layerOptions:e,webMap:t,connector:r}){const n=yield br(e,r);return class extends Ri{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||i.vector_layer&&li[i.vector_layer.geometry_type],l.layerOptions.adapterOptions=t,e.adapterOptions=l,void 0!==o&&"GEOJSON"!==o){if("MVT"!==o)return Yn(l);n=Dn(l)}else n=En(l)}else{if("raster_layer"===a)return Yn(l);if("basemap_layer"===a)n=function(e){return Jr(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(Fr.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 Jr(this,null,(function*(){return Hr(e.prototype,this,"addLayer").call(this,Wr(Zr({},t),{url:n}))}))}}return e}}}}))}(l);else if("GEOJSON"===o){const t=yield r.getResource(i.resource.parent.id);if(t){const r=Jn(Hn({},e),{resource:i.resource.parent.id});n=En(Jn(Hn({},l),{item:t,layerOptions:r}))}}else n=Dn(l)}else{if(!Kn[a])throw`Resource class '${a}' not yet supported.`;{const e=Kn[a];let t;t=o&&"function"!=typeof t?e[o]:e,t&&(n=t(l))}}}}if(n)return n.then((e=>{if(e){const t=e;return i&&(t.prototype.item=i,t.prototype.resourceId=i.resource.id,t.prototype.connector=r),E(t,[mr],{replace:!1}),t}}))}))}var ti=Object.defineProperty,ri=Object.getOwnPropertySymbols,ni=Object.prototype.hasOwnProperty,ii=Object.prototype.propertyIsEnumerable,oi=(e,t,r)=>t in e?ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,si=(e,t)=>{for(var r in t||(t={}))ni.call(t,r)&&oi(e,r,t[r]);if(ri)for(var r of ri(t))ii.call(t,r)&&oi(e,r,t[r]);return e};function ai(e,t){const{bbox:r,width:n,height:i,nd:o}=e;return{resource:Array.isArray(t)?t.join(","):t,extent:r,size:n+","+i,timestamp:Date.now(),nd:null!=o?o:200}}const li={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 ci;function ui(e,t=0){const r=t,n=function(){if(void 0===ci){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),ci=t}return ci}()*function(e){return 12756274*Math.PI*Math.cos(e*Math.PI/180)}(r)/e,i=function(e){return Math.log(e/256)/Math.LN2}(n);return i}var pi=Object.defineProperty,hi=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,yi=(e,t,r)=>t in e?pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mi=(e,t)=>{for(var r in t||(t={}))di.call(t,r)&&yi(e,r,t[r]);if(hi)for(var r of hi(t))fi.call(t,r)&&yi(e,r,t[r]);return e},gi=(e,t,r)=>(yi(e,"symbol"!=typeof t?t+"":t,r),r),bi=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const vi=class e extends Yt{constructor(t,n,i,o,s,a){if(super(mi(mi({},e.options),i)),this.webMap=t,gi(this,"item"),gi(this,"connector"),gi(this,"layer"),gi(this,"emitter",new r),gi(this,"_rootDescendantsCount",0),o&&(this.connector=o),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,i,o){return bi(this,null,(function*(){const s=new e(t,r,n,i,o,!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 bi(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",mi({params:{id:this.item.resourceId},cache:!0},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={visibility:!1,name:e.display_name,headers:this.options.headers,crossOrigin:this.options.crossOrigin,setViewDelay:this.options.setViewDelay,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,{updateWmsParams:e.updateWmsParams,url:e.url,headers:this.options.headers,ratio:this.options.ratio,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 ui(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 i;if("layer"===t.item_type)i=t.adapter||t.layer_adapter.toUpperCase();else if(e.GetAdapterFromLayerType[t.item_type]){i=(0,e.GetAdapterFromLayerType[t.item_type])(t,r,this.webMap,this.connector)}return i?this.webMap.addLayer(i,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,i=e.layer_max_scale_denom?this._mapScaleToZoomLevel(e.layer_max_scale_denom):void 0,o=[t,n].filter(Boolean),s=[r,i].filter(Boolean);return{minZoom:o.length?Math.max(...o):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}};gi(vi,"GetAdapterFromLayerType",{}),gi(vi,"options",{properties:[{type:"boolean",name:"visibility",getProperty(e){if(e){if("group"===e.item.item_type||"root"===e.item.item_type)return mt(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 xt{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 _i=vi;var wi=Object.defineProperty,Oi=Object.getOwnPropertySymbols,Li=Object.prototype.hasOwnProperty,Pi=Object.prototype.propertyIsEnumerable,Ii=(e,t,r)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ei=(e,t)=>{for(var r in t||(t={}))Li.call(t,r)&&Ii(e,r,t[r]);if(Oi)for(var r of Oi(t))Pi.call(t,r)&&Ii(e,r,t[r]);return e},ji=(e,t,r)=>(Ii(e,"symbol"!=typeof t?t+"":t,r),r),xi=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));function Ai(e){return t=this,r=arguments,n=function*({webMap:e,connector:t,item:r,adapterOptions:n={},idPrefix:i="first-show-adapter"}){const o=function(e){return xi(this,arguments,(function*({webMap:e,adapterOptions:t={},onLayerAdded:r,createAdapter:n}){return class{constructor(){ji(this,"options",{}),ji(this,"layer",[]),ji(this,"_removed",!1),ji(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 xi(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 xi(this,null,(function*(){if(this.options.visibility=!1,this.layer)for(const t of this.layer)yield e.hideLayer(t)}))}loadLayer(){return xi(this,null,(function*(){if(!this.layer.length&&!this._creatingInProgress){this._creatingInProgress=!0;const i=yield n(this);if(i){const n=new i(e.mapAdapter.map,Ei({},t)),o=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=o,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=i+"-"+r.resource_id},createAdapter:()=>ei({resource:r.resource_id,adapterOptions:{name:r.display_name,opacity:r.opacity}},e,t)});return o},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n}var Ci=Object.defineProperty,Mi=Object.getOwnPropertySymbols,ki=Object.prototype.hasOwnProperty,Si=Object.prototype.propertyIsEnumerable,Ni=(e,t,r)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ti=(e,t)=>{for(var r in t||(t={}))ki.call(t,r)&&Ni(e,r,t[r]);if(Mi)for(var r of Mi(t))Si.call(t,r)&&Ni(e,r,t[r]);return e},Fi=(e,t,r)=>(Ni(e,"symbol"!=typeof t?t+"":t,r),r),Bi=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));class Ri{constructor(e,t){this.map=e,this.options=t,Fi(this,"layer"),Fi(this,"NgwWebmapItem",_i),Fi(this,"pixelRadius",10),Fi(this,"resourceId"),Fi(this,"webmapClassName","webmap"),Fi(this,"emitter",new r),Fi(this,"_extent"),Fi(this,"response"),Fi(this,"_webmapLayersIds"),Fi(this,"_webmapBaselayersIds",[]),Fi(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 Bi(this,null,(function*(){var t,r;this.options=Ti(Ti({},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 Bi(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!0)}))}hideLayer(){return Bi(this,null,(function*(){if(this.layer&&this.layer.properties)return this.layer.properties.property("visibility").set(!1)}))}setOpacity(e){return Bi(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 cr(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(){const e=this.getBookmarksResourceId(),t=this.options.connector;if(e)return t.getResourceOrFail(e).then((r=>{var n;const i=null==(n=r.feature_layer)?void 0:n.fields.find((e=>e.label_field)),o=i&&i.keyname;return an({connector:t,resourceId:e,geom:!1,fields:o?[o]:void 0}).then((r=>{const n=[];for(const i of r){const r=new yt({item:i,resourceId:e,labelField:o,connector:t});n.push(r)}return n}))}));throw new Error("Webmap was not loaded correctly, it is impossible to extract bookmarks")}getLegend(){return Bi(this,null,(function*(){const e=[];let t=this.getDependLayers();t=t.sort(((e,t)=>t.id-e.id));for(const r of t){const t=yield r.getLegend();e.push(...t)}return e}))}getIdentificationIds(){return Bi(this,null,(function*(){const e=[];let t=this._webmapLayersIds;if(t||(t=yield this._getWebMapIds(),this._webmapLayersIds=t),t&&t.length){let t=this.getDependLayers();t=t.sort(((e,t)=>t.id-e.id)),t.forEach((t=>{const r=t.item,n=r.parentId;if(void 0!==n&&"layer"===r.item_type&&r.layer_identifiable){const r=t.properties.property("visibility");r.get()&&!r.isBlocked()&&e.push(n)}}))}return e}))}_getWebMapLayerItem(){return Bi(this,null,(function*(){if(this.resourceId){const e=yield this.getWebMapConfig(this.resourceId);if(e&&e.root_item)return new Promise((t=>{const r={};if(this.options.connector&&this.options.connector.options.auth){const e=this.options.connector.getAuthorizationHeaders();e&&(r.headers=e)}r.setViewDelay=this.options.setViewDelay,r.order=this.options.order,r.ratio=this.options.ratio,r.crossOrigin=this.options.crossOrigin,r.minZoom=this.options.minZoom,r.maxZoom=this.options.maxZoom,r.drawOrderEnabled=e.draw_order_enabled,r.popupOptions=this.options.popupOptions;const n=new this.NgwWebmapItem(this.options.webMap,e.root_item,r,this.options.connector);n.emitter.on("init",(()=>t(n)))}))}}))}getWebMapConfig(e){return Bi(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)Ai({webMap:t,connector:this.options.connector,item:n,adapterOptions:{crossOrigin:this.options.crossOrigin}}).then((e=>{const i=!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:i}).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=q(this.options.connector.options.baseUrl+"/api/component/render/image"),n=e.layer_style_id;e.url=r,e.resourceId=n,e.updateWmsParams=e=>ai(e,n);const i=xn({options:{adapter:e.layer_adapter.toUpperCase(),resource:n},webMap:t,baseUrl:this.options.connector.options.baseUrl||""});e=Ti(Ti({},e),i)}return e}_getWebMapIds(){return Bi(this,null,(function*(){const e=this.layer;if(e&&"root"===e.item.item_type){const t=e.tree.getDescendants(),r=[];for(const e of t){const t=e.item;if("layer"===t.item_type){const e=this.options.connector.getResource(t.layer_style_id).then((e=>{if(e){const r=Number(e.resource.parent.id);return t.parentId=r,r}}));r.push(e)}}return(yield Promise.all(r)).filter((e=>void 0!==e))}}))}}var $i=Object.defineProperty,Di=Object.getOwnPropertySymbols,qi=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable,Gi=(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)&&Gi(e,r,t[r]);if(Di)for(var r of Di(t))Vi.call(t,r)&&Gi(e,r,t[r]);return e},zi=(e,t,r)=>(Gi(e,"symbol"!=typeof t?t+"":t,r),r);class Zi{constructor(e){if(this.options=e,zi(this,"url"),zi(this,"connector"),zi(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 Ae({baseUrl:this.url,auth:this.options.auth})}}static addClassAdapters(e,t){Kn[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(Ri,Ui({visibility:!0,fit:!0,pixelRadius:this.options.pixelRadius},t))}}},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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 Ri{constructor(e,r){super(e,r=si(si({},t),r))}};var t}}var Wi=Object.defineProperty,Hi=Object.getOwnPropertySymbols,Ji=Object.prototype.hasOwnProperty,Qi=Object.prototype.propertyIsEnumerable,Ki=(e,t,r)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xi=(e,t,r)=>(Ki(e,"symbol"!=typeof t?t+"":t,r),r);class Yi{constructor(e){Xi(this,"id"),Xi(this,"label"),Xi(this,"layerId"),Xi(this,"parent"),Xi(this,"fields"),Xi(this,"geom"),Xi(this,"extensions"),Xi(this,"connector"),Xi(this,"_item"),Xi(this,"_geojson"),Xi(this,"_resource"),Xi(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?L.resolve(this._item):ht(((e,t)=>{for(var r in t||(t={}))Ji.call(t,r)&&Ki(e,r,t[r]);if(Hi)for(var r of Hi(t))Qi.call(t,r)&&Ki(e,r,t[r]);return e})({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(){return this._resource?L.resolve(this._resource.feature_layer):this.connector.getResource(this.layerId).then((e=>(this._resource=e,this._resource.feature_layer)))}getBounds(){return this._extent?L.resolve(this._extent):function({resourceId:e,featureId:t,connector:r,cache:n=!0}){return r.get("feature_layer.feature.item_extent",{cache:n},{id:e,fid:t}).then((e=>{if(e){const{maxLat:t,maxLon:r,minLat:n,minLon:i}=e.extent;return[i,n,r,t]}}))}({connector:this.connector,featureId:this.id,resourceId:this.layerId})}geojson(){return this._geojson?L.resolve(this._geojson):this.identify().then((e=>e.toGeojson().then((e=>(this._geojson=e,e)))))}}function eo(e){return ht(e).then((e=>Qe(e)))}var to=Object.defineProperty,ro=Object.defineProperties,no=Object.getOwnPropertyDescriptors,io=Object.getOwnPropertySymbols,oo=Object.prototype.hasOwnProperty,so=Object.prototype.propertyIsEnumerable,ao=(e,t,r)=>t in e?to(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lo=(e,t)=>{for(var r in t||(t={}))oo.call(t,r)&&ao(e,r,t[r]);if(io)for(var r of io(t))so.call(t,r)&&ao(e,r,t[r]);return e},co=(e,t)=>ro(e,no(t));function uo(e,t=!1){const r=[],n=[];for(const o in e){const e=Number(o);isNaN(e)||r.push(e)}const i=e.resources;i&&r.sort(((e,t)=>i.indexOf(e)-i.indexOf(t)));for(let o=0;o<r.length;o++){const i=r[o],s=e[i];if("features"in s){const e=po(s.features,Number(i),t);if(e.length&&(n.push(...e),!t))break}}return n}function po(e,t,r){const n=[];for(const i of e){if(n.push({featureId:i.id,resourceId:t,feature:i}),!r)break}return n}function ho(e){const{geom:t,signal:r,cache:n,layers:i}=e,o="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]=F(e,t);return`${r} ${n}`})).join(",")}))`}(t);if(!o)throw new Error("Not valid geometry format to make intersection");return e.connector.post("feature_layer.identify",{data:{geom:o,srs:3857,layers:i},signal:r,cache:n})}function fo(e,t){C(e);const[r,n]=e.lngLat,{geom:i,radius:o,signal:s,cache:a}=t,l=null!=i?i:function(e,t,r=10,n=6){const i=r/M*T,o=i/Math.cos(t*N),s=[];for(let a=0;a<n+1;a++){const r=Math.PI*(a/(n/2)),l=e+o*Math.cos(r),c=t+i*Math.sin(r);s.push([l,c])}return s}(r,n,o);return ho(co(lo({},t),{geom:l,signal:s,cache:a}))}function yo(e,t){return r=this,n=null,i=function*(){var r;const n=yield e.get("pyramid.settings",null,{component:"pyramid"});if(n&&n.company_logo&&n.company_logo.enabled){const o=document.createElement("a");o.style.position="absolute",o.style.bottom="0",o.style.right="0",o.style.padding=null!=(r=null==t?void 0:t.padding)?r:"10px",o.className="ngw-map-logo",t&&t.cssClass&&(o.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(i){console.warn(i)}return null!==n.company_logo.link&&""!==n.company_logo.link.trim()&&(o.href=n.company_logo.link,o.target="_blank",-1!==n.company_logo.link.search(/:\/\/nextgis/)&&(s.alt="Get your own Web GIS at nextgis.com")),o.appendChild(s),o}},new Promise(((e,t)=>{var o=e=>{try{a(i.next(e))}catch(r){t(r)}},s=e=>{try{a(i.throw(e))}catch(r){t(r)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((i=i.apply(r,n)).next())}));var r,n,i}function mo(e){return"function"==typeof e}function go(e){return(t,r)=>{const n=t.map((e=>e()));return e(n,r)}}const bo={"!":go((function([e]){return!e})),"!=":go((function([e,t]){return e!==t})),"<":go((function([e,t]){return e<t})),"<=":go((function([e,t]){return e<=t})),"==":go((function([e,t]){return e===t})),">":go((function([e,t]){return e>t})),">=":go((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(),i=r.splice(-1,r.length%2)[0];for(let o=0;o<r.length-1;o+=2){if(r[o]()===n)return r[o+1]()}return i()}},vo={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 _o(e){if("string"==typeof(r=e)&&/^#([A-Fa-f0-9]{3}){1,2}$/.test(r))return wo(e);if("string"==typeof(t=e)&&t in vo)return function(e){return wo(vo[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 wo(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 Oo(e,t,r,n,i){if("number"==typeof r&&"number"==typeof i)return r+(e-t)/(n-t)*(i-r);try{const o=_o(r),s=_o(i);return function(e){return`rgb(${e.join(",")})`}(o.map(((r,i)=>Math.ceil(Oo(e,t,r,n,s[i])))))}catch(o){console.log(o)}throw new Error("Unsupported output type for linear interpolation.")}const Lo={step:e=>{const[t,r,...n]=e,i=t();if("number"!=typeof i)return r();for(let o=0;o<n.length-2;o+=2){const e=n[o](),t=n[o+1](),r=n[o+2]();if(i>=e&&i<r)return t}return i>=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 i=e();for(let o=0;o<r.length-2;o+=2){const e=r[o](),t=r[o+1](),s=r[o+2](),a=r[o+3]();if(n>=e&&n<=s&&"linear"===i[0])return Oo(n,e,t,s,a)}throw new Error("Invalid interpolation type.")}};const Po={get:go((function([e,t],r){const n=t||r;return n&&"object"==typeof n&&e in n?n[e]:null})),length:go((([e])=>{if("string"==typeof e||Array.isArray(e))return e.length})),at:go((function([e,t]){return t[e]})),has:go((function([e,t],r){const n=t||r;return!(!n||"object"!=typeof n||!(e in n))})),in:go((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":go((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:go((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}.`)}))},Io={"+":go((e=>e.reduce(((e,t)=>e+t),0))),"-":go((e=>e.reduce(((e,t)=>e-t)))),"*":go((e=>e.reduce(((e,t)=>e*t),1))),"/":go((e=>e.reduce(((e,t)=>e/t)))),"%":go((e=>e[0]%e[1])),"^":go((e=>Math.pow(e[0],e[1]))),abs:go((e=>Math.abs(e[0]))),acos:go((e=>Math.acos(e[0]))),asin:go((e=>Math.asin(e[0]))),atan:go((e=>Math.atan(e[0]))),ceil:go((e=>Math.ceil(e[0]))),cos:go((e=>Math.cos(e[0]))),e:()=>Math.E,floor:go((e=>Math.floor(e[0]))),ln:go((e=>Math.log(e[0]))),ln2:()=>Math.LN2,log10:go((e=>Math.log10(e[0]))),log2:go((e=>Math.log2(e[0]))),max:go((e=>Math.max(...e))),min:go((e=>Math.min(...e))),pi:()=>Math.PI,round:go((e=>Math.round(e[0]))),sin:go((e=>Math.sin(e[0]))),sqrt:go((e=>Math.sqrt(e[0]))),tan:go((e=>Math.tan(e[0])))},Eo={concat:go((e=>e.reduce(((e,t)=>String(e)+String(t)),""))),downcase:go((e=>String(e[0]).toLowerCase())),upcase:go((e=>String(e[0]).toUpperCase()))},jo=(e,t,r)=>{try{const n=e(t,r);if(void 0!==n)return n}catch(n){}};function xo(e){return(t,r)=>{for(const n of t){const t=jo(e,n,r);if(void 0!==t)return t}throw new Error("Received a mismatched type")}}const Ao={array:go((e=>{const[t,r,n]=e;let i,o,s;if("string"==typeof t&&["string","number","boolean"].includes(t)?(i=t,"number"==typeof r?(o=r,s=n):s=r):Array.isArray(t)&&(s=t),!Array.isArray(s))throw new Error("Expected an array");if(i&&!s.every((e=>typeof e===i)))throw new Error(`Expected all items in array to be of type ${i}`);if(o&&s.length!==o)throw new Error(`Expected array of length ${o}`);return s})),boolean:go(xo((e=>"boolean"==typeof e?e:void 0))),literal:go((([e])=>e)),number:go(xo((e=>"number"==typeof e?e:void 0))),object:go(xo((e=>null===e||"object"!=typeof e||Array.isArray(e)?void 0:e))),string:go(xo((e=>"string"==typeof e?e:void 0))),"to-boolean":go(xo(Boolean)),"to-number":go(xo(Number)),"to-string":go(xo(String)),typeof:go((([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 Co=Object.defineProperty,Mo=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable,No=(e,t,r)=>t in e?Co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,To=(e,t)=>{for(var r in t||(t={}))ko.call(t,r)&&No(e,r,t[r]);if(Mo)for(var r of Mo(t))So.call(t,r)&&No(e,r,t[r]);return e};function Fo(e){if(Array.isArray(e)){const[t,...r]=e;return"string"==typeof t&&"literal"!==t&&t in Bo&&r.length>0}return!1}const Bo=To(To(To(To(To(To({},Io),Ao),Eo),Po),bo),Lo);function Ro(e,t={}){const[r,...n]=e,i=Bo[r];if(i)return i(n.map((e=>()=>Fo(e)?Ro(e,t):e)),t);throw new Error(`Expression "${r}" is not supported.`)}var $o=Object.defineProperty,Do=Object.getOwnPropertySymbols,qo=Object.prototype.hasOwnProperty,Vo=Object.prototype.propertyIsEnumerable,Go=(e,t,r)=>t in e?$o(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)&&Go(e,r,t[r]);if(Do)for(var r of Do(t))Vo.call(t,r)&&Go(e,r,t[r]);return e};function zo(e){return t=>{const r=t.properties;return!!r&&Ro(e,r)}}const Zo=["iconSize","iconAnchor"];var Wo=Object.defineProperty,Ho=Object.getOwnPropertySymbols,Jo=Object.prototype.hasOwnProperty,Qo=Object.prototype.propertyIsEnumerable,Ko=(e,t,r)=>t in e?Wo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Xo=(e,t)=>{for(var r in t||(t={}))Jo.call(t,r)&&Ko(e,r,t[r]);if(Ho)for(var r of Ho(t))Qo.call(t,r)&&Ko(e,r,t[r]);return e};function Yo(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=Te({},e.properties);return!!r&&(r.$id=e.id,$e(r,t))}(e,t[0])));return n?Xo(Xo({},t),n[1]):t}}function es({paint:e,defaultPaint:t}){const r=function(e){let t=!1;const r={};for(const n in e)if(-1===Zo.indexOf(n)){const i=n,o=e[i];Fo(o)&&(t=!0,r[i]=zo(o))}if(t)return t=>{const n={};for(const e in r)n[e]=r[e](t);return Uo(Uo({},e),n)}}(e);if(r){const n=e=>rs({paint:r(e),defaultPaint:t});return n.paint=ts({paint:e,defaultPaint:t}),n}return ts({paint:e,defaultPaint:t})}function ts({paint:e,defaultPaint:t}){var r;let n=Xo({},t);return n=Xo(Xo({},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 rs({paint:e,defaultPaint:t,getPaintFunctions:r}){if(!e)throw new Error("paint is empty");let n=Xo({},t);if(mo(e)){const n=n=>{const i=rs({paint:e(n),defaultPaint:t,getPaintFunctions:r});return i.type=e.type,i};return n.type=e.type,n}if(function(e){return!!Array.isArray(e)}(e))return n=>rs({paint:Yo(e)(n),defaultPaint:t,getPaintFunctions:r});if("get-paint"===e.type){const i=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);i&&(n=rs({paint:i,defaultPaint:t,getPaintFunctions:r}))}else{if("icon"===e.type)return e;n=es({paint:e,defaultPaint:t})}return mo(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 ns=Object.defineProperty,is=(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),r);class os{constructor(){is(this,"backspace",8),is(this,"tab",9),is(this,"enter",13),is(this,"shift",16),is(this,"ctrl",17),is(this,"alt",18),is(this,"pause/break",19),is(this,"caps_lock",20),is(this,"escape",27),is(this,"page_up",33),is(this,"page_down",34),is(this,"end",35),is(this,"home",36),is(this,"left_arrow",37),is(this,"up_arrow",38),is(this,"right_arrow",39),is(this,"down_arrow",40),is(this,"insert",45),is(this,"delete",46),is(this,"left_window_key",91),is(this,"right_window_key",92),is(this,"select_key",93),is(this,"numpad_0",96),is(this,"numpad_1",97),is(this,"numpad_2",98),is(this,"numpad_3",99),is(this,"numpad_4",100),is(this,"numpad_5",101),is(this,"numpad_6",102),is(this,"numpad_7",103),is(this,"numpad_8",104),is(this,"numpad_9",105),is(this,"multiply",106),is(this,"add",107),is(this,"subtract",109),is(this,"decimal_point",110),is(this,"divide",111),is(this,"f1",112),is(this,"f2",113),is(this,"f3",114),is(this,"f4",115),is(this,"f5",116),is(this,"f6",117),is(this,"f7",118),is(this,"f8",119),is(this,"f9",120),is(this,"f10",121),is(this,"f11",122),is(this,"f12",123),is(this,"num_lock",144),is(this,"scroll_lock",145),is(this,"semi-colon",186),is(this,"equal_sign",187),is(this,",",188),is(this,"-",189),is(this,".",190),is(this,"/",191),is(this,"`",192),is(this,"[",219),is(this,"\\",220),is(this,"]",221),is(this,"'",222)}}var ss=Object.defineProperty,as=(e,t,r)=>(((e,t,r)=>{t in e?ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);var ls=Object.defineProperty,cs=(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),r);class us{constructor(e,t){this.webMap=e,cs(this,"name"),cs(this,"event"),cs(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 ps=Object.defineProperty,hs=(e,t,r)=>(((e,t,r)=>{t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ds extends us{constructor(){super(...arguments),hs(this,"name","center"),hs(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 fs=Object.defineProperty,ys=(e,t,r)=>(((e,t,r)=>{t in e?fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class ms extends us{constructor(){super(...arguments),ys(this,"name","zoom"),ys(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 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),r),vs=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));let _s=0;const ws={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},Os=class e{constructor(t){bs(this,"options",ws),bs(this,"emitter",new r),bs(this,"keys",e.keys),bs(this,"mapAdapter"),bs(this,"runtimeParams",[]),bs(this,"getPaintFunctions",e.getPaintFunctions),bs(this,"mapState",[ds,ms]),bs(this,"id",_s++),bs(this,"_initMapState",{}),bs(this,"_starterKits"),bs(this,"_mapState",[]),bs(this,"_extent"),bs(this,"_eventsStatus",{}),bs(this,"_coordFromMapClickPromise"),bs(this,"_mapEvents",{}),this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=A(ws||{},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 vs(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:k(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&&j(t)?this.mapAdapter.setView(r,t):(r&&this.mapAdapter.setCenter(r),j(t)&&this.mapAdapter.setZoom(t))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(e,t){return e.every((e=>j(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)},i=null==(r=this.mapAdapter.isLoaded)||r;this.mapAdapter.map&&i?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._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new L(((e,t,r)=>{const n=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const i=()=>{this.setCursor(n),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=t=>{i(),C(t),e(t.lngLat)};this.mapAdapter.emitter.once("click",o),r(i)})),this._coordFromMapClickPromise)}_emitStatusEvent(e,t){const r=e;this._eventsStatus[r]=!0,this.emitter.emit(r,t)}_addLayerProviders(){return vs(this,null,(function*(){}))}_onLoadSync(){return vs(this,null,(function*(){}))}_setupMap(){return vs(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),j(e.maxzoom)&&(this.options.zoom=e.maxzoom),j(e.minzoom)&&(this.options.zoom=e.minzoom),j(e.maxzoom)&&j(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)}_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)}))}};bs(Os,"keys",new class{constructor(){as(this,"keyCodeAlias",new os),as(this,"keys",{}),as(this,"_windowOnFocus"),as(this,"_keysPressed"),as(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={}}}),bs(Os,"getPaintFunctions");let Ls=Os;function Ps(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 Is(e){let t;if("FeatureCollection"===e.type){t=Ps(e.features.map((e=>e.geometry.type)))}else if("GeometryCollection"===e.type){t=Ps(e.geometries.map((e=>e.type)))}else t="Feature"===e.type?e.geometry.type:e.type;return t}const Es={polygon:"path",line:"path",point:"circle"},js={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function xs(e){if(e.data){const t=js[Is(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":Es[t]),e.type=e.type||t}return e}var As=Object.defineProperty,Cs=Object.defineProperties,Ms=Object.getOwnPropertyDescriptors,ks=Object.getOwnPropertySymbols,Ss=Object.prototype.hasOwnProperty,Ns=Object.prototype.propertyIsEnumerable,Ts=(e,t,r)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Fs=(e,t)=>{for(var r in t||(t={}))Ss.call(t,r)&&Ts(e,r,t[r]);if(ks)for(var r of ks(t))Ns.call(t,r)&&Ts(e,r,t[r]);return e},Bs=(e,t)=>Cs(e,Ms(t)),Rs=(e,t,r)=>(Ts(e,"symbol"!=typeof t?t+"":t,r),r),$s=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));class Ds extends Ls{constructor(e){super(e),Rs(this,"_layersIdCounter",1),Rs(this,"_layersOrderCounter",1),Rs(this,"_baselayers",[]),Rs(this,"_layers",{}),Rs(this,"_selectedLayers",[]);const t=this.options.tileJson;t&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(t)))}fitLayer(e,t){return $s(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 $s(this,null,(function*(){return yield this.addLayer(e,Bs(Fs({},t),{baselayer:!0}),void 0)}))}addLayer(e){return $s(this,arguments,(function*(e,t={},r){var n,i;const o=this._layersIdCounter++,s=j(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=Fs({id:String(o),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=Fs(Fs({},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(o),e.options.id=e.id,t.baselayer&&(e.options.order=0),e.order=null!=(i=e.options.order)?i: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 $s(this,null,(function*(){const n=r||void 0!==t.order?t.order:this.reserveOrder(),i=e(),o=yield i;return o?this.addLayer(o,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 $s(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=xs(e)),e.paint=e.paint||{},this.addLayer(t||"GEOJSON",e)}addFeatureLayer(e={}){return this.addGeoJsonLayer(e)}addTileLayer(e,t={}){return this.addLayer("TILE",Bs(Fs({},t),{url:e}))}addImageLayer(e,t){let r;return"string"==typeof e?r=e:(r=e.url,t=e),this.addLayer("IMAGE",Bs(Fs({},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),i=void 0!==t?t:!(n&&n.options.visibility),o=void 0!==r.silent&&r.silent,s=e=>$s(this,null,(function*(){const t=String(e.id),r=i?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(i?"layer:preshow":"layer:prehide",t,e),this._emitLayerEvent("layer:pretoggle",t,e)),i&&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=i,o||(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||$e(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 i=!(void 0===e.onlyVisible||e.onlyVisible)||n.options.visibility;if(i&&e.onlyBaselayer&&(i=this._baselayers.includes(r)),i){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(j(t)&&n.startsWith("layer:")){const e=n.replace("layer:","layer-"+t+":");this.emitter.emit(e,r)}this.emitter.emit(e,r)}_onLayerClick(e){return $s(this,null,(function*(){return this._emitLayerEvent("layer:click",e.layer.id||"",e),Promise.resolve(e)}))}_onLayerSelect(e){return $s(this,null,(function*(){return this._emitLayerEvent("layer:select",e.layer.id||"",e),Promise.resolve(e)}))}_updateGeoJsonOptions(e){const{onSelect:t,onLayerSelect:r,onClick:n,onLayerClick:i,onMouseOut:o,onMouseOver:s}=e,a=n||i;e.onClick=e=>(a&&a(e),this._onLayerClick(e)),e.onMouseOut=e=>{const t=e.layer.id;o&&o(e),j(t)&&this._emitLayerEvent("layer:mouseout",t,e)},e.onMouseOver=e=>{const t=e.layer.id;s&&s(e),j(t)&&this._emitLayerEvent("layer:mouseover",t,e)};const l=t||r;e.onSelect=e=>(l&&l(e),this._onLayerSelect(e)),e.nativePaint||(this.options.paint&&(e.paint=rs({paint:e.paint||{},defaultPaint:this.options.paint,getPaintFunctions:this.getPaintFunctions})),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=rs({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 i=t.title||"",o=t.html;function s(){i&&(r.title="string"==typeof i?i:n?i.on:i.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(){o&&("string"==typeof o||o instanceof HTMLElement?a(o):a(n?o.on:o.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 Vs=Object.defineProperty,Gs=(e,t,r)=>(((e,t,r)=>{t in e?Vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),Us=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const zs=class e extends Ds{constructor(){super(...arguments),Gs(this,"_loadControlQueue",{"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]}),Gs(this,"_isControlLoading",{"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1})}addControl(e,t,r){return Us(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,(()=>Us(this,null,(function*(){const r=yield n,i=this.mapAdapter.addControl(r,t);e(i)}))))}))}))}createControl(e,t){return Us(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(e,t)}))}createButtonControl(e){return Us(this,null,(function*(){if(yield this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(e)}))}createToggleControl(e){return Us(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 Us(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}))}};Gs(zs,"controls",{CONTROL:(e,t)=>e.createControl(t.control,t.options),BUTTON:(e,t)=>e.createButtonControl(t),TOGGLE:(e,t)=>e.createToggleControl(t)});let Zs=zs;const Ws={};function Hs(e){return Ws[e]}function Js(e,t){Ws[e]=t}var Qs=Object.getOwnPropertySymbols,Ks=Object.prototype.hasOwnProperty,Xs=Object.prototype.propertyIsEnumerable,Ys=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),ea=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())})),ta=(e,t,r)=>(t=e[Ys("asyncIterator")])?t.call(e):(e=e[Ys("iterator")](),t={},r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,i,o)=>(t=n.call(e,t),o=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:o})),i))))),r("next"),r("return"),t);class ra extends Zs{constructor(e){super(e),this._addControls(),Js(this.id,this)}static get(e){return Hs(e)}_addLayerProviders(){return ea(this,null,(function*(){try{for(var e,t,r,n=ta(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 i,o,s,a=ta(t);i=!(o=yield a.next()).done;i=!1){const e=o.value,t=yield e.createAdapter(this);t&&(this.mapAdapter.layerAdapters[e.name]=t)}}catch(o){s=[o]}finally{try{i&&(o=a.return)&&(yield o.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 ea(this,null,(function*(){try{for(var e,t,r,n=ta(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(i){console.error(i)}}}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:i}=n,o=((e,t)=>{var r={};for(var n in e)Ks.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&Qs)for(var n of Qs(e))t.indexOf(n)<0&&Xs.call(e,n)&&(r[n]=e[n]);return r})(n,["position"]);this.addControl(t,i||"top-left",o)})),this._emitStatusEvent("controls:create")}}function na(){return["ZOOM","ATTRIBUTION"]}var ia=Object.defineProperty,oa=Object.defineProperties,sa=Object.getOwnPropertyDescriptors,aa=Object.getOwnPropertySymbols,la=Object.prototype.hasOwnProperty,ca=Object.prototype.propertyIsEnumerable,ua=(e,t,r)=>t in e?ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pa=(e,t)=>{for(var r in t||(t={}))la.call(t,r)&&ua(e,r,t[r]);if(aa)for(var r of aa(t))ca.call(t,r)&&ua(e,r,t[r]);return e},ha=(e,t)=>oa(e,sa(t));function da(e,t,r,n){if("number"==typeof t||"string"==typeof t)t=Number(t),e.push(ha(pa({},r),{resource:t}));else if(Array.isArray(t)){const[i,o]=t;e.push(pa(ha(pa({},r),{resource:i,id:o}),n))}else"object"==typeof t&&e.push(pa(pa(pa({},r),t),n))}var fa=Object.defineProperty,ya=Object.defineProperties,ma=Object.getOwnPropertyDescriptors,ga=Object.getOwnPropertySymbols,ba=Object.prototype.hasOwnProperty,va=Object.prototype.propertyIsEnumerable,_a=(e,t,r)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const wa={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 Oa(e){const t=[new Fr];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 Ae({baseUrl:e.baseUrl||"",auth:e.auth}),(e=A(wa,e)).center||e.bounds||(e.bounds=[-179,-90,180,90]),e.connector&&t.push(new Zi({connector:e.connector,auth:e.auth})),r=((e,t)=>{for(var r in t||(t={}))ba.call(t,r)&&_a(e,r,t[r]);if(ga)for(var r of ga(t))va.call(t,r)&&_a(e,r,t[r]);return e})({},e),e=ya(r,ma({starterKits:t,create:!1}))}var La=Object.defineProperty,Pa=Object.defineProperties,Ia=Object.getOwnPropertyDescriptors,Ea=Object.getOwnPropertySymbols,ja=Object.getPrototypeOf,xa=Object.prototype.hasOwnProperty,Aa=Object.prototype.propertyIsEnumerable,Ca=Reflect.get,Ma=(e,t,r)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ka=(e,t)=>{for(var r in t||(t={}))xa.call(t,r)&&Ma(e,r,t[r]);if(Ea)for(var r of Ea(t))Aa.call(t,r)&&Ma(e,r,t[r]);return e},Sa=(e,t)=>Pa(e,Ia(t)),Na=(e,t,r)=>(Ma(e,"symbol"!=typeof t?t+"":t,r),r),Ta=(e,t,r)=>Ca(ja(e),r,t),Fa=(e,t,r)=>new Promise(((n,i)=>{var o=e=>{try{a(r.next(e))}catch(t){i(t)}},s=e=>{try{a(r.throw(e))}catch(t){i(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((r=r.apply(e,t)).next())}));const Ba=class e extends ra{constructor(e){super(Oa(e)),Na(this,"emitter",new r),Na(this,"connector"),Na(this,"_ngwLayers",{}),Na(this,"$$selectFromNgwRaster"),Na(this,"$$selectFromNgwVector"),Na(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 Fa(this,null,(function*(){return yield this.onLoad("controls:create"),Ta(e.prototype,this,"addControl").call(this,t,r,n)}))}addNgwLayer(e){return Fa(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(j(this.options.baseUrl))try{j(this.options.setViewDelay)&&(e.adapterOptions=e.adapterOptions||{},j(e.adapterOptions.setViewDelay)||(e.adapterOptions.setViewDelay=this.options.setViewDelay));const t=function(e,t,r){const n=r.getAuthorizationHeaders();return n&&(e.headers=n),ei(e,t,r)}(e,this,this.connector),r=ka(ka({visibility:!0},e),e.adapterOptions),n=yield this.addLayer(t,r),i=n&&this.getLayerId(n);if(n&&i&&(this._ngwLayers[i]={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(i){const e=D(n)&&"id"in n?n.id:t||r||n;console.error(`Can't add NGW layer ${e}.`,i)}}))}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 ht(ka({connector:this.connector},e))}fetchNgwLayerItems(e){return an(ka({connector:this.connector},e))}fetchNgwLayerFeature(e){return eo(ka({connector:this.connector},e))}fetchNgwLayerFeatures(e){return cn(ka({connector:this.connector},e))}fetchIdentifyItem(e,t){const r=function(e){const{connector:t,identify:r}=e,n=uo(r);return n&&n.length?ht(lo(lo({connector:t},e.requestOptions),n[0])):L.resolve(void 0)}({identify:e,connector:this.connector,requestOptions:t});return this._addPromise("identify",r),r}fetchIdentifyGeoJson(e,t=!1){const r=function(e){const{connector:t,identify:r,requestOptions:n}=e;for(const o in r){const e=Number(o);if(!isNaN(e)){const e=r[o];if("features"in e){const t=e.features.find((e=>e.geom));if(t&&t.geom){const e=t.geom;return L.resolve(Qe(co(lo({},t),{geom:e})))}}}}const i=uo(r);return i&&i.length?eo(lo(co(lo({},n),{connector:t}),i[0])):L.resolve(void 0)}({identify:e,connector:this.connector,multiple:t});return r&&"then"in r?(this._addPromise("identify",r),r):L.resolve(r)}getIdentifyGeoJson(e,t=!1){return this.fetchIdentifyGeoJson(e,t)}getNgwLayers(){return Fa(this,null,(function*(){return yield this.onLoad(),this._ngwLayers}))}getNgwLayerByResourceId(e){return Fa(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 Fa(this,null,(function*(){let n;n="string"==typeof t||"number"==typeof t?String(n):t.id;const i=n&&this._ngwLayers[n];if(i)if(i.layer.getBounds){const e=yield i.layer.getBounds();e&&this.fitBounds(e,r)}else{let e;if(i.layer.item)e=i.layer.item;else{const t=i.resourceId;e=yield this.connector.getResource(t)}e&&pr({resourceId:e.resource.id,connector:this.connector}).then((e=>{e&&this.fitBounds(e,r)}))}else Ta(e.prototype,this,"fitLayer").call(this,"number"==typeof t?String(t):t,r)}))}zoomToLayer(e){return Fa(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.cancel())),this._promises[e]=[])}))}selectFromNgwRaster(e){return Fa(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,i="function"==typeof n.getIdentificationIds&&n.getIdentificationIds,o=null==(t=n.options.interactive)||t;i&&n.options.selectable&&o&&this.isLayerVisible(n)&&r.push(i.call(n))}const i=Promise.all(r),o=yield i,s=[];for(const e of o)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),p=fo(e,{layers:s,connector:this.connector,radius:u}).then((t=>{const r=Sa(ka({},t),{resources:s,sourceType:"raster",event:e}),n=this._prepareToIdentify(r);return this._emitStatusEvent("ngw:select",n),n}));return this._addPromise("select",p),p}))}_addPromise(e,t){const r=this._promises[e];if(r&&-1===r.indexOf(t)){const e=()=>{const e=r.indexOf(t);-1!==e&&r.splice(e,1)};t.then(e),t.catch(e),r.push(t)}}_isFitFromResource(){const e=this._initMapState;return!e.zoom||!e.center}_createWebMap(){return Fa(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&&da(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),da(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(Sa(ka({},t),{resources:[r],sourceType:"vector"}))),t}}}_prepareToIdentify(e){return Sa(ka({},e),{getIdentifyItems:()=>uo(e,!0).map((e=>new Yi({feature:e.feature,connector:this.connector})))})}_getSelectListenersCount(){return this.emitter.listenerCount("ngw:select")}_whiteLabel(){return Fa(this,null,(function*(){const e=this.getContainer();if(e){const t=yield yo(this.connector,this.options.companyLogoOptions);t&&e.appendChild(t)}}))}};Na(Ba,"getIcon",(function(e={}){var t,r,n,i,o,s;const a=null!=(t=e.shape)?t:"circle",l=null!=(r=e.color)?r:"blue",c=null!=(n=e.strokeColor)?n:"white",u=null!=(i=e.size)?i:I,p=null!=(o=e.rotate)?o:0,h=null!=(s=e.anchor)?s:[u/2,u/2],d=void 0!==e.stroke?Number(e.stroke):.8,f=e.p||P[a]||"circle",y="string"==typeof f?f:f(e),m=function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}(e.svg||function({width:e,height:t,stroke:r=0,content:n}){const i=r/2;return`<svg\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n width="${e}"\n height="${t}"\n viewBox="-${i} -${i} ${I+r} ${I+r}"\n >${n}</svg>`}({width:u,height:u,stroke:d,content:y}));return m.setAttribute("width",String(u)),m.setAttribute("height",String(u)),m.setAttribute("fill",l),d&&(m.setAttribute("stroke",c),m.setAttribute("stroke-width",String(d))),{type:"icon",iconSize:[u,u],iconAnchor:h,html:(new XMLSerializer).serializeToString(m),rotate:p,svg:m}}));let Ra=Ba;return e.NgwMap=Ra,e.WebMap=ra,e.WebMapControls=Zs,e.WebMapLayers=Ds,e.WebMapMain=Ls,e.createNgwMap=function(e){return t=this,r=null,n=function*(){return new Ra(e).onLoad()},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,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 ra(e).onLoad()},new Promise(((e,i)=>{var o=e=>{try{a(n.next(e))}catch(t){i(t)}},s=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,s);a((n=n.apply(t,r)).next())}));var t,r,n},e.detectGeometryType=Is,e.findMostFrequentGeomType=Ps,e.getDefaultControls=na,e.getWebMap=Hs,e.paintTypeAlias=Es,e.setWebMap=Js,e.typeAlias=js,e.updateGeoJsonAdapterOptions=xs,e}({});
2
2
  //# sourceMappingURL=ngw-map.global.prod.js.map