@nextgis/geocoder 1.19.2 → 2.0.0-alpha.1

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 Geocoder=function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,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=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(t){i(t)}}function u(e){try{c(n.throw(e))}catch(t){i(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}c((n=n.apply(e,t||[])).next())}))}function i(e,t){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:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,n=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){s.label=u[1];break}if(6===u[0]&&s.label<o[1]){s.label=o[1],o=u;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(u);break}o[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(c){u=[6,c],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function s(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function c(e){return this instanceof c?(this.v=e,this):new c(e)}function a(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),i=[];return n={},s("next"),s("throw"),s("return"),n[Symbol.asyncIterator]=function(){return this},n;function s(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){i.push([e,t,r,n])>1||u(e,t)}))})}function u(e,t){try{(r=o[e](t)).value instanceof c?Promise.resolve(r.value.v).then(a,f):l(i[0][2],r)}catch(n){l(i[0][3],n)}var r}function a(e){u("next",e)}function f(e){u("throw",e)}function l(e,t){e(t),i.shift(),i.length&&u(i[0][0],i[0][1])}}function f(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=s(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var l=function(e){function t(){var r=e.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error),h=function(){function e(e){void 0===e&&(e={}),this.options=e,this._promises=new Map}return Object.defineProperty(e.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),e.prototype.remove=function(e){this._promises.has(e)&&(this._promises.delete(e),this._onStop())},e.prototype.get=function(e){return this._promises.get(e)},e.prototype.add=function(e,t){var r=this,n=t||e,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,e),e.finally((function(){r.remove(n)})),e)},e.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(e){e.cancel&&e.cancel()})),this._promises.clear(),this._onStop())},e.prototype.waitFunc=function(e,t){void 0===t&&(t="");var r=this.get(t=t||e.name);return r||this.add(e(),t)},e.prototype.WaitForMe=function(e){void 0===e&&(e="");var t=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return e=e||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=t(e);return i||r(s.apply(this,n),e)},i}},e.prototype.GetOrCreateDecorator=function(e){return void 0===e&&(e=""),this.WaitForMe(e)},e.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},e}(),p=function(e){function t(){var r=e.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,t.prototype),r}return r(t,e),t}(Error),d=function(e,t,r,n){try{e(r(n))}catch(o){t(o)}},v=0,y=function(){function e(t,r){var n=this;this.id=v++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(e,t){n._setCanceledCallback=function(t){return e(t||new l)}}));var o=[this._cancelPromise,new Promise((function(r,o){return t((function(t){t instanceof e?n.attach(t):n._isPending=!1,r(t)}),(function(e){n._isPending=!1,o(e)}),(function(e){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(e)}))}))];r&&o.push(new Promise((function(e,t){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{t(new p)}}),r)}))),this._promise=Promise.race(o)}return e.createControl=function(e){return new h(e)},e.resolve=function(t){return new e((function(e){return e(t)}))},e.reject=function(t){return new e((function(e,r){return r(t)}))},e.all=function(t){var r=this;return new e((function(e,r){Promise.all(t).then(e).catch(r)})).catch((function(e){if(e instanceof r.CancelError)for(var n=0,o=t;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw e}))},e.prototype.attach=function(e){this._isCanceled?e.cancel():this._children.push(e)},e.prototype.then=function(t,r){var n=this,o=new e((function(e,o){if(n._promise){var i=function(t){r?d(e,o,r,t):o(t)};n._promise.then((function(r){n._isCanceled?i(r):t?d(e,o,t,r):e(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},e.prototype.catch=function(e){return this._isCanceled&&e&&e(new l),this.then(void 0,e)},e.prototype.finally=function(e){return this._promise?this._promise.finally(e):Promise.reject(this._isCanceled?new l:e)},e.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var e=this._getTopParent();if(e&&e.cancel(),this._children&&this._children.forEach((function(e){return e.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var t=0,r=this._cancelHandlers;t<r.length;t++){(0,r[t])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},e.prototype._getTopParent=function(){for(var e=this._parentPromise,t=!!e;t;)t=!(!e||!e._parentPromise)&&!!(e=e._parentPromise);return e},e.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},e.CancelError=l,e.TimeoutError=p,e.PromiseControl=h,e}();Object.setPrototypeOf(y.prototype,Promise.prototype);var m=y;function g(e){return null!=e}function b(e){return"string"==typeof e?!!e:g(e)}function _(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:w(e,t));return e===t}function w(e,t){var 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(var o=0;o<r.length;o++){if(!_(e[r[o]],t[n[o]],e,t))return!1}return!0}function O(e){var t={};return Object.keys(e).forEach((function(r){e[r]instanceof Array||e[r]!==Object(e[r])?void 0!==e[r]&&(t[r]=e[r]):t[r]=O(e[r])})),t}function E(e){return e.replace(/([^:]\/)\/+/g,"$1")}var x,P=function(e){e&&function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0,o=t;n<o.length;n++)for(var i=o[n],s=0,u=Object.getOwnPropertyNames(i);s<u.length;s++){var c=u[s];e[c]=i[c]}}(this,e)},C=0,R=function(e){function t(t){var r=e.call(this,t)||this;return r.providers=[],t&&t.providers&&(r.providers=t.providers),r}return r(t,e),t.prototype.abort=function(){this.providers.forEach((function(e){e.abort&&e.abort()}))},t.prototype.search=function(e){return a(this,arguments,(function(){var t,r,o,s,u,a,l,h,p,d,v,y,m,g,b;return i(this,(function(i){switch(i.label){case 0:this.abort(),t=!0,r=[],o=0,s=this.providers,i.label=1;case 1:if(!(o<s.length))return[3,19];u=s[o],i.label=2;case 2:i.trys.push([2,17,,18]),a=u.search(e),i.label=3;case 3:i.trys.push([3,10,11,16]),l=!0,g=void 0,h=f(a),i.label=4;case 4:return[4,c(h.next())];case 5:return p=i.sent(),(m=p.done)?[3,9]:(l=!1,t=!1,[4,c(n(n({},p.value),{provider:u,_id:C++}))]);case 6:return[4,i.sent()];case 7:i.sent(),i.label=8;case 8:return l=!0,[3,4];case 9:return[3,16];case 10:return d=i.sent(),g={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l||m||!(b=h.return)?[3,13]:[4,c(b.call(h))];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(g)throw g.error;return[7];case 15:return[7];case 16:return[3,18];case 17:return v=i.sent(),"CancelError"!==(y=v).name&&r.push(y),[3,18];case 18:return o++,[3,1];case 19:if(t&&r.length)throw new Error("All providers failed: ".concat(r.map((function(e){return e.message})).join("; ")));return[2]}}))}))},t.prototype.result=function(e){return e.provider?e.provider.result(e):m.resolve(void 0)},t.prototype.reverse=function(e){return a(this,arguments,(function(){var t,r,o,s,u,a,l,h,p,d,v;return i(this,(function(i){switch(i.label){case 0:t=0,r=this.providers,i.label=1;case 1:if(!(t<r.length))return[3,19];if(!(o=r[t]).reverse)return[3,18];i.label=2;case 2:i.trys.push([2,17,,18]),s=o.reverse(e),i.label=3;case 3:i.trys.push([3,10,11,16]),u=!0,d=void 0,a=f(s),i.label=4;case 4:return[4,c(a.next())];case 5:return l=i.sent(),(p=l.done)?[3,9]:(u=!1,[4,c(n(n({},l.value),{provider:o,_id:C++}))]);case 6:return[4,i.sent()];case 7:i.sent(),i.label=8;case 8:return u=!0,[3,4];case 9:return[3,16];case 10:return h=i.sent(),d={error:h},[3,16];case 11:return i.trys.push([11,,14,15]),u||p||!(v=a.return)?[3,13]:[4,c(v.call(a))];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(d)throw d.error;return[7];case 15:return[7];case 16:return[3,18];case 17:return i.sent(),[3,18];case 18:return t++,[3,1];case 19:return[2]}}))}))},t.prototype.reverseGeocodeFirstResult=function(e){var t,r,n;return o(this,void 0,void 0,(function(){var o,s,u,c,a,l,h,p;return i(this,(function(i){switch(i.label){case 0:o=0,s=this.providers,i.label=1;case 1:if(!(o<s.length))return[3,17];if("function"!=typeof(u=s[o]).reverse)return[3,16];i.label=2;case 2:i.trys.push([2,15,,16]),i.label=3;case 3:i.trys.push([3,8,9,14]),c=!0,r=void 0,a=f(u.reverse(e)),i.label=4;case 4:return[4,a.next()];case 5:return l=i.sent(),(t=l.done)?[3,7]:(c=!1,[2,l.value]);case 6:return c=!0,[3,4];case 7:return[3,14];case 8:return h=i.sent(),r={error:h},[3,14];case 9:return i.trys.push([9,,12,13]),c||t||!(n=a.return)?[3,11]:[4,n.call(a)];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(r)throw r.error;return[7];case 13:return[7];case 14:return[3,16];case 15:return p=i.sent(),console.error("Error in reverse geocoding:",p),[3,16];case 16:return o++,[3,1];case 17:return[2,void 0]}}))}))},t}(P),j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(P),L={exports:{}},I="object"==typeof Reflect?Reflect:null,k=I&&"function"==typeof I.apply?I.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};x=I&&"function"==typeof I.ownKeys?I.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var S=Number.isNaN||function(e){return e!=e};function T(){T.init.call(this)}L.exports=T,L.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}D(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&D(e,"error",t,r)}(e,o,{once:!0})}))},T.EventEmitter=T,T.prototype._events=void 0,T.prototype._eventsCount=0,T.prototype._maxListeners=void 0;var q=10;function A(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function N(e){return void 0===e._maxListeners?T.defaultMaxListeners:e._maxListeners}function F(e,t,r,n){var o,i,s,u;if(A(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=N(e))>0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,u=c,console&&console.warn&&console.warn(u)}return e}function U(){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 M(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=U.bind(n);return o.listener=r,n.wrapFn=o,o}function H(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):B(o,o.length)}function G(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function B(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function D(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){n.once&&e.removeEventListener(t,o),r(i)}))}}Object.defineProperty(T,"defaultMaxListeners",{enumerable:!0,get:function(){return q},set:function(e){if("number"!=typeof e||e<0||S(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");q=e}}),T.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},T.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||S(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},T.prototype.getMaxListeners=function(){return N(this)},T.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)k(u,this,t);else{var c=u.length,a=B(u,c);for(r=0;r<c;++r)k(a[r],this,t)}return!0},T.prototype.on=T.prototype.addListener=function(e,t){return F(this,e,t,!1)},T.prototype.prependListener=function(e,t){return F(this,e,t,!0)},T.prototype.once=function(e,t){return A(t),this.on(e,M(this,e,t)),this},T.prototype.prependOnceListener=function(e,t){return A(t),this.prependListener(e,M(this,e,t)),this},T.prototype.removeListener=function(e,t){var r,n,o,i,s;if(A(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},T.prototype.off=T.prototype.removeListener,T.prototype.removeAllListeners=function(e){var t,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[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),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(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},T.prototype.listeners=function(e){return H(this,e,!0)},T.prototype.rawListeners=function(e){return H(this,e,!1)},T.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):G.call(e,t)},T.prototype.listenerCount=G,T.prototype.eventNames=function(){return this._eventsCount>0?x(this._events):[]};var z=function(){function e(t){var r;void 0===t&&(t={}),this.cache=[];var n=null!==(r=t.namespace)&&void 0!==r?r:"default";return e.instance[n]?e.instance[n]:(e.instance[n]=this,this)}return e.prototype.clean=function(){this.cache.length=0},e.prototype.all=function(){return this.cache},e.prototype.addFull=function(e,t,r){return this.add(e,t,r,!0)},e.prototype.add=function(e,t,r,n){var o=this,i=this._find(e,r);if(i)return i.value;var s=void 0;s=t instanceof Function?t():t;var u=r&&JSON.parse(JSON.stringify(O(r))),c={key:e,value:s,props:u,options:u};return n&&!b(s)?s:(this.cache.push(c),s instanceof Promise?(s.catch((function(t){throw o.delete(e,r),t})),n&&s.then((function(t){return b(t)||o.delete(e,r),t})),s):s)},e.prototype.match=function(e,t){var r=this._find(e,t);if(r)return r.value},e.prototype.matchAll=function(e,t){var r=this;return e?this.cache.filter((function(n){return r._filter(n,e,t)})).map((function(e){return e.value})):this.cache.map((function(e){return e.value}))},e.prototype.delete=function(e,t){var r=this,n=[];"string"==typeof e?n=this.cache.filter((function(n){return r._filter(n,e,t)})):n.push(e);for(var o=0,i=n;o<i.length;o++){var s=this.cache.indexOf(i[o]);this.cache.splice(s,1)}},e.prototype._find=function(e,t){var r=this;return this.cache.find((function(n){return r._filter(n,e,t)}))},e.prototype._filter=function(e,t,r){return e.key===t&&(!r||w(e.props||e.options||{},O(r)))},e.instance={},e}(),J=z,$=function(e){function t(r){var n=e.call(this)||this;return n.name="NgwError",Object.assign(n,r),Object.setPrototypeOf(n,t.prototype),n}return r(t,e),t}(Error),Q=function(e){function t(r){var n=e.call(this,r)||this;return n.name="ResourceNotFoundError",n.exception="nextgisweb.resource.exception.ResourceNotFound",Object.setPrototypeOf(n,t.prototype),n}return r(t,e),t}($);function W(e){return"[object Object]"===Object.prototype.toString.call(e)}var K=["description"];function X(e,t){void 0===t&&(t=""),t=t?t+"__":"";for(var r={},n=0,o=Object.entries(e);n<o.length;n++){var i=o[n],s=i[0],u=i[1];if(-1===K.indexOf(s))if(W(u))if("owner_user"===s){var c=X(u,s);Object.assign(r,c)}else"parent"===s&&"id"in u&&(r.parent_id=u.id);else g(u)&&(r[t+s]=u)}return r}var V=function(){function e(e){this.connector=e,this.cache=new J}return e.prototype.getOne=function(e,t){var r=this,o=new J,i={},s=n(n({},t),{cache:!1});"string"==typeof e?i.keyname=e:"number"==typeof e?i.id=e:W(e)&&(void 0!==e.id?i.id=e.id:e.keyname&&(i.keyname=e.keyname));return o.addFull("resource",(function(){return"string"==typeof e?r._fetchResourceBy({keyname:e},s):"number"==typeof e?r._fetchResourceById(e,s):W(e)?r._fetchResourceBy(e,s):m.resolve(void 0)}),i)},e.prototype.getOneOrFail=function(e,t){return this.getOne(e,t).then((function(e){if(e)return e;throw new Q}))},e.prototype.getId=function(e,t){return"number"==typeof e?m.resolve(e):"string"==typeof e||W(e)?this.getOne(e,t).then((function(e){if(e)return e.resource.id})):m.resolve(void 0)},e.prototype.getIdOrFail=function(e,t){return this.getId(e,t).then((function(e){if(void 0===e)throw new Error;return e}))},e.prototype.getMany=function(e,t){var r=this;return this._resourceCacheFilter(e).then((function(o){if(!o.length){var i={};return e.keyname?i.keyname=e.keyname:Object.assign(i,X(e)),r.connector.get("resource.search",t,n({serialization:"full"},i)).then((function(e){if(e)for(var t=0,n=e;t<n.length;t++){var o=n[t];r.cache.add("resource.item",m.resolve(o),{id:o.resource.id})}return e}))}return o}))},e.prototype.getParent=function(e,t){var r=this;return this.getOne(e,t).then((function(e){return e?r.getOne(e.resource.parent.id,t):m.resolve(void 0)}))},e.prototype.getChildrenOf=function(e,t){var r=this;return this.getIdOrFail(e).then((function(e){return r._getChildrenOf(e,t)}))},e.prototype.update=function(e,t){var r=this;return this.getId(e).then((function(e){if(void 0!==e)return r.connector.put("resource.item",{data:t},{id:e})}))},e.prototype.delete=function(e){var t=this;return this.getId(e).then((function(e){if(void 0!==e)return t.connector.delete("resource.item",null,{id:e}).then((function(){t._cleanResourceItemCache(e)}))}))},e.prototype._getChildrenOf=function(e,t,r){var o=this;return void 0===r&&(r=[]),this.connector.get("resource.collection",n({cache:!0},t),{parent:e}).then((function(e){for(var n=[],i=0,s=e;i<s.length;i++){var u=s[i];o.cache.add("resource.item",m.resolve(u),{id:u.resource.id}),r.push(u),(null==t?void 0:t.recursive)&&u.resource.children&&n.push(o._getChildrenOf(u.resource.id,t,r))}return n.length?m.all(n).then((function(){return r})):r}))},e.prototype._cleanResourceItemCache=function(e){return o(this,void 0,void 0,(function(){var t,r,n,o,s,u,c,a;return i(this,(function(i){switch(i.label){case 0:t=this.cache.all(),r=[],n=0,o=t,i.label=1;case 1:return n<o.length?(u=(s=o[n]).options&&s.options.id,["resource.item","resource"].includes(s.key)&&void 0!==u?"number"!=typeof u?[3,2]:(u===e&&r.push(s),[3,4]):[3,4]):[3,5];case 2:return[4,this.getId(u)];case 3:i.sent()===e&&r.push(s),i.label=4;case 4:return n++,[3,1];case 5:for(c=0,a=r;c<a.length;c++)this.cache.delete(a[c]);return[2]}}))}))},e.prototype._fetchResourceById=function(e,t){var r=this;return this.cache.add("resource.item",(function(){return r.connector.get("resource.item",t,{id:e})}),{id:e}).catch((function(e){if(!(e instanceof Q))throw e}))},e.prototype._fetchResourceBy=function(e,t){return this.getMany(e,t).then((function(e){return e[0]}))},e.prototype._resourceCacheFilter=function(e){return m.all(this.cache.matchAll("resource.item")).then((function(t){return t.filter((function(t){if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:g(e.id)&&g(t.resource.id)?e.id===t.resource.id:w(e,t.resource)})),[]}))},e}(),Y=[];function Z(e){Y.push(e)}var ee=function(e){function t(r){var n=e.call(this,r)||this;return n.name="InsufficientPermissionsError",n.exception="nextgisweb.core.exception.InsufficientPermissions",Object.setPrototypeOf(n,t.prototype),n}return r(t,e),t}($),te=/\{ *([\w_-]+) *\}/g;function re(e,t){return e.replace(te,(function(e,r){var n=t[r];if(void 0===n)throw new Error("No value provided for letiable "+e);return"function"==typeof n&&(n=n(t)),n}))}var ne,oe=function(e){function t(r){var n=e.call(this)||this;return n.name="NetworkError",Object.setPrototypeOf(n,t.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(t,e),t}(Error);ne=function(e,t,r,n,o){void 0===r&&(r={}),r.method=r.method||"GET";var i=new XMLHttpRequest;i.open(r.method||"GET",e,!0),"blob"===r.responseType&&(i.responseType=r.responseType);var s=function(){try{return JSON.parse(i.responseText)}catch(e){return i.responseText}};i.onload=function(){-1!==[401,403,404,422,500].indexOf(i.status)&&n(new $(s())),function(e){void 0===e&&(e=!1);var o=e?n:t;"blob"===r.responseType?o(i.response):i.responseText?o(s()):n({message:""})}()},i.onerror=function(t){n(0===i.status?new oe(e):t)},i.upload.onprogress=function(e){e.lengthComputable&&(r.onProgress&&r.onProgress(e.loaded/e.total*100,e))};var u,c=r.headers;if(c)for(var a in c){var f=c[a];"string"==typeof f&&i.setRequestHeader(a,f)}if(void 0!==r.withCredentials&&(i.withCredentials=r.withCredentials),r.file){if((u=new FormData).append("file",r.file),r.data)for(var l in r.data)u.append(l,u[l])}else u=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;o&&o((function(){i.abort()})),i.send(u)};var ie=0,se=function(){function e(e){this.options=e,this.id=ie++,this.emitter=new L.exports.EventEmitter,this.routeStr="/api/component/pyramid/route",this.activeRequests=[];var t=function(e){return Y.find((function(t){if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return w(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 V(this),Z(this)}return e.create=function(e){return new this(e)},e.prototype.setRequestTransform=function(e){this.requestTransform=e},e.prototype.setNgw=function(e){this.logout(),this.options.baseUrl=e,Z(this)},e.prototype.connect=function(){var e=this,t=new J,r=this.options.auth;return t.add("route",(function(){return new m((function(t,n){var o=function(){return e.makeQuery(e.routeStr,{},{}).then((function(e){t(e)})).catch((function(e){n(e)}))};if(r){var i=r.login,s=r.password;if(i&&s)return e._login({login:i,password:s}).then((function(){return o()})).catch((function(e){return n(e)}))}return o()}))}),{id:this.id,auth:r,baseUrl:this.options.baseUrl})},e.prototype.login=function(e,t){return this.logout(),Z(this),this._login(e,t)},e.prototype.logout=function(){var e;this.abort(),-1!==(e=Y.indexOf(this))&&Y.splice(e,1),this.options.auth=void 0,this.user=void 0,this.emitter.emit("logout"),this.resources.cache.clean()},e.prototype.getUserInfo=function(e,t){if(this.user&&this.user.id)return m.resolve(this.user);e&&(this.options.auth=e);var r=n({headers:this.getAuthorizationHeaders(e)},t);return this.makeQuery("/api/component/auth/current_user",{},r)},e.prototype.getAuthorizationHeaders=function(e){var t=this.makeClientId(e);if(t)return{Authorization:"Basic "+t}},e.prototype.makeClientId=function(e){if(e=e||this.options.auth){var t=e.password,r=unescape(encodeURIComponent("".concat(e.login,":").concat(t)));return window.btoa(r)}},e.prototype.abort=function(){for(var e=0,t=this.activeRequests;e<t.length;e++){t[e].cancel()}this.activeRequests=[]},e.prototype.getActiveApiRequests=function(){return u([],this.activeRequests,!0)},e.prototype.apiRequest=function(e,t,r){var o,i,s=this;void 0===t&&(t={}),void 0===r&&(r={});var c=r.method,a=r.headers,f=r.withCredentials,l=r.responseType,h=O(t=null!==(o=r.params)&&void 0!==o?o:t),p=function(){return function(e){var t=e.params;return new m((function(r,n){e.connector.connect().then((function(o){var i=o&&o[e.name];if(i){var s=(i=u([],i,!0)).shift();if(i.length){for(var c={},a=0;a<i.length;a++){var f=i[a];if(c[a]="{"+f+"}",void 0===t[f])throw new Error("`"+f+"` url api argument is not specified")}s&&(s=re(s,c))}if(t){var l=[],h=t.paramList;for(var p in Array.isArray(h)&&(delete t.paramList,h.forEach((function(e){l.push("".concat(e[0],"=").concat(e[1]))}))),t)-1===i.indexOf(p)&&l.push("".concat(p,"=").concat(t[p]));l.length&&(s=s+"?"+l.join("&"))}s?r(e.connector.makeQuery(s,t,e.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((function(e){n(e)}))}))}({name:e,params:h,requestOptions:r,connector:s})};return r.cache&&"GET"===c?(new J).add(e,p,n({params:h},O({headers:a,withCredentials:f,responseType:l,baseUrl:this.options.baseUrl,userId:null===(i=this.user)||void 0===i?void 0:i.id}))):p()},e.prototype.post=function(e,t,r){return(t=t||{}).method="POST",this.apiRequest(e,r,t)},e.prototype.get=function(e,t,r){return(t=t||{}).method="GET",this.apiRequest(e,r,t)},e.prototype.patch=function(e,t,r){return(t=t||{}).method="PATCH",this.apiRequest(e,r,t)},e.prototype.put=function(e,t,r){return(t=t||{}).method="PUT",this.apiRequest(e,r,t)},e.prototype.delete=function(e,t,r){return(t=t||{}).method="DELETE",this.apiRequest(e,r,t)},e.prototype.makeQuery=function(e,t,r){if(void 0===r&&(r={}),e=(this.options.baseUrl?this.options.baseUrl:"")+e)return t&&(e=re(e,t)),e=encodeURI(E(e)),this._loadData(e,r);throw new Error("Empty `url` not allowed")},e.prototype.getResource=function(e,t){return this.resources.getOne(e,t)},e.prototype.getResourceOrFail=function(e,t){return this.resources.getOneOrFail(e,t)},e.prototype.getResourceBy=function(e){return this.resources.getOne(e)},e.prototype.getResourceByKeyname=function(e){return this.resources.getOne(e)},e.prototype.getResourceById=function(e){return this.resources.getOne(e)},e.prototype.getResourceId=function(e,t){return this.resources.getId(e,t)},e.prototype.getResourceIdOrFail=function(e,t){return this.resources.getIdOrFail(e,t)},e.prototype.getResourcesBy=function(e,t){return this.resources.getMany(e,t)},e.prototype.getResourceParent=function(e,t){return this.resources.getParent(e,t)},e.prototype.getResourceChildren=function(e,t){return this.resources.getChildrenOf(e,t)},e.prototype.updateResource=function(e,t){return this.resources.update(e,t)},e.prototype.deleteResource=function(e){return this.resources.delete(e)},e.prototype._loadData=function(e,t){var r=this;t.responseType=t.responseType||"json";var o=new m((function(o,i,s){if(r.user&&((t=t||{}).headers=n(n({},r.getAuthorizationHeaders()),t.headers)),r.requestTransform){var u=r.requestTransform(e,t);e=u[0],t=u[1]}ne(e,o,t,i,s)})).then((function(e){return r._cleanActiveRequests(o),e})).catch((function(e){if(r._cleanActiveRequests(o),e instanceof m.CancelError);else{var t=r._handleHttpError(e);if(t)throw t}}));return t.signal&&"function"==typeof t.signal.addEventListener&&t.signal.addEventListener("abort",(function(){o.cancel(),r._cleanActiveRequests(o)})),this.activeRequests.push(o),o},e.prototype._login=function(e,t){var r=this;return this.getUserInfo(e,t).then((function(e){return r.user=e,r.emitter.emit("login",e),e})).catch((function(e){throw r.emitter.emit("login:error",e),e}))},e.prototype._cleanActiveRequests=function(e){var t=this.activeRequests.indexOf(e);-1!==t&&this.activeRequests.splice(t,1)},e.prototype._handleHttpError=function(e){if(e&&e instanceof $){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new Q(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new ee(e)}return e},e.errors={NgwError:$,ResourceNotFoundError:Q},e}(),ue=se;function ce(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;var n,o="^".concat((n=t,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(e)}var ae={gt:function(e,t){return e>t},lt:function(e,t){return e<t},ge:function(e,t){return e>=t},le:function(e,t){return e<=t},eq:function(e,t){return e===t},ne:function(e,t){return e!==t},in:function(e,t){return-1!==t.indexOf(e)},notin:function(e,t){return-1===t.indexOf(e)},like:function(e,t){return ce(e,t)},ilike:function(e,t){return ce(e,t,!0)}};function fe(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function le(e,t){var r="string"==typeof t[0]?t[0]:"all",n=function(t){if(fe(t)){var r=t[0],n=t[1],o=t[2],i=ae[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",u=r.replace(/^%?(\w+)%?$/,(function(t,n){return s=e[n],r.replace(n,o)}));return i(s,u)}return i(e[r],o)}return!1}return le(e,t)},o=t.filter((function(e){return Array.isArray(e)}));return"any"===r?o.some(n):o.every(n)}var he={srs:4326,geom_format:"geojson"};function pe(e){var t=ve(e);return m.all(t).then((function(t){for(var r=[],n=[],o=0,i=t;o<i.length;o++)for(var s=0,u=i[o];s<u.length;s++){var c=u[s];r.includes(c.id)||(n.push(c),r.push(c.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 de(e){var t=e[0],r=e[1],n=e[2],o="id"!==t?"fld_":"",i="",s="",u=String(t).trim().replace(/^(%?)(.+?)(%?)$/,(function(e,t,r,n){return i=t,s=n,r})),c=i+n+s;return["".concat(o).concat(u,"__").concat(r),c]}function ve(e,t,r){void 0===t&&(t=[]),void 0===r&&(r=[]);var o=e.filters,i="string"==typeof o[0]?o[0]:"all",s=o.filter((function(e){return Array.isArray(e)}));if("any"===i)for(var c=0,a=s;c<a.length;c++){fe(d=a[c])?t.push(me(n(n({},e),{paramList:u(u([],r,!0),[de(d)],!1)}))):ve(n(n({},e),{filters:d}),t,u([],r,!0))}else if("all"===i){for(var f=[],l=[],h=0,p=s;h<p.length;h++){var d;fe(d=p[h])?f.push(de(d)):l.push(d)}if(l.length)for(var v=0,y=l;v<y.length;v++){var m=y[v];ve(n(n({},e),{filters:m}),t,u(u([],r,!0),f,!0))}else t.push(me(n(n({},e),{paramList:u(u([],r,!0),f,!0)})))}return t}function ye(e){var t=e.map((function(e){var t=function(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;var r=20037508.34*e/180,n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return[r,n=20037508.34*n/180]}(e[0],e[1]).map((function(e){return t=e,n=r?Number("1e+"+r):1,Math.round((t+Number.EPSILON)*n)/n;var t,r,n}));return t[0]+" "+t[1]}));return"POLYGON((".concat(t.join(", "),"))")}function me(e){var t,r,o,i=n({},he),s=e.limit,u=e.cache,c=e.signal,a=e.offset,f=e.orderBy,l=e.paramList,h=e.connector,p=e.geomFormat,d=e.intersects,v=e.resourceId;if(s?s!==Number.POSITIVE_INFINITY&&(i.limit=s):i.limit=7e3,a&&(i.offset=a),p&&(i.geom_format=p),function(e,t){var r=t.extensions,n=t.geom,o=t.fields,i=t.srs,s=t.ilike,u=t.like,c=r?r.join(","):"";"*"!==c&&(e.extensions=c),void 0!==o&&(e.fields=Array.isArray(o)?o.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),g(s)?e.ilike=s:g(u)&&(e.like=u),g(i)&&(e.srs=i)}(i,e),f&&(i.order_by=f.join(",")),Array.isArray(d)){var y=(o=d,Array.isArray(o)&&4===o.length&&o.every((function(e){return"number"==typeof e}))?[r=[(t=d)[0],t[1]],[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],r]:d);i.intersects=ye(y)}else"string"==typeof d&&(i.intersects=d);l&&(i.paramList=l);var m=n({id:v},i);return h.get("feature_layer.feature.collection",{cache:u,signal:c},m)}function ge(e){var t,r=function(){var r=e[t];if("[object Object]"===Object.prototype.toString.call(r)){var n=r;if(g(n.year)&&g(n.month)&&g(n.day)){var o=[n.year,n.month-1,n.day];"hour"in n&&[n.hour,n.minute,n.second].forEach((function(e){o.push(e)})),e[t]=(new(Date.bind.apply(Date,u([void 0],o,!1)))).toISOString()}}else"id"===t&&"string"==typeof r&&(e[t]=r.split(",").map(Number))};for(t in e)r();return e}function be(e){var t=e.filters;return t?pe(n(n({},e),{filters:t})).then((function(r){var o;return(null!==(o=e.clientFilterValidate)&&void 0!==o?o:_e(t))&&(r=r.filter((function(e){return le(ge(n(n({},e.fields),{id:e.id})),t)}))),r})):me(e)}function _e(e){if("any"===e[0])return!0;for(var t=1;t<e.length;t++){var r=e[t];if("[object Array]"===Object.prototype.toString.call(r))if(_e(r))return!0}return!1}var we=function(e){function t(t){var r,o=this;if((o=e.call(this,t)||this).searchResources=[],o._abortControllers=[],!t.searchUrl&&!(null===(r=t.connectorOptions)||void 0===r?void 0:r.baseUrl))throw new Error("The `searchUrl` of `connectorOptions.baseUrl` are required");return o.connector=t.connector||new ue(n({baseUrl:o.searchUrl},t.connectorOptions)),o.searchResources=t.searchResources,o}return r(t,e),t.prototype.abort=function(){this._abortControllers.forEach((function(e){e.abort()})),this._abortControllers.length=0},t.prototype.search=function(e){var r,n;return a(this,arguments,(function(){var o,s,u,a,f,l,h,p,d,v,y,m,g,b,_=this;return i(this,(function(w){switch(w.label){case 0:o=this._makeSignal(),s=0,u=this.searchResources,w.label=1;case 1:if(!(s<u.length))return[3,11];if(a=u[s],o.aborted)return[3,11];f=a.searchMethod,l=null!==(r=a.limit)&&void 0!==r?r:t.limit,h=null!==(n=a.id)&&void 0!==n?n:a.resourceId,w.label=2;case 2:return w.trys.push([2,9,,10]),[4,c(this.connector.getResourceOrFail(h,{cache:!0}))];case 3:return p=w.sent(),d={connector:this.connector,resourceId:h,signal:o,limit:l},"like"===f?d.like=e:d.ilike=e,[4,c(be(d))];case 4:v=w.sent(),y=function(e){return i(this,(function(t){switch(t.label){case 0:return e.result=function(){return _.result(e)},[4,c(e)];case 1:return[4,t.sent()];case 2:return t.sent(),[2]}}))},m=0,g=this._items({entries:v,query:e,config:a,resourceItem:p}),w.label=5;case 5:return m<g.length?[5,y(g[m])]:[3,8];case 6:w.sent(),w.label=7;case 7:return m++,[3,5];case 8:return[3,10];case 9:return(b=w.sent())&&"name"in b&&"CancelError"!==b.name&&console.warn(b),[3,10];case 10:return s++,[3,1];case 11:return[2]}}))}))},t.prototype.result=function(e){var t=this._makeSignal();return this.connector.get("feature_layer.feature.item_extent",{signal:t},{id:e.resourceId,fid:e.featureId}).then((function(t){var r=t.extent;return{text:e.text,extent:[r.minLon,r.minLat,r.maxLon,r.maxLat]}}))},t.prototype.reverse=function(e){return a(this,arguments,(function(){return i(this,(function(e){switch(e.label){case 0:throw new Error("Not implemented");case 1:return[4,e.sent()];case 2:return e.sent(),[2]}}))}))},t.prototype._makeSignal=function(){var e=new AbortController;return this._abortControllers.push(e),e.signal},t.prototype._items=function(e){var t,r=e.entries,n=e.query,o=e.config,i=e.resourceItem,s=[],u=void 0;i.feature_layer&&(u=null===(t=i.feature_layer.fields.find((function(e){return e.label_field})))||void 0===t?void 0:t.keyname);var c=this.searchResources.find((function(e){var t;return null!==(t=e.id)&&void 0!==t?t:e.resourceId===i.resource.id}));return c&&r.forEach((function(e){var t=u?e.fields[u]:e.id;o.renderSearch?t=o.renderSearch({item:e,resourceItem:i}):u&&(t=e.fields[u]),s.push({query:n,text:t,featureId:e.id,resourceId:i.resource.id,item:e,resourceItem:i})})),s},t.limit=300,t}(j),Oe=function(e){function t(t){var r=e.call(this,t)||this;return r.searchUrl="https://nominatim.openstreetmap.org",r._requests=[],t&&t.searchUrl&&(r.searchUrl=t.searchUrl),r}return r(t,e),t.prototype.abort=function(){this._requests.forEach((function(e){return e.cancel()})),this._requests=[]},t.prototype.search=function(e){return a(this,arguments,(function(){var t,r,n,o,s,u,a=this;return i(this,(function(f){switch(f.label){case 0:return t=E("".concat(this.searchUrl,"/search?format=geojson&polygon_geojson=1&q=").concat(e)),r=new m((function(r,n,o){var i=new XMLHttpRequest;i.open("GET",t,!0),i.onload=function(){try{var t=JSON.parse(i.responseText).features.map((function(t){return{geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:e}}));r(t)}catch(o){n(o)}},i.onerror=function(e){n(e)},o((function(){i.abort()})),i.send()})).catch((function(e){throw e})),this._requests.push(r),[4,c(r)];case 1:if(!(n=f.sent()))return[3,5];o=function(e){return i(this,(function(t){switch(t.label){case 0:return e.result=function(){return a.result(e)},[4,c(e)];case 1:return[4,t.sent()];case 2:return t.sent(),[2]}}))},s=0,u=n,f.label=2;case 2:return s<u.length?[5,o(u[s])]:[3,5];case 3:f.sent(),f.label=4;case 4:return s++,[3,2];case 5:return[2]}}))}))},t.prototype.result=function(e){return m.resolve({text:e.text,extent:e.extent||[],geom:e.geom})},t.prototype.reverse=function(e){return a(this,arguments,(function(){var t,r,n,o,s,u=this;return i(this,(function(i){switch(i.label){case 0:return t=e[0],r=e[1],n=E("".concat(this.searchUrl,"/reverse?format=geojson&lat=").concat(r,"&lon=").concat(t)),o=new m((function(e,o,i){var s=new XMLHttpRequest;s.open("GET",n,!0),s.onload=function(){try{var n=JSON.parse(s.responseText).features[0],i={geom:n,extent:n.bbox,text:n.properties&&n.properties.display_name,query:"".concat(r,", ").concat(t)};e(i)}catch(u){o(u)}},s.onerror=function(e){o(e)},i((function(){s.abort()})),s.send()})).catch((function(e){throw e})),this._requests.push(o),[4,c(o)];case 1:return(s=i.sent())?(s.result=function(){return u.result(s)},[4,c(s)]):[3,4];case 2:return[4,i.sent()];case 3:i.sent(),i.label=4;case 4:return[2]}}))}))},t}(j);return e.BaseProvider=j,e.Geocoder=R,e.NgwProvider=we,e.NominatimProvider=Oe,e.create=function(e){return new R(e)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var Geocoder=function(e){"use strict";var t=Object.defineProperty,r=(e,r,n)=>(((e,r,n)=>{r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n})(e,"symbol"!=typeof r?r+"":r,n),n);class n extends Error{constructor(){super(),r(this,"name","CancelError"),Object.setPrototypeOf(this,n.prototype)}}var s=Object.defineProperty,o=(e,t,r)=>(((e,t,r)=>{t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class i{constructor(e={}){this.options=e,o(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,s,o){const i=o.value;return e=e||s,o.value=function(...n){const s=t(e);if(s)return s;return r(i.apply(this,n),e)},o}}GetOrCreateDecorator(e=""){return this.WaitForMe(e)}_onStop(){this.options.onStop&&!this.isLoaded&&this.options.onStop()}}var a=Object.defineProperty,c=(e,t,r)=>(((e,t,r)=>{t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class l extends Error{constructor(){super(),c(this,"name","TimeoutError"),Object.setPrototypeOf(this,l.prototype)}}var u,h=Object.defineProperty,f=(e,t,r)=>(((e,t,r)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const p=(e,t,r,n)=>{try{e(r(n))}catch(s){t(s)}};let d=0;const y=class e{constructor(t,r){f(this,u),f(this,"id",d++),f(this,"_isCanceled",!1),f(this,"_isPending",!0),f(this,"_promise"),f(this,"_cancelPromise"),f(this,"_cancelHandlers",[]),f(this,"_setCanceledCallback"),f(this,"_parentPromise"),f(this,"_children",[]),this._cancelPromise=new Promise(((e,t)=>{this._setCanceledCallback=t=>e(t||new n)}));const s=[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&&s.push(new Promise(((e,t)=>{setTimeout((()=>{if(this._isPending)try{this.cancel()}finally{t(new l)}}),r)}))),this._promise=Promise.race(s)}static createControl(e){return new i(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 s=t=>{r?p(e,n,r,t):n(t)};this._promise.then((r=>{this._isCanceled?s(r):t?p(e,n,t,r):e(r)}),s)}}));return n._parentPromise=this,this._children.push(n),n}catch(e){return this._isCanceled&&e&&e(new n),this.then(void 0,e)}finally(e){return this._promise?this._promise.finally(e):Promise.reject(this._isCanceled?new n: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}};u=Symbol.toStringTag,f(y,"CancelError",n),f(y,"TimeoutError",l),f(y,"PromiseControl",i);let m=y;function v(e){return null!=e}function g(e){return"string"==typeof e?!!e:v(e)}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:w(e,t));return e===t}function w(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 s=0;s<r.length;s++){if(!b(e[r[s]],t[n[s]],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 O(e){return e.replace(/([^:]\/)\/+/g,"$1")}Object.setPrototypeOf(m.prototype,Promise.prototype);class P{constructor(e){e&&function(e,...t){for(const r of t)for(const t of Object.getOwnPropertyNames(r))e[t]=r[t]}(this,e)}}var j=Object.defineProperty,x=Object.defineProperties,E=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,L=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),k=(e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t)=>{for(var r in t||(t={}))R.call(t,r)&&k(e,r,t[r]);if(C)for(var r of C(t))I.call(t,r)&&k(e,r,t[r]);return e},q=(e,t)=>x(e,E(t)),T=function(e,t){this[0]=e,this[1]=t},A=(e,t,r)=>{var n=(e,t,s,o)=>{try{var i=r[e](t),a=(t=i.value)instanceof T,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?n("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,s,o):s({value:r,done:c}))).catch((e=>n("throw",e,s,o)))}catch(l){o(l)}},s=e=>o[e]=t=>new Promise(((r,s)=>n(e,t,r,s))),o={};return r=r.apply(e,t),o[L("asyncIterator")]=()=>o,s("next"),s("throw"),s("return"),o},U=(e,t,r)=>(t=e[L("asyncIterator")])?t.call(e):(e=e[L("iterator")](),t={},(r=(r,n)=>(n=e[r])&&(t[r]=t=>new Promise(((r,s,o)=>(t=n.call(e,t),o=t.done,Promise.resolve(t.value).then((e=>r({value:e,done:o})),s))))))("next"),r("return"),t);let N=0;class F extends P{constructor(e){var t;super(e),k(this,"symbol"!=typeof(t="providers")?t+"":t,[]),e&&e.providers&&(this.providers=e.providers)}abort(){this.providers.forEach((e=>{e.abort&&e.abort()}))}search(e){return A(this,null,(function*(){this.abort();let t=!0;const r=[];for(const c of this.providers)try{const r=c.search(e);try{for(var n,s,o,i=U(r);n=!(s=yield new T(i.next())).done;n=!1){const e=s.value;t=!1,yield q(S({},e),{provider:c,_id:N++})}}catch(s){o=[s]}finally{try{n&&(s=i.return)&&(yield new T(s.call(i)))}finally{if(o)throw o[0]}}}catch(a){"CancelError"!==a.name&&r.push(a)}if(t&&r.length)throw new Error(`All providers failed: ${r.map((e=>e.message)).join("; ")}`)}))}result(e){return e.provider?e.provider.result(e):m.resolve(void 0)}reverse(e){return A(this,null,(function*(){for(const i of this.providers)if(i.reverse)try{const o=i.reverse(e);try{for(var t,r,n,s=U(o);t=!(r=yield new T(s.next())).done;t=!1){const e=r.value;yield q(S({},e),{provider:i,_id:N++})}}catch(r){n=[r]}finally{try{t&&(r=s.return)&&(yield new T(r.call(s)))}finally{if(n)throw n[0]}}}catch(o){}}))}reverseGeocodeFirstResult(e){return t=this,r=null,n=function*(){for(const i of this.providers)if("function"==typeof i.reverse)try{try{for(var t,r,n,s=U(i.reverse(e));t=!(r=yield s.next()).done;t=!1)return r.value}catch(r){n=[r]}finally{try{t&&(r=s.return)&&(yield r.call(s))}finally{if(n)throw n[0]}}}catch(o){console.error("Error in reverse geocoding:",o)}},new Promise(((e,s)=>{var o=e=>{try{a(n.next(e))}catch(t){s(t)}},i=e=>{try{a(n.throw(e))}catch(t){s(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,i);a((n=n.apply(t,r)).next())}));var t,r,n}}var $=Object.defineProperty,M=(e,t,r)=>(((e,t,r)=>{t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class D extends P{constructor(){super(...arguments),M(this,"searchUrl"),M(this,"label")}}function H(){}function B(){B.init.call(this)}function G(e){return void 0===e._maxListeners?B.defaultMaxListeners:e._maxListeners}function z(e,t,r,n){var s,o,i,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),i=o[t]):(o=e._events=new H,e._eventsCount=0),i){if("function"==typeof i?i=o[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),!i.warned&&(s=G(e))&&s>0&&i.length>s){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else i=o[t]=r,++e._eventsCount;return e}function J(e,t,r){var n=!1;function s(){e.removeListener(t,s),n||(n=!0,r.apply(e,arguments))}return s.listener=r,s}function Q(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 W(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}H.prototype=Object.create(null),B.EventEmitter=B,B.usingDomains=!1,B.prototype.domain=void 0,B.prototype._events=void 0,B.prototype._maxListeners=void 0,B.defaultMaxListeners=10,B.init=function(){this.domain=null,B.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new H,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},B.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},B.prototype.getMaxListeners=function(){return G(this)},B.prototype.emit=function(e){var t,r,n,s,o,i,a,c="error"===e;if(i=this._events)c=c&&null==i.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=i[e]))return!1;var u="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,s=W(e,n),o=0;o<n;++o)s[o].call(r)}(r,u,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var s=e.length,o=W(e,s),i=0;i<s;++i)o[i].call(r,n)}(r,u,this,arguments[1]);break;case 3:!function(e,t,r,n,s){if(t)e.call(r,n,s);else for(var o=e.length,i=W(e,o),a=0;a<o;++a)i[a].call(r,n,s)}(r,u,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,s,o){if(t)e.call(r,n,s,o);else for(var i=e.length,a=W(e,i),c=0;c<i;++c)a[c].call(r,n,s,o)}(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(s=new Array(n-1),o=1;o<n;o++)s[o-1]=arguments[o];!function(e,t,r,n){if(t)e.apply(r,n);else for(var s=e.length,o=W(e,s),i=0;i<s;++i)o[i].apply(r,n)}(r,u,this,s)}return!0},B.prototype.on=B.prototype.addListener=function(e,t){return z(this,e,t,!1)},B.prototype.prependListener=function(e,t){return z(this,e,t,!0)},B.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,J(this,e,t)),this},B.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,J(this,e,t)),this},B.prototype.removeListener=function(e,t){var r,n,s,o,i;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new H:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,o=r.length;o-- >0;)if(r[o]===t||r[o].listener&&r[o].listener===t){i=r[o].listener,s=o;break}if(s<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new H,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,s=e.length;n<s;r+=1,n+=1)e[r]=e[n];e.pop()}(r,s);n.removeListener&&this.emit("removeListener",e,i||t)}return this},B.prototype.off=function(e,t){return this.removeListener(e,t)},B.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new H,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new H:delete r[e]),this;if(0===arguments.length){for(var n,s=Object.keys(r),o=0;o<s.length;++o)"removeListener"!==(n=s[o])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new H,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},B.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):[]},B.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Q.call(e,t)},B.prototype.listenerCount=Q,B.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var X=Object.defineProperty,K=(e,t,r)=>(((e,t,r)=>{t in e?X(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const V=class e{constructor(t={}){var r;K(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 s=this._find(e,r);if(s)return s.value;{let s;s=t instanceof Function?t():t;const o=r&&JSON.parse(JSON.stringify(_(r))),i={key:e,value:s,props:o,options:o};return n&&!g(s)?s:(this.cache.push(i),s instanceof Promise?(s.catch((t=>{throw this.delete(e,r),t})),n&&s.then((t=>(g(t)||this.delete(e,r),t))),s):s)}}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 w(e.props||e.options||{},_(r))}return!0}return!1}};K(V,"instance",{});let Y=V;var Z=Object.defineProperty,ee=(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 te extends Error{constructor(e){super(),ee(this,"name","NgwError"),ee(this,"title"),ee(this,"message"),ee(this,"detail"),ee(this,"exception"),ee(this,"status_code"),ee(this,"data"),ee(this,"guru_meditation"),Object.assign(this,e),Object.setPrototypeOf(this,te.prototype)}}var re=Object.defineProperty,ne=(e,t,r)=>(((e,t,r)=>{t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class se extends te{constructor(e){super(e),ne(this,"name","ResourceNotFoundError"),ne(this,"exception","nextgisweb.resource.exception.ResourceNotFound"),Object.setPrototypeOf(this,se.prototype)}}function oe(e){return"[object Object]"===Object.prototype.toString.call(e)}const ie=["description"];function ae(e,t=""){t=t?t+"__":"";const r={};for(const[n,s]of Object.entries(e))if(-1===ie.indexOf(n))if(oe(s))if("owner_user"===n){const e=ae(s,n);Object.assign(r,e)}else"parent"===n&&"id"in s&&(r.parent_id=s.id);else v(s)&&(r[t+n]=s);return r}var ce=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,de=(e,t,r)=>t in e?ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ye=(e,t)=>{for(var r in t||(t={}))fe.call(t,r)&&de(e,r,t[r]);if(he)for(var r of he(t))pe.call(t,r)&&de(e,r,t[r]);return e};class me{constructor(e){var t,r,n;this.connector=e,t=this,r="cache",n=new Y,de(t,"symbol"!=typeof r?r+"":r,n)}getOne(e,t){const r=new Y,n={},s=(o=ye({},t),le(o,ue({cache:!1})));var o;"string"==typeof e?n.keyname=e:"number"==typeof e?n.id=e:oe(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},s):"number"==typeof e?this._fetchResourceById(e,s):oe(e)?this._fetchResourceBy(e,s):m.resolve(void 0)),n)}getOneOrFail(e,t){return this.getOne(e,t).then((e=>{if(e)return e;throw new se}))}getId(e,t){return"number"==typeof e?m.resolve(e):"string"==typeof e||oe(e)?this.getOne(e,t).then((e=>{if(e)return e.resource.id})):m.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,ae(e)),this.connector.get("resource.search",t,ye({serialization:"full"},r)).then((e=>{if(e)for(const t of e)this.cache.add("resource.item",m.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):m.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",ye({cache:!0},t),{parent:e}).then((e=>{const n=[];for(const s of e)this.cache.add("resource.item",m.resolve(s),{id:s.resource.id}),r.push(s),(null==t?void 0:t.recursive)&&s.resource.children&&n.push(this._getChildrenOf(s.resource.id,t,r));return n.length?m.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,s)=>{var o=e=>{try{a(n.next(e))}catch(t){s(t)}},i=e=>{try{a(n.throw(e))}catch(t){s(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,i);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 se))throw e}))}_fetchResourceBy(e,t){return this.getMany(e,t).then((e=>e[0]))}_resourceCacheFilter(e){return m.all(this.cache.matchAll("resource.item")).then((t=>(t.filter((t=>{if(t)return e.keyname&&t.resource.keyname?e.keyname===t.resource.keyname:v(e.id)&&v(t.resource.id)?e.id===t.resource.id:w(e,t.resource)})),[])))}}const ve=[];function ge(e){ve.push(e)}var be=Object.defineProperty,we=(e,t,r)=>(((e,t,r)=>{t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class _e extends te{constructor(e){super(e),we(this,"name","InsufficientPermissionsError"),we(this,"exception","nextgisweb.core.exception.InsufficientPermissions"),Object.setPrototypeOf(this,_e.prototype)}}const Oe=/\{ *([\w_-]+) *\}/g;function Pe(e,t){return e.replace(Oe,((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 je=Object.defineProperty,xe=(e,t,r)=>(((e,t,r)=>{t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class Ee extends Error{constructor(e){super(),xe(this,"name","NetworkError"),Object.setPrototypeOf(this,Ee.prototype),this.message=`Unable to request ${e}.\n Possibly invalid NGW URL entered or CORS not configured to get request from ${location.origin}`}}let Ce;Ce=(e,t,r={},n,s)=>{r.method=r.method||"GET";const o=new XMLHttpRequest;o.open(r.method||"GET",e,!0),"blob"===r.responseType&&(o.responseType=r.responseType);const i=()=>{try{return JSON.parse(o.responseText)}catch(e){return o.responseText}};o.onload=()=>{-1!==[401,403,404,422,500].indexOf(o.status)&&n(new te(i())),((e=!1)=>{const s=e?n:t;"blob"===r.responseType?s(o.response):o.responseText?s(i()):n({message:""})})()},o.onerror=t=>{n(0===o.status?new Ee(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 l in a){const e=a[l];"string"==typeof e&&o.setRequestHeader(l,e)}let c;if(void 0!==r.withCredentials&&(o.withCredentials=r.withCredentials),r.file){if(c=new FormData,c.append("file",r.file),r.data)for(const l in r.data)c.append(l,c[l])}else c=r.data?"string"==typeof r.data?r.data:JSON.stringify(r.data):null;s&&s((()=>{o.abort()})),o.send(c)};var Re=Object.defineProperty,Ie=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,qe=(e,t)=>{for(var r in t||(t={}))Le.call(t,r)&&Se(e,r,t[r]);if(Ie)for(var r of Ie(t))ke.call(t,r)&&Se(e,r,t[r]);return e},Te=(e,t,r)=>(Se(e,"symbol"!=typeof t?t+"":t,r),r);let Ae=0;class Ue{constructor(e){this.options=e,Te(this,"id",Ae++),Te(this,"emitter",new B),Te(this,"user"),Te(this,"resources"),Te(this,"routeStr","/api/component/pyramid/route"),Te(this,"activeRequests",[]),Te(this,"requestTransform");const t=function(e){return ve.find((t=>{if(t.options.baseUrl===e.baseUrl){if(!e.auth)return!0;if(t.options.auth)return w(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 me(this),ge(this)}static create(e){return new this(e)}setRequestTransform(e){this.requestTransform=e}setNgw(e){this.logout(),this.options.baseUrl=e,ge(this)}connect(){const e=new Y,t=this.options.auth;return e.add("route",(()=>new m(((e,r)=>{const n=()=>this.makeQuery(this.routeStr,{},{}).then((t=>{e(t)})).catch((e=>{r(e)}));if(t){const{login:e,password:s}=t;if(e&&s)return this._login({login:e,password:s}).then((()=>n())).catch((e=>r(e)))}return n()}))),{id:this.id,auth:t,baseUrl:this.options.baseUrl})}login(e,t){return this.logout(),ge(this),this._login(e,t)}logout(){this.abort(),function(e){const t=ve.indexOf(e);-1!==t&&ve.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 m.resolve(this.user);e&&(this.options.auth=e);const r=qe({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,s;const{method:o,headers:i,withCredentials:a,responseType:c}=r,l=_(t=null!=(n=r.params)?n:t),u=()=>function(e){const t=e.params;return new m(((r,n)=>{e.connector.connect().then((s=>{let o=s&&s[e.name];if(o){o=[...o];let s=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")}s&&(s=Pe(s,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&&(s=s+"?"+e.join("&"))}s?r(e.connector.makeQuery(s,t,e.requestOptions)):n(new Error("request url is not set"))}else r(void 0)})).catch((e=>{n(e)}))}))}({name:e,params:l,requestOptions:r,connector:this});if(r.cache&&"GET"===o){return(new Y).add(e,u,qe({params:l},_({headers:i,withCredentials:a,responseType:c,baseUrl:this.options.baseUrl,userId:null==(s=this.user)?void 0:s.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=Pe(e,t)),e=encodeURI(O(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 m.reject(new m.CancelError);const r=new m(((r,n,s)=>{if(this.user&&((t=t||{}).headers=qe(qe({},this.getAuthorizationHeaders()),t.headers)),this.requestTransform){const[r,n]=this.requestTransform(e,t);e=r,t=n}Ce(e,r,t,n,s)})).then((e=>(this._cleanActiveRequests(r),e))).catch((e=>{if(this._cleanActiveRequests(r),e instanceof m.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 te){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new se(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new _e(e)}return e}}function Ne(e,t,r){if((t=String(t))===(e=String(e)))return!0;if(r&&t.toUpperCase()===e.toUpperCase())return!0;const n=`^${s=t,s.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var s;return null!==new RegExp(n,r?"i":"").exec(e)}Te(Ue,"errors",{NgwError:te,ResourceNotFoundError:se});const Fe={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)=>Ne(e,t),ilike:(e,t)=>Ne(e,t,!0)};function $e(e){return 3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]}function Me(e,t){const r="string"==typeof t[0]?t[0]:"all",n=t=>{if($e(t)){const[r,n,s]=t,o=Fe[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,s))));return o(t,n)}return o(e[r],s)}return!1}return Me(e,t)},s=t.filter((e=>Array.isArray(e)));return"any"===r?s.some(n):s.every(n)}var De=Object.defineProperty,He=Object.defineProperties,Be=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Qe=(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={}))ze.call(t,r)&&Qe(e,r,t[r]);if(Ge)for(var r of Ge(t))Je.call(t,r)&&Qe(e,r,t[r]);return e},Xe=(e,t)=>He(e,Be(t));const Ke={srs:4326,geom_format:"geojson"};function Ve(e){const t=Ze(e);return m.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 s="",o="";return[`${"id"!==t?"fld_":""}${String(t).trim().replace(/^(%?)(.+?)(%?)$/,((e,t,r,n)=>(s=t,o=n,r)))}__${r}`,s+n+o]}function Ze(e,t=[],r=[]){const{filters:n}=e,s="string"==typeof n[0]?n[0]:"all",o=n.filter((e=>Array.isArray(e)));if("any"===s)for(const i of o)$e(i)?t.push(tt(Xe(We({},e),{paramList:[...r,Ye(i)]}))):Ze(Xe(We({},e),{filters:i}),t,[...r]);else if("all"===s){const n=[],s=[];for(const e of o)$e(e)?n.push(Ye(e)):s.push(e);if(s.length)for(const o of s)Ze(Xe(We({},e),{filters:o}),t,[...r,...n]);else t.push(tt(Xe(We({},e),{paramList:[...r,...n]})))}return t}function et(e){return`POLYGON((${e.map((([e,t])=>{const[r,n]=function(e,t){t=t>85.06?85.06:t<-85.06?-85.06:t;const r=20037508.34*e/180;let n=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return n=20037508.34*n/180,[r,n]}(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 tt(e){const t=We({},Ke),{limit:r,cache:n,signal:s,offset:o,orderBy:i,paramList:a,connector:c,geomFormat:l,intersects:u,resourceId:h}=e;if(r?r!==Number.POSITIVE_INFINITY&&(t.limit=r):t.limit=7e3,o&&(t.offset=o),l&&(t.geom_format=l),function(e,t){const{extensions:r,geom:n,fields:s,srs:o,ilike:i,like:a}=t,c=r?r.join(","):"";"*"!==c&&(e.extensions=c),void 0!==s&&(e.fields=Array.isArray(s)?s.join(","):""),void 0!==n&&(e.geom=n?"yes":"no",n||(delete e.srs,delete e.geom_format)),v(i)?e.ilike=i:v(a)&&(e.like=a),v(o)&&(e.srs=o)}(t,e),i&&(t.order_by=i.join(",")),Array.isArray(u)){const e=(f=u,Array.isArray(f)&&4===f.length&&f.every((e=>"number"==typeof e))?function(e){const t=[e[0],e[1]];return[t,[e[2],e[1]],[e[2],e[3]],[e[0],e[3]],t]}(u):u);t.intersects=et(e)}else"string"==typeof u&&(t.intersects=u);var f;a&&(t.paramList=a);const p=We({id:h},t);return c.get("feature_layer.feature.collection",{cache:n,signal:s},p)}var rt=Object.defineProperty,nt=Object.defineProperties,st=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,ct=(e,t,r)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lt=(e,t)=>{for(var r in t||(t={}))it.call(t,r)&&ct(e,r,t[r]);if(ot)for(var r of ot(t))at.call(t,r)&&ct(e,r,t[r]);return e},ut=(e,t)=>nt(e,st(t));function ht(e){const t=e.filters;return t?Ve(ut(lt({},e),{filters:t})).then((r=>{var n;return(null!=(n=e.clientFilterValidate)?n:ft(t))&&(r=r.filter((e=>Me(function(e){let t;for(t in e){const r=e[t];if("[object Object]"===Object.prototype.toString.call(r)){const n=r;if(v(n.year)&&v(n.month)&&v(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}(ut(lt({},e.fields),{id:e.id})),t)))),r})):tt(e)}function ft(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(ft(r))return!0}}return!1}var pt=Object.defineProperty,dt=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable,vt=(e,t,r)=>t in e?pt(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),bt=function(e,t){this[0]=e,this[1]=t},wt=(e,t,r)=>{var n,s,o=(e,t,n,s)=>{try{var i=r[e](t),a=(t=i.value)instanceof bt,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?o("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,s):n({value:r,done:c}))).catch((e=>o("throw",e,n,s)))}catch(l){s(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>o(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(s=Symbol[n])?s:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};const _t=class e extends D{constructor(e){var t;if(super(e),gt(this,"searchResources",[]),gt(this,"connector"),gt(this,"_abortControllers",[]),!e.searchUrl&&!(null==(t=e.connectorOptions)?void 0:t.baseUrl))throw new Error("The `searchUrl` of `connectorOptions.baseUrl` are required");this.connector=e.connector||new Ue(((e,t)=>{for(var r in t||(t={}))yt.call(t,r)&&vt(e,r,t[r]);if(dt)for(var r of dt(t))mt.call(t,r)&&vt(e,r,t[r]);return e})({baseUrl:this.searchUrl},e.connectorOptions)),this.searchResources=e.searchResources}abort(){this._abortControllers.forEach((e=>{e.abort()})),this._abortControllers.length=0}search(t){return wt(this,null,(function*(){var r,n;const s=this._makeSignal();for(const i of this.searchResources){if(s.aborted)break;const{searchMethod:a}=i,c=null!=(r=i.limit)?r:e.limit,l=null!=(n=i.id)?n:i.resourceId;try{const e=yield new bt(this.connector.getResourceOrFail(l,{cache:!0})),r={connector:this.connector,resourceId:l,signal:s,limit:c};"like"===a?r.like=t:r.ilike=t;const n=ht(r),o=yield new bt(n);for(const s of this._items({entries:o,query:t,config:i,resourceItem:e}))s.result=()=>this.result(s),yield s}catch(o){o&&"name"in o&&"CancelError"!==o.name&&console.warn(o)}}}))}result(e){const t=this._makeSignal();return this.connector.get("feature_layer.feature.item_extent",{signal:t},{id:e.resourceId,fid:e.featureId}).then((t=>{const r=t.extent;return{text:e.text,extent:[r.minLon,r.minLat,r.maxLon,r.maxLat]}}))}reverse(e){return wt(this,null,(function*(){throw new Error("Not implemented")}))}_makeSignal(){const e=new AbortController;return this._abortControllers.push(e),e.signal}_items({entries:e,query:t,config:r,resourceItem:n}){var s;const o=[];let i;n.feature_layer&&(i=null==(s=n.feature_layer.fields.find((e=>e.label_field)))?void 0:s.keyname);return this.searchResources.find((e=>{var t;return null!=(t=e.id)?t:e.resourceId===n.resource.id}))&&e.forEach((e=>{let s=i?e.fields[i]:e.id;r.renderSearch?s=r.renderSearch({item:e,resourceItem:n}):i&&(s=e.fields[i]),o.push({query:t,text:s,featureId:e.id,resourceId:n.resource.id,item:e,resourceItem:n})})),o}};gt(_t,"limit",300);let Ot=_t;var Pt=Object.defineProperty,jt=(e,t,r)=>(((e,t,r)=>{t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),xt=function(e,t){this[0]=e,this[1]=t},Et=(e,t,r)=>{var n,s,o=(e,t,n,s)=>{try{var i=r[e](t),a=(t=i.value)instanceof xt,c=i.done;Promise.resolve(a?t[0]:t).then((r=>a?o("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,s):n({value:r,done:c}))).catch((e=>o("throw",e,n,s)))}catch(l){s(l)}},i=e=>a[e]=t=>new Promise(((r,n)=>o(e,t,r,n))),a={};return r=r.apply(e,t),a[(n="asyncIterator",(s=Symbol[n])?s:Symbol.for("Symbol."+n))]=()=>a,i("next"),i("throw"),i("return"),a};return e.BaseProvider=D,e.Geocoder=F,e.NgwProvider=Ot,e.NominatimProvider=class extends D{constructor(e){super(e),jt(this,"searchUrl","https://nominatim.openstreetmap.org"),jt(this,"_requests",[]),e&&e.searchUrl&&(this.searchUrl=e.searchUrl)}abort(){this._requests.forEach((e=>e.cancel())),this._requests=[]}search(e){return Et(this,null,(function*(){const t=O(`${this.searchUrl}/search?format=geojson&polygon_geojson=1&q=${e}`),r=new m(((r,n,s)=>{const o=new XMLHttpRequest;o.open("GET",t,!0),o.onload=()=>{try{const t=JSON.parse(o.responseText).features.map((t=>({geom:t,extent:t.bbox,text:t.properties&&t.properties.display_name,query:e})));r(t)}catch(t){n(t)}},o.onerror=e=>{n(e)},s((()=>{o.abort()})),o.send()})).catch((e=>{throw e}));this._requests.push(r);const n=yield new xt(r);if(n)for(const e of n)e.result=()=>this.result(e),yield e}))}result(e){return m.resolve({text:e.text,extent:e.extent||[],geom:e.geom})}reverse(e){return Et(this,null,(function*(){const[t,r]=e,n=O(`${this.searchUrl}/reverse?format=geojson&lat=${r}&lon=${t}`),s=new m(((e,s,o)=>{const i=new XMLHttpRequest;i.open("GET",n,!0),i.onload=()=>{try{const n=JSON.parse(i.responseText).features[0];e({geom:n,extent:n.bbox,text:n.properties&&n.properties.display_name,query:`${r}, ${t}`})}catch(n){s(n)}},i.onerror=e=>{s(e)},o((()=>{i.abort()})),i.send()})).catch((e=>{throw e}));this._requests.push(s);const o=yield new xt(s);o&&(o.result=()=>this.result(o),yield o)}))}},e.create=function(e){return new F(e)},e}({});
2
2
  //# sourceMappingURL=geocoder.global.prod.js.map