@nextgis/geocoder 1.17.0 → 1.18.6
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.
- package/README.md +40 -5
- package/lib/geocoder.cjs.js +105 -43
- package/lib/geocoder.cjs.js.map +1 -1
- package/lib/geocoder.cjs.prod.js +1 -1
- package/lib/geocoder.cjs.prod.js.map +1 -1
- package/lib/geocoder.esm-browser.js +474 -46
- package/lib/geocoder.esm-browser.js.map +1 -1
- package/lib/geocoder.esm-browser.prod.js +1 -1
- package/lib/geocoder.esm-browser.prod.js.map +1 -1
- package/lib/geocoder.esm-bundler.js +105 -43
- package/lib/geocoder.esm-bundler.js.map +1 -1
- package/lib/geocoder.esm-bundler.prod.js +1 -1
- package/lib/geocoder.esm-bundler.prod.js.map +1 -1
- package/lib/geocoder.global.js +498 -90
- package/lib/geocoder.global.js.map +1 -1
- package/lib/geocoder.global.prod.js +1 -1
- package/lib/geocoder.global.prod.js.map +1 -1
- package/lib/index.d.ts +131 -9
- package/package.json +5 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Geocoder=function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)};function o(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(t){i(t)}}function u(e){try{c(r.throw(e))}catch(t){i(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,u)}c((r=r.apply(e,t||[])).next())}))}function i(e,t){var n,r,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(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=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++,r=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],r=0}finally{n=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,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function c(e){return this instanceof c?(this.v=e,this):new c(e)}function a(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||u(e,t)}))})}function u(e,t){try{(n=o[e](t)).value instanceof c?Promise.resolve(n.value.v).then(a,f):h(i[0][2],n)}catch(r){h(i[0][3],r)}var n}function a(e){u("next",e)}function f(e){u("throw",e)}function h(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,n=e[Symbol.asyncIterator];return n?n.call(e):(e=s(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var h=function(e){function t(){var n=e.call(this)||this;return n.name="CancelError",Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error),p=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 n=this,r=t||e,o=this._promises.get(r);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(r,e),e.finally((function(){n.remove(r)})),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 n=this.get(t=t||e.name);return n||this.add(e(),t)},e.prototype.WaitForMe=function(e){void 0===e&&(e="");var t=this.get.bind(this),n=this.add.bind(this);return function(r,o,i){var s=i.value;return e=e||o,i.value=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=t(e);return i||n(s.apply(this,r),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}(),l=function(e){function t(){var n=e.call(this)||this;return n.name="TimeoutError",Object.setPrototypeOf(n,t.prototype),n}return n(t,e),t}(Error),d=function(e,t,n,r){try{e(n(r))}catch(o){t(o)}},v=0,y=function(){function e(t,n){var r=this;this.id=v++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(e,t){r._setCanceledCallback=function(t){return e(t||new h)}}));var o=[this._cancelPromise,new Promise((function(n,o){return t((function(t){t instanceof e?r.attach(t):r._isPending=!1,n(t)}),(function(e){r._isPending=!1,o(e)}),(function(e){if(!r._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");r._cancelHandlers.push(e)}))}))];n&&o.push(new Promise((function(e,t){setTimeout((function(){if(r._isPending)try{r.cancel()}finally{t(new l)}}),n)}))),this._promise=Promise.race(o)}return e.createControl=function(e){return new p(e)},e.resolve=function(t){return new e((function(e){return e(t)}))},e.reject=function(t){return new e((function(e,n){return n(t)}))},e.all=function(t){var n=this;return new e((function(e,n){Promise.all(t).then(e).catch(n)})).catch((function(e){if(e instanceof n.CancelError)for(var r=0,o=t;r<o.length;r++){var i=o[r];"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,n){var r=this,o=new e((function(e,o){if(r._promise){var i=function(t){n?d(e,o,n,t):o(t)};r._promise.then((function(n){r._isCanceled?i(n):t?d(e,o,t,n):e(n)}),i)}}));return o._parentPromise=this,this._children.push(o),o},e.prototype.catch=function(e){return this._isCanceled&&e&&e(new h),this.then(void 0,e)},e.prototype.finally=function(e){return this._promise?this._promise.finally(e):Promise.reject(this._isCanceled?new h: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,n=this._cancelHandlers;t<n.length;t++){(0,n[t])()}}catch(r){}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=h,e.TimeoutError=l,e.PromiseControl=p,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,n,r){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===n?t===r:w(e,t));return e===t}function w(e,t){var n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;if(n.join("")!==r.join(""))return!1;for(var o=0;o<n.length;o++){if(!_(e[n[o]],t[r[o]],e,t))return!1}return!0}function O(e){var t={};return Object.keys(e).forEach((function(n){e[n]instanceof Array||e[n]!==Object(e[n])?void 0!==e[n]&&(t[n]=e[n]):t[n]=O(e[n])})),t}function E(e){return e.replace(/([^:]\/)\/+/g,"$1")}var x,P=function(e){e&&function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0,o=t;r<o.length;r++)for(var i=o[r],s=0,u=Object.getOwnPropertyNames(i);s<u.length;s++){var c=u[s];e[c]=i[c]}}(this,e)},R=0,C=function(e){function t(t){var n=e.call(this,t)||this;return n.providers=[],t&&t.providers&&(n.providers=t.providers),n}return n(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,n,o,s,u,a,h,p,l,d,v;return i(this,(function(i){switch(i.label){case 0:t=0,n=this.providers,i.label=1;case 1:if(!(t<n.length))return[3,19];o=n[t],i.label=2;case 2:i.trys.push([2,17,,18]),s=o.search(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 h=i.sent(),(l=h.done)?[3,9]:(u=!1,[4,c(r(r({},h.value),{provider:o,_id:R++}))]);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 p=i.sent(),d={error:p},[3,16];case 11:return i.trys.push([11,,14,15]),u||l||!(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.result=function(e){return e.provider?e.provider.result(e):m.resolve(void 0)},t}(P),L=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(P),j={exports:{}},q="object"==typeof Reflect?Reflect:null,T=q&&"function"==typeof q.apply?q.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};x=q&&"function"==typeof q.ownKeys?q.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var I=Number.isNaN||function(e){return e!=e};function k(){k.init.call(this)}j.exports=k,j.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}D(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&D(e,"error",t,n)}(e,o,{once:!0})}))},k.EventEmitter=k,k.prototype._events=void 0,k.prototype._eventsCount=0,k.prototype._maxListeners=void 0;var S=10;function A(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function F(e){return void 0===e._maxListeners?k.defaultMaxListeners:e._maxListeners}function N(e,t,n,r){var o,i,s,u;if(A(n),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),i=e._events),s=i[t]),void 0===s)s=i[t]=n,++e._eventsCount;else if("function"==typeof s?s=i[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(o=F(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,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=U.bind(r);return o.listener=n,r.wrapFn=o,o}function H(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):G(o,o.length)}function B(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function G(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function D(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);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){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return S},set:function(e){if("number"!=typeof e||e<0||I(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");S=e}}),k.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||I(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},k.prototype.getMaxListeners=function(){return F(this)},k.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){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)T(u,this,t);else{var c=u.length,a=G(u,c);for(n=0;n<c;++n)T(a[n],this,t)}return!0},k.prototype.on=k.prototype.addListener=function(e,t){return N(this,e,t,!1)},k.prototype.prependListener=function(e,t){return N(this,e,t,!0)},k.prototype.once=function(e,t){return A(t),this.on(e,M(this,e,t)),this},k.prototype.prependOnceListener=function(e,t){return A(t),this.prependListener(e,M(this,e,t)),this},k.prototype.removeListener=function(e,t){var n,r,o,i,s;if(A(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){s=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},k.prototype.off=k.prototype.removeListener,k.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},k.prototype.listeners=function(e){return H(this,e,!0)},k.prototype.rawListeners=function(e){return H(this,e,!1)},k.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):B.call(e,t)},k.prototype.listenerCount=B,k.prototype.eventNames=function(){return this._eventsCount>0?x(this._events):[]};var z,J=function(){function e(t){var n;void 0===t&&(t={}),this.cache=[];var r=null!==(n=t.namespace)&&void 0!==n?n:"default";return e.instance[r]?e.instance[r]:(e.instance[r]=this,this)}return e.prototype.clean=function(){this.cache.length=0},e.prototype.all=function(){return this.cache},e.prototype.addFull=function(e,t,n){return this.add(e,t,n,!0)},e.prototype.add=function(e,t,n,r){var o=this,i=this._find(e,n);if(i)return i.value;var s=void 0;s=t instanceof Function?t():t;var u=n&&JSON.parse(JSON.stringify(O(n))),c={key:e,value:s,props:u,options:u};return r&&!b(s)?s:(this.cache.push(c),s instanceof Promise?(s.catch((function(t){throw o.delete(e,n),t})),r&&s.then((function(t){return b(t)||o.delete(e,n),t})),s):s)},e.prototype.match=function(e,t){var n=this._find(e,t);if(n)return n.value},e.prototype.matchAll=function(e,t){var n=this;return e?this.cache.filter((function(r){return n._filter(r,e,t)})).map((function(e){return e.value})):this.cache.map((function(e){return e.value}))},e.prototype.delete=function(e,t){var n=this,r=[];"string"==typeof e?r=this.cache.filter((function(r){return n._filter(r,e,t)})):r.push(e);for(var o=0,i=r;o<i.length;o++){var s=this.cache.indexOf(i[o]);this.cache.splice(s,1)}},e.prototype._find=function(e,t){var n=this;return this.cache.find((function(r){return n._filter(r,e,t)}))},e.prototype._filter=function(e,t,n){return e.key===t&&(!n||w(e.props||e.options||{},O(n)))},e.instance={},e}(),Q=J,W=function(e){function t(n){var r=e.call(this)||this;return r.name="NetworkError",Object.setPrototypeOf(r,t.prototype),r.message="Unable to request ".concat(n,".\n Possibly invalid NGW URL entered or CORS not configured to get request from ").concat(location.origin),r}return n(t,e),t}(Error),K=function(e){function t(n){var r=e.call(this)||this;return r.name="NgwError",Object.assign(r,n),Object.setPrototypeOf(r,t.prototype),r}return n(t,e),t}(Error);function X(e){return"[object Object]"===Object.prototype.toString.call(e)}z=function(e,t,n,r,o){void 0===n&&(n={}),n.method=n.method||"GET";var i=new XMLHttpRequest;i.open(n.method||"GET",e,!0),"blob"===n.responseType&&(i.responseType=n.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)&&r(new K(s())),function(e){void 0===e&&(e=!1);var o=e?r:t;"blob"===n.responseType?o(i.response):i.responseText?o(s()):r({message:""})}()},i.onerror=function(t){r(0===i.status?new W(e):t)},i.upload.onprogress=function(e){e.lengthComputable&&(n.onProgress&&n.onProgress(e.loaded/e.total*100,e))};var u,c=n.headers;if(c)for(var a in c){var f=c[a];"string"==typeof f&&i.setRequestHeader(a,f)}if(void 0!==n.withCredentials&&(i.withCredentials=n.withCredentials),n.file){if((u=new FormData).append("file",n.file),n.data)for(var h in n.data)u.append(h,u[h])}else u=n.data?"string"==typeof n.data?n.data:JSON.stringify(n.data):null;o&&o((function(){i.abort()})),i.send(u)};var $=/\{ *([\w_-]+) *\}/g;function V(e,t){return e.replace($,(function(e,n){var r=t[n];if(void 0===r)throw new Error("No value provided for letiable "+e);return"function"==typeof r&&(r=r(t)),r}))}var Y=function(e){function t(n){var r=e.call(this,n)||this;return r.name="ResourceNotFoundError",r.exception="nextgisweb.resource.exception.ResourceNotFound",Object.setPrototypeOf(r,t.prototype),r}return n(t,e),t}(K),Z=function(e){function t(n){var r=e.call(this,n)||this;return r.name="InsufficientPermissionsError",r.exception="nextgisweb.core.exception.InsufficientPermissions",Object.setPrototypeOf(r,t.prototype),r}return n(t,e),t}(K),ee=[];function te(e){ee.push(e)}var ne=["description"];function re(e,t){void 0===t&&(t=""),t=t?t+"__":"";for(var n={},r=0,o=Object.entries(e);r<o.length;r++){var i=o[r],s=i[0],u=i[1];if(-1===ne.indexOf(s))if(X(u))if("owner_user"===s){var c=re(u,s);Object.assign(n,c)}else"parent"===s&&"id"in u&&(n.parent_id=u.id);else g(u)&&(n[t+s]=u)}return n}var oe=function(){function e(e){this.connector=e,this.cache=new Q}return e.prototype.getOne=function(e,t){var n=this,o=new Q,i={},s=r(r({},t),{cache:!1});"string"==typeof e?i.keyname=e:"number"==typeof e?i.id=e:X(e)&&(void 0!==e.id?i.id=e.id:e.keyname&&(i.keyname=e.keyname));return o.addFull("resource",(function(){return"string"==typeof e?n._fetchResourceBy({keyname:e},s):"number"==typeof e?n._fetchResourceById(e,s):X(e)?n._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 Y}))},e.prototype.getId=function(e,t){return"number"==typeof e?m.resolve(e):"string"==typeof e||X(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 n=this;return this._resourceCacheFilter(e).then((function(o){if(!o.length){var i={};return e.keyname?i.keyname=e.keyname:Object.assign(i,re(e)),n.connector.get("resource.search",t,r({serialization:"full"},i)).then((function(e){if(e)for(var t=0,r=e;t<r.length;t++){var o=r[t];n.cache.add("resource.item",m.resolve(o),{id:o.resource.id})}return e}))}return o}))},e.prototype.getParent=function(e,t){var n=this;return this.getOne(e,t).then((function(e){return e?n.getOne(e.resource.parent.id,t):m.resolve(void 0)}))},e.prototype.getChildrenOf=function(e,t){var n=this;return this.getIdOrFail(e).then((function(e){return n._getChildrenOf(e,t)}))},e.prototype.update=function(e,t){var n=this;return this.getId(e).then((function(e){if(void 0!==e)return n.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,n){var o=this;return void 0===n&&(n=[]),this.connector.get("resource.collection",r({cache:!0},t),{parent:e}).then((function(e){for(var r=[],i=0,s=e;i<s.length;i++){var u=s[i];o.cache.add("resource.item",m.resolve(u),{id:u.resource.id}),n.push(u),(null==t?void 0:t.recursive)&&u.resource.children&&r.push(o._getChildrenOf(u.resource.id,t,n))}return r.length?m.all(r).then((function(){return n})):n}))},e.prototype._cleanResourceItemCache=function(e){return o(this,void 0,void 0,(function(){var t,n,r,o,s,u,c,a;return i(this,(function(i){switch(i.label){case 0:t=this.cache.all(),n=[],r=0,o=t,i.label=1;case 1:return r<o.length?(u=(s=o[r]).options&&s.options.id,["resource.item","resource"].includes(s.key)&&void 0!==u?"number"!=typeof u?[3,2]:(u===e&&n.push(s),[3,4]):[3,4]):[3,5];case 2:return[4,this.getId(u)];case 3:i.sent()===e&&n.push(s),i.label=4;case 4:return r++,[3,1];case 5:for(c=0,a=n;c<a.length;c++)this.cache.delete(a[c]);return[2]}}))}))},e.prototype._fetchResourceById=function(e,t){var n=this;return this.cache.add("resource.item",(function(){return n.connector.get("resource.item",t,{id:e})}),{id:e}).catch((function(e){if(!(e instanceof Y))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}(),ie=0,se=function(){function e(e){this.options=e,this.id=ie++,this.emitter=new j.exports.EventEmitter,this.routeStr="/api/component/pyramid/route",this.activeRequests=[];var t=function(e){return ee.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 oe(this),te(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,te(this)},e.prototype.connect=function(){var e=this,t=new Q,n=this.options.auth;return t.add("route",(function(){return new m((function(t,r){var o=function(){return e.makeQuery(e.routeStr,{},{}).then((function(e){t(e)})).catch((function(e){r(e)}))};if(n){var i=n.login,s=n.password;if(i&&s)return e._login({login:i,password:s}).then((function(){return o()})).catch((function(e){return r(e)}))}return o()}))}),{id:this.id,auth:n,baseUrl:this.options.baseUrl})},e.prototype.login=function(e,t){return this.logout(),te(this),this._login(e,t)},e.prototype.logout=function(){var e;this.abort(),-1!==(e=ee.indexOf(this))&&ee.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 n=r({headers:this.getAuthorizationHeaders(e)},t);return this.makeQuery("/api/component/auth/current_user",{},n)},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,n=unescape(encodeURIComponent("".concat(e.login,":").concat(t)));return window.btoa(n)}},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,n){var o,i=this;void 0===t&&(t={}),void 0===n&&(n={});var s=n.method,c=n.headers,a=n.withCredentials,f=n.responseType,h=O(t),p=function(){return function(e){var t=e.params;return new m((function(n,r){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=V(s,c))}if(t){var h=[],p=t.paramList;for(var l in Array.isArray(p)&&(delete t.paramList,p.forEach((function(e){h.push("".concat(e[0],"=").concat(e[1]))}))),t)-1===i.indexOf(l)&&h.push("".concat(l,"=").concat(t[l]));h.length&&(s=s+"?"+h.join("&"))}s?n(e.connector.makeQuery(s,t,e.requestOptions)):r(new Error("request url is not set"))}else n(void 0)})).catch((function(e){r(e)}))}))}({name:e,params:h,requestOptions:n,connector:i})};return n.cache&&"GET"===s?(new Q).add(e,p,r({params:h},O({headers:c,withCredentials:a,responseType:f,baseUrl:this.options.baseUrl,userId:null===(o=this.user)||void 0===o?void 0:o.id}))):p()},e.prototype.post=function(e,t,n){return(t=t||{}).method="POST",this.apiRequest(e,n,t)},e.prototype.get=function(e,t,n){return(t=t||{}).method="GET",this.apiRequest(e,n,t)},e.prototype.patch=function(e,t,n){return(t=t||{}).method="PATCH",this.apiRequest(e,n,t)},e.prototype.put=function(e,t,n){return(t=t||{}).method="PUT",this.apiRequest(e,n,t)},e.prototype.delete=function(e,t,n){return(t=t||{}).method="DELETE",this.apiRequest(e,n,t)},e.prototype.makeQuery=function(e,t,n){if(void 0===n&&(n={}),e=(this.options.baseUrl?this.options.baseUrl:"")+e)return t&&(e=V(e,t)),e=encodeURI(E(e)),this._loadData(e,n);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 n=this;t.responseType=t.responseType||"json";var o=new m((function(o,i,s){if(n.user&&((t=t||{}).headers=r(r({},n.getAuthorizationHeaders()),t.headers)),n.requestTransform){var u=n.requestTransform(e,t);e=u[0],t=u[1]}z(e,o,t,i,s)})).then((function(e){return n._cleanActiveRequests(o),e})).catch((function(e){if(n._cleanActiveRequests(o),e instanceof m.CancelError);else{var t=n._handleHttpError(e);if(t)throw t}}));return t.signal&&"function"==typeof t.signal.addEventListener&&t.signal.addEventListener("abort",(function(){o.cancel(),n._cleanActiveRequests(o)})),this.activeRequests.push(o),o},e.prototype._login=function(e,t){var n=this;return this.getUserInfo(e,t).then((function(e){return n.user=e,n.emitter.emit("login",e),e})).catch((function(e){throw n.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 K){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new Y(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new Z(e)}return e},e.errors={NgwError:K,ResourceNotFoundError:Y},e}(),ue=se,ce=function(e){function t(t){var n=e.call(this,t)||this;return n.caseInsensitive=!0,n.searchUrl="https://maxim.nextgis.com",n.searchResources=[],n.requests=[],n.connector=t.connector||new ue({baseUrl:n.searchUrl}),n.searchResources=t.searchResources,n}return n(t,e),t.prototype.abort=function(){this.requests.forEach((function(e){e.cancel()})),this.requests=[]},t.prototype.search=function(e){return a(this,arguments,(function(){var t,n,o,s,u=this;return i(this,(function(a){switch(a.label){case 0:t=function(t){var o,s,a,f,h,p;return i(this,(function(l){switch(l.label){case 0:return o=n.connector.get("feature_layer.store",{headers:{RANGE:"items=0-".concat(t.limit||300)}},{id:t.id,like:e}),n.requests.push(o),o.catch((function(e){console.warn(e)})),[4,c(o)];case 1:s=l.sent(),a=[],s&&s.forEach((function(n){a.push(r({query:e,resourceId:t.id},n))})),f=function(e){return i(this,(function(t){switch(t.label){case 0:return e.result=function(){return u.result(e)},[4,c(e)];case 1:return[4,t.sent()];case 2:return t.sent(),[2]}}))},h=0,p=n._items(a),l.label=2;case 2:return h<p.length?[5,f(p[h])]:[3,5];case 3:l.sent(),l.label=4;case 4:return h++,[3,2];case 5:return[2]}}))},n=this,o=0,s=this.searchResources,a.label=1;case 1:return o<s.length?[5,t(s[o])]:[3,4];case 2:a.sent(),a.label=3;case 3:return o++,[3,1];case 4:return[2]}}))}))},t.prototype.result=function(e){var t=this.connector.get("feature_layer.feature.item_extent",null,{id:e.resourceId,fid:e.featureId}).then((function(t){var n=t.extent;return{text:e.text,extent:[n.minLon,n.minLat,n.maxLon,n.maxLat]}}));return this.requests.push(t),t},t.prototype._items=function(e){var t=this,n=[];return e.forEach((function(e){t.searchResources.find((function(t){return t.id===e.resourceId}))&&n.push({query:e.query,text:e.label,featureId:e.id,resourceId:e.resourceId})})),n},t}(L),ae=function(e){function t(t){var n=e.call(this,t)||this;return n.searchUrl="https://nominatim.openstreetmap.org",n._requests=[],n}return n(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,n,r,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)),n=new m((function(n,r,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}}));n(t)}catch(o){r(o)}},i.onerror=function(e){r(e)},o((function(){i.abort()})),i.send()})).catch((function(e){throw e})),this._requests.push(n),[4,c(n)];case 1:if(!(r=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=r,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}(L);return e.BaseProvider=L,e.Geocoder=C,e.NgwProvider=ce,e.NominatimProvider=ae,e.create=function(e){return new C(e)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
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;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];o=r[t],i.label=2;case 2:i.trys.push([2,17,,18]),s=o.search(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.result=function(e){return e.provider?e.provider.result(e):m.resolve(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):G(o,o.length)}function B(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 G(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=G(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):B.call(e,t)},T.prototype.listenerCount=B,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=$,Q=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),W=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);function K(e){return"[object Object]"===Object.prototype.toString.call(e)}z=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 W(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 Q(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 V=/\{ *([\w_-]+) *\}/g;function X(e,t){return e.replace(V,(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 Y=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}(W),Z=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}(W),ee=[];function te(e){ee.push(e)}var re=["description"];function ne(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===re.indexOf(s))if(K(u))if("owner_user"===s){var c=ne(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 oe=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:K(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):K(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 Y}))},e.prototype.getId=function(e,t){return"number"==typeof e?m.resolve(e):"string"==typeof e||K(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,ne(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 Y))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}(),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 ee.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 oe(this),te(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,te(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(),te(this),this._login(e,t)},e.prototype.logout=function(){var e;this.abort(),-1!==(e=ee.indexOf(this))&&ee.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=X(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=X(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]}z(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 W){if("nextgisweb.resource.exception.ResourceNotFound"===e.exception)throw new Y(e);if("nextgisweb.core.exception.InsufficientPermissions"===e.exception)throw new Z(e)}return e},e.errors={NgwError:W,ResourceNotFoundError:Y},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;r&&(e.extensions=r.join(",")),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._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=[],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}(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}({});
|
|
2
2
|
//# sourceMappingURL=geocoder.global.prod.js.map
|