website/web/static/js/openlayers-7.5.1/en/latest/ol/dist/ol.js
2023-08-19 19:11:33 -07:00

5 lines
748 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var ol=function(){"use strict";const t={1:"The view center is not defined",2:"The view resolution is not defined",3:"The view rotation is not defined",4:"`image` and `src` cannot be provided at the same time",5:"`imgSize` must be set when `image` is provided",7:"`format` must be set when `url` is set",8:"Unknown `serverType` configured",9:"`url` must be configured or set using `#setUrl()`",10:"The default `geometryFunction` can only handle `Point` geometries",11:"`options.featureTypes` must be an Array",12:"`options.geometryName` must also be provided when `options.bbox` is set",13:"Invalid corner",14:"Invalid color",15:"Tried to get a value for a key that does not exist in the cache",16:"Tried to set a value for a key that is used already",17:"`resolutions` must be sorted in descending order",18:"Either `origin` or `origins` must be configured, never both",19:"Number of `tileSizes` and `resolutions` must be equal",20:"Number of `origins` and `resolutions` must be equal",22:"Either `tileSize` or `tileSizes` must be configured, never both",24:"Invalid extent or geometry provided as `geometry`",25:"Cannot fit empty extent provided as `geometry`",26:"Features must have an id set",27:"Features must have an id set",28:'`renderMode` must be `"hybrid"` or `"vector"`',30:"The passed `feature` was already added to the source",31:"Tried to enqueue an `element` that was already added to the queue",32:"Transformation matrix cannot be inverted",33:"Invalid units",34:"Invalid geometry layout",36:"Unknown SRS type",37:"Unknown geometry type found",38:"`styleMapValue` has an unknown type",39:"Unknown geometry type",40:"Expected `feature` to have a geometry",41:"Expected an `ol/style/Style` or an array of `ol/style/Style.js`",42:"Question unknown, the answer is 42",43:"Expected `layers` to be an array or a `Collection`",47:"Expected `controls` to be an array or an `ol/Collection`",48:"Expected `interactions` to be an array or an `ol/Collection`",49:"Expected `overlays` to be an array or an `ol/Collection`",50:"`options.featureTypes` should be an Array",51:"Either `url` or `tileJSON` options must be provided",52:"Unknown `serverType` configured",53:"Unknown `tierSizeCalculation` configured",55:"The {-y} placeholder requires a tile grid with extent",56:"mapBrowserEvent must originate from a pointer event",57:"At least 2 conditions are required",59:"Invalid command found in the PBF",60:"Missing or invalid `size`",61:"Cannot determine IIIF Image API version from provided image information JSON",62:"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",64:"Layer opacity must be a number",66:"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",67:"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",68:"A VectorTile source can only be rendered if it has a projection compatible with the view projection",69:"`width` or `height` cannot be provided together with `scale`"};class e extends Error{constructor(e){const i=t[e];super(i),this.code=e,this.name="AssertionError",this.message=i}}var i=e;function n(t){t.stopPropagation()}var r=class{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},s="propertychange";var o=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function a(t,e,i){let n,r;i=i||l;let s=0,o=t.length,a=!1;for(;s<o;)n=s+(o-s>>1),r=+i(t[n],e),r<0?s=n+1:(o=n,a=!r);return a?s:~s}function l(t,e){return t>e?1:t<e?-1:0}function h(t,e){return t<e?1:t>e?-1:0}function c(t,e,i){if(t[0]<=e)return 0;const n=t.length;if(e<=t[n-1])return n-1;if("function"==typeof i){for(let r=1;r<n;++r){const n=t[r];if(n===e)return r;if(n<e)return i(e,t[r-1],n)>0?r-1:r}return n-1}if(i>0){for(let i=1;i<n;++i)if(t[i]<e)return i-1;return n-1}if(i<0){for(let i=1;i<n;++i)if(t[i]<=e)return i;return n-1}for(let i=1;i<n;++i){if(t[i]==e)return i;if(t[i]<e)return t[i-1]-e<e-t[i]?i-1:i}return n-1}function u(t,e,i){for(;e<i;){const n=t[e];t[e]=t[i],t[i]=n,++e,--i}}function d(t,e){const i=Array.isArray(e)?e:[e],n=i.length;for(let e=0;e<n;e++)t[t.length]=i[e]}function g(t,e){const i=t.length;if(i!==e.length)return!1;for(let n=0;n<i;n++)if(t[n]!==e[n])return!1;return!0}function f(t,e,i){const n=e||l;return t.every((function(e,r){if(0===r)return!0;const s=n(t[r-1],e);return!(s>0||i&&0===s)}))}function p(){return!0}function m(){return!1}function _(){}function y(t){let e,i,n,r=!1;return function(){const s=Array.prototype.slice.call(arguments);return r&&this===n&&g(s,i)||(r=!0,n=this,i=s,e=t.apply(this,arguments)),e}}function x(t){return function(){let e;try{e=t()}catch(t){return Promise.reject(t)}return e instanceof Promise?e:Promise.resolve(e)}()}function v(t){for(const e in t)delete t[e]}function S(t){let e;for(e in t)return!1;return!e}var w=class extends o{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(t){const e="string"==typeof t,i=e?t:t.type,n=this.listeners_&&this.listeners_[i];if(!n)return;const s=e?new r(t):t;s.target||(s.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});let l;i in o||(o[i]=0,a[i]=0),++o[i];for(let t=0,e=n.length;t<e;++t)if(l="handleEvent"in n[t]?n[t].handleEvent(s):n[t].call(this,s),!1===l||s.propagationStopped){l=!1;break}if(0==--o[i]){let t=a[i];for(delete a[i];t--;)this.removeEventListener(i,_);delete o[i]}return l}disposeInternal(){this.listeners_&&v(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return!!this.listeners_&&(t?t in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(t,e){const i=this.listeners_&&this.listeners_[t];if(i){const n=i.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=_,++this.pendingRemovals_[t]):(i.splice(n,1),0===i.length&&delete this.listeners_[t]))}}},E="change",T="error",C="contextmenu",R="click",b="dblclick",P="dragenter",I="dragover",F="drop",L="keydown",M="keypress",A="load",O="touchmove",N="wheel";function D(t,e,i,n,r){if(n&&n!==t&&(i=i.bind(n)),r){const n=i;i=function(){t.removeEventListener(e,i),n.apply(this,arguments)}}const s={target:t,type:e,listener:i};return t.addEventListener(e,i),s}function k(t,e,i,n){return D(t,e,i,n,!0)}function G(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),v(t))}class j extends w{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(E)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=D(this,t[r],e);return n}return D(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const n=t.length;i=new Array(n);for(let r=0;r<n;++r)i[r]=k(this,t[r],e)}else i=k(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)B(i);else if(Array.isArray(t))for(let i=0,n=t.length;i<n;++i)this.removeEventListener(t[i],e);else this.removeEventListener(t,e)}}function B(t){if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)G(t[e]);else G(t)}j.prototype.on,j.prototype.once,j.prototype.un;var U=j;function z(){throw new Error("Unimplemented abstract method.")}let X=0;function V(t){return t.ol_uid||(t.ol_uid=String(++X))}class W extends r{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}var Z=class extends U{constructor(t){super(),this.on,this.once,this.un,V(this),this.values_=null,void 0!==t&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new W(i,t,e)),i=s,this.hasListener(i)&&this.dispatchEvent(new W(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const n=this.values_||(this.values_={});if(i)n[t]=e;else{const i=n[t];n[t]=e,i!==e&&this.notify(t,i)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],S(this.values_)&&(this.values_=null),e||this.notify(t,i)}}},Y="add",K="remove";const H="length";class q extends r{constructor(t,e,i){super(t),this.element=e,this.index=i}}class $ extends Z{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let t=0,e=this.array_.length;t<e;++t)this.assertUnique_(this.array_[t],t);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,n=e.length;i<n;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(H)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new q(Y,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,n=e.length;i<n;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new q(K,e,t)),e}setAt(t,e){if(t>=this.getLength())return void this.insertAt(t,e);if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const i=this.array_[t];this.array_[t]=e,this.dispatchEvent(new q(K,i,t)),this.dispatchEvent(new q(Y,e,t))}updateLength_(){this.set(H,this.array_.length)}assertUnique_(t,e){for(let n=0,r=this.array_.length;n<r;++n)if(this.array_[n]===t&&n!==e)throw new i(58)}}var J=0,Q=1,tt=2,et=3,it=4;function nt(t){return Math.pow(t,3)}function rt(t){return 1-nt(1-t)}function st(t){return 3*t*t-2*t*t*t}function ot(t){return t}var at=class extends w{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.interimTile=null,this.key="",this.transition_=void 0===i.transition?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(E)}release(){this.state===et&&this.setState(it)}getKey(){return this.key+"/"+this.tileCoord}getInterimTile(){if(!this.interimTile)return this;let t=this.interimTile;do{if(t.getState()==tt)return this.transition_=0,t;t=t.interimTile}while(t);return this}refreshInterimChain(){if(!this.interimTile)return;let t=this.interimTile,e=this;do{if(t.getState()==tt){t.interimTile=null;break}t.getState()==Q?e=t:t.getState()==J?e.interimTile=t.interimTile:e=t,t=e.interimTile}while(t)}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==et&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}load(){z()}getAlpha(t,e){if(!this.transition_)return 1;let i=this.transitionStarts_[t];if(i){if(-1===i)return 1}else i=e,this.transitionStarts_[t]=i;const n=e-i+1e3/60;return n>=this.transition_?1:nt(n/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}};const lt="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",ht=lt.includes("firefox"),ct=lt.includes("safari")&&!lt.includes("chrom"),ut=ct&&(lt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(lt)),dt=lt.includes("webkit")&&!lt.includes("edge"),gt=lt.includes("macintosh"),ft="undefined"!=typeof devicePixelRatio?devicePixelRatio:1,pt="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,mt="undefined"!=typeof Image&&Image.prototype.decode,_t=function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch(t){}return t}();function yt(t,e,i,n){let r;return r=i&&i.length?i.shift():pt?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",n)}function xt(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function vt(t){let e=t.offsetWidth;const i=getComputedStyle(t);return e+=parseInt(i.marginLeft,10)+parseInt(i.marginRight,10),e}function St(t){let e=t.offsetHeight;const i=getComputedStyle(t);return e+=parseInt(i.marginTop,10)+parseInt(i.marginBottom,10),e}function wt(t,e){const i=e.parentNode;i&&i.replaceChild(t,e)}function Et(t){return t&&t.parentNode?t.parentNode.removeChild(t):null}function Tt(t){for(;t.lastChild;)t.removeChild(t.lastChild)}function Ct(t,e){const i=t.childNodes;for(let n=0;;++n){const r=i[n],s=e[n];if(!r&&!s)break;r!==s&&(r?s?t.insertBefore(s,r):(t.removeChild(r),--n):t.appendChild(s))}}function Rt(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement?t:null}function bt(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t instanceof DataView?t:null}let Pt=null;function It(t){Pt||(Pt=yt(t.width,t.height,void 0,{willReadFrequently:!0}));const e=Pt.canvas,i=t.width;e.width!==i&&(e.width=i);const n=t.height;return e.height!==n&&(e.height=n),Pt.clearRect(0,0,i,n),Pt.drawImage(t,0,0),Pt.getImageData(0,0,i,n).data}const Ft=[256,256];var Lt=class extends at{constructor(t){const e=J;super(t.tileCoord,e,{transition:t.transition,interpolate:t.interpolate}),this.loader_=t.loader,this.data_=null,this.error_=null,this.size_=t.size||null}getSize(){if(this.size_)return this.size_;const t=Rt(this.data_);return t?[t.width,t.height]:Ft}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==J&&this.state!==et)return;this.state=Q,this.changed();const t=this;this.loader_().then((function(e){t.data_=e,t.state=tt,t.changed()})).catch((function(e){t.error_=e,t.state=et,t.changed()}))}};function Mt(t,e){if(!t)throw new i(e)}class At extends Z{constructor(t){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),t)if("function"==typeof t.getSimplifiedGeometry){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new At(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(G(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=D(t,E,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?Ot(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function Ot(t){if("function"==typeof t)return t;let e;if(Array.isArray(t))e=t;else{Mt("function"==typeof t.getZIndex,41);e=[t]}return function(){return e}}var Nt=At;const Dt=new Array(6);function kt(){return[1,0,0,1,0,0]}function Gt(t){return Bt(t,1,0,0,1,0,0)}function jt(t,e){const i=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=e[0],h=e[1],c=e[2],u=e[3],d=e[4],g=e[5];return t[0]=i*l+r*h,t[1]=n*l+s*h,t[2]=i*c+r*u,t[3]=n*c+s*u,t[4]=i*d+r*g+o,t[5]=n*d+s*g+a,t}function Bt(t,e,i,n,r,s,o){return t[0]=e,t[1]=i,t[2]=n,t[3]=r,t[4]=s,t[5]=o,t}function Ut(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function zt(t,e){const i=e[0],n=e[1];return e[0]=t[0]*i+t[2]*n+t[4],e[1]=t[1]*i+t[3]*n+t[5],e}function Xt(t,e){const i=Math.cos(e),n=Math.sin(e);return jt(t,Bt(Dt,i,n,-n,i,0,0))}function Vt(t,e,i){return jt(t,Bt(Dt,e,0,0,i,0,0))}function Wt(t,e,i){return Bt(t,e,0,0,i,0,0)}function Zt(t,e,i){return jt(t,Bt(Dt,1,0,0,1,e,i))}function Yt(t,e,i,n,r,s,o,a){const l=Math.sin(s),h=Math.cos(s);return t[0]=n*h,t[1]=r*l,t[2]=-n*l,t[3]=r*h,t[4]=o*n*h-a*n*l+e,t[5]=o*r*l+a*r*h+i,t}function Kt(t,e){const i=Ht(e);Mt(0!==i,32);const n=e[0],r=e[1],s=e[2],o=e[3],a=e[4],l=e[5];return t[0]=o/i,t[1]=-r/i,t[2]=-s/i,t[3]=n/i,t[4]=(s*l-o*a)/i,t[5]=-(n*l-r*a)/i,t}function Ht(t){return t[0]*t[3]-t[1]*t[2]}let qt;function $t(t){const e="matrix("+t.join(", ")+")";if(pt)return e;const i=qt||(qt=document.createElement("div"));return i.style.transform=e,i.style.transform}var Jt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Qt(t){const e=ae();for(let i=0,n=t.length;i<n;++i)pe(e,t[i]);return e}function te(t,e,i){return i?(i[0]=t[0]-e,i[1]=t[1]-e,i[2]=t[2]+e,i[3]=t[3]+e,i):[t[0]-e,t[1]-e,t[2]+e,t[3]+e]}function ee(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t.slice()}function ie(t,e,i){let n,r;return n=e<t[0]?t[0]-e:t[2]<e?e-t[2]:0,r=i<t[1]?t[1]-i:t[3]<i?i-t[3]:0,n*n+r*r}function ne(t,e){return se(t,e[0],e[1])}function re(t,e){return t[0]<=e[0]&&e[2]<=t[2]&&t[1]<=e[1]&&e[3]<=t[3]}function se(t,e,i){return t[0]<=e&&e<=t[2]&&t[1]<=i&&i<=t[3]}function oe(t,e){const i=t[0],n=t[1],r=t[2],s=t[3],o=e[0],a=e[1];let l=Jt.UNKNOWN;return o<i?l|=Jt.LEFT:o>r&&(l|=Jt.RIGHT),a<n?l|=Jt.BELOW:a>s&&(l|=Jt.ABOVE),l===Jt.UNKNOWN&&(l=Jt.INTERSECTING),l}function ae(){return[1/0,1/0,-1/0,-1/0]}function le(t,e,i,n,r){return r?(r[0]=t,r[1]=e,r[2]=i,r[3]=n,r):[t,e,i,n]}function he(t){return le(1/0,1/0,-1/0,-1/0,t)}function ce(t,e){const i=t[0],n=t[1];return le(i,n,i,n,e)}function ue(t,e,i,n,r){return _e(he(r),t,e,i,n)}function de(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function ge(t,e,i){return Math.abs(t[0]-e[0])<i&&Math.abs(t[2]-e[2])<i&&Math.abs(t[1]-e[1])<i&&Math.abs(t[3]-e[3])<i}function fe(t,e){return e[0]<t[0]&&(t[0]=e[0]),e[2]>t[2]&&(t[2]=e[2]),e[1]<t[1]&&(t[1]=e[1]),e[3]>t[3]&&(t[3]=e[3]),t}function pe(t,e){e[0]<t[0]&&(t[0]=e[0]),e[0]>t[2]&&(t[2]=e[0]),e[1]<t[1]&&(t[1]=e[1]),e[1]>t[3]&&(t[3]=e[1])}function me(t,e){for(let i=0,n=e.length;i<n;++i)pe(t,e[i]);return t}function _e(t,e,i,n,r){for(;i<n;i+=r)xe(t,e[i],e[i+1]);return t}function ye(t,e){for(let i=0,n=e.length;i<n;++i)me(t,e[i]);return t}function xe(t,e,i){t[0]=Math.min(t[0],e),t[1]=Math.min(t[1],i),t[2]=Math.max(t[2],e),t[3]=Math.max(t[3],i)}function ve(t,e){let i;return i=e(we(t)),i||(i=e(Ee(t)),i||(i=e(Le(t)),i||(i=e(Fe(t)),i||!1)))}function Se(t){let e=0;return Oe(t)||(e=Me(t)*Pe(t)),e}function we(t){return[t[0],t[1]]}function Ee(t){return[t[2],t[1]]}function Te(t){return[(t[0]+t[2])/2,(t[1]+t[3])/2]}function Ce(t,e){let i;return"bottom-left"===e?i=we(t):"bottom-right"===e?i=Ee(t):"top-left"===e?i=Fe(t):"top-right"===e?i=Le(t):Mt(!1,13),i}function Re(t,e,i,n,r){const[s,o,a,l,h,c,u,d]=be(t,e,i,n);return le(Math.min(s,a,h,u),Math.min(o,l,c,d),Math.max(s,a,h,u),Math.max(o,l,c,d),r)}function be(t,e,i,n){const r=e*n[0]/2,s=e*n[1]/2,o=Math.cos(i),a=Math.sin(i),l=r*o,h=r*a,c=s*o,u=s*a,d=t[0],g=t[1];return[d-l+u,g-h-c,d-l-u,g-h+c,d+l-u,g+h+c,d+l+u,g+h-c,d-l+u,g-h-c]}function Pe(t){return t[3]-t[1]}function Ie(t,e,i){const n=i||[1/0,1/0,-1/0,-1/0];return Ae(t,e)?(t[0]>e[0]?n[0]=t[0]:n[0]=e[0],t[1]>e[1]?n[1]=t[1]:n[1]=e[1],t[2]<e[2]?n[2]=t[2]:n[2]=e[2],t[3]<e[3]?n[3]=t[3]:n[3]=e[3]):he(n),n}function Fe(t){return[t[0],t[3]]}function Le(t){return[t[2],t[3]]}function Me(t){return t[2]-t[0]}function Ae(t,e){return t[0]<=e[2]&&t[2]>=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function Oe(t){return t[2]<t[0]||t[3]<t[1]}function Ne(t,e){return e?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e):t}function De(t,e){const i=(t[2]-t[0])/2*(e-1),n=(t[3]-t[1])/2*(e-1);t[0]-=i,t[2]+=i,t[1]-=n,t[3]+=n}function ke(t,e,i){let n=!1;const r=oe(t,e),s=oe(t,i);if(r===Jt.INTERSECTING||s===Jt.INTERSECTING)n=!0;else{const o=t[0],a=t[1],l=t[2],h=t[3],c=e[0],u=e[1],d=i[0],g=i[1],f=(g-u)/(d-c);let p,m;s&Jt.ABOVE&&!(r&Jt.ABOVE)&&(p=d-(g-h)/f,n=p>=o&&p<=l),n||!(s&Jt.RIGHT)||r&Jt.RIGHT||(m=g-(d-l)*f,n=m>=a&&m<=h),n||!(s&Jt.BELOW)||r&Jt.BELOW||(p=d-(g-a)/f,n=p>=o&&p<=l),n||!(s&Jt.LEFT)||r&Jt.LEFT||(m=g-(d-o)*f,n=m>=a&&m<=h)}return n}function Ge(t,e,i,n){if(Oe(t))return he(i);let r=[];if(n>1){const e=t[2]-t[0],i=t[3]-t[1];for(let s=0;s<n;++s)r.push(t[0]+e*s/n,t[1],t[2],t[1]+i*s/n,t[2]-e*s/n,t[3],t[0],t[3]-i*s/n)}else r=[t[0],t[1],t[2],t[1],t[2],t[3],t[0],t[3]];e(r,r,2);const s=[],o=[];for(let t=0,e=r.length;t<e;t+=2)s.push(r[t]),o.push(r[t+1]);return function(t,e,i){return le(Math.min.apply(null,t),Math.min.apply(null,e),Math.max.apply(null,t),Math.max.apply(null,e),i)}(s,o,i)}function je(t,e){const i=e.getExtent(),n=Te(t);if(e.canWrapX()&&(n[0]<i[0]||n[0]>=i[2])){const e=Me(i),r=Math.floor((n[0]-i[0])/e)*e;t[0]-=r,t[2]-=r}return t}function Be(t,e){if(e.canWrapX()){const i=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[i[0],t[1],i[2],t[3]]];je(t,e);const n=Me(i);if(Me(t)>n)return[[i[0],t[1],i[2],t[3]]];if(t[0]<i[0])return[[t[0]+n,t[1],i[2],t[3]],[i[0],t[1],t[2],t[3]]];if(t[2]>i[2])return[[t[0],t[1],i[2],t[3]],[i[0],t[1],t[2]-n,t[3]]]}return[t]}const Ue={9001:"m",9002:"ft",9003:"us-ft",9101:"radians",9102:"degrees"};function ze(t){return Ue[t]}const Xe={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var Ve=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Xe[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}};const We=6378137,Ze=Math.PI*We,Ye=[-Ze,-Ze,Ze,Ze],Ke=[-180,-85,180,85],He=We*Math.log(Math.tan(Math.PI/2));class qe extends Ve{constructor(t){super({code:t,units:"m",extent:Ye,global:!0,worldExtent:Ke,getPointResolution:function(t,e){return t/Math.cosh(e[1]/We)}})}}const $e=[new qe("EPSG:3857"),new qe("EPSG:102100"),new qe("EPSG:102113"),new qe("EPSG:900913"),new qe("http://www.opengis.net/def/crs/EPSG/0/3857"),new qe("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Je(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;r<n;r+=i){e[r]=Ze*t[r]/180;let i=We*Math.log(Math.tan(Math.PI*(+t[r+1]+90)/360));i>He?i=He:i<-He&&(i=-He),e[r+1]=i}return e}function Qe(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;r<n;r+=i)e[r]=180*t[r]/Ze,e[r+1]=360*Math.atan(Math.exp(t[r+1]/We))/Math.PI-90;return e}const ti=6378137,ei=[-180,-90,180,90],ii=Math.PI*ti/180;class ni extends Ve{constructor(t,e){super({code:t,units:"degrees",extent:ei,axisOrientation:e,global:!0,metersPerUnit:ii,worldExtent:ei})}}const ri=[new ni("CRS:84"),new ni("EPSG:4326","neu"),new ni("urn:ogc:def:crs:OGC:1.3:CRS84"),new ni("urn:ogc:def:crs:OGC:2:84"),new ni("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ni("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ni("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let si={};function oi(){si={}}function ai(t){return si[t]||si[t.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function li(t,e){si[t]=e}let hi={};function ci(){hi={}}function ui(t,e,i){const n=t.getCode(),r=e.getCode();n in hi||(hi[n]={}),hi[n][r]=i}function di(t,e){let i;return t in hi&&e in hi[t]&&(i=hi[t][e]),i}function gi(t,e,i){return Math.min(Math.max(t,e),i)}function fi(t,e,i,n,r,s){const o=r-i,a=s-n;if(0!==o||0!==a){const l=((t-i)*o+(e-n)*a)/(o*o+a*a);l>1?(i=r,n=s):l>0&&(i+=o*l,n+=a*l)}return pi(t,e,i,n)}function pi(t,e,i,n){const r=i-t,s=n-e;return r*r+s*s}function mi(t){const e=t.length;for(let i=0;i<e;i++){let n=i,r=Math.abs(t[i][i]);for(let s=i+1;s<e;s++){const e=Math.abs(t[s][i]);e>r&&(r=e,n=s)}if(0===r)return null;const s=t[n];t[n]=t[i],t[i]=s;for(let n=i+1;n<e;n++){const r=-t[n][i]/t[i][i];for(let s=i;s<e+1;s++)i==s?t[n][s]=0:t[n][s]+=r*t[i][s]}}const i=new Array(e);for(let n=e-1;n>=0;n--){i[n]=t[n][e]/t[n][n];for(let r=n-1;r>=0;r--)t[r][e]-=t[r][n]*i[n]}return i}function _i(t){return 180*t/Math.PI}function yi(t){return t*Math.PI/180}function xi(t,e){const i=t%e;return i*e<0?i+e:i}function vi(t,e,i){return t+i*(e-t)}function Si(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}function wi(t,e){return Math.round(Si(t,e))}function Ei(t,e){return Math.floor(Si(t,e))}function Ti(t,e){return Math.ceil(Si(t,e))}function Ci(t,e,i){const n=void 0!==i?t.toFixed(i):""+t;let r=n.indexOf(".");return r=-1===r?n.length:r,r>e?n:new Array(1+e-r).join("0")+n}function Ri(t,e){const i=(""+t).split("."),n=(""+e).split(".");for(let t=0;t<Math.max(i.length,n.length);t++){const e=parseInt(i[t]||"0",10),r=parseInt(n[t]||"0",10);if(e>r)return 1;if(r>e)return-1}return 0}function bi(t,e){return t[0]+=+e[0],t[1]+=+e[1],t}function Pi(t,e){const i=e.getRadius(),n=e.getCenter(),r=n[0],s=n[1];let o=t[0]-r;const a=t[1]-s;0===o&&0===a&&(o=1);const l=Math.sqrt(o*o+a*a);return[r+i*o/l,s+i*a/l]}function Ii(t,e){const i=t[0],n=t[1],r=e[0],s=e[1],o=r[0],a=r[1],l=s[0],h=s[1],c=l-o,u=h-a,d=0===c&&0===u?0:(c*(i-o)+u*(n-a))/(c*c+u*u||0);let g,f;return d<=0?(g=o,f=a):d>=1?(g=l,f=h):(g=o+d*c,f=a+d*u),[g,f]}function Fi(t,e,i){const n=xi(e+180,360)-180,r=Math.abs(3600*n),s=i||0;let o=Math.floor(r/3600),a=Math.floor((r-3600*o)/60),l=Si(r-3600*o-60*a,s);l>=60&&(l=0,a+=1),a>=60&&(a=0,o+=1);let h=o+"°";return 0===a&&0===l||(h+=" "+Ci(a,2)+""),0!==l&&(h+=" "+Ci(l,2,s)+"″"),0!==n&&(h+=" "+t.charAt(n<0?1:0)),h}function Li(t,e,i){return t?e.replace("{x}",t[0].toFixed(i)).replace("{y}",t[1].toFixed(i)):""}function Mi(t,e){let i=!0;for(let n=t.length-1;n>=0;--n)if(t[n]!=e[n]){i=!1;break}return i}function Ai(t,e){const i=Math.cos(e),n=Math.sin(e),r=t[0]*i-t[1]*n,s=t[1]*i+t[0]*n;return t[0]=r,t[1]=s,t}function Oi(t,e){return t[0]*=e,t[1]*=e,t}function Ni(t,e){const i=t[0]-e[0],n=t[1]-e[1];return i*i+n*n}function Di(t,e){return Math.sqrt(Ni(t,e))}function ki(t,e){return Ni(t,Ii(t,e))}function Gi(t,e){return Li(t,"{x}, {y}",e)}function ji(t,e){if(e.canWrapX()){const i=Me(e.getExtent()),n=Bi(t,e,i);n&&(t[0]-=n*i)}return t}function Bi(t,e,i){const n=e.getExtent();let r=0;return e.canWrapX()&&(t[0]<n[0]||t[0]>n[2])&&(i=i||Me(n),r=Math.floor((t[0]-n[0])/i)),r}const Ui=6371008.8;function zi(t,e,i){i=i||Ui;const n=yi(t[1]),r=yi(e[1]),s=(r-n)/2,o=yi(e[0]-t[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(n)*Math.cos(r);return 2*i*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Xi(t,e){let i=0;for(let n=0,r=t.length;n<r-1;++n)i+=zi(t[n],t[n+1],e);return i}function Vi(t,e){let i=0;const n=t.length;let r=t[n-1][0],s=t[n-1][1];for(let e=0;e<n;e++){const n=t[e][0],o=t[e][1];i+=yi(n-r)*(2+Math.sin(yi(s))+Math.sin(yi(o))),r=n,s=o}return i*e*e/2}function Wi(t,e,i,n){n=n||Ui;const r=yi(t[1]),s=yi(t[0]),o=e/n,a=Math.asin(Math.sin(r)*Math.cos(o)+Math.cos(r)*Math.sin(o)*Math.cos(i));return[_i(s+Math.atan2(Math.sin(i)*Math.sin(o)*Math.cos(r),Math.cos(o)-Math.sin(r)*Math.sin(a))),_i(a)]}const Zi={info:1,warn:2,error:3,none:4};let Yi=Zi.info;function Ki(...t){Yi>Zi.warn||console.warn(...t)}function Hi(...t){Yi>Zi.error||console.error(...t)}let qi=!0;function $i(t){qi=!(void 0===t||t)}function Ji(t,e){if(void 0!==e)for(let i=0,n=t.length;i<n;++i)e[i]=t[i];else e=t.slice();return e}function Qi(t,e){if(void 0!==e&&t!==e){for(let i=0,n=t.length;i<n;++i)e[i]=t[i];t=e}return t}function tn(t){li(t.getCode(),t),ui(t,t,Ji)}function en(t){t.forEach(tn)}function nn(t){return"string"==typeof t?ai(t):t||null}function rn(t,e,i,n){let r;const s=(t=nn(t)).getPointResolutionFunc();if(s){if(r=s(e,i),n&&n!==t.getUnits()){const e=t.getMetersPerUnit();e&&(r=r*e/Xe[n])}}else{const s=t.getUnits();if("degrees"==s&&!n||"degrees"==n)r=e;else{const o=un(t,nn("EPSG:4326"));if(o===Qi&&"degrees"!==s)r=e*t.getMetersPerUnit();else{let t=[i[0]-e/2,i[1],i[0]+e/2,i[1],i[0],i[1]-e/2,i[0],i[1]+e/2];t=o(t,t,2);r=(zi(t.slice(0,2),t.slice(2,4))+zi(t.slice(4,6),t.slice(6,8)))/2}const a=n?Xe[n]:t.getMetersPerUnit();void 0!==a&&(r/=a)}}return r}function sn(t){en(t),t.forEach((function(e){t.forEach((function(t){e!==t&&ui(e,t,Ji)}))}))}function on(t,e,i,n){t.forEach((function(t){e.forEach((function(e){ui(t,e,i),ui(e,t,n)}))}))}function an(t,e){return t?"string"==typeof t?nn(t):t:nn(e)}function ln(t){return function(e,i,n){const r=e.length;n=void 0!==n?n:2,i=void 0!==i?i:new Array(r);for(let s=0;s<r;s+=n){const r=t(e.slice(s,s+n)),o=r.length;for(let t=0,a=n;t<a;++t)i[s+t]=t>=o?e[s+t]:r[t]}return i}}function hn(t,e,i,n){const r=nn(t),s=nn(e);ui(r,s,ln(i)),ui(s,r,ln(n))}function cn(t,e){if(t===e)return!0;const i=t.getUnits()===e.getUnits();if(t.getCode()===e.getCode())return i;return un(t,e)===Ji&&i}function un(t,e){let i=di(t.getCode(),e.getCode());return i||(i=Qi),i}function dn(t,e){return un(nn(t),nn(e))}function gn(t,e,i){return dn(e,i)(t,void 0,t.length)}function fn(t,e,i,n){return Ge(t,dn(e,i),void 0,n)}let pn=null;function mn(t){pn=nn(t)}function _n(){return pn}function yn(t,e){return pn?gn(t,e,pn):t}function xn(t,e){return pn?gn(t,pn,e):(qi&&!Mi(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(qi=!1,Ki("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t)}function vn(t,e){return pn?fn(t,e,pn):t}function Sn(t,e){return pn?fn(t,pn,e):t}function wn(t,e){if(!pn)return t;const i=nn(e).getUnits(),n=pn.getUnits();return i&&n?t*Xe[i]/Xe[n]:t}function En(t,e){if(!pn)return t;const i=nn(e).getUnits(),n=pn.getUnits();return i&&n?t*Xe[n]/Xe[i]:t}function Tn(t,e,i){return function(n){let r,s;if(t.canWrapX()){const e=t.getExtent(),o=Me(e);s=Bi(n=n.slice(0),t,o),s&&(n[0]=n[0]-s*o),n[0]=gi(n[0],e[0],e[2]),n[1]=gi(n[1],e[1],e[3]),r=i(n)}else r=i(n);return s&&e.canWrapX()&&(r[0]+=s*Me(e.getExtent())),r}}function Cn(){sn($e),sn(ri),on(ri,$e,Je,Qe)}function Rn(t,e,i,n,r,s){s=s||[];let o=0;for(let a=e;a<i;a+=n){const e=t[a],i=t[a+1];s[o++]=r[0]*e+r[2]*i+r[4],s[o++]=r[1]*e+r[3]*i+r[5]}return s&&s.length!=o&&(s.length=o),s}function bn(t,e,i,n,r,s,o){o=o||[];const a=Math.cos(r),l=Math.sin(r),h=s[0],c=s[1];let u=0;for(let r=e;r<i;r+=n){const e=t[r]-h,i=t[r+1]-c;o[u++]=h+e*a-i*l,o[u++]=c+e*l+i*a;for(let e=r+2;e<r+n;++e)o[u++]=t[e]}return o&&o.length!=u&&(o.length=u),o}function Pn(t,e,i,n,r,s,o,a){a=a||[];const l=o[0],h=o[1];let c=0;for(let o=e;o<i;o+=n){const e=t[o]-l,i=t[o+1]-h;a[c++]=l+r*e,a[c++]=h+s*i;for(let e=o+2;e<o+n;++e)a[c++]=t[e]}return a&&a.length!=c&&(a.length=c),a}function In(t,e,i,n,r,s,o){o=o||[];let a=0;for(let l=e;l<i;l+=n){o[a++]=t[l]+r,o[a++]=t[l+1]+s;for(let e=l+2;e<l+n;++e)o[a++]=t[e]}return o&&o.length!=a&&(o.length=a),o}Cn();const Fn=[1,0,0,1,0,0];var Ln=class extends Z{constructor(){super(),this.extent_=[1/0,1/0,-1/0,-1/0],this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=y((function(t,e,i){if(!i)return this.getSimplifiedGeometry(e);const n=this.clone();return n.applyTransform(i),n.getSimplifiedGeometry(e)}))}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return z()}closestPointXY(t,e,i,n){return z()}containsXY(t,e){const i=this.getClosestPoint([t,e]);return i[0]===t&&i[1]===e}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return z()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&he(t),this.extentRevision_=this.getRevision()}return Ne(this.extent_,t)}rotate(t,e){z()}scale(t,e,i){z()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return z()}getType(){return z()}applyTransform(t){z()}intersectsExtent(t){return z()}translate(t,e){z()}transform(t,e){const i=nn(t),n="tile-pixels"==i.getUnits()?function(t,n,r){const s=i.getExtent(),o=i.getWorldExtent(),a=Pe(o)/Pe(s);return Yt(Fn,o[0],o[3],a,-a,0,0,0),Rn(t,0,t.length,r,Fn,n),dn(i,e)(t,n,r)}:dn(i,e);return this.applyTransform(n),this}};function Mn(t){let e;return"XY"==t?e=2:"XYZ"==t||"XYM"==t?e=3:"XYZM"==t&&(e=4),e}function An(t,e,i){const n=t.getFlatCoordinates();if(!n)return null;const r=t.getStride();return Rn(n,0,n.length,r,e,i)}var On=class extends Ln{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates=null}computeExtent(t){return ue(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return z()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=Mn(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){z()}setLayout(t,e,i){let n;if(t)n=Mn(t);else{for(let t=0;t<i;++t){if(0===e.length)return this.layout="XY",void(this.stride=2);e=e[0]}n=e.length,t=function(t){let e;2==t?e="XY":3==t?e="XYZ":4==t&&(e="XYZM");return e}(n)}this.layout=t,this.stride=n}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();bn(i,0,i.length,n,t,e,i),this.changed()}}scale(t,e,i){void 0===e&&(e=t),i||(i=Te(this.getExtent()));const n=this.getFlatCoordinates();if(n){const r=this.getStride();Pn(n,0,n.length,r,t,e,i,n),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const n=this.getStride();In(i,0,i.length,n,t,e,i),this.changed()}}};function Nn(t,e,i,n,r,s,o){const a=t[e],l=t[e+1],h=t[i]-a,c=t[i+1]-l;let u;if(0===h&&0===c)u=e;else{const d=((r-a)*h+(s-l)*c)/(h*h+c*c);if(d>1)u=i;else{if(d>0){for(let r=0;r<n;++r)o[r]=vi(t[e+r],t[i+r],d);return void(o.length=n)}u=e}}for(let e=0;e<n;++e)o[e]=t[u+e];o.length=n}function Dn(t,e,i,n,r){let s=t[e],o=t[e+1];for(e+=n;e<i;e+=n){const i=t[e],n=t[e+1],a=pi(s,o,i,n);a>r&&(r=a),s=i,o=n}return r}function kn(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s){const o=i[s];r=Dn(t,e,o,n,r),e=o}return r}function Gn(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s){const o=i[s];r=kn(t,e,o,n,r),e=o[o.length-1]}return r}function jn(t,e,i,n,r,s,o,a,l,h,c){if(e==i)return h;let u,d;if(0===r){if(d=pi(o,a,t[e],t[e+1]),d<h){for(u=0;u<n;++u)l[u]=t[e+u];return l.length=n,d}return h}c=c||[NaN,NaN];let g=e+n;for(;g<i;)if(Nn(t,g-n,g,n,o,a,c),d=pi(o,a,c[0],c[1]),d<h){for(h=d,u=0;u<n;++u)l[u]=c[u];l.length=n,g+=n}else g+=n*Math.max((Math.sqrt(d)-Math.sqrt(h))/r|0,1);if(s&&(Nn(t,i-n,e,n,o,a,c),d=pi(o,a,c[0],c[1]),d<h)){for(h=d,u=0;u<n;++u)l[u]=c[u];l.length=n}return h}function Bn(t,e,i,n,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=i.length;u<d;++u){const d=i[u];h=jn(t,e,d,n,r,s,o,a,l,h,c),e=d}return h}function Un(t,e,i,n,r,s,o,a,l,h,c){c=c||[NaN,NaN];for(let u=0,d=i.length;u<d;++u){const d=i[u];h=Bn(t,e,d,n,r,s,o,a,l,h,c),e=d[d.length-1]}return h}function zn(t,e,i,n){for(let n=0,r=i.length;n<r;++n)t[e++]=i[n];return e}function Xn(t,e,i,n){for(let r=0,s=i.length;r<s;++r){const s=i[r];for(let i=0;i<n;++i)t[e++]=s[i]}return e}function Vn(t,e,i,n,r){r=r||[];let s=0;for(let o=0,a=i.length;o<a;++o){const a=Xn(t,e,i[o],n);r[s++]=a,e=a}return r.length=s,r}function Wn(t,e,i,n,r){r=r||[];let s=0;for(let o=0,a=i.length;o<a;++o){const a=Vn(t,e,i[o],n,r[s]);0===a.length&&(a[0]=e),r[s++]=a,e=a[a.length-1]}return r.length=s,r}function Zn(t,e,i,n,r,s,o){const a=(i-e)/n;if(a<3){for(;e<i;e+=n)s[o++]=t[e],s[o++]=t[e+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const h=[e,i-n];let c=0;for(;h.length>0;){const i=h.pop(),s=h.pop();let o=0;const a=t[s],u=t[s+1],d=t[i],g=t[i+1];for(let e=s+n;e<i;e+=n){const i=fi(t[e],t[e+1],a,u,d,g);i>o&&(c=e,o=i)}o>r&&(l[(c-e)/n]=1,s+n<c&&h.push(s,c),c+n<i&&h.push(c,i))}for(let i=0;i<a;++i)l[i]&&(s[o++]=t[e+i*n],s[o++]=t[e+i*n+1]);return o}function Yn(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;l<h;++l){const h=i[l];o=Zn(t,e,h,n,r,s,o),a.push(o),e=h}return o}function Kn(t,e,i,n,r,s,o){if(i<=e+n){for(;e<i;e+=n)s[o++]=t[e],s[o++]=t[e+1];return o}let a=t[e],l=t[e+1];s[o++]=a,s[o++]=l;let h=a,c=l;for(e+=n;e<i;e+=n)h=t[e],c=t[e+1],pi(a,l,h,c)>r&&(s[o++]=h,s[o++]=c,a=h,l=c);return h==a&&c==l||(s[o++]=h,s[o++]=c),o}function Hn(t,e){return e*Math.round(t/e)}function qn(t,e,i,n,r,s,o){if(e==i)return o;let a,l,h=Hn(t[e],r),c=Hn(t[e+1],r);e+=n,s[o++]=h,s[o++]=c;do{if(a=Hn(t[e],r),l=Hn(t[e+1],r),(e+=n)==i)return s[o++]=a,s[o++]=l,o}while(a==h&&l==c);for(;e<i;){const i=Hn(t[e],r),u=Hn(t[e+1],r);if(e+=n,i==a&&u==l)continue;const d=a-h,g=l-c,f=i-h,p=u-c;d*p==g*f&&(d<0&&f<d||d==f||d>0&&f>d)&&(g<0&&p<g||g==p||g>0&&p>g)?(a=i,l=u):(s[o++]=a,s[o++]=l,h=a,c=l,a=i,l=u)}return s[o++]=a,s[o++]=l,o}function $n(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;l<h;++l){const h=i[l];o=qn(t,e,h,n,r,s,o),a.push(o),e=h}return o}function Jn(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;l<h;++l){const h=i[l],c=[];o=$n(t,e,h,n,r,s,o,c),a.push(c),e=h[h.length-1]}return o}function Qn(t,e,i,n,r){r=void 0!==r?r:[];let s=0;for(let o=e;o<i;o+=n)r[s++]=t.slice(o,o+n);return r.length=s,r}function tr(t,e,i,n,r){r=void 0!==r?r:[];let s=0;for(let o=0,a=i.length;o<a;++o){const a=i[o];r[s++]=Qn(t,e,a,n,r[s]),e=a}return r.length=s,r}function er(t,e,i,n,r){r=void 0!==r?r:[];let s=0;for(let o=0,a=i.length;o<a;++o){const a=i[o];r[s++]=1===a.length&&a[0]===e?[]:tr(t,e,a,n,r[s]),e=a[a.length-1]}return r.length=s,r}function ir(t,e,i,n){let r=0,s=t[i-n],o=t[i-n+1];for(;e<i;e+=n){const i=t[e],n=t[e+1];r+=o*i-s*n,s=i,o=n}return r/2}function nr(t,e,i,n){let r=0;for(let s=0,o=i.length;s<o;++s){const o=i[s];r+=ir(t,e,o,n),e=o}return r}function rr(t,e,i,n){let r=0;for(let s=0,o=i.length;s<o;++s){const o=i[s];r+=nr(t,e,o,n),e=o[o.length-1]}return r}class sr extends On{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}clone(){return new sr(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,n){return n<ie(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),jn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,n))}getArea(){return ir(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return Qn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=Zn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new sr(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Xn(this.flatCoordinates,0,t,this.stride),this.changed()}}var or=sr;class ar extends On{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new ar(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,s=pi(t,e,r[0],r[1]);if(s<n){const t=this.stride;for(let e=0;e<t;++e)i[e]=r[e];return i.length=t,s}return n}getCoordinates(){return this.flatCoordinates?this.flatCoordinates.slice():[]}computeExtent(t){return ce(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return se(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=zn(this.flatCoordinates,0,t,this.stride),this.changed()}}var lr=ar;function hr(t,e,i,n,r){return!ve(r,(function(r){return!cr(t,e,i,n,r[0],r[1])}))}function cr(t,e,i,n,r,s){let o=0,a=t[i-n],l=t[i-n+1];for(;e<i;e+=n){const i=t[e],n=t[e+1];l<=s?n>s&&(i-a)*(s-l)-(r-a)*(n-l)>0&&o++:n<=s&&(i-a)*(s-l)-(r-a)*(n-l)<0&&o--,a=i,l=n}return 0!==o}function ur(t,e,i,n,r,s){if(0===i.length)return!1;if(!cr(t,e,i[0],n,r,s))return!1;for(let e=1,o=i.length;e<o;++e)if(cr(t,i[e-1],i[e],n,r,s))return!1;return!0}function dr(t,e,i,n,r,s){if(0===i.length)return!1;for(let o=0,a=i.length;o<a;++o){const a=i[o];if(ur(t,e,a,n,r,s))return!0;e=a[a.length-1]}return!1}function gr(t,e,i,n,r,s,o){let a,h,c,u,d,g,f;const p=r[s+1],m=[];for(let r=0,s=i.length;r<s;++r){const s=i[r];for(u=t[s-n],g=t[s-n+1],a=e;a<s;a+=n)d=t[a],f=t[a+1],(p<=g&&f<=p||g<=p&&p<=f)&&(c=(p-g)/(f-g)*(d-u)+u,m.push(c)),u=d,g=f}let _=NaN,y=-1/0;for(m.sort(l),u=m[0],a=1,h=m.length;a<h;++a){d=m[a];const r=Math.abs(d-u);r>y&&(c=(u+d)/2,ur(t,e,i,n,c,p)&&(_=c,y=r)),u=d}return isNaN(_)&&(_=r[s]),o?(o.push(_,p,y),o):[_,p,y]}function fr(t,e,i,n,r){let s=[];for(let o=0,a=i.length;o<a;++o){const a=i[o];s=gr(t,e,a,n,r,2*o,s),e=a[a.length-1]}return s}function pr(t,e,i,n,r){let s;for(e+=n;e<i;e+=n)if(s=r(t.slice(e-n,e),t.slice(e,e+n)),s)return s;return!1}function mr(t,e,i,n,r){const s=_e([1/0,1/0,-1/0,-1/0],t,e,i,n);return!!Ae(r,s)&&(!!re(r,s)||(s[0]>=r[0]&&s[2]<=r[2]||(s[1]>=r[1]&&s[3]<=r[3]||pr(t,e,i,n,(function(t,e){return ke(r,t,e)})))))}function _r(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s){if(mr(t,e,i[s],n,r))return!0;e=i[s]}return!1}function yr(t,e,i,n,r){return!!mr(t,e,i,n,r)||(!!cr(t,e,i,n,r[0],r[1])||(!!cr(t,e,i,n,r[0],r[3])||(!!cr(t,e,i,n,r[2],r[1])||!!cr(t,e,i,n,r[2],r[3]))))}function xr(t,e,i,n,r){if(!yr(t,e,i[0],n,r))return!1;if(1===i.length)return!0;for(let e=1,s=i.length;e<s;++e)if(hr(t,i[e-1],i[e],n,r)&&!mr(t,i[e-1],i[e],n,r))return!1;return!0}function vr(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s){const o=i[s];if(xr(t,e,o,n,r))return!0;e=o[o.length-1]}return!1}function Sr(t,e,i,n){for(;e<i-n;){for(let r=0;r<n;++r){const s=t[e+r];t[e+r]=t[i-n+r],t[i-n+r]=s}e+=n,i-=n}}function wr(t,e,i,n){let r=0,s=t[i-n],o=t[i-n+1];for(;e<i;e+=n){const i=t[e],n=t[e+1];r+=(i-s)*(n+o),s=i,o=n}return 0===r?void 0:r>0}function Er(t,e,i,n,r){r=void 0!==r&&r;for(let s=0,o=i.length;s<o;++s){const o=i[s],a=wr(t,e,o,n);if(0===s){if(r&&a||!r&&!a)return!1}else if(r&&!a||!r&&a)return!1;e=o}return!0}function Tr(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s){const o=i[s];if(!Er(t,e,o,n,r))return!1;o.length&&(e=o[o.length-1])}return!0}function Cr(t,e,i,n,r){r=void 0!==r&&r;for(let s=0,o=i.length;s<o;++s){const o=i[s],a=wr(t,e,o,n);(0===s?r&&a||!r&&!a:r&&!a||!r&&a)&&Sr(t,e,o,n),e=o}return e}function Rr(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s)e=Cr(t,e,i[s],n,r);return e}function br(t,e){const i=[];let n=0,r=0;for(let s=0,o=e.length;s<o;++s){const o=e[s];if(wr(t,n,o,2)){if(0===i.length)continue;i[i.length-1].push(e[r])}else i.push(e.slice(r,s+1));r=s+1,n=o}return i}class Pr extends On{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,void 0!==e&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?d(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Pr(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<ie(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kn(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Bn(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return ur(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return nr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),Cr(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,tr(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Te(this.getExtent());this.flatInteriorPoint_=gr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new lr(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new or(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,n=[];let r=0;for(let s=0,o=i.length;s<o;++s){const o=i[s],a=new or(e.slice(r,o),t);n.push(a),r=o}return n}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Er(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Cr(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=$n(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new Pr(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return xr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Vn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===i.length?0:i[i.length-1],this.changed()}}var Ir=Pr;function Fr(t,e,i,n){i=i||32;const r=[];for(let s=0;s<i;++s)d(r,Wi(t,e,2*Math.PI*s/i,n));return r.push(r[0],r[1]),new Pr(r,"XY",[r.length])}function Lr(t){if(Oe(t))throw new Error("Cannot create polygon from empty extent");const e=t[0],i=t[1],n=t[2],r=t[3],s=[e,i,e,r,n,r,n,i,e,i];return new Pr(s,"XY",[s.length])}function Mr(t,e,i){e=e||32;const n=t.getStride(),r=t.getLayout(),s=t.getCenter(),o=n*(e+1),a=new Array(o);for(let t=0;t<o;t+=n){a[t]=0,a[t+1]=0;for(let e=2;e<n;e++)a[t+e]=s[e]}const l=[a.length],h=new Pr(a,r,l);return Ar(h,s,t.getRadius(),i),h}function Ar(t,e,i,n){const r=t.getFlatCoordinates(),s=t.getStride(),o=r.length/s-1,a=n||0;for(let t=0;t<=o;++t){const n=t*s,l=a+2*xi(t,o)*Math.PI/o;r[n]=e[0]+i*Math.cos(l),r[n+1]=e[1]+i*Math.sin(l)}t.changed()}const Or="accuracy",Nr="accuracyGeometry",Dr="altitude",kr="altitudeAccuracy",Gr="heading",jr="position",Br="projection",Ur="speed",zr="tracking",Xr="trackingOptions",Vr="error";class Wr extends r{constructor(t){super(Vr),this.code=t.code,this.message=t.message}}var Zr=class extends Z{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.position_=null,this.transform_=Qi,this.watchId_=void 0,this.addChangeListener(Br,this.handleProjectionChanged_),this.addChangeListener(zr,this.handleTrackingChanged_),void 0!==t.projection&&this.setProjection(t.projection),void 0!==t.trackingOptions&&this.setTrackingOptions(t.trackingOptions),this.setTracking(void 0!==t.tracking&&t.tracking)}disposeInternal(){this.setTracking(!1),super.disposeInternal()}handleProjectionChanged_(){const t=this.getProjection();t&&(this.transform_=un(nn("EPSG:4326"),t),this.position_&&this.set(jr,this.transform_(this.position_)))}handleTrackingChanged_(){if("geolocation"in navigator){const t=this.getTracking();t&&void 0===this.watchId_?this.watchId_=navigator.geolocation.watchPosition(this.positionChange_.bind(this),this.positionError_.bind(this),this.getTrackingOptions()):t||void 0===this.watchId_||(navigator.geolocation.clearWatch(this.watchId_),this.watchId_=void 0)}}positionChange_(t){const e=t.coords;this.set(Or,e.accuracy),this.set(Dr,null===e.altitude?void 0:e.altitude),this.set(kr,null===e.altitudeAccuracy?void 0:e.altitudeAccuracy),this.set(Gr,null===e.heading?void 0:yi(e.heading)),this.position_?(this.position_[0]=e.longitude,this.position_[1]=e.latitude):this.position_=[e.longitude,e.latitude];const i=this.transform_(this.position_);this.set(jr,i.slice()),this.set(Ur,null===e.speed?void 0:e.speed);const n=Fr(this.position_,e.accuracy);n.applyTransform(this.transform_),this.set(Nr,n),this.changed()}positionError_(t){this.dispatchEvent(new Wr(t))}getAccuracy(){return this.get(Or)}getAccuracyGeometry(){return this.get(Nr)||null}getAltitude(){return this.get(Dr)}getAltitudeAccuracy(){return this.get(kr)}getHeading(){return this.get(Gr)}getPosition(){return this.get(jr)}getProjection(){return this.get(Br)}getSpeed(){return this.get(Ur)}getTracking(){return this.get(zr)}getTrackingOptions(){return this.get(Xr)}setProjection(t){this.set(Br,nn(t))}setTracking(t){this.set(zr,t)}setTrackingOptions(t){this.set(Xr,t)}};var Yr=class extends w{constructor(t,e,i,n){super(),this.extent=t,this.pixelRatio_=i,this.resolution=e,this.state=n}changed(){this.dispatchEvent(E)}getExtent(){return this.extent}getImage(){return z()}getPixelRatio(){return this.pixelRatio_}getResolution(){return this.resolution}getState(){return this.state}load(){z()}},Kr=0,Hr=1,qr=2,$r=3,Jr=4;function Qr(t,e,i){const n=t;let r=!0,s=!1,o=!1;const a=[k(n,A,(function(){o=!0,s||e()}))];return n.src&&mt?(s=!0,n.decode().then((function(){r&&e()})).catch((function(t){r&&(o?e():i())}))):a.push(k(n,T,i)),function(){r=!1,a.forEach(G)}}var ts=class extends Yr{constructor(t,e,i,n,r,s,o){super(t,e,i,Kr),this.src_=n,this.image_=new Image,null!==r&&(this.image_.crossOrigin=r),this.context_=o,this.unlisten_=null,this.state=Kr,this.imageLoadFunction_=s}getImage(){if(this.state==qr&&this.context_&&!(this.image_ instanceof HTMLCanvasElement)){const t=this.context_.canvas;t.width=this.image_.width,t.height=this.image_.height,this.context_.drawImage(this.image_,0,0),this.image_=this.context_.canvas}return this.image_}handleImageError_(){this.state=$r,this.unlistenImage_(),this.changed()}handleImageLoad_(){void 0===this.resolution&&(this.resolution=Pe(this.extent)/this.image_.height),this.state=qr,this.unlistenImage_(),this.changed()}load(){this.state!=Kr&&this.state!=$r||(this.state=Hr,this.changed(),this.imageLoadFunction_(this,this.src_),this.unlisten_=Qr(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}setImage(t){this.image_=t,this.resolution=Pe(this.extent)/this.image_.height}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}};var es=class extends Yr{constructor(t,e,i,n,r){super(t,e,i,void 0!==r?Kr:qr),this.loader_=void 0!==r?r:null,this.canvas_=n,this.error_=null}getError(){return this.error_}handleLoad_(t){t?(this.error_=t,this.state=$r):this.state=qr,this.changed()}load(){this.state==Kr&&(this.state=Hr,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}};var is=class extends at{constructor(t,e,i,n,r,s){super(t,e,s),this.crossOrigin_=n,this.src_=i,this.key=i,this.image_=new Image,null!==n&&(this.image_.crossOrigin=n),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=tt,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=et,this.unlistenImage_(),this.image_=function(){const t=yt(1,1);return t.fillStyle="rgba(0,0,0,0)",t.fillRect(0,0,1,1),t.canvas}(),this.changed()}handleImageLoad_(){const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=tt:this.state=it,this.unlistenImage_(),this.changed()}load(){this.state==et&&(this.state=J,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==J&&(this.state=Q,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Qr(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}};var ns=class{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const n=this.points_[e+2]-this.points_[i+2];if(n<1e3/60)return!1;const r=this.points_[e]-this.points_[i],s=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(s,r),this.initialVelocity_=Math.sqrt(r*r+s*s)/n,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}};const rs=/^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i,ss=/^([a-z]*)$|^hsla?\(.*\)$/i;function os(t){return"string"==typeof t?t:us(t)}function as(t){const e=document.createElement("div");if(e.style.color=t,""!==e.style.color){document.body.appendChild(e);const t=getComputedStyle(e).color;return document.body.removeChild(e),t}return""}const ls=function(){const t={};let e=0;return function(i){let n;if(t.hasOwnProperty(i))n=t[i];else{if(e>=1024){let i=0;for(const n in t)0==(3&i++)&&(delete t[n],--e)}n=function(t){let e,i,n,r,s;ss.exec(t)&&(t=as(t));if(rs.exec(t)){const o=t.length-1;let a;a=o<=4?1:2;const l=4===o||8===o;e=parseInt(t.substr(1+0*a,a),16),i=parseInt(t.substr(1+1*a,a),16),n=parseInt(t.substr(1+2*a,a),16),r=l?parseInt(t.substr(1+3*a,a),16):255,1==a&&(e=(e<<4)+e,i=(i<<4)+i,n=(n<<4)+n,l&&(r=(r<<4)+r)),s=[e,i,n,r/255]}else t.startsWith("rgba(")?(s=t.slice(5,-1).split(",").map(Number),cs(s)):t.startsWith("rgb(")?(s=t.slice(4,-1).split(",").map(Number),s.push(1),cs(s)):Mt(!1,14);return s}(i),t[i]=n,++e}return n}}();function hs(t){return Array.isArray(t)?t:ls(t)}function cs(t){return t[0]=gi(t[0]+.5|0,0,255),t[1]=gi(t[1]+.5|0,0,255),t[2]=gi(t[2]+.5|0,0,255),t[3]=gi(t[3],0,1),t}function us(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let i=t[1];i!=(0|i)&&(i=i+.5|0);let n=t[2];n!=(0|n)&&(n=n+.5|0);return"rgba("+e+","+i+","+n+","+(void 0===t[3]?1:Math.round(100*t[3])/100)+")"}function ds(t){return ss.test(t)&&(t=as(t)),rs.test(t)||t.startsWith("rgba(")||t.startsWith("rgb(")}class gs{constructor(){this.cache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];0!=(3&t++)||i.hasListener()||(delete this.cache_[e],--this.cacheSize_)}}}get(t,e,i){const n=fs(t,e,i);return n in this.cache_?this.cache_[n]:null}set(t,e,i,n){const r=fs(t,e,i);this.cache_[r]=n,++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function fs(t,e,i){return e+":"+t+":"+(i?os(i):"null")}var ps=gs;const ms=new gs;var _s="opacity",ys="visible",xs="extent",vs="zIndex",Ss="maxResolution",ws="minResolution",Es="maxZoom",Ts="minZoom",Cs="source",Rs="map";var bs=class extends Z{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);"object"==typeof t.properties&&(delete e.properties,Object.assign(e,t.properties)),e[_s]=void 0!==t.opacity?t.opacity:1,Mt("number"==typeof e[_s],64),e[ys]=void 0===t.visible||t.visible,e[vs]=t.zIndex,e[Ss]=void 0!==t.maxResolution?t.maxResolution:1/0,e[ws]=void 0!==t.minResolution?t.minResolution:0,e[Ts]=void 0!==t.minZoom?t.minZoom:-1/0,e[Es]=void 0!==t.maxZoom?t.maxZoom:1/0,this.className_=void 0!==e.className?e.className:"ol-layer",delete e.className,this.setProperties(e),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(t){const e=this.state_||{layer:this,managed:void 0===t||t},i=this.getZIndex();return e.opacity=gi(Math.round(100*this.getOpacity())/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=void 0!==i||e.managed?i:1/0,e.maxResolution=this.getMaxResolution(),e.minResolution=Math.max(this.getMinResolution(),0),e.minZoom=this.getMinZoom(),e.maxZoom=this.getMaxZoom(),this.state_=e,e}getLayersArray(t){return z()}getLayerStatesArray(t){return z()}getExtent(){return this.get(xs)}getMaxResolution(){return this.get(Ss)}getMinResolution(){return this.get(ws)}getMinZoom(){return this.get(Ts)}getMaxZoom(){return this.get(Es)}getOpacity(){return this.get(_s)}getSourceState(){return z()}getVisible(){return this.get(ys)}getZIndex(){return this.get(vs)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(xs,t)}setMaxResolution(t){this.set(Ss,t)}setMinResolution(t){this.set(ws,t)}setMaxZoom(t){this.set(Es,t)}setMinZoom(t){this.set(Ts,t)}setOpacity(t){Mt("number"==typeof t,64),this.set(_s,t)}setVisible(t){this.set(ys,t)}setZIndex(t){this.set(vs,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Ps="prerender",Is="postrender",Fs="precompose",Ls="postcompose",Ms="rendercomplete",As=0,Os=1,Ns={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};const Ds=42,ks=256;function Gs(t,e,i){return function(n,r,s,o,a){if(!n)return;if(!r&&!e)return n;const l=e?0:s[0]*r,h=e?0:s[1]*r,c=a?a[0]:0,u=a?a[1]:0;let d=t[0]+l/2+c,g=t[2]-l/2+c,f=t[1]+h/2+u,p=t[3]-h/2+u;d>g&&(d=(g+d)/2,g=d),f>p&&(f=(p+f)/2,p=f);let m=gi(n[0],d,g),_=gi(n[1],f,p);if(o&&i&&r){const t=30*r;m+=-t*Math.log(1+Math.max(0,d-n[0])/t)+t*Math.log(1+Math.max(0,n[0]-g)/t),_+=-t*Math.log(1+Math.max(0,f-n[1])/t)+t*Math.log(1+Math.max(0,n[1]-p)/t)}return[m,_]}}function js(t){return t}function Bs(t,e,i,n){const r=Me(e)/i[0],s=Pe(e)/i[1];return n?Math.min(t,Math.max(r,s)):Math.min(t,Math.min(r,s))}function Us(t,e,i){let n=Math.min(t,e);return n*=Math.log(1+50*Math.max(0,t/e-1))/50+1,i&&(n=Math.max(n,i),n/=Math.log(1+50*Math.max(0,i/t-1))/50+1),gi(n,i/2,2*e)}function zs(t,e,i,n){return e=void 0===e||e,function(r,s,o,a){if(void 0!==r){const l=t[0],h=t[t.length-1],u=i?Bs(l,i,o,n):l;if(a)return e?Us(r,u,h):gi(r,h,u);const d=Math.min(u,r),g=Math.floor(c(t,d,s));return t[g]>u&&g<t.length-1?t[g+1]:t[g]}}}function Xs(t,e,i,n,r,s){return n=void 0===n||n,i=void 0!==i?i:0,function(o,a,l,h){if(void 0!==o){const c=r?Bs(e,r,l,s):e;if(h)return n?Us(o,c,i):gi(o,i,c);const u=1e-9,d=Math.ceil(Math.log(e/c)/Math.log(t)-u),g=-a*(.5-u)+.5,f=Math.min(c,o),p=Math.floor(Math.log(e/f)/Math.log(t)+g),m=Math.max(d,p);return gi(e/Math.pow(t,m),i,c)}}}function Vs(t,e,i,n,r){return i=void 0===i||i,function(s,o,a,l){if(void 0!==s){const o=n?Bs(t,n,a,r):t;return i&&l?Us(s,o,e):gi(s,e,o)}}}function Ws(t){if(void 0!==t)return 0}function Zs(t){if(void 0!==t)return t}function Ys(t){const e=2*Math.PI/t;return function(t,i){return i?t:void 0!==t?t=Math.floor(t/e+.5)*e:void 0}}function Ks(t){return t=t||yi(5),function(e,i){return i?e:void 0!==e?Math.abs(e)<=t?0:e:void 0}}function Hs(t,e){setTimeout((function(){t(e)}),0)}function qs(t){if(void 0!==t.extent){const e=void 0===t.smoothExtentConstraint||t.smoothExtentConstraint;return Gs(t.extent,t.constrainOnlyCenter,e)}const e=an(t.projection,"EPSG:3857");if(!0!==t.multiWorld&&e.isGlobal()){const t=e.getExtent().slice();return t[0]=-1/0,t[2]=1/0,Gs(t,!1,!1)}return js}function $s(t){let e,i,n;let r=void 0!==t.minZoom?t.minZoom:0,s=void 0!==t.maxZoom?t.maxZoom:28;const o=void 0!==t.zoomFactor?t.zoomFactor:2,a=void 0!==t.multiWorld&&t.multiWorld,l=void 0===t.smoothResolutionConstraint||t.smoothResolutionConstraint,h=void 0!==t.showFullExtent&&t.showFullExtent,c=an(t.projection,"EPSG:3857"),u=c.getExtent();let d=t.constrainOnlyCenter,g=t.extent;if(a||g||!c.isGlobal()||(d=!1,g=u),void 0!==t.resolutions){const o=t.resolutions;i=o[r],n=void 0!==o[s]?o[s]:o[o.length-1],e=t.constrainResolution?zs(o,l,!d&&g,h):Vs(i,n,l,!d&&g,h)}else{const a=(u?Math.max(Me(u),Pe(u)):360*Xe.degrees/c.getMetersPerUnit())/ks/Math.pow(2,0),f=a/Math.pow(2,28);i=t.maxResolution,void 0!==i?r=0:i=a/Math.pow(o,r),n=t.minResolution,void 0===n&&(n=void 0!==t.maxZoom?void 0!==t.maxResolution?i/Math.pow(o,s):a/Math.pow(o,s):f),s=r+Math.floor(Math.log(i/n)/Math.log(o)),n=i/Math.pow(o,s-r),e=t.constrainResolution?Xs(o,i,n,l,!d&&g,h):Vs(i,n,l,!d&&g,h)}return{constraint:e,maxResolution:i,minResolution:n,minZoom:r,zoomFactor:o}}function Js(t){if(void 0===t.enableRotation||t.enableRotation){const e=t.constrainRotation;return void 0===e||!0===e?Ks():!1===e?Zs:"number"==typeof e?Ys(e):Zs}return Ws}function Qs(t){return!(t.sourceCenter&&t.targetCenter&&!Mi(t.sourceCenter,t.targetCenter))&&(t.sourceResolution===t.targetResolution&&t.sourceRotation===t.targetRotation)}function to(t,e,i,n,r){const s=Math.cos(-r);let o=Math.sin(-r),a=t[0]*s-t[1]*o,l=t[1]*s+t[0]*o;a+=(e[0]/2-i[0])*n,l+=(i[1]-e[1]/2)*n,o=-o;return[a*s-l*o,l*s+a*o]}var eo=class extends Z{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=an(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&$i(),t.center&&(t.center=xn(t.center,this.projection_)),t.extent&&(t.extent=Sn(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const t in Ns)delete e[t];this.setProperties(e,!0);const i=$s(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const n=qs(t),r=i.constraint,s=Js(t);this.constraints_={center:n,resolution:r,rotation:s},this.setRotation(void 0!==t.rotation?t.rotation:0),this.setCenterInternal(void 0!==t.center?t.center:null),void 0!==t.resolution?this.setResolution(t.resolution):void 0!==t.zoom&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const n=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),s=r/2*(n[3]-e[3]+e[1]-n[1]),o=r/2*(n[0]-e[0]+e[2]-n[2]);this.setCenterInternal([i[0]+s,i[1]-o])}}getUpdatedOptions_(t){const e=this.getProperties();return void 0!==e.resolution?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let t=0;t<e.length;++t){let i=arguments[t];i.center&&(i=Object.assign({},i),i.center=xn(i.center,this.getProjection())),i.anchor&&(i=Object.assign({},i),i.anchor=xn(i.anchor,this.getProjection())),e[t]=i}this.animateInternal.apply(this,e)}animateInternal(t){let e,i=arguments.length;i>1&&"function"==typeof arguments[i-1]&&(e=arguments[i-1],--i);let n=0;for(;n<i&&!this.isDef();++n){const t=arguments[n];t.center&&this.setCenterInternal(t.center),void 0!==t.zoom?this.setZoom(t.zoom):t.resolution&&this.setResolution(t.resolution),void 0!==t.rotation&&this.setRotation(t.rotation)}if(n===i)return void(e&&Hs(e,!0));let r=Date.now(),s=this.targetCenter_.slice(),o=this.targetResolution_,a=this.targetRotation_;const l=[];for(;n<i;++n){const t=arguments[n],i={start:r,complete:!1,anchor:t.anchor,duration:void 0!==t.duration?t.duration:1e3,easing:t.easing||st,callback:e};if(t.center&&(i.sourceCenter=s,i.targetCenter=t.center.slice(),s=i.targetCenter),void 0!==t.zoom?(i.sourceResolution=o,i.targetResolution=this.getResolutionForZoom(t.zoom),o=i.targetResolution):t.resolution&&(i.sourceResolution=o,i.targetResolution=t.resolution,o=i.targetResolution),void 0!==t.rotation){i.sourceRotation=a;const e=xi(t.rotation-a+Math.PI,2*Math.PI)-Math.PI;i.targetRotation=a+e,a=i.targetRotation}Qs(i)?i.complete=!0:r+=i.duration,l.push(i)}this.animations_.push(l),this.setHint(As,1),this.updateAnimations_()}getAnimating(){return this.hints_[As]>0}getInteracting(){return this.hints_[Os]>0}cancelAnimations(){let t;this.setHint(As,-this.hints_[As]);for(let e=0,i=this.animations_.length;e<i;++e){const i=this.animations_[e];if(i[0].callback&&Hs(i[0].callback,!1),!t)for(let e=0,n=i.length;e<n;++e){const n=i[e];if(!n.complete){t=n.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(void 0!==this.updateAnimationKey_&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const n=this.animations_[i];let r=!0;for(let i=0,s=n.length;i<s;++i){const s=n[i];if(s.complete)continue;const o=t-s.start;let a=s.duration>0?o/s.duration:1;a>=1?(s.complete=!0,a=1):r=!1;const l=s.easing(a);if(s.sourceCenter){const t=s.sourceCenter[0],e=s.sourceCenter[1],i=s.targetCenter[0],n=s.targetCenter[1];this.nextCenter_=s.targetCenter;const r=t+l*(i-t),o=e+l*(n-e);this.targetCenter_=[r,o]}if(s.sourceResolution&&s.targetResolution){const t=1===l?s.targetResolution:s.sourceResolution+l*(s.targetResolution-s.sourceResolution);if(s.anchor){const e=this.getViewportSize_(this.getRotation()),i=this.constraints_.resolution(t,0,e,!0);this.targetCenter_=this.calculateCenterZoom(i,s.anchor)}this.nextResolution_=s.targetResolution,this.targetResolution_=t,this.applyTargetState_(!0)}if(void 0!==s.sourceRotation&&void 0!==s.targetRotation){const t=1===l?xi(s.targetRotation+Math.PI,2*Math.PI)-Math.PI:s.sourceRotation+l*(s.targetRotation-s.sourceRotation);if(s.anchor){const e=this.constraints_.rotation(t,!0);this.targetCenter_=this.calculateCenterRotate(e,s.anchor)}this.nextRotation_=s.targetRotation,this.targetRotation_=t}if(this.applyTargetState_(!0),e=!0,!s.complete)break}if(r){this.animations_[i]=null,this.setHint(As,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=n[0].callback;t&&Hs(t,!0)}}this.animations_=this.animations_.filter(Boolean),e&&void 0===this.updateAnimationKey_&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const n=this.getCenterInternal();return void 0!==n&&(i=[n[0]-e[0],n[1]-e[1]],Ai(i,t-this.getRotation()),bi(i,e)),i}calculateCenterZoom(t,e){let i;const n=this.getCenterInternal(),r=this.getResolution();if(void 0!==n&&void 0!==r){i=[e[0]-t*(e[0]-n[0])/r,e[1]-t*(e[1]-n[1])/r]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],n=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(n*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(n*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t?yn(t,this.getProjection()):t}getCenterInternal(){return this.get(Ns.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return void 0!==t?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){return vn(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Mt(e,1);const i=this.getResolution();Mt(void 0!==i,2);const n=this.getRotation();return Mt(void 0!==n,3),Re(e,i,n,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get(Ns.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Sn(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=Me(t)/e[0],n=Pe(t)/e[1];return Math.max(i,n)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,n=Math.log(e/i)/Math.log(t);return function(i){return e/Math.pow(t,i*n)}}getRotation(){return this.get(Ns.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(i/n)/e;return function(t){return Math.log(i/t)/e/r}}getViewportSizeMinusPadding_(t){let e=this.getViewportSize_(t);const i=this.padding_;return i&&(e=[e[0]-i[1]-i[3],e[1]-i[0]-i[2]]),e}getState(){const t=this.getProjection(),e=this.getResolution(),i=this.getRotation();let n=this.getCenterInternal();const r=this.padding_;if(r){const t=this.getViewportSizeMinusPadding_();n=to(n,this.getViewportSize_(),[t[0]/2+r[3],t[1]/2+r[0]],e,i)}return{center:n.slice(0),projection:void 0!==t?t:null,resolution:e,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let t;const e=this.getResolution();return void 0!==e&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e,i,n=this.minZoom_||0;if(this.resolutions_){const r=c(this.resolutions_,t,1);n=r,e=this.resolutions_[r],i=r==this.resolutions_.length-1?2:e/this.resolutions_[r+1]}else e=this.maxResolution_,i=this.zoomFactor_;return n+Math.log(e/t)/Math.log(i)}getResolutionForZoom(t){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const e=gi(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,gi(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Mt(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,24),Array.isArray(t)){Mt(!Oe(t),25);i=Lr(Sn(t,this.getProjection()))}else if("Circle"===t.getType()){const e=Sn(t.getExtent(),this.getProjection());i=Lr(e),i.rotate(this.getRotation(),Te(e))}else{const e=_n();i=e?t.clone().transform(e,this.getProjection()):t}this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),n=Math.sin(-e),r=t.getFlatCoordinates(),s=t.getStride();let o=1/0,a=1/0,l=-1/0,h=-1/0;for(let t=0,e=r.length;t<e;t+=s){const e=r[t]*i-r[t+1]*n,s=r[t]*n+r[t+1]*i;o=Math.min(o,e),a=Math.min(a,s),l=Math.max(l,e),h=Math.max(h,s)}return[o,a,l,h]}fitInternal(t,e){let i=(e=e||{}).size;i||(i=this.getViewportSizeMinusPadding_());const n=void 0!==e.padding?e.padding:[0,0,0,0],r=void 0!==e.nearest&&e.nearest;let s;s=void 0!==e.minResolution?e.minResolution:void 0!==e.maxZoom?this.getResolutionForZoom(e.maxZoom):0;const o=this.rotatedExtentForGeometry(t);let a=this.getResolutionForExtentInternal(o,[i[0]-n[1]-n[3],i[1]-n[0]-n[2]]);a=isNaN(a)?s:Math.max(a,s),a=this.getConstrainedResolution(a,r?0:1);const l=this.getRotation(),h=Math.sin(l),c=Math.cos(l),u=Te(o);u[0]+=(n[1]-n[3])/2*a,u[1]+=(n[0]-n[2])/2*a;const d=u[0]*c-u[1]*h,g=u[1]*c+u[0]*h,f=this.getConstrainedCenter([d,g],a),p=e.callback?e.callback:_;void 0!==e.duration?this.animateInternal({resolution:a,center:f,duration:e.duration,easing:e.easing},p):(this.targetResolution_=a,this.targetCenter_=f,this.applyTargetState_(!1,!0),Hs(p,!0))}centerOn(t,e,i){this.centerOnInternal(xn(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(to(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,n){let r;const s=this.padding_;if(s&&t){const o=this.getViewportSizeMinusPadding_(-i),a=to(t,n,[o[0]/2+s[3],o[1]/2+s[0]],e,i);r=[t[0]-a[0],t[1]-a[1]]}return r}isDef(){return!!this.getCenterInternal()&&void 0!==this.getResolution()}adjustCenter(t){const e=yn(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&xn(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),n=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,n,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=xn(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),n=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(n,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t?xn(t,this.getProjection()):t)}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,n=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(n),s=this.constraints_.resolution(this.targetResolution_,0,r,i),o=this.constraints_.center(this.targetCenter_,s,r,i,this.calculateCenterShift(this.targetCenter_,s,n,r));this.get(Ns.ROTATION)!==n&&this.set(Ns.ROTATION,n),this.get(Ns.RESOLUTION)!==s&&(this.set(Ns.RESOLUTION,s),this.set("zoom",this.getZoom(),!0)),o&&this.get(Ns.CENTER)&&Mi(this.get(Ns.CENTER),o)||this.set(Ns.CENTER,o),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=void 0!==t?t:200;const n=e||0,r=this.constraints_.rotation(this.targetRotation_),s=this.getViewportSize_(r),o=this.constraints_.resolution(this.targetResolution_,n,s),a=this.constraints_.center(this.targetCenter_,o,s,!1,this.calculateCenterShift(this.targetCenter_,o,r,s));if(0===t&&!this.cancelAnchor_)return this.targetResolution_=o,this.targetRotation_=r,this.targetCenter_=a,void this.applyTargetState_();i=i||(0===t?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,this.getResolution()===o&&this.getRotation()===r&&this.getCenterInternal()&&Mi(this.getCenterInternal(),a)||(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:a,resolution:o,duration:t,easing:rt,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(Os,1)}endInteraction(t,e,i){i=i&&xn(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(Os,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}};function io(t,e){if(!t.visible)return!1;const i=e.resolution;if(i<t.minResolution||i>=t.maxResolution)return!1;const n=e.zoom;return n>t.minZoom&&n<=t.maxZoom}var no=class extends bs{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(Cs,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return(t=t||[]).push(this),t}getLayerStatesArray(t){return(t=t||[]).push(this.getLayerState()),t}getSource(){return this.get(Cs)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),this.sourceReady_||"ready"!==this.getSource().getState()||(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(G(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=D(t,E,this.handleSourceChange_,this),"ready"===t.getState()&&(this.sourceReady_=!0,setTimeout((()=>{this.dispatchEvent("sourceready")}),0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const i=this.getMapInternal();let n;!t&&i&&(t=i.getView()),e=t instanceof eo?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray()),n=e.layerStatesArray?e.layerStatesArray.find((t=>t.layer===this)):this.getLayerState();const r=this.getExtent();return io(n,e.viewState)&&(!r||Ae(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];let e;const i=this.getSource();if(i&&(e=i.getAttributions()),!e)return[];let n=e(t instanceof eo?t.getViewStateAndExtent():t);return Array.isArray(n)||(n=[n]),n}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}setMapInternal(t){t||this.unrender(),this.set(Rs,t)}getMapInternal(){return this.get(Rs)}setMap(t){this.mapPrecomposeKey_&&(G(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(G(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=D(t,Fs,(function(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Mt(!e.some((function(t){return t.layer===i.layer})),67),e.push(i)}),this),this.mapRenderKey_=D(this,E,t.render,t),this.changed())}setSource(t){this.set(Cs,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}};function ro(t,e){ms.expire()}var so=class extends o{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){z()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,n=t.pixelToCoordinateTransform;Yt(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Kt(n,i)}forEachFeatureAtCoordinate(t,e,i,n,r,s,o,a){let l;const h=e.viewState;function c(t,e,i,n){return r.call(s,e,t?i:null,n)}const u=h.projection,d=ji(t.slice(),u),g=[[0,0]];if(u.canWrapX()&&n){const t=Me(u.getExtent());g.push([-t,0],[t,0])}const f=e.layerStatesArray,p=f.length,m=[],_=[];for(let n=0;n<g.length;n++)for(let r=p-1;r>=0;--r){const s=f[r],u=s.layer;if(u.hasRenderer()&&io(s,h)&&o.call(a,u)){const r=u.getRenderer(),o=u.getSource();if(r&&o){const a=o.getWrapX()?d:t,h=c.bind(null,s.managed);_[0]=a[0]+g[n][0],_[1]=a[1]+g[n][1],l=r.forEachFeatureAtCoordinate(_,e,i,h,m)}if(l)return l}}if(0===m.length)return;const y=1/m.length;return m.forEach(((t,e)=>t.distanceSq+=e*y)),m.sort(((t,e)=>t.distanceSq-e.distanceSq)),m.some((t=>l=t.callback(t.feature,t.layer,t.geometry))),l}hasFeatureAtCoordinate(t,e,i,n,r,s){return void 0!==this.forEachFeatureAtCoordinate(t,e,i,n,p,this,r,s)}getMap(){return this.map_}renderFrame(t){z()}flushDeclutterItems(t){}scheduleExpireIconCache(t){ms.canExpireCache()&&t.postRenderFunctions.push(ro)}};var oo=class extends r{constructor(t,e,i,n){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=n}};const ao="ol-hidden",lo="ol-selectable",ho="ol-unselectable",co="ol-unsupported",uo="ol-control",go="ol-collapsed",fo=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))","?\\s*([-,\\\"\\'\\sa-z]+?)\\s*$"].join(""),"i"),po=["style","variant","weight","size","lineHeight","family"],mo=function(t){const e=t.match(fo);if(!e)return null;const i={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let t=0,n=po.length;t<n;++t){const n=e[t+1];void 0!==n&&(i[po[t]]=n)}return i.families=i.family.split(/,\s?/),i},_o="10px sans-serif",yo="#000",xo="round",vo=[],So="round",wo=10,Eo="#000",To="center",Co="middle",Ro=[0,0,0,0],bo=new Z;let Po,Io=null;const Fo={},Lo=function(){const t="32px ",e=["monospace","serif"],i=e.length,n="wmytzilWMYTZIL@#/&?$%10";let r,s;function o(r,o,a){let l=!0;for(let h=0;h<i;++h){const i=e[h];if(s=Oo(r+" "+o+" "+t+i,n),a!=i){const e=Oo(r+" "+o+" "+t+a+","+i,n);l=l&&e!=s}}return!!l}function a(){let t=!0;const e=bo.getKeys();for(let i=0,n=e.length;i<n;++i){const n=e[i];bo.get(n)<100&&(o.apply(this,n.split("\n"))?(v(Fo),Io=null,Po=void 0,bo.set(n,100)):(bo.set(n,bo.get(n)+1,!0),t=!1))}t&&(clearInterval(r),r=void 0)}return function(t){const e=mo(t);if(!e)return;const i=e.families;for(let t=0,n=i.length;t<n;++t){const n=i[t],s=e.style+"\n"+e.weight+"\n"+n;void 0===bo.get(s)&&(bo.set(s,100,!0),o(e.style,e.weight,n)||(bo.set(s,0,!0),void 0===r&&(r=setInterval(a,32))))}}}(),Mo=function(){let t;return function(e){let i=Fo[e];if(null==i){if(pt){const t=mo(e),n=Ao(e,"Žg");i=(isNaN(Number(t.lineHeight))?1.2:Number(t.lineHeight))*(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent)}else t||(t=document.createElement("div"),t.innerHTML="M",t.style.minHeight="0",t.style.maxHeight="none",t.style.height="auto",t.style.padding="0",t.style.border="none",t.style.position="absolute",t.style.display="block",t.style.left="-99999px"),t.style.font=e,document.body.appendChild(t),i=t.offsetHeight,document.body.removeChild(t);Fo[e]=i}return i}}();function Ao(t,e){return Io||(Io=yt(1,1)),t!=Po&&(Io.font=t,Po=Io.font),Io.measureText(e)}function Oo(t,e){return Ao(t,e).width}function No(t,e,i){if(e in i)return i[e];const n=e.split("\n").reduce(((e,i)=>Math.max(e,Oo(t,i))),0);return i[e]=n,n}function Do(t,e){const i=[],n=[],r=[];let s=0,o=0,a=0,l=0;for(let h=0,c=e.length;h<=c;h+=2){const u=e[h];if("\n"===u||h===c){s=Math.max(s,o),r.push(o),o=0,a+=l;continue}const d=e[h+1]||t.font,g=Oo(d,u);i.push(g),o+=g;const f=Mo(d);n.push(f),l=Math.max(l,f)}return{width:s,height:a,widths:i,heights:n,lineWidths:r}}function ko(t,e,i,n,r,s,o,a,l,h,c){t.save(),1!==i&&(t.globalAlpha*=i),e&&t.setTransform.apply(t,e),n.contextInstructions?(t.translate(l,h),t.scale(c[0],c[1]),function(t,e){const i=t.contextInstructions;for(let t=0,n=i.length;t<n;t+=2)Array.isArray(i[t+1])?e[i[t]].apply(e,i[t+1]):e[i[t]]=i[t+1]}(n,t)):c[0]<0||c[1]<0?(t.translate(l,h),t.scale(c[0],c[1]),t.drawImage(n,r,s,o,a,0,0,o,a)):t.drawImage(n,r,s,o,a,l,h,o*c[0],a*c[1]),t.restore()}var Go=class extends so{constructor(t){super(t),this.fontChangeListenerKey_=D(bo,s,t.redrawText.bind(t)),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=ho+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0,this.declutterLayers_=[]}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new oo(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){G(this.fontChangeListenerKey_),this.element_.parentNode.removeChild(this.element_),super.disposeInternal()}renderFrame(t){if(!t)return void(this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1));this.calculateMatrices2D(t),this.dispatchRenderEvent(Fs,t);const e=t.layerStatesArray.sort((function(t,e){return t.zIndex-e.zIndex})),i=t.viewState;this.children_.length=0;const n=this.declutterLayers_;n.length=0;let r=null;for(let s=0,o=e.length;s<o;++s){const o=e[s];t.layerIndex=s;const a=o.layer,l=a.getSourceState();if(!io(o,i)||"ready"!=l&&"undefined"!=l){a.unrender();continue}const h=a.render(t,r);h&&(h!==r&&(this.children_.push(h),r=h),"getDeclutter"in a&&n.push(a))}this.flushDeclutterItems(t),Ct(this.element_,this.children_),this.dispatchRenderEvent(Ls,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}flushDeclutterItems(t){const e=this.declutterLayers_;for(let i=e.length-1;i>=0;--i)e[i].renderDeclutter(t);t.declutterTree=null,e.length=0}};class jo extends r{constructor(t,e){super(t),this.layer=e}}const Bo="layers";class Uo extends bs{constructor(t){t=t||{};const e=Object.assign({},t);delete e.layers;let i=t.layers;super(e),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Bo,this.handleLayersChanged_),i?Array.isArray(i)?i=new $(i.slice(),{unique:!0}):Mt("function"==typeof i.getArray,43):i=new $(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(G),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(D(t,Y,this.handleLayersAdd_,this),D(t,K,this.handleLayersRemove_,this));for(const t in this.listenerKeys_)this.listenerKeys_[t].forEach(G);v(this.listenerKeys_);const e=t.getArray();for(let t=0,i=e.length;t<i;t++){const i=e[t];this.registerLayerListeners_(i),this.dispatchEvent(new jo("addlayer",i))}this.changed()}registerLayerListeners_(t){const e=[D(t,s,this.handleLayerChange_,this),D(t,E,this.handleLayerChange_,this)];t instanceof Uo&&e.push(D(t,"addlayer",this.handleLayerGroupAdd_,this),D(t,"removelayer",this.handleLayerGroupRemove_,this)),this.listenerKeys_[V(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new jo("addlayer",t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new jo("removelayer",t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new jo("addlayer",e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=V(e);this.listenerKeys_[i].forEach(G),delete this.listenerKeys_[i],this.dispatchEvent(new jo("removelayer",e)),this.changed()}getLayers(){return this.get(Bo)}setLayers(t){const e=this.getLayers();if(e){const t=e.getArray();for(let e=0,i=t.length;e<i;++e)this.dispatchEvent(new jo("removelayer",t[e]))}this.set(Bo,t)}getLayersArray(t){return t=void 0!==t?t:[],this.getLayers().forEach((function(e){e.getLayersArray(t)})),t}getLayerStatesArray(t){const e=void 0!==t?t:[],i=e.length;this.getLayers().forEach((function(t){t.getLayerStatesArray(e)}));const n=this.getLayerState();let r=n.zIndex;t||void 0!==n.zIndex||(r=0);for(let t=i,s=e.length;t<s;t++){const i=e[t];i.opacity*=n.opacity,i.visible=i.visible&&n.visible,i.maxResolution=Math.min(i.maxResolution,n.maxResolution),i.minResolution=Math.max(i.minResolution,n.minResolution),i.minZoom=Math.max(i.minZoom,n.minZoom),i.maxZoom=Math.min(i.maxZoom,n.maxZoom),void 0!==n.extent&&(void 0!==i.extent?i.extent=Ie(i.extent,n.extent):i.extent=n.extent),void 0===i.zIndex&&(i.zIndex=r)}return e}getSourceState(){return"ready"}}var zo=Uo;var Xo=class extends r{constructor(t,e,i){super(t),this.map=e,this.frameState=void 0!==i?i:null}};var Vo=class extends Xo{constructor(t,e,i,n,r,s){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=void 0!==n&&n,this.activePointers=s}get pixel(){return this.pixel_||(this.pixel_=this.map.getEventPixel(this.originalEvent)),this.pixel_}set pixel(t){this.pixel_=t}get coordinate(){return this.coordinate_||(this.coordinate_=this.map.getCoordinateFromPixel(this.pixel)),this.coordinate_}set coordinate(t){this.coordinate_=t}preventDefault(){super.preventDefault(),"preventDefault"in this.originalEvent&&this.originalEvent.preventDefault()}stopPropagation(){super.stopPropagation(),"stopPropagation"in this.originalEvent&&this.originalEvent.stopPropagation()}},Wo={SINGLECLICK:"singleclick",CLICK:R,DBLCLICK:b,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Zo="pointermove",Yo="pointerdown",Ko="pointerup",Ho="pointerout";var qo=class extends w{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=void 0===e?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=D(i,Yo,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=D(i,Zo,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(O,this.boundHandleTouchMove_,!!_t&&{passive:!1})}emulateClick_(t){let e=new Vo(Wo.CLICK,this.map_,t);this.dispatchEvent(e),void 0!==this.clickTimeoutId_?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Vo(Wo.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout((()=>{this.clickTimeoutId_=void 0;const e=new Vo(Wo.SINGLECLICK,this.map_,t);this.dispatchEvent(e)}),250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==Wo.POINTERUP||e.type==Wo.POINTERCANCEL){delete this.trackedTouches_[i];for(const t in this.trackedTouches_)if(this.trackedTouches_[t].target!==e.target){delete this.trackedTouches_[t];break}}else e.type!=Wo.POINTERDOWN&&e.type!=Wo.POINTERMOVE||(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Vo(Wo.POINTERUP,this.map_,t,void 0,void 0,this.activePointers_);this.dispatchEvent(e),this.emulateClicks_&&!e.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(t)&&this.emulateClick_(this.down_),0===this.activePointers_.length&&(this.dragListenerKeys_.forEach(G),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return 0===t.button}handlePointerDown_(t){this.emulateClicks_=0===this.activePointers_.length,this.updateActivePointers_(t);const e=new Vo(Wo.POINTERDOWN,this.map_,t,void 0,void 0,this.activePointers_);if(this.dispatchEvent(e),this.down_=new PointerEvent(t.type,t),Object.defineProperty(this.down_,"target",{writable:!1,value:t.target}),0===this.dragListenerKeys_.length){const t=this.map_.getOwnerDocument();this.dragListenerKeys_.push(D(t,Wo.POINTERMOVE,this.handlePointerMove_,this),D(t,Wo.POINTERUP,this.handlePointerUp_,this),D(this.element_,Wo.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(D(this.element_.getRootNode(),Wo.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Vo(Wo.POINTERDRAG,this.map_,t,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(e)}}relayMoveEvent_(t){this.originalPointerMoveEvent_=t;const e=!(!this.down_||!this.isMoving_(t));this.dispatchEvent(new Vo(Wo.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;e&&!e.defaultPrevented||"boolean"==typeof t.cancelable&&!0!==t.cancelable||t.preventDefault()}isMoving_(t){return this.dragging_||Math.abs(t.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(G(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(O,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(G(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(G),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}},$o="postrender",Jo="movestart",Qo="moveend",ta="loadstart",ea="loadend",ia="layergroup",na="size",ra="target",sa="view";const oa=1/0;var aa=class{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,v(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];1==t.length?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const n=this.keyFunction_(i);return delete this.queuedElements_[n],i}enqueue(t){Mt(!(this.keyFunction_(t)in this.queuedElements_),31);const e=this.priorityFunction_(t);return e!=oa&&(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0)}getCount(){return this.elements_.length}getLeftChildIndex_(t){return 2*t+1}getRightChildIndex_(t){return 2*t+2}getParentIndex_(t){return t-1>>1}heapify_(){let t;for(t=(this.elements_.length>>1)-1;t>=0;t--)this.siftUp_(t)}isEmpty(){return 0===this.elements_.length}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,n=e.length,r=e[t],s=i[t],o=t;for(;t<n>>1;){const r=this.getLeftChildIndex_(t),s=this.getRightChildIndex_(t),o=s<n&&i[s]<i[r]?s:r;e[t]=e[o],i[t]=i[o],t=o}e[t]=r,i[t]=s,this.siftDown_(o,t)}siftDown_(t,e){const i=this.elements_,n=this.priorities_,r=i[e],s=n[e];for(;e>t;){const t=this.getParentIndex_(e);if(!(n[t]>s))break;i[e]=i[t],n[e]=n[t],e=t}i[e]=r,n[e]=s}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let n=0;const r=e.length;let s,o,a;for(o=0;o<r;++o)s=e[o],a=t(s),a==oa?delete this.queuedElements_[this.keyFunction_(s)]:(i[n]=a,e[n++]=s);e.length=n,i.length=n,this.heapify_()}};var la=class extends aa{constructor(t,e){super((function(e){return t.apply(null,e)}),(function(t){return t[0].getKey()})),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);if(e){t[0].addEventListener(E,this.boundHandleTileChange_)}return e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===tt||i===et||i===it){i!==et&&e.removeEventListener(E,this.boundHandleTileChange_);const t=e.getKey();t in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[t],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i,n,r,s=0;for(;this.tilesLoading_<t&&s<e&&this.getCount()>0;)n=this.dequeue()[0],r=n.getKey(),i=n.getState(),i!==J||r in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++s,n.load())}};function ha(t,e,i,n,r){if(!t||!(i in t.wantedTiles))return oa;if(!t.wantedTiles[i][e.getKey()])return oa;const s=t.viewState.center,o=n[0]-s[0],a=n[1]-s[1];return 65536*Math.log(r)+Math.sqrt(o*o+a*a)/r}var ca=class extends Z{constructor(t){super();const e=t.element;!e||t.target||e.style.pointerEvents||(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){Et(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&Et(this.element);for(let t=0,e=this.listenerKeys.length;t<e;++t)G(this.listenerKeys[t]);if(this.listenerKeys.length=0,this.map_=t,t){(this.target_?this.target_:t.getOverlayContainerStopEvent()).appendChild(this.element),this.render!==_&&this.listenerKeys.push(D(t,$o,this.render,this)),t.render()}}render(t){}setTarget(t){this.target_="string"==typeof t?document.getElementById(t):t}};var ua=class extends ca{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=void 0===t.collapsed||t.collapsed,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=void 0!==t.collapsible,this.collapsible_=void 0===t.collapsible||t.collapsible,this.collapsible_||(this.collapsed_=!1);const e=void 0!==t.className?t.className:"ol-attribution",i=void 0!==t.tipLabel?t.tipLabel:"Attributions",n=void 0!==t.expandClassName?t.expandClassName:e+"-expand",r=void 0!==t.collapseLabel?t.collapseLabel:"",s=void 0!==t.collapseClassName?t.collapseClassName:e+"-collapse";"string"==typeof r?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=s):this.collapseLabel_=r;const o=void 0!==t.label?t.label:"i";"string"==typeof o?(this.label_=document.createElement("span"),this.label_.textContent=o,this.label_.className=n):this.label_=o;const a=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(a),this.toggleButton_.addEventListener(R,this.handleClick_.bind(this),!1);const l=e+" "+ho+" "+uo+(this.collapsed_&&this.collapsible_?" "+go:"")+(this.collapsible_?"":" ol-uncollapsible"),h=this.element;h.className=l,h.appendChild(this.toggleButton_),h.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=Array.from(new Set(this.getMap().getAllLayers().flatMap((e=>e.getAttributions(t))))),i=!this.getMap().getAllLayers().some((t=>t.getSource()&&!1===t.getSource().getAttributionsCollapsible()));return this.overrideCollapsible_||this.setCollapsible(i),e}updateElement_(t){if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=this.collectSourceAttributions_(t),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!g(e,this.renderedAttributions_)){Tt(this.ulElement_);for(let t=0,i=e.length;t<i;++t){const i=document.createElement("li");i.innerHTML=e[t],this.ulElement_.appendChild(i)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(go),this.collapsed_?wt(this.collapseLabel_,this.label_):wt(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,this.collapsible_&&this.collapsed_!==t&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}};var da=class extends ca{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=void 0!==t.className?t.className:"ol-rotate",i=void 0!==t.label?t.label:"⇧",n=void 0!==t.compassClassName?t.compassClassName:"ol-compass";this.label_=null,"string"==typeof i?(this.label_=document.createElement("span"),this.label_.className=n,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(n));const r=t.tipLabel?t.tipLabel:"Reset rotation",s=document.createElement("button");s.className=e+"-reset",s.setAttribute("type","button"),s.title=r,s.appendChild(this.label_),s.addEventListener(R,this.handleClick_.bind(this),!1);const o=e+" "+ho+" "+uo,a=this.element;a.className=o,a.appendChild(s),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=void 0!==t.duration?t.duration:250,this.autoHide_=void 0===t.autoHide||t.autoHide,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(ao)}handleClick_(t){t.preventDefault(),void 0!==this.callResetNorth_?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const t=this.getMap().getView();if(!t)return;const e=t.getRotation();void 0!==e&&(this.duration_>0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:rt}):t.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const t="rotate("+i+"rad)";if(this.autoHide_){const t=this.element.classList.contains(ao);t||0!==i?t&&0!==i&&this.element.classList.remove(ao):this.element.classList.add(ao)}this.label_.style.transform=t}this.rotation_=i}};var ga=class extends ca{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=void 0!==t.className?t.className:"ol-zoom",i=void 0!==t.delta?t.delta:1,n=void 0!==t.zoomInClassName?t.zoomInClassName:e+"-in",r=void 0!==t.zoomOutClassName?t.zoomOutClassName:e+"-out",s=void 0!==t.zoomInLabel?t.zoomInLabel:"+",o=void 0!==t.zoomOutLabel?t.zoomOutLabel:"",a=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",l=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=n,h.setAttribute("type","button"),h.title=a,h.appendChild("string"==typeof s?document.createTextNode(s):s),h.addEventListener(R,this.handleClick_.bind(this,i),!1);const c=document.createElement("button");c.className=r,c.setAttribute("type","button"),c.title=l,c.appendChild("string"==typeof o?document.createTextNode(o):o),c.addEventListener(R,this.handleClick_.bind(this,-i),!1);const u=e+" "+ho+" "+uo,d=this.element;d.className=u,d.appendChild(h),d.appendChild(c),this.duration_=void 0!==t.duration?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const e=this.getMap().getView();if(!e)return;const i=e.getZoom();if(void 0!==i){const n=e.getConstrainedZoom(i+t);this.duration_>0?(e.getAnimating()&&e.cancelAnimations(),e.animate({zoom:n,duration:this.duration_,easing:rt})):e.setZoom(n)}}};function fa(t){t=t||{};const e=new $;(void 0===t.zoom||t.zoom)&&e.push(new ga(t.zoomOptions));(void 0===t.rotate||t.rotate)&&e.push(new da(t.rotateOptions));return(void 0===t.attribution||t.attribution)&&e.push(new ua(t.attributionOptions)),e}var pa="active";function ma(t,e,i){const n=t.getCenterInternal();if(n){const r=[n[0]+e[0],n[1]+e[1]];t.animateInternal({duration:void 0!==i?i:250,easing:ot,center:t.getConstrainedCenter(r)})}}function _a(t,e,i,n){const r=t.getZoom();if(void 0===r)return;const s=t.getConstrainedZoom(r+e),o=t.getResolutionForZoom(s);t.getAnimating()&&t.cancelAnimations(),t.animate({resolution:o,anchor:i,duration:void 0!==n?n:250,easing:rt})}var ya=class extends Z{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(pa)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(pa,t)}setMap(t){this.map_=t}};var xa=class extends ya{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:250}handleEvent(t){let e=!1;if(t.type==Wo.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,s=i.shiftKey?-this.delta_:this.delta_;_a(n.getView(),s,r,this.duration_),i.preventDefault(),e=!0}return!e}};function va(t){const e=t.length;let i=0,n=0;for(let r=0;r<e;r++)i+=t[r].clientX,n+=t[r].clientY;return{clientX:i/e,clientY:n/e}}var Sa=class extends ya{constructor(t){super(t=t||{}),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==Wo.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Wo.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence=e&&this.targetPointers.length>0}}else if(t.type==Wo.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==Wo.POINTERMOVE&&this.handleMoveEvent(t);return!e}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};function wa(t){const e=arguments;return function(t){let i=!0;for(let n=0,r=e.length;n<r&&(i=i&&e[n](t),i);++n);return i}}const Ea=function(t){const e=t.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},Ta=function(t){const e=t.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Ca=function(t){const e=t.map.getTargetElement(),i=t.map.getOwnerDocument().activeElement;return e.contains(i)},Ra=function(t){return!t.map.getTargetElement().hasAttribute("tabindex")||Ca(t)},ba=p,Pa=function(t){const e=t.originalEvent;return 0==e.button&&!(dt&&gt&&e.ctrlKey)},Ia=m,Fa=function(t){return t.type==Wo.SINGLECLICK},La=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey},Ma=function(t){const e=t.originalEvent;return gt?e.metaKey:e.ctrlKey},Aa=function(t){const e=t.originalEvent;return!e.altKey&&!(e.metaKey||e.ctrlKey)&&e.shiftKey},Oa=function(t){const e=t.originalEvent,i=e.target.tagName;return"INPUT"!==i&&"SELECT"!==i&&"TEXTAREA"!==i&&!e.target.isContentEditable},Na=function(t){const e=t.originalEvent;return Mt(void 0!==e,56),"mouse"==e.pointerType},Da=function(t){const e=t.originalEvent;return Mt(void 0!==e,56),e.isPrimary&&0===e.button};var ka=class extends Sa{constructor(t){super({stopDown:m}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:wa(La,Da);this.condition_=t.onFocusOnly?wa(Ra,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,n=e.getEventPixel(va(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(n[0],n[1]),this.lastCentroid){const e=[this.lastCentroid[0]-n[0],n[1]-this.lastCentroid[1]],i=t.map.getView();Oi(e,i.getResolution()),Ai(e,i.getRotation()),i.adjustCenterInternal(e)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=n,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(0===this.targetPointers.length){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const t=this.kinetic_.getDistance(),n=this.kinetic_.getAngle(),r=i.getCenterInternal(),s=e.getPixelFromCoordinateInternal(r),o=e.getCoordinateFromPixelInternal([s[0]-t*Math.cos(n),s[1]-t*Math.sin(n)]);i.animateInternal({center:i.getConstrainedCenter(o),duration:500,easing:rt})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const e=t.map.getView();return this.lastCentroid=null,e.getAnimating()&&e.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}};var Ga=class extends Sa{constructor(t){t=t||{},super({stopDown:m}),this.condition_=t.condition?t.condition:Ta,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!Na(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Ws)return;const n=e.getSize(),r=t.pixel,s=Math.atan2(n[1]/2-r[1],r[0]-n[0]/2);if(void 0!==this.lastAngle_){const t=s-this.lastAngle_;i.adjustRotationInternal(-t)}this.lastAngle_=s}handleUpEvent(t){if(!Na(t))return!0;return t.map.getView().endInteraction(this.duration_),!1}handleDownEvent(t){if(!Na(t))return!1;if(Pa(t)&&this.condition_(t)){return t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0}return!1}};var ja=class extends o{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",n=this.element_.style;n.left=Math.min(t[0],e[0])+i,n.top=Math.min(t[1],e[1])+i,n.width=Math.abs(e[0]-t[0])+i,n.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=t,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(t,e){this.startPixel_=t,this.endPixel_=e,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){const t=this.startPixel_,e=this.endPixel_,i=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);i[4]=i[0].slice(),this.geometry_?this.geometry_.setCoordinates([i]):this.geometry_=new Ir([i])}getGeometry(){return this.geometry_}};const Ba="boxstart",Ua="boxdrag",za="boxend",Xa="boxcancel";class Va extends r{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}var Wa=class extends Sa{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.box_=new ja(t.className||"ol-dragbox"),this.minArea_=void 0!==t.minArea?t.minArea:64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition?t.condition:Pa,this.boxEndCondition_=t.boxEndCondition?t.boxEndCondition:this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const n=i[0]-e[0],r=i[1]-e[1];return n*n+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new Va(Ua,t.coordinate,t))}handleUpEvent(t){this.box_.setMap(null);const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new Va(e?za:Xa,t.coordinate,t)),!1}handleDownEvent(t){return!!this.condition_(t)&&(this.startPixel_=t.pixel,this.box_.setMap(t.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Va(Ba,t.coordinate,t)),!0)}onBoxEnd(t){}};var Za=class extends Wa{constructor(t){super({condition:(t=t||{}).condition?t.condition:Aa,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=void 0!==t.duration?t.duration:200,this.out_=void 0!==t.out&&t.out}onBoxEnd(t){const e=this.getMap().getView();let i=this.getGeometry();if(this.out_){const t=e.rotatedExtentForGeometry(i),n=e.getResolutionForExtentInternal(t),r=e.getResolution()/n;i=i.clone(),i.scale(r*r)}e.fitInternal(i,{duration:this.duration_,easing:rt})}},Ya="ArrowLeft",Ka="ArrowUp",Ha="ArrowRight",qa="ArrowDown";var $a=class extends ya{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return La(t)&&Oa(t)},this.condition_=void 0!==t.condition?t.condition:this.defaultCondition_,this.duration_=void 0!==t.duration?t.duration:100,this.pixelDelta_=void 0!==t.pixelDelta?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==L){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==qa||n==Ya||n==Ha||n==Ka)){const r=t.map.getView(),s=r.getResolution()*this.pixelDelta_;let o=0,a=0;n==qa?a=-s:n==Ya?o=-s:n==Ha?o=s:a=s;const l=[o,a];Ai(l,r.getRotation()),ma(r,l,this.duration_),i.preventDefault(),e=!0}}return!e}};var Ja=class extends ya{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!Ma(t)&&Oa(t)},this.delta_=t.delta?t.delta:1,this.duration_=void 0!==t.duration?t.duration:100}handleEvent(t){let e=!1;if(t.type==L||t.type==M){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&("+"===n||"-"===n)){const r=t.map,s="+"===n?this.delta_:-this.delta_;_a(r.getView(),s,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}};var Qa=class extends ya{constructor(t){super(t=t||{}),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=void 0!==t.maxDelta?t.maxDelta:1,this.duration_=void 0!==t.duration?t.duration:250,this.timeout_=void 0!==t.timeout?t.timeout:80,this.useAnchor_=void 0===t.useAnchor||t.useAnchor,this.constrainResolution_=void 0!==t.constrainResolution&&t.constrainResolution;const e=t.condition?t.condition:ba;this.condition_=t.onFocusOnly?wa(Ra,e):e,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const t=this.getMap();if(!t)return;t.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==N)return!0;const e=t.map,i=t.originalEvent;let n;if(i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.coordinate),t.type==N&&(n=i.deltaY,ht&&i.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(n/=ft),i.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=40)),0===n)return!1;this.lastDelta_=n;const r=Date.now();void 0===this.startTime_&&(this.startTime_=r),(!this.mode_||r-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(n)<4?"trackpad":"wheel");const s=e.getView();if("trackpad"===this.mode_&&!s.getConstrainResolution()&&!this.constrainResolution_)return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(s.getAnimating()&&s.cancelAnimations(),s.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),s.adjustZoom(-n/this.deltaPerZoom_,this.lastAnchor_),this.startTime_=r,!1;this.totalDelta_+=n;const o=Math.max(this.timeout_-(r-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,e),o),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-gi(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),_a(e,i,this.lastAnchor_,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(t){this.useAnchor_=t,t||(this.lastAnchor_=null)}};var tl=class extends Sa{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=m),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=void 0!==t.threshold?t.threshold:.3,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){let e=0;const i=this.targetPointers[0],n=this.targetPointers[1],r=Math.atan2(n.clientY-i.clientY,n.clientX-i.clientX);if(void 0!==this.lastAngle_){const t=r-this.lastAngle_;this.rotationDelta_+=t,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=t}this.lastAngle_=r;const s=t.map,o=s.getView();o.getConstraints().rotation!==Ws&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(va(this.targetPointers))),this.rotating_&&(s.render(),o.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){if(this.targetPointers.length<2){return t.map.getView().endInteraction(this.duration_),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}};var el=class extends Sa{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=m),super(e),this.anchor_=null,this.duration_=void 0!==t.duration?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const i=this.targetPointers[0],n=this.targetPointers[1],r=i.clientX-n.clientX,s=i.clientY-n.clientY,o=Math.sqrt(r*r+s*s);void 0!==this.lastDistance_&&(e=this.lastDistance_/o),this.lastDistance_=o;const a=t.map,l=a.getView();1!=e&&(this.lastScaleDelta_=e),this.anchor_=a.getCoordinateFromPixelInternal(a.getEventPixel(va(this.targetPointers))),a.render(),l.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const e=t.map.getView(),i=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,i),!1}return!0}handleDownEvent(t){if(this.targetPointers.length>=2){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||e.getView().beginInteraction(),!0}return!1}};function il(t){t=t||{};const e=new $,i=new ns(-.005,.05,100);(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new Ga);(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new xa({delta:t.zoomDelta,duration:t.zoomDuration}));(void 0===t.dragPan||t.dragPan)&&e.push(new ka({onFocusOnly:t.onFocusOnly,kinetic:i}));(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new tl);(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new el({duration:t.zoomDuration}));(void 0===t.keyboard||t.keyboard)&&(e.push(new $a),e.push(new Ja({delta:t.zoomDelta,duration:t.zoomDuration})));(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new Qa({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration}));return(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new Za({duration:t.zoomDuration})),e}function nl(t,e,i){return void 0===i&&(i=[0,0]),i[0]=t[0]+2*e,i[1]=t[1]+2*e,i}function rl(t){return t[0]>0&&t[1]>0}function sl(t,e,i){return void 0===i&&(i=[0,0]),i[0]=t[0]*e+.5|0,i[1]=t[1]*e+.5|0,i}function ol(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}function al(t){t instanceof no?t.setMapInternal(null):t instanceof zo&&t.getLayers().forEach(al)}function ll(t,e){if(t instanceof no)t.setMapInternal(e);else if(t instanceof zo){const i=t.getLayers().getArray();for(let t=0,n=i.length;t<n;++t)ll(i[t],e)}}var hl=class extends Z{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=function(t){let e=null;void 0!==t.keyboardEventTarget&&(e="string"==typeof t.keyboardEventTarget?document.getElementById(t.keyboardEventTarget):t.keyboardEventTarget);const i={},n=t.layers&&"function"==typeof t.layers.getLayers?t.layers:new zo({layers:t.layers});let r,s,o;i[ia]=n,i[ra]=t.target,i[sa]=t.view instanceof eo?t.view:new eo,void 0!==t.controls&&(Array.isArray(t.controls)?r=new $(t.controls.slice()):(Mt("function"==typeof t.controls.getArray,47),r=t.controls));void 0!==t.interactions&&(Array.isArray(t.interactions)?s=new $(t.interactions.slice()):(Mt("function"==typeof t.interactions.getArray,48),s=t.interactions));void 0!==t.overlays?Array.isArray(t.overlays)?o=new $(t.overlays.slice()):(Mt("function"==typeof t.overlays.getArray,49),o=t.overlays):o=new $;return{controls:r,interactions:s,keyboardEventTarget:e,overlays:o,values:i}}(t);this.renderComplete_,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=void 0!==t.maxTilesLoading?t.maxTilesLoading:16,this.pixelRatio_=void 0!==t.pixelRatio?t.pixelRatio:ft,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=[1,0,0,1,0,0],this.pixelToCoordinateTransform_=[1,0,0,1,0,0],this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,this.resizeObserver_=new ResizeObserver((()=>this.updateSize())),this.controls=e.controls||fa(),this.interactions=e.interactions||il({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new la(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(ia,this.handleLayerGroupChanged_),this.addChangeListener(sa,this.handleViewChanged_),this.addChangeListener(na,this.handleSizeChanged_),this.addChangeListener(ra,this.handleTargetChanged_),this.setProperties(e.values);const i=this;!t.view||t.view instanceof eo||t.view.then((function(t){i.setView(new eo(t))})),this.controls.addEventListener(Y,(t=>{t.element.setMap(this)})),this.controls.addEventListener(K,(t=>{t.element.setMap(null)})),this.interactions.addEventListener(Y,(t=>{t.element.setMap(this)})),this.interactions.addEventListener(K,(t=>{t.element.setMap(null)})),this.overlays_.addEventListener(Y,(t=>{this.addOverlayInternal_(t.element)})),this.overlays_.addEventListener(K,(t=>{const e=t.element.getId();void 0!==e&&delete this.overlayIdIndex_[e.toString()],t.element.setMap(null)})),this.controls.forEach((t=>{t.setMap(this)})),this.interactions.forEach((t=>{t.setMap(this)})),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(t){this.getControls().push(t)}addInteraction(t){this.getInteractions().push(t)}addLayer(t){this.getLayerGroup().getLayers().push(t)}handleLayerAdd_(t){ll(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();void 0!==e&&(this.overlayIdIndex_[e.toString()]=t),t.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(t,e,i){if(!this.frameState_||!this.renderer_)return;const n=this.getCoordinateFromPixelInternal(t),r=void 0!==(i=void 0!==i?i:{}).hitTolerance?i.hitTolerance:0,s=void 0!==i.layerFilter?i.layerFilter:p,o=!1!==i.checkWrapped;return this.renderer_.forEachFeatureAtCoordinate(n,this.frameState_,r,o,e,null,s,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,(function(t){i.push(t)}),e),i}getAllLayers(){const t=[];return function e(i){i.forEach((function(i){i instanceof zo?e(i.getLayers()):t.push(i)}))}(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t),n=void 0!==(e=void 0!==e?e:{}).layerFilter?e.layerFilter:p,r=void 0!==e.hitTolerance?e.hitTolerance:0,s=!1!==e.checkWrapped;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,s,n,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const e=this.viewport_.getBoundingClientRect(),i=this.getSize(),n=e.width/i[0],r=e.height/i[1],s="changedTouches"in t?t.changedTouches[0]:t;return[(s.clientX-e.left)/n,(s.clientY-e.top)/r]}getTarget(){return this.get(ra)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return yn(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?zt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return void 0!==e?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(ia)}setLayers(t){const e=this.getLayerGroup();if(t instanceof $)return void e.setLayers(t);const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const i=t[e];if(!i.visible)continue;const n=i.layer.getRenderer();if(n&&!n.ready)return!0;const r=i.layer.getSource();if(r&&r.loading)return!0}return!1}getPixelFromCoordinate(t){const e=xn(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?zt(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(na)}getView(){return this.get(sa)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,n){return ha(this.frameState_,t,e,i,n)}handleBrowserEvent(t,e){e=e||t.type;const i=new Vo(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===Yo||i===N||i===L){const t=this.getOwnerDocument(),i=this.viewport_.getRootNode?this.viewport_.getRootNode():t,n=e.target;if(this.overlayContainerStopEvent_.contains(n)||!(i===t?t.documentElement:i).contains(n))return}if(t.frameState=this.frameState_,!1!==this.dispatchEvent(t)){const e=this.getInteractions().getArray().slice();for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.getMap()!==this||!n.getActive()||!this.getTargetElement())continue;if(!n.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let i=this.maxTilesLoading_,n=i;if(t){const e=t.viewHints;if(e[As]||e[Os]){const e=Date.now()-t.time>8;i=e?0:8,n=e?0:2}}e.getTilesLoading()<i&&(e.reprioritize(),e.loadMoreTiles(i,n))}t&&this.renderer_&&!t.animate&&(!0===this.renderComplete_?(this.hasListener(Ms)&&this.renderer_.dispatchRenderEvent(Ms,t),!1===this.loaded_&&(this.loaded_=!0,this.dispatchEvent(new Xo(ea,this,t)))):!0===this.loaded_&&(this.loaded_=!1,this.dispatchEvent(new Xo(ta,this,t))));const i=this.postRenderFunctions_;for(let e=0,n=i.length;e<n;++e)i[e](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let t=0,e=this.targetChangeHandlerKeys_.length;t<e;++t)G(this.targetChangeHandlerKeys_[t]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(C,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(N,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,Et(this.viewport_)}if(this.targetElement_){this.resizeObserver_.unobserve(this.targetElement_);const t=this.targetElement_.getRootNode();t instanceof ShadowRoot&&this.resizeObserver_.unobserve(t.host),this.setSize(void 0)}const t=this.getTarget(),e="string"==typeof t?document.getElementById(t):t;if(this.targetElement_=e,e){e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Go(this)),this.mapBrowserEventHandler_=new qo(this,this.moveTolerance_);for(const t in Wo)this.mapBrowserEventHandler_.addEventListener(Wo[t],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(C,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(N,this.boundHandleBrowserEvent_,!!_t&&{passive:!1});const t=this.keyboardEventTarget_?this.keyboardEventTarget_:e;this.targetChangeHandlerKeys_=[D(t,L,this.handleBrowserEvent,this),D(t,M,this.handleBrowserEvent,this)];const i=e.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.observe(i.host),this.resizeObserver_.observe(e)}else this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);this.updateSize()}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(G(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(G(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(),this.viewPropertyListenerKey_=D(t,s,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=D(t,E,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(G),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new jo("addlayer",t)),this.layerGroupPropertyListenerKeys_=[D(t,s,this.render,this),D(t,E,this.render,this),D(t,"addlayer",this.handleLayerAdd_,this),D(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const i=t[e].layer;i.hasRenderer()&&i.getRenderer().handleFontsChanged()}}render(){this.renderer_&&void 0===this.animationDelayKey_&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}flushDeclutterItems(){const t=this.frameState_;t&&this.renderer_.flushDeclutterItems(t)}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){al(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),n=this.frameState_;let r=null;if(void 0!==e&&rl(e)&&i&&i.isDef()){const n=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),s=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutterTree:null,extent:Re(s.center,s.resolution,s.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:s,viewHints:n,wantedTiles:{},mapId:V(this),renderTargets:{}},s.nextCenter&&s.nextResolution){const t=isNaN(s.nextRotation)?s.rotation:s.nextRotation;r.nextExtent=Re(s.nextCenter,s.nextResolution,t,e)}}if(this.frameState_=r,this.renderer_.renderFrame(r),r){if(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),n){(!this.previousExtent_||!Oe(this.previousExtent_)&&!de(r.extent,this.previousExtent_))&&(this.dispatchEvent(new Xo(Jo,this,n)),this.previousExtent_=he(this.previousExtent_))}this.previousExtent_&&!r.viewHints[As]&&!r.viewHints[Os]&&!de(r.extent,this.previousExtent_)&&(this.dispatchEvent(new Xo(Qo,this,r)),ee(r.extent,this.previousExtent_))}this.dispatchEvent(new Xo($o,this,r)),this.renderComplete_=this.hasListener(ta)||this.hasListener(ea)||this.hasListener(Ms)?!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady():void 0,this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout((()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()}),0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new jo("removelayer",e)),this.set(ia,t)}setSize(t){this.set(na,t)}setTarget(t){this.set(ra,t)}setView(t){if(!t||t instanceof eo)return void this.set(sa,t);this.set(sa,new eo);const e=this;t.then((function(t){e.setView(new eo(t))}))}updateSize(){const t=this.getTargetElement();let e;if(t){const i=getComputedStyle(t),n=t.offsetWidth-parseFloat(i.borderLeftWidth)-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight)-parseFloat(i.borderRightWidth),r=t.offsetHeight-parseFloat(i.borderTopWidth)-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom)-parseFloat(i.borderBottomWidth);isNaN(n)||isNaN(r)||(e=[n,r],!rl(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Ki("No map visible because the map container's width or height are 0."))}const i=this.getSize();!e||i&&g(e,i)||(this.setSize(e),this.updateViewportSize_())}updateViewportSize_(){const t=this.getView();if(t){let e;const i=getComputedStyle(this.viewport_);i.width&&i.height&&(e=[parseInt(i.width,10),parseInt(i.height,10)]),t.setViewportSize(e)}}};const cl="element",ul="map",dl="offset",gl="position",fl="positioning";var pl=class extends Z{constructor(t){super(),this.on,this.once,this.un,this.options=t,this.id=t.id,this.insertFirst=void 0===t.insertFirst||t.insertFirst,this.stopEvent=void 0===t.stopEvent||t.stopEvent,this.element=document.createElement("div"),this.element.className=void 0!==t.className?t.className:"ol-overlay-container "+lo,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.autoPan=!0===t.autoPan?{}:t.autoPan||void 0,this.rendered={transform_:"",visible:!0},this.mapPostrenderListenerKey=null,this.addChangeListener(cl,this.handleElementChanged),this.addChangeListener(ul,this.handleMapChanged),this.addChangeListener(dl,this.handleOffsetChanged),this.addChangeListener(gl,this.handlePositionChanged),this.addChangeListener(fl,this.handlePositioningChanged),void 0!==t.element&&this.setElement(t.element),this.setOffset(void 0!==t.offset?t.offset:[0,0]),this.setPositioning(t.positioning||"top-left"),void 0!==t.position&&this.setPosition(t.position)}getElement(){return this.get(cl)}getId(){return this.id}getMap(){return this.get(ul)||null}getOffset(){return this.get(dl)}getPosition(){return this.get(gl)}getPositioning(){return this.get(fl)}handleElementChanged(){Tt(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(Et(this.element),G(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=D(t,$o,this.render,this),this.updatePixelPosition();const e=this.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this.insertFirst?e.insertBefore(this.element,e.childNodes[0]||null):e.appendChild(this.element),this.performAutoPan()}}render(){this.updatePixelPosition()}handleOffsetChanged(){this.updatePixelPosition()}handlePositionChanged(){this.updatePixelPosition(),this.performAutoPan()}handlePositioningChanged(){this.updatePixelPosition()}setElement(t){this.set(cl,t)}setMap(t){this.set(ul,t)}setOffset(t){this.set(dl,t)}setPosition(t){this.set(gl,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(gl))return;const i=this.getRect(e.getTargetElement(),e.getSize()),n=this.getElement(),r=this.getRect(n,[vt(n),St(n)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!re(i,r)){const n=r[0]-i[0],o=i[2]-r[2],a=r[1]-i[1],l=i[3]-r[3],h=[0,0];if(n<0?h[0]=n-s:o<0&&(h[0]=Math.abs(o)+s),a<0?h[1]=a-s:l<0&&(h[1]=Math.abs(l)+s),0!==h[0]||0!==h[1]){const i=e.getView().getCenterInternal(),n=e.getPixelFromCoordinateInternal(i);if(!n)return;const r=[n[0]+h[0],n[1]+h[1]],s=t.animation||{};e.getView().animateInternal({center:e.getCoordinateFromPixelInternal(r),duration:s.duration,easing:s.easing})}}}getRect(t,e){const i=t.getBoundingClientRect(),n=i.left+window.pageXOffset,r=i.top+window.pageYOffset;return[n,r,n+e[0],r+e[1]]}setPositioning(t){this.set(fl,t)}setVisible(t){this.rendered.visible!==t&&(this.element.style.display=t?"":"none",this.rendered.visible=t)}updatePixelPosition(){const t=this.getMap(),e=this.getPosition();if(!t||!t.isRendered()||!e)return void this.setVisible(!1);const i=t.getPixelFromCoordinate(e),n=t.getSize();this.updateRenderedPosition(i,n)}updateRenderedPosition(t,e){const i=this.element.style,n=this.getOffset(),r=this.getPositioning();this.setVisible(!0);let s="0%",o="0%";"bottom-right"==r||"center-right"==r||"top-right"==r?s="-100%":"bottom-center"!=r&&"center-center"!=r&&"top-center"!=r||(s="-50%"),"bottom-left"==r||"bottom-center"==r||"bottom-right"==r?o="-100%":"center-left"!=r&&"center-center"!=r&&"center-right"!=r||(o="-50%");const a=`translate(${s}, ${o}) translate(${Math.round(t[0]+n[0])+"px"}, ${Math.round(t[1]+n[1])+"px"})`;this.rendered.transform_!=a&&(this.rendered.transform_=a,i.transform=a)}getOptions(){return this.options}};var ml=class{constructor(t){this.highWaterMark=void 0!==t?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.pop()}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return Mt(void 0!==i,15),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(t){const e=this.entries_[t];return Mt(void 0!==e,15),e===this.newest_?(this.newest_=e.older,this.newest_&&(this.newest_.newer=null)):e===this.oldest_?(this.oldest_=e.newer,this.oldest_&&(this.oldest_.older=null)):(e.newer.older=e.older,e.older.newer=e.newer),delete this.entries_[t],--this.count_,e.value_}getCount(){return this.count_}getKeys(){const t=new Array(this.count_);let e,i=0;for(e=this.newest_;e;e=e.older)t[i++]=e.key_;return t}getValues(){const t=new Array(this.count_);let e,i=0;for(e=this.newest_;e;e=e.older)t[i++]=e.value_;return t}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(t){if(this.containsKey(t))return this.entries_[t].value_}pop(){const t=this.oldest_;return delete this.entries_[t.key_],t.newer&&(t.newer.older=null),this.oldest_=t.newer,this.oldest_||(this.newest_=null),--this.count_,t.value_}replace(t,e){this.get(t),this.entries_[t].value_=e}set(t,e){Mt(!(t in this.entries_),16);const i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}};function _l(t,e,i,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=i,n):[t,e,i]}function yl(t,e,i){return t+"/"+e+"/"+i}function xl(t){return yl(t[0],t[1],t[2])}function vl(t){const[e,i,n]=t.substring(t.lastIndexOf("/")+1,t.length).split(",").map(Number);return yl(e,i,n)}function Sl(t){return t.split("/").map(Number)}function wl(t){return(t[1]<<t[0])+t[2]}function El(t,e){const i=t[0],n=t[1],r=t[2];if(e.getMinZoom()>i||i>e.getMaxZoom())return!1;const s=e.getFullTileRange(i);return!s||s.containsXY(n,r)}var Tl=class extends ml{clear(){for(;this.getCount()>0;)this.pop().release();super.clear()}expireCache(t){for(;this.canExpireCache();){if(this.peekLast().getKey()in t)break;this.pop().release()}}pruneExceptNewestZ(){if(0===this.getCount())return;const t=Sl(this.peekFirstKey())[0];this.forEach((e=>{e.tileCoord[0]!==t&&(this.remove(xl(e.tileCoord)),e.release())}))}};class Cl{constructor(t,e,i,n){this.minX=t,this.maxX=e,this.minY=i,this.maxY=n}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function Rl(t,e,i,n,r){return void 0!==r?(r.minX=t,r.maxX=e,r.minY=i,r.maxY=n,r):new Cl(t,e,i,n)}var bl=Cl;const Pl=[];var Il=class extends at{constructor(t,e,i,n){super(t,e,{transition:0}),this.context_={},this.executorGroups={},this.declutterExecutorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=n.bind(void 0,this),this.wrappedTileCoord=i}getContext(t){const e=V(t);return e in this.context_||(this.context_[e]=yt(1,1,Pl)),this.context_[e]}hasContext(t){return V(t)in this.context_}getImage(t){return this.hasContext(t)?this.getContext(t).canvas:null}getReplayState(t){const e=V(t);return e in this.replayState_||(this.replayState_[e]={dirty:!1,renderedRenderOrder:null,renderedResolution:NaN,renderedRevision:-1,renderedTileResolution:NaN,renderedTileRevision:-1,renderedTileZ:-1}),this.replayState_[e]}load(){this.getSourceTiles()}release(){for(const t in this.context_){const e=this.context_[t];xt(e),Pl.push(e.canvas),delete this.context_[t]}super.release()}};var Fl=class extends at{constructor(t,e,i,n,r,s){super(t,e,s),this.extent=null,this.format_=n,this.features_=null,this.loader_,this.projection=null,this.resolution,this.tileLoadFunction_=r,this.url_=i,this.key=i}getFormat(){return this.format_}getFeatures(){return this.features_}load(){this.state==J&&(this.setState(Q),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(t,e){this.setFeatures(t)}onError(){this.setState(et)}setFeatures(t){this.features_=t,this.setState(tt)}setLoader(t){this.loader_=t}};function Ll(t){return Array.isArray(t)?us(t):t}let Ml,Al=!1;function Ol(t,e,i,n,r,s,o){const a=new XMLHttpRequest;a.open("GET","function"==typeof t?t(i,n,r):t,!0),"arraybuffer"==e.getType()&&(a.responseType="arraybuffer"),a.withCredentials=Al,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();let n;"json"==t||"text"==t?n=a.responseText:"xml"==t?(n=a.responseXML,n||(n=(new DOMParser).parseFromString(a.responseText,"application/xml"))):"arraybuffer"==t&&(n=a.response),n?s(e.readFeatures(n,{extent:i,featureProjection:r}),e.readProjection(n)):o()}else o()},a.onerror=o,a.send()}function Nl(t,e){return function(i,n,r,s,o){const a=this;Ol(t,e,i,n,r,(function(t,e){a.addFeatures(t),void 0!==s&&s(t)}),o||_)}}function Dl(t,e){return[[-1/0,-1/0,1/0,1/0]]}function kl(t,e,i,n){const r=document.createElement("script"),s="olc_"+V(e);function o(){delete window[s],r.parentNode.removeChild(r)}r.async=!0,r.src=t+(t.includes("?")?"&":"?")+(n||"callback")+"="+s;const a=setTimeout((function(){o(),i&&i()}),1e4);window[s]=function(t){clearTimeout(a),o(),e(t)},document.head.appendChild(r)}class Gl extends Error{constructor(t){super("Unexpected response status: "+t.status),this.name="ResponseError",this.response=t}}class jl extends Error{constructor(t){super("Failed to issue request"),this.name="ClientError",this.client=t}}function Bl(t){return new Promise((function(e,i){const n=new XMLHttpRequest;n.addEventListener("load",(function(t){const n=t.target;if(!n.status||n.status>=200&&n.status<300){let t;try{t=JSON.parse(n.responseText)}catch(t){const e="Error parsing response text as JSON: "+t.message;return void i(new Error(e))}e(t)}else i(new Gl(n))})),n.addEventListener("error",(function(t){i(new jl(t.target))})),n.open("GET",t),n.setRequestHeader("Accept","application/json"),n.send()}))}function Ul(t,e){return e.includes("://")?e:new URL(e,t).href}var zl=class{drawCustom(t,e,i,n){}drawGeometry(t){}setStyle(t){}drawCircle(t,e){}drawFeature(t,e){}drawGeometryCollection(t,e){}drawLineString(t,e){}drawMultiLineString(t,e){}drawMultiPoint(t,e){}drawMultiPolygon(t,e){}drawPoint(t,e){}drawPolygon(t,e){}drawText(t,e){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}};var Xl=class extends zl{constructor(t,e,i,n,r,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?Si(Math.atan2(n[1],n[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=s,this.userTransform_=o,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=[1,0,0,1,0,0]}drawImages_(t,e,i,n){if(!this.image_)return;const r=Rn(t,e,i,n,this.transform_,this.pixelCoordinates_),s=this.context_,o=this.tmpLocalTransform_,a=s.globalAlpha;1!=this.imageOpacity_&&(s.globalAlpha=a*this.imageOpacity_);let l=this.imageRotation_;0===this.transformRotation_&&(l-=this.viewRotation_),this.imageRotateWithView_&&(l+=this.viewRotation_);for(let t=0,e=r.length;t<e;t+=2){const e=r[t]-this.imageAnchorX_,i=r[t+1]-this.imageAnchorY_;if(0!==l||1!=this.imageScale_[0]||1!=this.imageScale_[1]){const t=e+this.imageAnchorX_,n=i+this.imageAnchorY_;Yt(o,t,n,1,1,l,-t,-n),s.setTransform.apply(s,o),s.translate(t,n),s.scale(this.imageScale_[0],this.imageScale_[1]),s.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),s.setTransform(1,0,0,1,0,0)}else s.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,e,i,this.imageWidth_,this.imageHeight_)}1!=this.imageOpacity_&&(s.globalAlpha=a)}drawText_(t,e,i,n){if(!this.textState_||""===this.text_)return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=Rn(t,e,i,n,this.transform_,this.pixelCoordinates_),s=this.context_;let o=this.textRotation_;for(0===this.transformRotation_&&(o-=this.viewRotation_),this.textRotateWithView_&&(o+=this.viewRotation_);e<i;e+=n){const t=r[e]+this.textOffsetX_,i=r[e+1]+this.textOffsetY_;0!==o||1!=this.textScale_[0]||1!=this.textScale_[1]?(s.translate(t-this.textOffsetX_,i-this.textOffsetY_),s.rotate(o),s.translate(this.textOffsetX_,this.textOffsetY_),s.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&s.strokeText(this.text_,0,0),this.textFillState_&&s.fillText(this.text_,0,0),s.setTransform(1,0,0,1,0,0)):(this.textStrokeState_&&s.strokeText(this.text_,t,i),this.textFillState_&&s.fillText(this.text_,t,i))}}moveToLineTo_(t,e,i,n,r){const s=this.context_,o=Rn(t,e,i,n,this.transform_,this.pixelCoordinates_);s.moveTo(o[0],o[1]);let a=o.length;r&&(a-=2);for(let t=2;t<a;t+=2)s.lineTo(o[t],o[t+1]);return r&&s.closePath(),i}drawRings_(t,e,i,n){for(let r=0,s=i.length;r<s;++r)e=this.moveToLineTo_(t,e,i[r],n,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Ae(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=An(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],n=e[3]-e[1],r=Math.sqrt(i*i+n*n),s=this.context_;s.beginPath(),s.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&s.fill(),this.strokeState_&&s.stroke()}""!==this.text_&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t)}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let t=0,i=e.length;t<i;++t)this.drawGeometry(e[t])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),""!==this.text_&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),""!==this.text_&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Ae(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(""!==this.text_){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(Ae(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();let n=0;const r=t.getEnds(),s=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t)n=this.moveToLineTo_(i,n,r[t],s,!1);e.stroke()}if(""!==this.text_){const e=t.getFlatMidpoints();this.drawText_(e,0,e.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Ae(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(""!==this.text_){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),Ae(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let n=0;const r=t.getEndss(),s=t.getStride();e.beginPath();for(let t=0,e=r.length;t<e;++t){const e=r[t];n=this.drawRings_(i,n,e,s)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(""!==this.text_){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),g(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,n=t.textAlign?t.textAlign:To;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=n&&(i.textAlign=n,e.textAlign=n),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=n,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:n,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(t){const e=t.getColor();this.fillState_={fillStyle:Ll(e||yo)}}else this.fillState_=null;if(e){const t=e.getColor(),i=e.getLineCap(),n=e.getLineDash(),r=e.getLineDashOffset(),s=e.getLineJoin(),o=e.getWidth(),a=e.getMiterLimit(),l=n||vo;this.strokeState_={lineCap:void 0!==i?i:xo,lineDash:1===this.pixelRatio_?l:l.map((t=>t*this.pixelRatio_)),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==s?s:So,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:wo,strokeStyle:Ll(t||Eo)}}else this.strokeState_=null}setImageStyle(t){let e;if(!t||!(e=t.getSize()))return void(this.image_=null);const i=t.getPixelRatio(this.pixelRatio_),n=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=n[0]*i,this.imageAnchorY_=n[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const s=t.getScaleArray();this.imageScale_=[s[0]*this.pixelRatio_/i,s[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(t){const e=t.getFill();if(e){const t=e.getColor();this.textFillState_={fillStyle:Ll(t||yo)}}else this.textFillState_=null;const i=t.getStroke();if(i){const t=i.getColor(),e=i.getLineCap(),n=i.getLineDash(),r=i.getLineDashOffset(),s=i.getLineJoin(),o=i.getWidth(),a=i.getMiterLimit();this.textStrokeState_={lineCap:void 0!==e?e:xo,lineDash:n||vo,lineDashOffset:r||0,lineJoin:void 0!==s?s:So,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:wo,strokeStyle:Ll(t||Eo)}}else this.textStrokeState_=null;const n=t.getFont(),r=t.getOffsetX(),s=t.getOffsetY(),o=t.getRotateWithView(),a=t.getRotation(),l=t.getScaleArray(),h=t.getText(),c=t.getTextAlign(),u=t.getTextBaseline();this.textState_={font:void 0!==n?n:_o,textAlign:void 0!==c?c:To,textBaseline:void 0!==u?u:Co},this.text_=void 0!==h?Array.isArray(h)?h.reduce(((t,e,i)=>t+(i%2?" ":e)),""):h:"",this.textOffsetX_=void 0!==r?this.pixelRatio_*r:0,this.textOffsetY_=void 0!==s?this.pixelRatio_*s:0,this.textRotateWithView_=void 0!==o&&o,this.textRotation_=void 0!==a?a:0,this.textScale_=[this.pixelRatio_*l[0],this.pixelRatio_*l[1]]}else this.text_=""}};const Vl=.5,Wl={Point:function(t,e,i,n,r){const s=i.getImage(),o=i.getText();let a;if(s){if(s.getImageState()!=qr)return;let l=t;if(r){const h=s.getDeclutterMode();if("none"!==h)if(l=r,"obstacle"===h){const r=t.getBuilder(i.getZIndex(),"Image");r.setImageStyle(s,a),r.drawPoint(e,n)}else o&&o.getText()&&(a={})}const h=l.getBuilder(i.getZIndex(),"Image");h.setImageStyle(s,a),h.drawPoint(e,n)}if(o&&o.getText()){let s=t;r&&(s=r);const l=s.getBuilder(i.getZIndex(),"Text");l.setTextStyle(o,a),l.drawText(e,n)}},LineString:function(t,e,i,n,r){const s=i.getStroke();if(s){const r=t.getBuilder(i.getZIndex(),"LineString");r.setFillStrokeStyle(null,s),r.drawLineString(e,n)}const o=i.getText();if(o&&o.getText()){const s=(r||t).getBuilder(i.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,n)}},Polygon:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(s||o){const r=t.getBuilder(i.getZIndex(),"Polygon");r.setFillStrokeStyle(s,o),r.drawPolygon(e,n)}const a=i.getText();if(a&&a.getText()){const s=(r||t).getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n)}},MultiPoint:function(t,e,i,n,r){const s=i.getImage(),o=i.getText();let a;if(s){if(s.getImageState()!=qr)return;let l=t;if(r){const h=s.getDeclutterMode();if("none"!==h)if(l=r,"obstacle"===h){const r=t.getBuilder(i.getZIndex(),"Image");r.setImageStyle(s,a),r.drawMultiPoint(e,n)}else o&&o.getText()&&(a={})}const h=l.getBuilder(i.getZIndex(),"Image");h.setImageStyle(s,a),h.drawMultiPoint(e,n)}if(o&&o.getText()){let s=t;r&&(s=r);const l=s.getBuilder(i.getZIndex(),"Text");l.setTextStyle(o,a),l.drawText(e,n)}},MultiLineString:function(t,e,i,n,r){const s=i.getStroke();if(s){const r=t.getBuilder(i.getZIndex(),"LineString");r.setFillStrokeStyle(null,s),r.drawMultiLineString(e,n)}const o=i.getText();if(o&&o.getText()){const s=(r||t).getBuilder(i.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,n)}},MultiPolygon:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(o||s){const r=t.getBuilder(i.getZIndex(),"Polygon");r.setFillStrokeStyle(s,o),r.drawMultiPolygon(e,n)}const a=i.getText();if(a&&a.getText()){const s=(r||t).getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n)}},GeometryCollection:function(t,e,i,n,r){const s=e.getGeometriesArray();let o,a;for(o=0,a=s.length;o<a;++o){(0,Wl[s[o].getType()])(t,s[o],i,n,r)}},Circle:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(s||o){const r=t.getBuilder(i.getZIndex(),"Circle");r.setFillStrokeStyle(s,o),r.drawCircle(e,n)}const a=i.getText();if(a&&a.getText()){const s=(r||t).getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n)}}};function Zl(t,e){return parseInt(V(t),10)-parseInt(V(e),10)}function Yl(t,e){const i=Kl(t,e);return i*i}function Kl(t,e){return Vl*t/e}function Hl(t,e,i,n,r,s,o){let a=!1;const l=i.getImage();if(l){const t=l.getImageState();t==qr||t==$r?l.unlistenImageChange(r):(t==Kr&&l.load(),l.listenImageChange(r),a=!0)}return function(t,e,i,n,r,s){const o=i.getGeometryFunction()(e);if(!o)return;const a=o.simplifyTransformed(n,r),l=i.getRenderer();if(l)ql(t,a,i,e);else{(0,Wl[a.getType()])(t,a,i,e,s)}}(t,e,i,n,s,o),a}function ql(t,e,i,n){if("GeometryCollection"==e.getType()){const r=e.getGeometries();for(let e=0,s=r.length;e<s;++e)ql(t,r[e],i,n);return}t.getBuilder(i.getZIndex(),"Default").drawCustom(e,n,i.getRenderer(),i.getHitDetectionRenderer())}function $l(t){if(!(t.context instanceof CanvasRenderingContext2D))throw new Error("Only works for render events from Canvas 2D layers");const e=t.inversePixelTransform[0],i=t.inversePixelTransform[1],n=Math.sqrt(e*e+i*i),r=t.frameState,s=jt(t.inversePixelTransform.slice(),r.coordinateToPixelTransform),o=Yl(r.viewState.resolution,n);let a;const l=_n();return l&&(a=un(l,r.viewState.projection)),new Xl(t.context,n,r.extent,s,r.viewState.rotation,o,a)}let Jl;const Ql=[];function th(t,e,i,n,r){t.beginPath(),t.moveTo(0,0),t.lineTo(e,i),t.lineTo(n,r),t.closePath(),t.save(),t.clip(),t.fillRect(0,0,Math.max(e,n)+1,Math.max(i,r)),t.restore()}function eh(t,e){return Math.abs(t[4*e]-210)>2||Math.abs(t[4*e+3]-191.25)>2}function ih(t,e,i,n){const r=gn(i,e,t);let s=rn(e,n,i);const o=e.getMetersPerUnit();void 0!==o&&(s*=o);const a=t.getMetersPerUnit();void 0!==a&&(s/=a);const l=t.getExtent();if(!l||ne(l,r)){const e=rn(t,s,r)/s;isFinite(e)&&e>0&&(s/=e)}return s}function nh(t,e,i,n){const r=Te(i);let s=ih(t,e,r,n);return(!isFinite(s)||s<=0)&&ve(i,(function(i){return s=ih(t,e,i,n),isFinite(s)&&s>0})),s}function rh(t,e,i,n,r,s,o,a,l,h,c,u){const d=yt(Math.round(i*t),Math.round(i*e),Ql);if(u||(d.imageSmoothingEnabled=!1),0===l.length)return d.canvas;function g(t){return Math.round(t*i)/i}d.scale(i,i),d.globalCompositeOperation="lighter";const f=[1/0,1/0,-1/0,-1/0];l.forEach((function(t,e,i){fe(f,t.extent)}));const p=Me(f),m=Pe(f),_=yt(Math.round(i*p/n),Math.round(i*m/n),Ql);u||(_.imageSmoothingEnabled=!1);const y=i/n;l.forEach((function(t,e,i){const n=t.extent[0]-f[0],r=-(t.extent[3]-f[3]),s=Me(t.extent),o=Pe(t.extent);t.image.width>0&&t.image.height>0&&_.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,n*y,r*y,s*y,o*y)}));const x=Fe(o);return a.getTriangles().forEach((function(t,e,r){const o=t.source,a=t.target;let l=o[0][0],h=o[0][1],c=o[1][0],p=o[1][1],m=o[2][0],y=o[2][1];const v=g((a[0][0]-x[0])/s),S=g(-(a[0][1]-x[1])/s),w=g((a[1][0]-x[0])/s),E=g(-(a[1][1]-x[1])/s),T=g((a[2][0]-x[0])/s),C=g(-(a[2][1]-x[1])/s),R=l,b=h;l=0,h=0,c-=R,p-=b,m-=R,y-=b;const P=mi([[c,p,0,0,w-v],[m,y,0,0,T-v],[0,0,c,p,E-S],[0,0,m,y,C-S]]);if(P){if(d.save(),d.beginPath(),function(){if(void 0===Jl){const t=yt(6,6,Ql);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",th(t,4,5,4,0),th(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;Jl=eh(e,0)||eh(e,4)||eh(e,8),xt(t),Ql.push(t.canvas)}return Jl}()||!u){d.moveTo(w,E);const t=4,e=v-w,i=S-E;for(let n=0;n<t;n++)d.lineTo(w+g((n+1)*e/t),E+g(n*i/(t-1))),n!=t-1&&d.lineTo(w+g((n+1)*e/t),E+g((n+1)*i/(t-1)));d.lineTo(T,C)}else d.moveTo(w,E),d.lineTo(v,S),d.lineTo(T,C);d.clip(),d.transform(P[0],P[2],P[1],P[3],v,S),d.translate(f[0]-R,f[3]-b),d.scale(n/i,-n/i),d.drawImage(_.canvas,0,0),d.restore()}})),xt(_),Ql.push(_.canvas),c&&(d.save(),d.globalCompositeOperation="source-over",d.strokeStyle="black",d.lineWidth=1,a.getTriangles().forEach((function(t,e,i){const n=t.target,r=(n[0][0]-x[0])/s,o=-(n[0][1]-x[1])/s,a=(n[1][0]-x[0])/s,l=-(n[1][1]-x[1])/s,h=(n[2][0]-x[0])/s,c=-(n[2][1]-x[1])/s;d.beginPath(),d.moveTo(a,l),d.lineTo(r,o),d.lineTo(h,c),d.closePath(),d.stroke()})),d.restore()),d.canvas}const sh=.5;var oh=class{constructor(t,e,i,n,r,s){this.sourceProj_=t,this.targetProj_=e;let o={};const a=dn(this.targetProj_,this.sourceProj_);this.transformInv_=function(t){const e=t[0]+"/"+t[1];return o[e]||(o[e]=a(t)),o[e]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&Me(n)>=Me(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?Me(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?Me(this.targetProj_.getExtent()):null;const l=Fe(i),h=Le(i),c=Ee(i),u=we(i),d=this.transformInv_(l),g=this.transformInv_(h),f=this.transformInv_(c),p=this.transformInv_(u),m=10+(s?Math.max(0,Math.ceil(Math.log2(Se(i)/(s*s*256*256)))):0);if(this.addQuad_(l,h,c,u,d,g,f,p,m),this.wrapsXInSource_){let t=1/0;this.triangles_.forEach((function(e,i,n){t=Math.min(t,e.source[0][0],e.source[1][0],e.source[2][0])})),this.triangles_.forEach((e=>{if(Math.max(e.source[0][0],e.source[1][0],e.source[2][0])-t>this.sourceWorldWidth_/2){const i=[[e.source[0][0],e.source[0][1]],[e.source[1][0],e.source[1][1]],[e.source[2][0],e.source[2][1]]];i[0][0]-t>this.sourceWorldWidth_/2&&(i[0][0]-=this.sourceWorldWidth_),i[1][0]-t>this.sourceWorldWidth_/2&&(i[1][0]-=this.sourceWorldWidth_),i[2][0]-t>this.sourceWorldWidth_/2&&(i[2][0]-=this.sourceWorldWidth_);const n=Math.min(i[0][0],i[1][0],i[2][0]);Math.max(i[0][0],i[1][0],i[2][0])-n<this.sourceWorldWidth_/2&&(e.source=i)}}))}o={}}addTriangle_(t,e,i,n,r,s){this.triangles_.push({source:[n,r,s],target:[t,e,i]})}addQuad_(t,e,i,n,r,s,o,a,l){const h=Qt([r,s,o,a]),c=this.sourceWorldWidth_?Me(h)/this.sourceWorldWidth_:null,u=this.sourceWorldWidth_,d=this.sourceProj_.canWrapX()&&c>.5&&c<1;let g=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){g=Me(Qt([t,e,i,n]))/this.targetWorldWidth_>.25||g}!d&&this.sourceProj_.isGlobal()&&c&&(g=c>.25||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Ae(h,this.maxSourceExtent_))return;let f=0;if(!(g||isFinite(r[0])&&isFinite(r[1])&&isFinite(s[0])&&isFinite(s[1])&&isFinite(o[0])&&isFinite(o[1])&&isFinite(a[0])&&isFinite(a[1])))if(l>0)g=!0;else if(f=(isFinite(r[0])&&isFinite(r[1])?0:8)+(isFinite(s[0])&&isFinite(s[1])?0:4)+(isFinite(o[0])&&isFinite(o[1])?0:2)+(isFinite(a[0])&&isFinite(a[1])?0:1),1!=f&&2!=f&&4!=f&&8!=f)return;if(l>0){if(!g){const e=[(t[0]+i[0])/2,(t[1]+i[1])/2],n=this.transformInv_(e);let s;if(d){s=(xi(r[0],u)+xi(o[0],u))/2-xi(n[0],u)}else s=(r[0]+o[0])/2-n[0];const a=(r[1]+o[1])/2-n[1];g=s*s+a*a>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const h=[(e[0]+i[0])/2,(e[1]+i[1])/2],c=this.transformInv_(h),u=[(n[0]+t[0])/2,(n[1]+t[1])/2],d=this.transformInv_(u);this.addQuad_(t,e,h,u,r,s,c,d,l-1),this.addQuad_(u,h,i,n,d,c,o,a,l-1)}else{const h=[(t[0]+e[0])/2,(t[1]+e[1])/2],c=this.transformInv_(h),u=[(i[0]+n[0])/2,(i[1]+n[1])/2],d=this.transformInv_(u);this.addQuad_(t,h,u,n,r,c,d,a,l-1),this.addQuad_(h,e,i,u,c,s,o,d,l-1)}return}}if(d){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}0==(11&f)&&this.addTriangle_(t,i,n,r,o,a),0==(14&f)&&this.addTriangle_(t,i,e,r,o,s),f&&(0==(13&f)&&this.addTriangle_(e,n,t,s,a,r),0==(7&f)&&this.addTriangle_(e,n,i,s,a,o))}calculateSourceExtent(){const t=[1/0,1/0,-1/0,-1/0];return this.triangles_.forEach((function(e,i,n){const r=e.source;pe(t,r[0]),pe(t,r[1]),pe(t,r[2])})),t}getTriangles(){return this.triangles_}};var ah=class extends at{constructor(t,e,i,n,r,s,o,a,l,h,c,u){super(r,J,{interpolate:!!u}),this.renderEdges_=void 0!==c&&c,this.pixelRatio_=o,this.gutter_=a,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=n,this.wrappedTileCoord_=s||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0;const d=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let f=this.sourceTileGrid_.getExtent();const p=g?Ie(d,g):d;if(0===Se(p))return void(this.state=it);const m=t.getExtent();m&&(f=f?Ie(f,m):m);const _=n.getResolution(this.wrappedTileCoord_[0]),y=nh(t,i,p,_);if(!isFinite(y)||y<=0)return void(this.state=it);const x=void 0!==h?h:sh;if(this.triangulation_=new oh(t,i,p,f,y*x,_),0===this.triangulation_.getTriangles().length)return void(this.state=it);this.sourceZ_=e.getZForResolution(y);let v=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(v[1]=gi(v[1],f[1],f[3]),v[3]=gi(v[3],f[1],f[3])):v=Ie(v,f)),Se(v)){const t=e.getTileRangeForExtentAndZ(v,this.sourceZ_);for(let e=t.minX;e<=t.maxX;e++)for(let i=t.minY;i<=t.maxY;i++){const t=l(this.sourceZ_,e,i,o);t&&this.sourceTiles_.push(t)}0===this.sourceTiles_.length&&(this.state=it)}else this.state=it}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach((e=>{e&&e.getState()==tt&&t.push({extent:this.sourceTileGrid_.getTileCoordExtent(e.tileCoord),image:e.getImage()})})),this.sourceTiles_.length=0,0===t.length)this.state=et;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),n="number"==typeof i?i:i[0],r="number"==typeof i?i:i[1],s=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=rh(n,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=tt}this.changed()}load(){if(this.state==J){this.state=Q,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach((e=>{const i=e.getState();if(i==J||i==Q){t++;const i=D(e,E,(function(n){const r=e.getState();r!=tt&&r!=et&&r!=it||(G(i),t--,0===t&&(this.unlistenSources_(),this.reproject_()))}),this);this.sourcesListenerKeys_.push(i)}})),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function(t,e,i){t.getState()==J&&t.load()}))}}unlistenSources_(){this.sourcesListenerKeys_.forEach(G),this.sourcesListenerKeys_=null}release(){this.canvas_&&(xt(this.canvas_.getContext("2d")),Ql.push(this.canvas_),this.canvas_=null),super.release()}},lh="tileloadstart",hh="tileloadend",ch="tileloaderror";function uh(t){return t?Array.isArray(t)?function(e){return t}:"function"==typeof t?t:function(e){return[t]}:null}var dh=class extends Z{constructor(t){super(),this.projection=nn(t.projection),this.attributions_=uh(t.attributions),this.attributionsCollapsible_=void 0===t.attributionsCollapsible||t.attributionsCollapsible,this.loading=!1,this.state_=void 0!==t.state?t.state:"ready",this.wrapX_=void 0!==t.wrapX&&t.wrapX,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise((function(t,i){e.viewResolver=t,e.viewRejector=i}))}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=uh(t),this.changed()}setState(t){this.state_=t,this.changed()}};const gh=[0,0,0];var fh=class{constructor(t){let e;if(this.minZoom=void 0!==t.minZoom?t.minZoom:0,this.resolutions_=t.resolutions,Mt(f(this.resolutions_,(function(t,e){return e-t}),!0),17),!t.origins)for(let t=0,i=this.resolutions_.length-1;t<i;++t)if(e){if(this.resolutions_[t]/this.resolutions_[t+1]!==e){e=void 0;break}}else e=this.resolutions_[t]/this.resolutions_[t+1];this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=void 0!==t.origin?t.origin:null,this.origins_=null,void 0!==t.origins&&(this.origins_=t.origins,Mt(this.origins_.length==this.resolutions_.length,20));const i=t.extent;void 0===i||this.origin_||this.origins_||(this.origin_=Fe(i)),Mt(!this.origin_&&this.origins_||this.origin_&&!this.origins_,18),this.tileSizes_=null,void 0!==t.tileSizes&&(this.tileSizes_=t.tileSizes,Mt(this.tileSizes_.length==this.resolutions_.length,19)),this.tileSize_=void 0!==t.tileSize?t.tileSize:this.tileSizes_?null:ks,Mt(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,22),this.extent_=void 0!==i?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],void 0!==t.sizes?this.fullTileRanges_=t.sizes.map((function(t,e){const n=new bl(Math.min(0,t[0]),Math.max(t[0]-1,-1),Math.min(0,t[1]),Math.max(t[1]-1,-1));if(i){const t=this.getTileRangeForExtentAndZ(i,e);n.minX=Math.max(t.minX,n.minX),n.maxX=Math.min(t.maxX,n.maxX),n.minY=Math.max(t.minY,n.minY),n.maxY=Math.min(t.maxY,n.maxY)}return n}),this):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){const n=this.getTileRangeForExtentAndZ(t,e);for(let t=n.minX,r=n.maxX;t<=r;++t)for(let r=n.minY,s=n.maxY;r<=s;++r)i([e,t,r])}forEachTileCoordParentTileRange(t,e,i,n){let r,s,o,a=null,l=t[0]-1;for(2===this.zoomFactor_?(s=t[1],o=t[2]):a=this.getTileCoordExtent(t,n);l>=this.minZoom;){if(2===this.zoomFactor_?(s=Math.floor(s/2),o=Math.floor(o/2),r=Rl(s,s,o,o,i)):r=this.getTileRangeForExtentAndZ(a,l,i),e(l,r))return!0;--l}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(2===this.zoomFactor_){const i=2*t[1],n=2*t[2];return Rl(i,i+1,n,n+1,e)}const n=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(n,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;const n=t[0],r=t[1],s=t[2];if(e===n)return Rl(r,s,r,s,i);if(this.zoomFactor_){const t=Math.pow(this.zoomFactor_,e-n),o=Math.floor(r*t),a=Math.floor(s*t);if(e<n)return Rl(o,o,a,a,i);return Rl(o,Math.floor(t*(r+1))-1,a,Math.floor(t*(s+1))-1,i)}const o=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(o,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,gh);const n=gh[1],r=gh[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,gh);return Rl(n,gh[1],r,gh[2],i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),n=ol(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*n[0]*i,e[1]-(t[2]+.5)*n[1]*i]}getTileCoordExtent(t,e){const i=this.getOrigin(t[0]),n=this.getResolution(t[0]),r=ol(this.getTileSize(t[0]),this.tmpSize_),s=i[0]+t[1]*r[0]*n,o=i[1]-(t[2]+1)*r[1]*n;return le(s,o,s+r[0]*n,o+r[1]*n,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,n,r){const s=this.getZForResolution(i),o=i/this.getResolution(s),a=this.getOrigin(s),l=ol(this.getTileSize(s),this.tmpSize_);let h=o*(t-a[0])/i/l[0],c=o*(a[1]-e)/i/l[1];return n?(h=Ti(h,5)-1,c=Ti(c,5)-1):(h=Ei(h,5),c=Ei(c,5)),_l(s,h,c,r)}getTileCoordForXYAndZ_(t,e,i,n,r){const s=this.getOrigin(i),o=this.getResolution(i),a=ol(this.getTileSize(i),this.tmpSize_);let l=(t-s[0])/o/a[0],h=(s[1]-e)/o/a[1];return n?(l=Ti(l,5)-1,h=Ti(h,5)-1):(l=Ei(l,5),h=Ei(h,5)),_l(i,l,h,r)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){return gi(c(this.resolutions_,t,e||0),this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return yr(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,i=new Array(e);for(let n=this.minZoom;n<e;++n)i[n]=this.getTileRangeForExtentAndZ(t,n);this.fullTileRanges_=i}};function ph(t){let e=t.getDefaultTileGrid();return e||(e=vh(t),t.setDefaultTileGrid(e)),e}function mh(t,e,i){const n=e[0],r=t.getTileCoordCenter(e),s=Sh(i);if(!ne(s,r)){const e=Me(s),i=Math.ceil((s[0]-r[0])/e);return r[0]+=e*i,t.getTileCoordForCoordAndZ(r,n)}return e}function _h(t,e,i,n){n=void 0!==n?n:"top-left";const r=xh(t,e,i);return new fh({extent:t,origin:Ce(t,n),resolutions:r,tileSize:i})}function yh(t){const e=t||{},i=e.extent||nn("EPSG:3857").getExtent(),n={extent:i,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:xh(i,e.maxZoom,e.tileSize,e.maxResolution)};return new fh(n)}function xh(t,e,i,n){e=void 0!==e?e:Ds,i=ol(void 0!==i?i:ks);const r=Pe(t),s=Me(t);n=n>0?n:Math.max(s/i[0],r/i[1]);const o=e+1,a=new Array(o);for(let t=0;t<o;++t)a[t]=n/Math.pow(2,t);return a}function vh(t,e,i,n){return _h(Sh(t),e,i,n)}function Sh(t){let e=(t=nn(t)).getExtent();if(!e){const i=180*Xe.degrees/t.getMetersPerUnit();e=le(-i,-i,i,i)}return e}class wh extends r{constructor(t,e){super(t),this.tile=e}}var Eh=class extends dh{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:t.projection,state:t.state,wrapX:t.wrapX,interpolate:t.interpolate}),this.on,this.once,this.un,this.opaque_=void 0!==t.opaque&&t.opaque,this.tilePixelRatio_=void 0!==t.tilePixelRatio?t.tilePixelRatio:1,this.tileGrid=void 0!==t.tileGrid?t.tileGrid:null;const e=[256,256];this.tileGrid&&ol(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tileCache=new Tl(t.cacheSize||0),this.tmpSize=[0,0],this.key_=t.key||"",this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}canExpireCache(){return this.tileCache.canExpireCache()}expireCache(t,e){const i=this.getTileCacheForProjection(t);i&&i.expireCache(e)}forEachLoadedTile(t,e,i,n){const r=this.getTileCacheForProjection(t);if(!r)return!1;let s,o,a,l=!0;for(let t=i.minX;t<=i.maxX;++t)for(let h=i.minY;h<=i.maxY;++h)o=yl(e,t,h),a=!1,r.containsKey(o)&&(s=r.get(o),a=s.getState()===tt,a&&(a=!1!==n(s))),a||(l=!1);return l}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getOpaque(t){return this.opaque_}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,n,r){return z()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:ph(t)}getTileCacheForProjection(t){const e=this.getProjection();return Mt(null===e||cn(e,t),68),this.tileCache}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),s=ol(n.getTileSize(t),this.tmpSize);return 1==r?s:sl(s,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){e=void 0!==e?e:this.getProjection();const i=this.getTileGridForProjection(e);return this.getWrapX()&&e.isGlobal()&&(t=mh(i,t,e)),El(t,i)?t:null}clear(){this.tileCache.clear()}refresh(){this.clear(),super.refresh()}updateCacheSize(t,e){const i=this.getTileCacheForProjection(e);t>i.highWaterMark&&(i.highWaterMark=t)}useTile(t,e,i,n){}};function Th(t,e){const i=/\{z\}/g,n=/\{x\}/g,r=/\{y\}/g,s=/\{-y\}/g;return function(o,a,l){if(o)return t.replace(i,o[0].toString()).replace(n,o[1].toString()).replace(r,o[2].toString()).replace(s,(function(){const t=o[0],i=e.getFullTileRange(t);Mt(i,55);return(i.getHeight()-o[2]-1).toString()}))}}function Ch(t,e){const i=t.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=Th(t[r],e);return Rh(n)}function Rh(t){return 1===t.length?t[0]:function(e,i,n){if(!e)return;const r=xi(wl(e),t.length);return t[r](e,i,n)}}function bh(t,e,i){}function Ph(t){const e=[];let i=/\{([a-z])-([a-z])\}/.exec(t);if(i){const n=i[1].charCodeAt(0),r=i[2].charCodeAt(0);let s;for(s=n;s<=r;++s)e.push(t.replace(i[0],String.fromCharCode(s)));return e}if(i=/\{(\d+)-(\d+)\}/.exec(t),i){const n=parseInt(i[2],10);for(let r=parseInt(i[1],10);r<=n;r++)e.push(t.replace(i[0],r.toString()));return e}return e.push(t),e}class Ih extends Eh{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,opaque:t.opaque,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tilePixelRatio:t.tilePixelRatio,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.generateTileUrlFunction_=this.tileUrlFunction===Ih.prototype.tileUrlFunction,this.tileLoadFunction=t.tileLoadFunction,t.tileUrlFunction&&(this.tileUrlFunction=t.tileUrlFunction),this.urls=null,t.urls?this.setUrls(t.urls):t.url&&this.setUrl(t.url),this.tileLoadingKeys_={}}getTileLoadFunction(){return this.tileLoadFunction}getTileUrlFunction(){return Object.getPrototypeOf(this).tileUrlFunction===this.tileUrlFunction?this.tileUrlFunction.bind(this):this.tileUrlFunction}getUrls(){return this.urls}handleTileChange(t){const e=t.target,i=V(e),n=e.getState();let r;n==Q?(this.tileLoadingKeys_[i]=!0,r=lh):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==et?ch:n==tt?hh:void 0),null!=r&&this.dispatchEvent(new wh(r,e))}setTileLoadFunction(t){this.tileCache.clear(),this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,this.tileCache.pruneExceptNewestZ(),void 0!==e?this.setKey(e):this.changed()}setUrl(t){const e=Ph(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(Ch(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}useTile(t,e,i){const n=yl(t,e,i);this.tileCache.containsKey(n)&&this.tileCache.get(n)}}var Fh=Ih;function Lh(t,e){t.getImage().src=e}var Mh=class extends Fh{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,opaque:t.opaque,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Lh,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:void 0===t.interpolate||t.interpolate,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=void 0!==t.crossOrigin?t.crossOrigin:null,this.tileClass=void 0!==t.tileClass?t.tileClass:is,this.tileCacheForProjection={},this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}canExpireCache(){if(this.tileCache.canExpireCache())return!0;for(const t in this.tileCacheForProjection)if(this.tileCacheForProjection[t].canExpireCache())return!0;return!1}expireCache(t,e){const i=this.getTileCacheForProjection(t);this.tileCache.expireCache(this.tileCache==i?e:{});for(const t in this.tileCacheForProjection){const n=this.tileCacheForProjection[t];n.expireCache(n==i?e:{})}}getGutterForProjection(t){return this.getProjection()&&t&&!cn(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getOpaque(t){return!(this.getProjection()&&t&&!cn(this.getProjection(),t))&&super.getOpaque(t)}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||cn(e,t)))return this.tileGrid;const i=V(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=ph(t)),this.tileGridForProjection[i]}getTileCacheForProjection(t){const e=this.getProjection();if(!e||cn(e,t))return this.tileCache;const i=V(t);return i in this.tileCacheForProjection||(this.tileCacheForProjection[i]=new Tl(this.tileCache.highWaterMark)),this.tileCacheForProjection[i]}createTile_(t,e,i,n,r,s){const o=[t,e,i],a=this.getTileCoordForTileUrlFunction(o,r),l=a?this.tileUrlFunction(a,n,r):void 0,h=new this.tileClass(o,void 0!==l?J:it,void 0!==l?l:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return h.key=s,h.addEventListener(E,this.handleTileChange.bind(this)),h}getTile(t,e,i,n,r){const s=this.getProjection();if(!s||!r||cn(s,r))return this.getTileInternal(t,e,i,n,s||r);const o=this.getTileCacheForProjection(r),a=[t,e,i];let l;const h=xl(a);o.containsKey(h)&&(l=o.get(h));const c=this.getKey();if(l&&l.key==c)return l;const u=this.getTileGridForProjection(s),d=this.getTileGridForProjection(r),g=this.getTileCoordForTileUrlFunction(a,r),f=new ah(s,u,r,d,a,g,this.getTilePixelRatio(n),this.getGutter(),((t,e,i,n)=>this.getTileInternal(t,e,i,n,s)),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.getInterpolate());return f.key=c,l?(f.interimTile=l,f.refreshInterimChain(),o.replace(h,f)):o.set(h,f),f}getTileInternal(t,e,i,n,r){let s=null;const o=yl(t,e,i),a=this.getKey();if(this.tileCache.containsKey(o)){if(s=this.tileCache.get(o),s.key!=a){const l=s;s=this.createTile_(t,e,i,n,r,a),l.getState()==J?s.interimTile=l.interimTile:s.interimTile=l,s.refreshInterimChain(),this.tileCache.replace(o,s)}}else s=this.createTile_(t,e,i,n,r,a),this.tileCache.set(o,s);return s}setRenderReprojectionEdges(t){if(this.renderReprojectionEdges_!=t){this.renderReprojectionEdges_=t;for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear();this.changed()}}setTileGridForProjection(t,e){const i=nn(t);if(i){const t=V(i);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}clear(){super.clear();for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear()}};function Ah(t){const e=t[0],i=new Array(e);let n,r,s=1<<e-1;for(n=0;n<e;++n)r=48,t[1]&s&&(r+=1),t[2]&s&&(r+=2),i[n]=String.fromCharCode(r),s>>=1;return i.join("")}var Oh=class extends Mh{constructor(t){const e=void 0!==t.hidpi&&t.hidpi;super({cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,opaque:!0,projection:nn("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,tilePixelRatio:e?2:1,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.hidpi_=e,this.culture_=void 0!==t.culture?t.culture:"en-us",this.maxZoom_=void 0!==t.maxZoom?t.maxZoom:-1,this.apiKey_=t.key,this.imagerySet_=t.imagerySet,this.placeholderTiles_=t.placeholderTiles;const i="https://dev.virtualearth.net/REST/v1/Imagery/Metadata/"+this.imagerySet_+"?uriScheme=https&include=ImageryProviders&key="+this.apiKey_+"&c="+this.culture_;fetch(i).then((t=>t.json())).then((t=>this.handleImageryMetadataResponse(t)))}getApiKey(){return this.apiKey_}getImagerySet(){return this.imagerySet_}handleImageryMetadataResponse(t){if(200!=t.statusCode||"OK"!=t.statusDescription||"ValidCredentials"!=t.authenticationResultCode||1!=t.resourceSets.length||1!=t.resourceSets[0].resources.length)return void this.setState("error");const e=t.resourceSets[0].resources[0],i=-1==this.maxZoom_?e.zoomMax:this.maxZoom_,n=Sh(this.getProjection()),r=this.hidpi_?2:1,s=e.imageWidth==e.imageHeight?e.imageWidth/r:[e.imageWidth/r,e.imageHeight/r],o=yh({extent:n,minZoom:e.zoomMin,maxZoom:i,tileSize:s});this.tileGrid=o;const a=this.culture_,l=this.hidpi_,h=this.placeholderTiles_;if(this.tileUrlFunction=Rh(e.imageUrlSubdomains.map((function(t){const i=[0,0,0],n=e.imageUrl.replace("{subdomain}",t).replace("{culture}",a);return function(t,e,r){if(!t)return;_l(t[0],t[1],t[2],i);const s=new URL(n.replace("{quadkey}",Ah(i))),o=s.searchParams;return l&&(o.set("dpi","d1"),o.set("device","mobile")),!0===h?o.delete("n"):!1===h&&o.set("n","z"),s.toString()}}))),e.imageryProviders){const t=un(nn("EPSG:4326"),this.getProjection());this.setAttributions((i=>{const n=[],r=i.viewState,s=this.getTileGrid(),o=s.getZForResolution(r.resolution,this.zDirection),a=s.getTileCoordForCoordAndZ(r.center,o)[0];return e.imageryProviders.map((function(e){let r=!1;const s=e.coverageAreas;for(let e=0,n=s.length;e<n;++e){const n=s[e];if(a>=n.zoomMin&&a<=n.zoomMax){const e=n.bbox;if(Ae(Ge([e[1],e[0],e[3],e[2]],t),i.extent)){r=!0;break}}}r&&n.push(e.attribution)})),n.push('<a class="ol-attribution-bing-tos" href="https://www.microsoft.com/maps/product/terms.html" target="_blank">Terms of Use</a>'),n}))}this.setState("ready")}};var Nh=class extends Mh{constructor(t){const e=void 0!==(t=t||{}).projection?t.projection:"EPSG:3857",i=void 0!==t.tileGrid?t.tileGrid:yh({extent:Sh(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,opaque:t.opaque,projection:e,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0}getGutter(){return this.gutter_}};var Dh=class extends Nh{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,maxZoom:void 0!==t.maxZoom?t.maxZoom:18,minZoom:t.minZoom,projection:t.projection,transition:t.transition,wrapX:t.wrapX,zDirection:t.zDirection}),this.account_=t.account,this.mapId_=t.map||"",this.config_=t.config||{},this.templateCache_={},this.initializeMap_()}getConfig(){return this.config_}updateConfig(t){Object.assign(this.config_,t),this.initializeMap_()}setConfig(t){this.config_=t||{},this.initializeMap_()}initializeMap_(){const t=JSON.stringify(this.config_);if(this.templateCache_[t])return void this.applyTemplate_(this.templateCache_[t]);let e="https://"+this.account_+".carto.com/api/v1/map";this.mapId_&&(e+="/named/"+this.mapId_);const i=new XMLHttpRequest;i.addEventListener("load",this.handleInitResponse_.bind(this,t)),i.addEventListener("error",this.handleInitError_.bind(this)),i.open("POST",e),i.setRequestHeader("Content-type","application/json"),i.send(JSON.stringify(this.config_))}handleInitResponse_(t,e){const i=e.target;if(!i.status||i.status>=200&&i.status<300){let e;try{e=JSON.parse(i.responseText)}catch(t){return void this.setState("error")}this.applyTemplate_(e),this.templateCache_[t]=e,this.setState("ready")}else this.setState("error")}handleInitError_(t){this.setState("error")}applyTemplate_(t){const e="https://"+t.cdn_url.https+"/"+this.account_+"/api/v1/map/"+t.layergroupid+"/{z}/{x}/{y}.png";this.setUrl(e)}};function kh(t,e,i,n,r){Gh(t,e,i||0,n||t.length-1,r||Bh)}function Gh(t,e,i,n,r){for(;n>i;){if(n-i>600){var s=n-i+1,o=e-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);Gh(t,e,Math.max(i,Math.floor(e-o*l/s+h)),Math.min(n,Math.floor(e+(s-o)*l/s+h)),r)}var c=t[e],u=i,d=n;for(jh(t,i,e),r(t[n],c)>0&&jh(t,i,n);u<d;){for(jh(t,u,d),u++,d--;r(t[u],c)<0;)u++;for(;r(t[d],c)>0;)d--}0===r(t[i],c)?jh(t,i,d):jh(t,++d,n),d<=e&&(i=d+1),e<=d&&(n=d-1)}}function jh(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Bh(t,e){return t<e?-1:t>e?1:0}class Uh{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Jh(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let s=0;s<e.children.length;s++){const o=e.children[s],a=e.leaf?n(o):o;Jh(t,a)&&(e.leaf?i.push(o):$h(t,a)?this._all(o,i):r.push(o))}e=r.pop()}return i}collides(t){let e=this.data;if(!Jh(t,e))return!1;const i=[];for(;e;){for(let n=0;n<e.children.length;n++){const r=e.children[n],s=e.leaf?this.toBBox(r):r;if(Jh(t,s)){if(e.leaf||$h(t,s))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Qh([]),this}remove(t,e){if(!t)return this;let i=this.data;const n=this.toBBox(t),r=[],s=[];let o,a,l;for(;i||r.length;){if(i||(i=r.pop(),a=r[r.length-1],o=s.pop(),l=!0),i.leaf){const n=zh(t,i.children,e);if(-1!==n)return i.children.splice(n,1),r.push(i),this._condense(r),this}l||i.leaf||!$h(i,n)?a?(o++,i=a.children[o],l=!1):i=null:(r.push(i),s.push(o),o=0,a=i,i=i.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,n){const r=i-e+1;let s,o=this._maxEntries;if(r<=o)return s=Qh(t.slice(e,i+1)),Xh(s,this.toBBox),s;n||(n=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,n-1))),s=Qh([]),s.leaf=!1,s.height=n;const a=Math.ceil(r/o),l=a*Math.ceil(Math.sqrt(o));tc(t,e,i,l,this.compareMinX);for(let r=e;r<=i;r+=l){const e=Math.min(r+l-1,i);tc(t,r,e,a,this.compareMinY);for(let i=r;i<=e;i+=a){const r=Math.min(i+a-1,e);s.children.push(this._build(t,i,r,n-1))}}return Xh(s,this.toBBox),s}_chooseSubtree(t,e,i,n){for(;n.push(e),!e.leaf&&n.length-1!==i;){let i,n=1/0,o=1/0;for(let a=0;a<e.children.length;a++){const l=e.children[a],h=Kh(l),c=(r=t,s=l,(Math.max(s.maxX,r.maxX)-Math.min(s.minX,r.minX))*(Math.max(s.maxY,r.maxY)-Math.min(s.minY,r.minY))-h);c<o?(o=c,n=h<n?h:n,i=l):c===o&&h<n&&(n=h,i=l)}e=i||e.children[0]}var r,s;return e}_insert(t,e,i){const n=i?t:this.toBBox(t),r=[],s=this._chooseSubtree(n,this.data,e,r);for(s.children.push(t),Wh(s,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const s=this._chooseSplitIndex(i,r,n),o=Qh(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,Xh(i,this.toBBox),Xh(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=Qh([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Xh(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,s=1/0;for(let o=e;o<=i-e;o++){const e=Vh(t,0,o,this.toBBox),a=Vh(t,o,i,this.toBBox),l=qh(e,a),h=Kh(e)+Kh(a);l<r?(r=l,n=o,s=h<s?h:s):l===r&&h<s&&(s=h,n=o)}return n||i-e}_chooseSplitAxis(t,e,i){const n=t.leaf?this.compareMinX:Zh,r=t.leaf?this.compareMinY:Yh;this._allDistMargin(t,e,i,n)<this._allDistMargin(t,e,i,r)&&t.children.sort(n)}_allDistMargin(t,e,i,n){t.children.sort(n);const r=this.toBBox,s=Vh(t,0,e,r),o=Vh(t,i-e,i,r);let a=Hh(s)+Hh(o);for(let n=e;n<i-e;n++){const e=t.children[n];Wh(s,t.leaf?r(e):e),a+=Hh(s)}for(let n=i-e-1;n>=e;n--){const e=t.children[n];Wh(o,t.leaf?r(e):e),a+=Hh(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)Wh(e[n],t)}_condense(t){for(let e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children,e.splice(e.indexOf(t[i]),1)):this.clear():Xh(t[i],this.toBBox)}}function zh(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n<e.length;n++)if(i(t,e[n]))return n;return-1}function Xh(t,e){Vh(t,0,t.children.length,e,t)}function Vh(t,e,i,n,r){r||(r=Qh(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(let s=e;s<i;s++){const e=t.children[s];Wh(r,t.leaf?n(e):e)}return r}function Wh(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Zh(t,e){return t.minX-e.minX}function Yh(t,e){return t.minY-e.minY}function Kh(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Hh(t){return t.maxX-t.minX+(t.maxY-t.minY)}function qh(t,e){const i=Math.max(t.minX,e.minX),n=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),s=Math.min(t.maxY,e.maxY);return Math.max(0,r-i)*Math.max(0,s-n)}function $h(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Jh(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Qh(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function tc(t,e,i,n,r){const s=[e,i];for(;s.length;){if((i=s.pop())-(e=s.pop())<=n)continue;const o=e+Math.ceil((i-e)/n/2)*n;kh(t,o,e,i,r),s.push(e,o,o,i)}}var ec=class{constructor(t){this.rbush_=new Uh(t),this.items_={}}insert(t,e){const i={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:e};this.rbush_.insert(i),this.items_[V(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n<r;n++){const r=t[n],s=e[n],o={minX:r[0],minY:r[1],maxX:r[2],maxY:r[3],value:s};i[n]=o,this.items_[V(s)]=o}this.rbush_.load(i)}remove(t){const e=V(t),i=this.items_[e];return delete this.items_[e],null!==this.rbush_.remove(i)}update(t,e){const i=this.items_[V(e)];de([i.minX,i.minY,i.maxX,i.maxY],t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map((function(t){return t.value}))}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map((function(t){return t.value}))}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let n=0,r=t.length;n<r;n++)if(i=e(t[n]),i)return i;return i}isEmpty(){return S(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return le(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}},ic="addfeature",nc="changefeature",rc="clear",sc="removefeature",oc="featuresloadstart",ac="featuresloadend",lc="featuresloaderror";class hc extends r{constructor(t,e,i){super(t),this.feature=e,this.features=i}}var cc=class extends dh{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:void 0===t.wrapX||t.wrapX}),this.on,this.once,this.un,this.loader_=_,this.format_=t.format,this.overlaps_=void 0===t.overlaps||t.overlaps,this.url_=t.url,void 0!==t.loader?this.loader_=t.loader:void 0!==this.url_&&(Mt(this.format_,7),this.loader_=Nl(this.url_,this.format_)),this.strategy_=void 0!==t.strategy?t.strategy:Dl;const e=void 0===t.useSpatialIndex||t.useSpatialIndex;let i,n;this.featuresRtree_=e?new ec:null,this.loadedExtentsRtree_=new ec,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null,Array.isArray(t.features)?n=t.features:t.features&&(i=t.features,n=i.getArray()),e||void 0!==i||(i=new $(n)),void 0!==n&&this.addFeaturesInternal(n),void 0!==i&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=V(t);if(!this.addToIndex_(e,t))return void(this.featuresCollection_&&this.featuresCollection_.remove(t));this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const e=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(e,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new hc(ic,t))}setupChangeEvents_(t,e){this.featureChangeKeys_[t]=[D(e,E,this.handleFeatureChange_,this),D(e,s,this.handleFeatureChange_,this)]}addToIndex_(t,e){let i=!0;const n=e.getId();return void 0!==n&&(n.toString()in this.idIndex_?i=!1:this.idIndex_[n.toString()]=e),i&&(Mt(!(t in this.uidIndex_),30),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],n=[];for(let e=0,n=t.length;e<n;e++){const n=t[e],r=V(n);this.addToIndex_(r,n)&&i.push(n)}for(let t=0,r=i.length;t<r;t++){const r=i[t],s=V(r);this.setupChangeEvents_(s,r);const o=r.getGeometry();if(o){const t=o.getExtent();e.push(t),n.push(r)}else this.nullGeometryFeatures_[s]=r}if(this.featuresRtree_&&this.featuresRtree_.load(e,n),this.hasListener(ic))for(let t=0,e=i.length;t<e;t++)this.dispatchEvent(new hc(ic,i[t]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(ic,(function(i){e||(e=!0,t.push(i.feature),e=!1)})),this.addEventListener(sc,(function(i){e||(e=!0,t.remove(i.feature),e=!1)})),t.addEventListener(Y,(t=>{e||(e=!0,this.addFeature(t.element),e=!1)})),t.addEventListener(K,(t=>{e||(e=!0,this.removeFeature(t.element),e=!1)})),this.featuresCollection_=t}clear(t){if(t){for(const t in this.featureChangeKeys_){this.featureChangeKeys_[t].forEach(G)}this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const t=t=>{this.removeFeatureInternal(t)};this.featuresRtree_.forEach(t);for(const t in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[t])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new hc(rc);this.dispatchEvent(e),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,e){const i=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(i,(function(i){if(i.getGeometry().intersectsCoordinate(t))return e(i)}))}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,(function(i){if(i.getGeometry().intersectsExtent(t)){const t=e(i);if(t)return t}}))}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),S(this.nullGeometryFeatures_)||d(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,(function(t){e.push(t)})),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const i=Be(t,e);return[].concat(...i.map((t=>this.featuresRtree_.getInExtent(t))))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],n=t[1];let r=null;const s=[NaN,NaN];let o=1/0;const a=[-1/0,-1/0,1/0,1/0];return e=e||p,this.featuresRtree_.forEachInExtent(a,(function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e.closestPointXY(i,n,s,o),o<l){r=t;const e=Math.sqrt(o);a[0]=i-e,a[1]=n-e,a[2]=i+e,a[3]=n+e}}})),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return void 0!==e?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return void 0!==e?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=V(e),n=e.getGeometry();if(n){const t=n.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(t,e)):this.featuresRtree_&&this.featuresRtree_.update(t,e)}else i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);const r=e.getId();if(void 0!==r){const t=r.toString();this.idIndex_[t]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[t]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new hc(nc,e))}hasFeature(t){const e=t.getId();return void 0!==e?e in this.idIndex_:V(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&S(this.nullGeometryFeatures_):!this.featuresCollection_||0===this.featuresCollection_.getLength()}loadFeatures(t,e,i){const n=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let t=0,s=r.length;t<s;++t){const s=r[t];n.forEachInExtent(s,(function(t){return re(t.extent,s)}))||(++this.loadingExtentsCount_,this.dispatchEvent(new hc(oc)),this.loader_.call(this,s,e,i,(t=>{--this.loadingExtentsCount_,this.dispatchEvent(new hc(ac,void 0,t))}),(()=>{--this.loadingExtentsCount_,this.dispatchEvent(new hc(lc))})),n.insert(s,{extent:s.slice()}))}this.loading=!(this.loader_.length<4)&&this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_;let i;e.forEachInExtent(t,(function(e){if(de(e.extent,t))return i=e,!0})),i&&e.remove(i)}removeFeature(t){if(!t)return;const e=V(t);e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t);this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=V(t),i=this.featureChangeKeys_[e];if(!i)return;i.forEach(G),delete this.featureChangeKeys_[e];const n=t.getId();return void 0!==n&&delete this.idIndex_[n.toString()],delete this.uidIndex_[e],this.dispatchEvent(new hc(sc,t)),t}removeFromIdIndex_(t){let e=!1;for(const i in this.idIndex_)if(this.idIndex_[i]===t){delete this.idIndex_[i],e=!0;break}return e}setLoader(t){this.loader_=t}setUrl(t){Mt(this.format_,7),this.url_=t,this.setLoader(Nl(t,this.format_))}};var uc=class extends cc{constructor(t){super({attributions:t.attributions,wrapX:t.wrapX}),this.resolution=void 0,this.distance=void 0!==t.distance?t.distance:20,this.minDistance=t.minDistance||0,this.interpolationRatio=0,this.features=[],this.geometryFunction=t.geometryFunction||function(t){const e=t.getGeometry();return Mt(!e||"Point"===e.getType(),10),e},this.createCustomCluster_=t.createCluster,this.source=null,this.boundRefresh_=this.refresh.bind(this),this.updateDistance(this.distance,this.minDistance),this.setSource(t.source||null)}clear(t){this.features.length=0,super.clear(t)}getDistance(){return this.distance}getSource(){return this.source}loadFeatures(t,e,i){this.source.loadFeatures(t,e,i),e!==this.resolution&&(this.resolution=e,this.refresh())}setDistance(t){this.updateDistance(t,this.minDistance)}setMinDistance(t){this.updateDistance(this.distance,t)}getMinDistance(){return this.minDistance}setSource(t){this.source&&this.source.removeEventListener(E,this.boundRefresh_),this.source=t,t&&t.addEventListener(E,this.boundRefresh_),this.refresh()}refresh(){this.clear(),this.cluster(),this.addFeatures(this.features)}updateDistance(t,e){const i=0===t?0:Math.min(e,t)/t,n=t!==this.distance||this.interpolationRatio!==i;this.distance=t,this.minDistance=e,this.interpolationRatio=i,n&&this.refresh()}cluster(){if(void 0===this.resolution||!this.source)return;const t=[1/0,1/0,-1/0,-1/0],e=this.distance*this.resolution,i=this.source.getFeatures(),n={};for(let r=0,s=i.length;r<s;r++){const s=i[r];if(!(V(s)in n)){const i=this.geometryFunction(s);if(i){ce(i.getCoordinates(),t),te(t,e,t);const r=this.source.getFeaturesInExtent(t).filter((function(t){const e=V(t);return!(e in n)&&(n[e]=!0,!0)}));this.features.push(this.createCluster(r,t))}}}}createCluster(t,e){const i=[0,0];for(let e=t.length-1;e>=0;--e){const n=this.geometryFunction(t[e]);n?bi(i,n.getCoordinates()):t.splice(e,1)}Oi(i,1/t.length);const n=Te(e),r=this.interpolationRatio,s=new lr([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(s,t):new Nt({geometry:s,features:t})}};var dc=class extends Lt{constructor(t){super({tileCoord:t.tileCoord,loader:()=>Promise.resolve(new Uint8Array(4)),interpolate:t.interpolate,transition:t.transition}),this.pixelRatio_=t.pixelRatio,this.gutter_=t.gutter,this.reprojData_=null,this.reprojError_=null,this.reprojSize_=void 0,this.sourceTileGrid_=t.sourceTileGrid,this.targetTileGrid_=t.targetTileGrid,this.wrappedTileCoord_=t.wrappedTileCoord||t.tileCoord,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0;const e=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),i=this.targetTileGrid_.getExtent();let n=this.sourceTileGrid_.getExtent();const r=i?Ie(e,i):e;if(0===Se(r))return void(this.state=it);const s=t.sourceProj,o=s.getExtent();o&&(n=n?Ie(n,o):o);const a=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),l=t.targetProj,h=nh(s,l,r,a);if(!isFinite(h)||h<=0)return void(this.state=it);const c=void 0!==t.errorThreshold?t.errorThreshold:sh;if(this.triangulation_=new oh(s,l,r,n,h*c,a),0===this.triangulation_.getTriangles().length)return void(this.state=it);this.sourceZ_=this.sourceTileGrid_.getZForResolution(h);let u=this.triangulation_.calculateSourceExtent();if(n&&(s.canWrapX()?(u[1]=gi(u[1],n[1],n[3]),u[3]=gi(u[3],n[1],n[3])):u=Ie(u,n)),Se(u)){const e=this.sourceTileGrid_.getTileRangeForExtentAndZ(u,this.sourceZ_),i=t.getTileFunction;for(let t=e.minX;t<=e.maxX;t++)for(let n=e.minY;n<=e.maxY;n++){const e=i(this.sourceZ_,t,n,this.pixelRatio_);e&&this.sourceTiles_.push(e)}0===this.sourceTiles_.length&&(this.state=it)}else this.state=it}getSize(){return this.reprojSize_}getData(){return this.reprojData_}getError(){return this.reprojError_}reproject_(){const t=[];if(this.sourceTiles_.forEach((e=>{if(!e||e.getState()!==tt)return;const i=e.getSize(),n=this.gutter_;let r;const s=bt(e.getData());r=s||It(Rt(e.getData()));const o=[i[0]+2*n,i[1]+2*n],a=r instanceof Float32Array,l=o[0]*o[1],h=a?Float32Array:Uint8Array,c=new h(r.buffer),u=h.BYTES_PER_ELEMENT,d=u*c.length/l,g=c.byteLength/o[1],f=Math.floor(g/u/o[0]),p=l*f;let m=c;if(c.length!==p){m=new h(p);let t=0,e=0;const i=o[0]*f;for(let n=0;n<o[1];++n){for(let n=0;n<i;++n)m[t++]=c[e+n];e+=g/u}}t.push({extent:this.sourceTileGrid_.getTileCoordExtent(e.tileCoord),data:new Uint8Array(m.buffer),dataType:h,bytesPerPixel:d,pixelSize:o})})),this.sourceTiles_.length=0,0===t.length)this.state=et;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),n="number"==typeof i?i:i[0],r="number"==typeof i?i:i[1],s=this.targetTileGrid_.getResolution(e),o=this.sourceTileGrid_.getResolution(this.sourceZ_),a=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);let l,h;const c=t[0].bytesPerPixel;for(let e=Math.ceil(c/3)-1;e>=0;--e){const i=[];for(let n=0,r=t.length;n<r;++n){const r=t[n],s=r.data,o=r.pixelSize,a=o[0],l=o[1],h=yt(a,l,Ql),u=h.createImageData(a,l),d=u.data;let g=3*e;for(let t=0,e=d.length;t<e;t+=4)d[t]=s[g],d[t+1]=s[g+1],d[t+2]=s[g+2],d[t+3]=255,g+=c;h.putImageData(u,0,0),i.push({extent:r.extent,image:h.canvas})}const u=rh(n,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,i,this.gutter_,!1,!1);for(let t=0,e=i.length;t<e;++t){const e=i[t].image.getContext("2d");xt(e),Ql.push(e.canvas)}const d=u.getContext("2d"),g=d.getImageData(0,0,u.width,u.height);xt(d),Ql.push(u),l||(h=new Uint8Array(c*g.width*g.height),l=new t[0].dataType(h.buffer));const f=g.data;let p=3*e;for(let t=0,e=f.length;t<e;t+=4)255===f[t+3]?(h[p]=f[t],h[p+1]=f[t+1],h[p+2]=f[t+2]):(h[p]=0,h[p+1]=0,h[p+2]=0),p+=c}this.reprojData_=l,this.reprojSize_=[Math.round(n*this.pixelRatio_),Math.round(r*this.pixelRatio_)],this.state=tt}this.changed()}load(){if(this.state!==J&&this.state!==et)return;this.state=Q,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach((e=>{const i=e.getState();if(i!==J&&i!==Q)return;t++;const n=D(e,E,(function(){const i=e.getState();i!=tt&&i!=et&&i!=it||(G(n),t--,0===t&&(this.unlistenSources_(),this.reproject_()))}),this);this.sourcesListenerKeys_.push(n)})),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function(t){t.getState()==J&&t.load()}))}unlistenSources_(){this.sourcesListenerKeys_.forEach(G),this.sourcesListenerKeys_=null}};var gc=class extends Eh{constructor(t){const e=void 0===t.projection?"EPSG:3857":t.projection;let i=t.tileGrid;void 0===i&&e&&(i=yh({extent:Sh(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize})),super({cacheSize:.1,attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,projection:e,tileGrid:i,opaque:t.opaque,state:t.state,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate}),this.gutter_=void 0!==t.gutter?t.gutter:0,this.tileSize_=t.tileSize?ol(t.tileSize):null,this.tileSizes_=null,this.tileLoadingKeys_={},this.loader_=t.loader,this.handleTileChange_=this.handleTileChange_.bind(this),this.bandCount=void 0===t.bandCount?4:t.bandCount,this.tileGridForProjection_={},this.tileCacheForProjection_={}}setTileSizes(t){this.tileSizes_=t}getTileSize(t){if(this.tileSizes_)return this.tileSizes_[t];if(this.tileSize_)return this.tileSize_;const e=this.getTileGrid();return e?ol(e.getTileSize(t)):[256,256]}getGutterForProjection(t){const e=this.getProjection();return!e||cn(e,t)?this.gutter_:0}setLoader(t){this.loader_=t}getReprojTile_(t,e,i,n,r){const s=this.getTileCacheForProjection(n),o=yl(t,e,i);if(s.containsKey(o)){const t=s.get(o);if(t&&t.key==this.getKey())return t}const a=this.getTileGrid(),l=Math.max.apply(null,a.getResolutions().map(((t,e)=>{const i=ol(a.getTileSize(e)),n=this.getTileSize(e);return Math.max(n[0]/i[0],n[1]/i[1])}))),h=this.getTileGridForProjection(r),c=this.getTileGridForProjection(n),u=[t,e,i],d=this.getTileCoordForTileUrlFunction(u,n),g=Object.assign({sourceProj:r,sourceTileGrid:h,targetProj:n,targetTileGrid:c,tileCoord:u,wrappedTileCoord:d,pixelRatio:l,gutter:this.getGutterForProjection(r),getTileFunction:(t,e,i,n)=>this.getTile(t,e,i,n,r)},this.tileOptions),f=new dc(g);return f.key=this.getKey(),f}getTile(t,e,i,n,r){const s=this.getProjection();if(s&&r&&!cn(s,r))return this.getReprojTile_(t,e,i,r,s);const o=this.getTileSize(t),a=yl(t,e,i);if(this.tileCache.containsKey(a))return this.tileCache.get(a);const l=this.loader_;const h=Object.assign({tileCoord:[t,e,i],loader:function(){return x((function(){return l(t,e,i)}))},size:o},this.tileOptions),c=new Lt(h);return c.key=this.getKey(),c.addEventListener(E,this.handleTileChange_),this.tileCache.set(a,c),c}handleTileChange_(t){const e=t.target,i=V(e),n=e.getState();let r;n==Q?(this.tileLoadingKeys_[i]=!0,r=lh):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==et?ch:n==tt?hh:void 0),r&&this.dispatchEvent(new wh(r,e))}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||cn(e,t)))return this.tileGrid;const i=V(t);return i in this.tileGridForProjection_||(this.tileGridForProjection_[i]=ph(t)),this.tileGridForProjection_[i]}setTileGridForProjection(t,e){const i=nn(t);if(i){const t=V(i);t in this.tileGridForProjection_||(this.tileGridForProjection_[t]=e)}}getTileCacheForProjection(t){const e=this.getProjection();if(!e||cn(e,t))return this.tileCache;const i=V(t);return i in this.tileCacheForProjection_||(this.tileCacheForProjection_[i]=new Tl(.1)),this.tileCacheForProjection_[i]}expireCache(t,e){const i=this.getTileCacheForProjection(t);this.tileCache.expireCache(this.tileCache==i?e:{});for(const t in this.tileCacheForProjection_){const n=this.tileCacheForProjection_[t];n.expireCache(n==i?e:{})}}clear(){super.clear();for(const t in this.tileCacheForProjection_)this.tileCacheForProjection_[t].clear()}};function fc(t,e){if(!t)return!1;if(!0===t)return!0;if(3!==e.getSamplesPerPixel())return!1;const i=e.fileDirectory.PhotometricInterpretation,n=GeoTIFF.globals.photometricInterpretations;return i===n.CMYK||i===n.YCbCr||i===n.CIELab||i===n.ICCLab}const pc="STATISTICS_MAXIMUM",mc="STATISTICS_MINIMUM";let _c;function yc(t){try{return t.getBoundingBox()}catch(e){return[0,0,t.getWidth(),t.getHeight()]}}function xc(t){try{return t.getOrigin().slice(0,2)}catch(e){return[0,t.getHeight()]}}function vc(t,e){try{return t.getResolution(e)}catch(i){return[e.getWidth()/t.getWidth(),e.getHeight()/t.getHeight()]}}function Sc(t){const e=t.geoKeys;if(!e)return null;if(e.ProjectedCSTypeGeoKey&&32767!==e.ProjectedCSTypeGeoKey){const t="EPSG:"+e.ProjectedCSTypeGeoKey;let i=nn(t);if(!i){const n=ze(e.ProjLinearUnitsGeoKey);n&&(i=new Ve({code:t,units:n}))}return i}if(e.GeographicTypeGeoKey&&32767!==e.GeographicTypeGeoKey){const t="EPSG:"+e.GeographicTypeGeoKey;let i=nn(t);if(!i){const n=ze(e.GeogAngularUnitsGeoKey);n&&(i=new Ve({code:t,units:n}))}return i}return null}function wc(t){return t.getImageCount().then((function(e){const i=new Array(e);for(let n=0;n<e;++n)i[n]=t.getImage(n);return Promise.all(i)}))}function Ec(t,e){let i;return i=t.blob?GeoTIFF.fromBlob(t.blob):t.overviews?GeoTIFF.fromUrls(t.url,t.overviews,e):GeoTIFF.fromUrl(t.url,e),i.then(wc)}function Tc(t,e,i,n,r){if(Array.isArray(t)){const s=t.length;if(!Array.isArray(e)||s!=e.length){const t=new Error(n);throw r(t),t}for(let o=0;o<s;++o)Tc(t[o],e[o],i,n,r)}else if(Math.abs(t-e)>i*t)throw new Error(n)}function Cc(t){return t instanceof Int8Array?127:t instanceof Uint8Array||t instanceof Uint8ClampedArray?255:t instanceof Int16Array?32767:t instanceof Uint16Array?65535:t instanceof Int32Array?2147483647:t instanceof Uint32Array?4294967295:t instanceof Float32Array?34e37:255}class Rc extends gc{constructor(t){super({state:"loading",tileGrid:null,projection:null,opaque:t.opaque,transition:t.transition,interpolate:!1!==t.interpolate,wrapX:t.wrapX}),this.sourceInfo_=t.sources;const e=this.sourceInfo_.length;this.sourceOptions_=t.sourceOptions,this.sourceImagery_=new Array(e),this.sourceMasks_=new Array(e),this.resolutionFactors_=new Array(e),this.samplesPerPixel_,this.nodataValues_,this.metadata_,this.normalize_=!1!==t.normalize,this.addAlpha_=!1,this.error_=null,this.convertToRGB_=t.convertToRGB||!1,this.setKey(this.sourceInfo_.map((t=>t.url)).join(","));const i=this,n=new Array(e);for(let t=0;t<e;++t)n[t]=Ec(this.sourceInfo_[t],this.sourceOptions_);Promise.all(n).then((function(t){i.configure_(t)})).catch((function(t){Hi(t),i.error_=t,i.setState("error")}))}getError(){return this.error_}determineProjection(t){const e=t[0];for(let t=e.length-1;t>=0;--t){const i=Sc(e[t]);if(i){this.projection=i;break}}}configure_(t){let e,i,n,r,s;const o=new Array(t.length),a=new Array(t.length),l=new Array(t.length);let h=0;const c=t.length;for(let u=0;u<c;++u){const c=[],d=[];t[u].forEach((t=>{4==(4&(t.fileDirectory.NewSubfileType||0))?d.push(t):c.push(t)}));const g=c.length;if(d.length>0&&d.length!==g)throw new Error(`Expected one mask per image found ${d.length} masks and ${g} images`);let f,p;const m=new Array(g),_=new Array(g),y=new Array(g);a[u]=new Array(g),l[u]=new Array(g);for(let t=0;t<g;++t){const e=c[t],i=e.getGDALNoData();l[u][t]=e.getGDALMetadata(0),a[u][t]=i;const n=this.sourceInfo_[u].bands;o[u]=n?n.length:e.getSamplesPerPixel();const r=g-(t+1);f||(f=yc(e)),p||(p=xc(e));const s=vc(e,c[0]);y[r]=s[0];const h=[e.getTileWidth(),e.getTileHeight()];h[0]!==h[1]&&h[1]<256&&(h[0]=256,h[1]=256),m[r]=h;const d=s[0]/Math.abs(s[1]);_[r]=[h[0],h[1]/d]}if(e?Ie(e,f,e):e=f,i){Tc(i,p,0,`Origin mismatch for source ${u}, got [${p}] but expected [${i}]`,this.viewRejector)}else i=p;if(s){s.length-h>y.length&&(h=s.length-y.length);const t=s[s.length-1]/y[y.length-1];this.resolutionFactors_[u]=t;const e=y.map((e=>e*t)),i=`Resolution mismatch for source ${u}, got [${e}] but expected [${s}]`;Tc(s.slice(h,s.length),e,.02,i,this.viewRejector)}else s=y,this.resolutionFactors_[u]=1;n?Tc(n.slice(h,n.length),_,.01,`Tile size mismatch for source ${u}`,this.viewRejector):n=_,r?Tc(r.slice(h,r.length),m,0,`Tile size mismatch for source ${u}`,this.viewRejector):r=m,this.sourceImagery_[u]=c.reverse(),this.sourceMasks_[u]=d.reverse()}for(let t=0,e=this.sourceImagery_.length;t<e;++t){const e=this.sourceImagery_[t];for(;e.length<s.length;)e.unshift(void 0)}this.getProjection()||this.determineProjection(t),this.samplesPerPixel_=o,this.nodataValues_=a,this.metadata_=l;t:for(let t=0;t<c;++t){if(void 0!==this.sourceInfo_[t].nodata){this.addAlpha_=!0;break}if(this.sourceMasks_[t].length){this.addAlpha_=!0;break}const e=a[t],i=this.sourceInfo_[t].bands;if(i){for(let t=0;t<i.length;++t)if(null!==e[i[t]-1]){this.addAlpha_=!0;break t}}else for(let t=0;t<e.length;++t)if(null!==e[t]){this.addAlpha_=!0;break t}}let u=this.addAlpha_?1:0;for(let t=0;t<c;++t)u+=o[t];this.bandCount=u;const d=new fh({extent:e,minZoom:h,origin:i,resolutions:s,tileSizes:n});this.tileGrid=d,this.setTileSizes(r),this.setLoader(this.loadTile_.bind(this)),this.setState("ready");2===s.length?s=[s[0],s[1],s[1]/2]:1===s.length&&(s=[2*s[0],s[0],s[0]/2]),this.viewResolver({showFullExtent:!0,projection:this.projection,resolutions:s,center:yn(Te(e),this.projection),extent:vn(e,this.projection),zoom:1})}loadTile_(t,e,i){const n=this.getTileSize(t),r=this.sourceImagery_.length,s=new Array(2*r),o=this.nodataValues_,a=this.sourceInfo_,l=(_c||(_c=new GeoTIFF.Pool),_c);for(let h=0;h<r;++h){const c=a[h],u=this.resolutionFactors_[h],d=[Math.round(e*(n[0]*u)),Math.round(i*(n[1]*u)),Math.round((e+1)*(n[0]*u)),Math.round((i+1)*(n[1]*u))],g=this.sourceImagery_[h][t];let f,p;c.bands&&(f=c.bands.map((function(t){return t-1}))),p="nodata"in c&&null!==c.nodata?c.nodata:f?f.map((function(t){return o[h][t]})):o[h];const m={window:d,width:n[0],height:n[1],samples:f,fillValue:p,pool:l,interleave:!1};fc(this.convertToRGB_,g)?s[h]=g.readRGB(m):s[h]=g.readRasters(m);const _=r+h,y=this.sourceMasks_[h][t];y?s[_]=y.readRasters({window:d,width:n[0],height:n[1],samples:[0],pool:l,interleave:!1}):s[_]=Promise.resolve(null)}return Promise.all(s).then(this.composeTile_.bind(this,n)).catch((function(t){throw Hi(t),t}))}composeTile_(t,e){const i=this.metadata_,n=this.sourceInfo_,r=this.sourceImagery_.length,s=this.bandCount,o=this.samplesPerPixel_,a=this.nodataValues_,l=this.normalize_,h=this.addAlpha_,c=t[0]*t[1],u=c*s;let d;d=l?new Uint8Array(u):new Float32Array(u);let g=0;for(let t=0;t<c;++t){let s=h;for(let c=0;c<r;++c){const u=n[c];let p,m,_=u.min,y=u.max;if(l){const t=i[c][0];void 0===_&&(_=t&&mc in t?parseFloat(t[mc]):(f=e[c][0])instanceof Int8Array?-128:f instanceof Int16Array?-32768:f instanceof Int32Array?-2147483648:f instanceof Float32Array?12e-39:0),void 0===y&&(y=t&&pc in t?parseFloat(t[pc]):Cc(e[c][0])),p=255/(y-_),m=-_*p}for(let i=0;i<o[c];++i){const n=e[c][i][t];let r;if(r=l?gi(p*n+m,0,255):n,h){let t=u.nodata;if(void 0===t){let e;e=u.bands?u.bands[i]-1:i,t=a[c][e]}const e=isNaN(t);(!e&&n!==t||e&&!isNaN(n))&&(s=!1,d[g]=r)}else d[g]=r;g++}if(!s){const i=e[r+c];i&&!i[0][t]&&(s=!0)}}h&&(s||(d[g]=255),g++)}var f;return d}}Rc.prototype.getView;var bc=Rc;class Pc extends is{constructor(t,e,i,n,r,s,o){super(e,i,n,r,s,o),this.zoomifyImage_=null,this.tileSize_=t}getImage(){if(this.zoomifyImage_)return this.zoomifyImage_;const t=super.getImage();if(this.state==tt){const e=this.tileSize_;if(t.width==e[0]&&t.height==e[1])return this.zoomifyImage_=t,t;const i=yt(e[0],e[1]);return i.drawImage(t,0,0),this.zoomifyImage_=i.canvas,i.canvas}return t}}var Ic=class extends Mh{constructor(t){const e=t.size,i=void 0!==t.tierSizeCalculation?t.tierSizeCalculation:"default",n=t.tilePixelRatio||1,r=e[0],s=e[1],o=[],a=t.tileSize||ks;let l=a*n;switch(i){case"default":for(;r>l||s>l;)o.push([Math.ceil(r/l),Math.ceil(s/l)]),l+=l;break;case"truncated":let t=r,e=s;for(;t>l||e>l;)o.push([Math.ceil(t/l),Math.ceil(e/l)]),t>>=1,e>>=1;break;default:Mt(!1,53)}o.push([1,1]),o.reverse();const h=[n],c=[0];for(let t=1,e=o.length;t<e;t++)h.push(n<<t),c.push(o[t-1][0]*o[t-1][1]+c[t-1]);h.reverse();const u=new fh({tileSize:a,extent:t.extent||[0,-s,r,0],resolutions:h});let d=t.url;!d||d.includes("{TileGroup}")||d.includes("{tileIndex}")||(d+="{TileGroup}/{z}-{x}-{y}.jpg");const g=Ph(d);let f=a*n;const p=Rh(g.map((function(t){return function(e,i,n){if(!e)return;const r=e[0],s=e[1],a=e[2],l=s+a*o[r][0],h={z:r,x:s,y:a,tileIndex:l,TileGroup:"TileGroup"+((l+c[r])/f|0)};return t.replace(/\{(\w+?)\}/g,(function(t,e){return h[e]}))}}))),m=Pc.bind(null,ol(a*n));super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,tilePixelRatio:n,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileClass:m,tileGrid:u,tileUrlFunction:p,transition:t.transition}),this.zDirection=t.zDirection;const _=p(u.getTileCoordForCoordAndResolution(Te(u.getExtent()),h[h.length-1]),1,null),y=new Image;y.addEventListener("error",(()=>{f=a,this.changed()})),y.src=_}};const Fc="version1",Lc="version2",Mc="version3",Ac={};Ac[Fc]={level0:{supports:[],formats:[],qualities:["native"]},level1:{supports:["regionByPx","sizeByW","sizeByH","sizeByPct"],formats:["jpg"],qualities:["native"]},level2:{supports:["regionByPx","regionByPct","sizeByW","sizeByH","sizeByPct","sizeByConfinedWh","sizeByWh"],formats:["jpg","png"],qualities:["native","color","grey","bitonal"]}},Ac[Lc]={level0:{supports:[],formats:["jpg"],qualities:["default"]},level1:{supports:["regionByPx","sizeByW","sizeByH","sizeByPct"],formats:["jpg"],qualities:["default"]},level2:{supports:["regionByPx","regionByPct","sizeByW","sizeByH","sizeByPct","sizeByConfinedWh","sizeByDistortedWh","sizeByWh"],formats:["jpg","png"],qualities:["default","bitonal"]}},Ac[Mc]={level0:{supports:[],formats:["jpg"],qualities:["default"]},level1:{supports:["regionByPx","regionSquare","sizeByW","sizeByH","sizeByWh"],formats:["jpg"],qualities:["default"]},level2:{supports:["regionByPx","regionSquare","regionByPct","sizeByW","sizeByH","sizeByPct","sizeByConfinedWh","sizeByWh"],formats:["jpg","png"],qualities:["default"]}},Ac.none={none:{supports:[],formats:[],qualities:[]}};const Oc=/^https?:\/\/library\.stanford\.edu\/iiif\/image-api\/(?:1\.1\/)?compliance\.html#level[0-2]$/,Nc=/^https?:\/\/iiif\.io\/api\/image\/2\/level[0-2](?:\.json)?$/,Dc=/(^https?:\/\/iiif\.io\/api\/image\/3\/level[0-2](?:\.json)?$)|(^level[0-2]$)/;const kc={};kc[Fc]=function(t){let e=t.getComplianceLevelSupportedFeatures();return void 0===e&&(e=Ac[Fc].level0),{url:void 0===t.imageInfo["@id"]?void 0:t.imageInfo["@id"].replace(/\/?(?:info\.json)?$/g,""),supports:e.supports,formats:[...e.formats,void 0===t.imageInfo.formats?[]:t.imageInfo.formats],qualities:[...e.qualities,void 0===t.imageInfo.qualities?[]:t.imageInfo.qualities],resolutions:t.imageInfo.scale_factors,tileSize:void 0!==t.imageInfo.tile_width?void 0!==t.imageInfo.tile_height?[t.imageInfo.tile_width,t.imageInfo.tile_height]:[t.imageInfo.tile_width,t.imageInfo.tile_width]:null!=t.imageInfo.tile_height?[t.imageInfo.tile_height,t.imageInfo.tile_height]:void 0}},kc[Lc]=function(t){const e=t.getComplianceLevelSupportedFeatures(),i=Array.isArray(t.imageInfo.profile)&&t.imageInfo.profile.length>1,n=i&&t.imageInfo.profile[1].supports?t.imageInfo.profile[1].supports:[],r=i&&t.imageInfo.profile[1].formats?t.imageInfo.profile[1].formats:[],s=i&&t.imageInfo.profile[1].qualities?t.imageInfo.profile[1].qualities:[];return{url:t.imageInfo["@id"].replace(/\/?(?:info\.json)?$/g,""),sizes:void 0===t.imageInfo.sizes?void 0:t.imageInfo.sizes.map((function(t){return[t.width,t.height]})),tileSize:void 0===t.imageInfo.tiles?void 0:[t.imageInfo.tiles.map((function(t){return t.width}))[0],t.imageInfo.tiles.map((function(t){return void 0===t.height?t.width:t.height}))[0]],resolutions:void 0===t.imageInfo.tiles?void 0:t.imageInfo.tiles.map((function(t){return t.scaleFactors}))[0],supports:[...e.supports,...n],formats:[...e.formats,...r],qualities:[...e.qualities,...s]}},kc[Mc]=function(t){const e=t.getComplianceLevelSupportedFeatures(),i=void 0===t.imageInfo.extraFormats?e.formats:[...e.formats,...t.imageInfo.extraFormats],n=void 0!==t.imageInfo.preferredFormats&&Array.isArray(t.imageInfo.preferredFormats)&&t.imageInfo.preferredFormats.length>0?t.imageInfo.preferredFormats.filter((function(t){return["jpg","png","gif"].includes(t)})).reduce((function(t,e){return void 0===t&&i.includes(e)?e:t}),void 0):void 0;return{url:t.imageInfo.id,sizes:void 0===t.imageInfo.sizes?void 0:t.imageInfo.sizes.map((function(t){return[t.width,t.height]})),tileSize:void 0===t.imageInfo.tiles?void 0:[t.imageInfo.tiles.map((function(t){return t.width}))[0],t.imageInfo.tiles.map((function(t){return t.height}))[0]],resolutions:void 0===t.imageInfo.tiles?void 0:t.imageInfo.tiles.map((function(t){return t.scaleFactors}))[0],supports:void 0===t.imageInfo.extraFeatures?e.supports:[...e.supports,...t.imageInfo.extraFeatures],formats:i,qualities:void 0===t.imageInfo.extraQualities?e.qualities:[...e.qualities,...t.imageInfo.extraQualities],preferredFormat:n}};var Gc=class{constructor(t){this.setImageInfo(t)}setImageInfo(t){this.imageInfo="string"==typeof t?JSON.parse(t):t}getImageApiVersion(){if(void 0===this.imageInfo)return;let t=this.imageInfo["@context"]||"ol-no-context";"string"==typeof t&&(t=[t]);for(let e=0;e<t.length;e++)switch(t[e]){case"http://library.stanford.edu/iiif/image-api/1.1/context.json":case"http://iiif.io/api/image/1/context.json":return Fc;case"http://iiif.io/api/image/2/context.json":return Lc;case"http://iiif.io/api/image/3/context.json":return Mc;case"ol-no-context":if(this.getComplianceLevelEntryFromProfile(Fc)&&this.imageInfo.identifier)return Fc}Mt(!1,61)}getComplianceLevelEntryFromProfile(t){if(void 0!==this.imageInfo&&void 0!==this.imageInfo.profile)switch(void 0===t&&(t=this.getImageApiVersion()),t){case Fc:if(Oc.test(this.imageInfo.profile))return this.imageInfo.profile;break;case Mc:if(Dc.test(this.imageInfo.profile))return this.imageInfo.profile;break;case Lc:if("string"==typeof this.imageInfo.profile&&Nc.test(this.imageInfo.profile))return this.imageInfo.profile;if(Array.isArray(this.imageInfo.profile)&&this.imageInfo.profile.length>0&&"string"==typeof this.imageInfo.profile[0]&&Nc.test(this.imageInfo.profile[0]))return this.imageInfo.profile[0]}}getComplianceLevelFromProfile(t){const e=this.getComplianceLevelEntryFromProfile(t);if(void 0===e)return;const i=e.match(/level[0-2](?:\.json)?$/g);return Array.isArray(i)?i[0].replace(".json",""):void 0}getComplianceLevelSupportedFeatures(){if(void 0===this.imageInfo)return;const t=this.getImageApiVersion(),e=this.getComplianceLevelFromProfile(t);return void 0===e?Ac.none.none:Ac[t][e]}getTileSourceOptions(t){const e=t||{},i=this.getImageApiVersion();if(void 0===i)return;const n=void 0===i?void 0:kc[i](this);return void 0!==n?{url:n.url,version:i,size:[this.imageInfo.width,this.imageInfo.height],sizes:n.sizes,format:void 0!==e.format&&n.formats.includes(e.format)?e.format:void 0!==n.preferredFormat?n.preferredFormat:"jpg",supports:n.supports,quality:e.quality&&n.qualities.includes(e.quality)?e.quality:n.qualities.includes("native")?"native":"default",resolutions:Array.isArray(n.resolutions)?n.resolutions.sort((function(t,e){return e-t})):void 0,tileSize:n.tileSize}:void 0}};function jc(t){return t.toLocaleString("en",{maximumFractionDigits:10})}var Bc=class extends Mh{constructor(t){const e=t||{};let i=e.url||"";i+=i.lastIndexOf("/")===i.length-1||""===i?"":"/";const n=e.version||Lc,r=e.sizes||[],s=e.size;Mt(null!=s&&Array.isArray(s)&&2==s.length&&!isNaN(s[0])&&s[0]>0&&!isNaN(s[1])&&s[1]>0,60);const o=s[0],a=s[1],l=e.tileSize,h=e.tilePixelRatio||1,c=e.format||"jpg",u=e.quality||(e.version==Fc?"native":"default");let d=e.resolutions||[];const g=e.supports||[],f=e.extent||[0,-a,o,0],p=null!=r&&Array.isArray(r)&&r.length>0,m=void 0!==l&&("number"==typeof l&&Number.isInteger(l)&&l>0||Array.isArray(l)&&l.length>0),_=null!=g&&Array.isArray(g)&&(g.includes("regionByPx")||g.includes("regionByPct"))&&(g.includes("sizeByWh")||g.includes("sizeByH")||g.includes("sizeByW")||g.includes("sizeByPct"));let y,x,v;if(d.sort((function(t,e){return e-t})),m||_)if(null!=l&&("number"==typeof l&&Number.isInteger(l)&&l>0?(y=l,x=l):Array.isArray(l)&&l.length>0&&((1==l.length||null==l[1]&&Number.isInteger(l[0]))&&(y=l[0],x=l[0]),2==l.length&&(Number.isInteger(l[0])&&Number.isInteger(l[1])?(y=l[0],x=l[1]):null==l[0]&&Number.isInteger(l[1])&&(y=l[1],x=l[1])))),void 0!==y&&void 0!==x||(y=ks,x=ks),0==d.length){v=Math.max(Math.ceil(Math.log(o/y)/Math.LN2),Math.ceil(Math.log(a/x)/Math.LN2));for(let t=v;t>=0;t--)d.push(Math.pow(2,t))}else{const t=Math.max(...d);v=Math.round(Math.log(t)/Math.LN2)}else if(y=o,x=a,d=[],p){r.sort((function(t,e){return t[0]-e[0]})),v=-1;const t=[];for(let e=0;e<r.length;e++){const i=o/r[e][0];d.length>0&&d[d.length-1]==i?t.push(e):(d.push(i),v++)}if(t.length>0)for(let e=0;e<t.length;e++)r.splice(t[e]-e,1)}else d.push(1),r.push([o,a]),v=0;const S=new fh({tileSize:[y,x],extent:f,origin:Fe(f),resolutions:d}),w=Pc.bind(null,ol(l||256).map((function(t){return t*h})));super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,state:e.state,tileClass:w,tileGrid:S,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:function(t,e,s){let l,h;const f=t[0];if(f>v)return;const S=t[1],w=t[2],E=d[f];if(!(void 0===S||void 0===w||void 0===E||S<0||Math.ceil(o/E/y)<=S||w<0||Math.ceil(a/E/x)<=w)){if(_||m){const t=S*y*E,e=w*x*E;let i=y*E,r=x*E,s=y,c=x;if(t+i>o&&(i=o-t),e+r>a&&(r=a-e),t+y*E>o&&(s=Math.floor((o-t+E-1)/E)),e+x*E>a&&(c=Math.floor((a-e+E-1)/E)),0==t&&i==o&&0==e&&r==a)l="full";else if(!_||g.includes("regionByPx"))l=t+","+e+","+i+","+r;else if(g.includes("regionByPct")){l="pct:"+jc(t/o*100)+","+jc(e/a*100)+","+jc(i/o*100)+","+jc(r/a*100)}n!=Mc||_&&!g.includes("sizeByWh")?!_||g.includes("sizeByW")?h=s+",":g.includes("sizeByH")?h=","+c:g.includes("sizeByWh")?h=s+","+c:g.includes("sizeByPct")&&(h="pct:"+jc(100/E)):h=s+","+c}else if(l="full",p){const t=r[f][0],e=r[f][1];h=n==Mc?t==o&&e==a?"max":t+","+e:t==o?"full":t+","}else h=n==Mc?"max":"full";return i+l+"/"+h+"/0/"+u+"."+c}},transition:e.transition}),this.zDirection=e.zDirection}};var Uc=class extends Yr{constructor(t,e,i,n,r,s,o){let a=t.getExtent();a&&t.canWrapX()&&(a=a.slice(),a[0]=-1/0,a[2]=1/0);let l=e.getExtent();l&&e.canWrapX()&&(l=l.slice(),l[0]=-1/0,l[2]=1/0);const h=l?Ie(i,l):i,c=ih(t,e,Te(h),n),u=new oh(t,e,h,a,.5*c,n),d=u.calculateSourceExtent(),g=Oe(d)?null:s(d,c,r),f=g?Kr:Jr,p=g?g.getPixelRatio():1;super(i,n,p,f),this.targetProj_=e,this.maxSourceExtent_=a,this.triangulation_=u,this.targetResolution_=n,this.targetExtent_=i,this.sourceImage_=g,this.sourcePixelRatio_=p,this.interpolate_=o,this.canvas_=null,this.sourceListenerKey_=null}disposeInternal(){this.state==Hr&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==qr){const t=Me(this.targetExtent_)/this.targetResolution_,e=Pe(this.targetExtent_)/this.targetResolution_;this.canvas_=rh(t,e,this.sourcePixelRatio_,this.sourceImage_.getResolution(),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_)}this.state=t,this.changed()}load(){if(this.state==Kr){this.state=Hr,this.changed();const t=this.sourceImage_.getState();t==qr||t==$r?this.reproject_():(this.sourceListenerKey_=D(this.sourceImage_,E,(function(t){const e=this.sourceImage_.getState();e!=qr&&e!=$r||(this.unlistenSource_(),this.reproject_())}),this),this.sourceImage_.load())}}unlistenSource_(){G(this.sourceListenerKey_),this.sourceListenerKey_=null}};const zc="imageloadstart",Xc="imageloadend",Vc="imageloaderror";class Wc extends r{constructor(t,e){super(t),this.image=e}}function Zc(t,e){t.getImage().src=e}var Yc=class extends dh{constructor(t){super({attributions:t.attributions,projection:t.projection,state:t.state,interpolate:void 0===t.interpolate||t.interpolate}),this.on,this.once,this.un,this.resolutions_=void 0!==t.resolutions?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();if(e){t=e[c(e,t,0)]}return t}getImage(t,e,i,n){const r=this.getProjection();if(!r||!n||cn(r,n))return r&&(n=r),this.getImageInternal(t,e,i,n);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&cn(this.reprojectedImage_.getProjection(),n)&&this.reprojectedImage_.getResolution()==e&&de(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Uc(r,n,t,e,i,((t,e,i)=>this.getImageInternal(t,e,i,r)),this.getInterpolate()),this.reprojectedRevision_=this.getRevision(),this.reprojectedImage_}getImageInternal(t,e,i,n){return z()}handleImageChange(t){const e=t.target;let i;switch(e.getState()){case Hr:this.loading=!0,i=zc;break;case qr:this.loading=!1,i=Xc;break;case $r:this.loading=!1,i=Vc;break;default:return}this.hasListener(i)&&this.dispatchEvent(new Wc(i,e))}};function Kc(t,e){const i=[];Object.keys(e).forEach((function(t){null!==e[t]&&void 0!==e[t]&&i.push(t+"="+encodeURIComponent(e[t]))}));const n=i.join("&");return t=t.replace(/[?&]$/,""),(t+=t.includes("?")?"&":"?")+n}var Hc=class extends Yc{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.context_=yt(1,1),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.hidpi_=void 0===t.hidpi||t.hidpi,this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:Zc,this.params_=t.params||{},this.image_=null,this.imageSize_=[0,0],this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5}getParams(){return this.params_}getImageInternal(t,e,i,n){if(void 0===this.url_)return null;e=this.findNearestResolution(e),i=this.hidpi_?i:1;const r=this.image_;if(r&&this.renderedRevision_==this.getRevision()&&r.getResolution()==e&&r.getPixelRatio()==i&&re(r.getExtent(),t))return r;const s={F:"image",FORMAT:"PNG32",TRANSPARENT:!0};Object.assign(s,this.params_);const o=((t=t.slice())[0]+t[2])/2,a=(t[1]+t[3])/2;if(1!=this.ratio_){const e=this.ratio_*Me(t)/2,i=this.ratio_*Pe(t)/2;t[0]=o-e,t[1]=a-i,t[2]=o+e,t[3]=a+i}const l=e/i,h=Math.ceil(Me(t)/l),c=Math.ceil(Pe(t)/l);t[0]=o-l*h/2,t[2]=o+l*h/2,t[1]=a-l*c/2,t[3]=a+l*c/2,this.imageSize_[0]=h,this.imageSize_[1]=c;const u=this.getRequestUrl_(t,this.imageSize_,i,n,s);return this.image_=new ts(t,e,i,u,this.crossOrigin_,this.imageLoadFunction_,this.context_),this.renderedRevision_=this.getRevision(),this.image_.addEventListener(E,this.handleImageChange.bind(this)),this.image_}getImageLoadFunction(){return this.imageLoadFunction_}getRequestUrl_(t,e,i,n,r){const s=n.getCode().split(/:(?=\d+$)/).pop();r.SIZE=e[0]+","+e[1],r.BBOX=t.join(","),r.BBOXSR=s,r.IMAGESR=s,r.DPI=Math.round(90*i);const o=this.url_,a=o.replace(/MapServer\/?$/,"MapServer/export").replace(/ImageServer\/?$/,"ImageServer/exportImage");return a==o&&Mt(!1,50),Kc(a,r)}getUrl(){return this.url_}setImageLoadFunction(t){this.image_=null,this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.image_=null,this.changed())}updateParams(t){Object.assign(this.params_,t),this.image_=null,this.changed()}};var qc=class extends Yc{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions,state:t.state}),this.canvasFunction_=t.canvasFunction,this.canvas_=null,this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5}getImageInternal(t,e,i,n){e=this.findNearestResolution(e);let r=this.canvas_;if(r&&this.renderedRevision_==this.getRevision()&&r.getResolution()==e&&r.getPixelRatio()==i&&re(r.getExtent(),t))return r;De(t=t.slice(),this.ratio_);const s=[Me(t)/e*i,Pe(t)/e*i],o=this.canvasFunction_.call(this,t,e,i,s,n);return o&&(r=new es(t,e,i,o)),this.canvas_=r,this.renderedRevision_=this.getRevision(),r}};var $c=class extends Yc{constructor(t){super({interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.context_=yt(1,1),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.displayDpi_=void 0!==t.displayDpi?t.displayDpi:96,this.params_=t.params||{},this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:Zc,this.hidpi_=void 0===t.hidpi||t.hidpi,this.metersPerUnit_=void 0!==t.metersPerUnit?t.metersPerUnit:1,this.ratio_=void 0!==t.ratio?t.ratio:1,this.useOverlay_=void 0!==t.useOverlay&&t.useOverlay,this.image_=null,this.renderedRevision_=0}getParams(){return this.params_}getImageInternal(t,e,i,n){e=this.findNearestResolution(e),i=this.hidpi_?i:1;let r=this.image_;if(r&&this.renderedRevision_==this.getRevision()&&r.getResolution()==e&&r.getPixelRatio()==i&&re(r.getExtent(),t))return r;1!=this.ratio_&&De(t=t.slice(),this.ratio_);const s=[Me(t)/e*i,Pe(t)/e*i];if(void 0!==this.url_){const o=this.getUrl(this.url_,this.params_,t,s,n);r=new ts(t,e,i,o,this.crossOrigin_,this.imageLoadFunction_,this.context_),r.addEventListener(E,this.handleImageChange.bind(this))}else r=null;return this.image_=r,this.renderedRevision_=this.getRevision(),r}getImageLoadFunction(){return this.imageLoadFunction_}updateParams(t){Object.assign(this.params_,t),this.changed()}getUrl(t,e,i,n,r){const s=function(t,e,i,n){const r=Me(t),s=Pe(t),o=e[0],a=e[1],l=.0254/n;if(a*r>o*s)return r*i/(o*l);return s*i/(a*l)}(i,n,this.metersPerUnit_,this.displayDpi_),o=Te(i),a={OPERATION:this.useOverlay_?"GETDYNAMICMAPOVERLAYIMAGE":"GETMAPIMAGE",VERSION:"2.0.0",LOCALE:"en",CLIENTAGENT:"ol/source/ImageMapGuide source",CLIP:"1",SETDISPLAYDPI:this.displayDpi_,SETDISPLAYWIDTH:Math.round(n[0]),SETDISPLAYHEIGHT:Math.round(n[1]),SETVIEWSCALE:s,SETVIEWCENTERX:o[0],SETVIEWCENTERY:o[1]};return Object.assign(a,e),Kc(t,a)}setImageLoadFunction(t){this.image_=null,this.imageLoadFunction_=t,this.changed()}};var Jc=class extends Yc{constructor(t){const e=void 0!==t.crossOrigin?t.crossOrigin:null,i=void 0!==t.imageLoadFunction?t.imageLoadFunction:Zc;super({attributions:t.attributions,interpolate:t.interpolate,projection:nn(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image_=new ts(this.imageExtent_,void 0,1,this.url_,e,i,yt(1,1)),this.imageSize_=t.imageSize?t.imageSize:null,this.image_.addEventListener(E,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,n){return Ae(t,this.image_.getExtent())?this.image_:null}getUrl(){return this.url_}handleImageChange(t){if(this.image_.getState()==qr){const t=this.image_.getExtent(),e=this.image_.getImage();let i,n;this.imageSize_?(i=this.imageSize_[0],n=this.imageSize_[1]):(i=e.width,n=e.height);const r=Me(t),s=Pe(t),o=r/i,a=s/n;let l=i,h=n;if(o>a?l=Math.round(r/a):h=Math.round(s/o),l!==i||h!==n){const t=yt(l,h);this.getInterpolate()||(t.imageSmoothingEnabled=!1);const r=t.canvas;t.drawImage(e,0,0,i,n,0,0,r.width,r.height),this.image_.setImage(r)}}super.handleImageChange(t)}};const Qc="1.3.0",tu=[101,101];var eu=class extends Yc{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.context_=yt(1,1),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:Zc,this.params_=Object.assign({},t.params),this.v13_=!0,this.updateV13_(),this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.image_=null,this.imageSize_=[0,0],this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5}getFeatureInfoUrl(t,e,i,n){if(void 0===this.url_)return;const r=nn(i),s=this.getProjection();s&&s!==r&&(e=ih(s,r,t,e),t=gn(t,r,s));const o=Re(t,e,0,tu),a={SERVICE:"WMS",VERSION:Qc,REQUEST:"GetFeatureInfo",FORMAT:"image/png",TRANSPARENT:!0,QUERY_LAYERS:this.params_.LAYERS};Object.assign(a,this.params_,n);const l=Ei((t[0]-o[0])/e,4),h=Ei((o[3]-t[1])/e,4);return a[this.v13_?"I":"X"]=l,a[this.v13_?"J":"Y"]=h,this.getRequestUrl_(o,tu,1,s||r,a)}getLegendUrl(t,e){if(void 0===this.url_)return;const i={SERVICE:"WMS",VERSION:Qc,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0===e||void 0===e.LAYER){const t=this.params_.LAYERS;if(!(!Array.isArray(t)||1===t.length))return;i.LAYER=t}if(void 0!==t){const e=this.getProjection()?this.getProjection().getMetersPerUnit():1,n=28e-5;i.SCALE=t*e/n}return Object.assign(i,e),Kc(this.url_,i)}getParams(){return this.params_}getImageInternal(t,e,i,n){if(void 0===this.url_)return null;e=this.findNearestResolution(e),1==i||this.hidpi_&&void 0!==this.serverType_||(i=1);const r=e/i,s=Te(t),o=Ti(Me(t)/r,4),a=Ti(Pe(t)/r,4),l=Re(s,r,0,[o,a]),h=Re(s,r,0,[o+2*Ti((this.ratio_-1)*o/2,4),a+2*Ti((this.ratio_-1)*a/2,4)]),c=this.image_;if(c&&this.renderedRevision_==this.getRevision()&&c.getResolution()==e&&c.getPixelRatio()==i&&re(c.getExtent(),l))return c;const u={SERVICE:"WMS",VERSION:Qc,REQUEST:"GetMap",FORMAT:"image/png",TRANSPARENT:!0};Object.assign(u,this.params_),this.imageSize_[0]=wi(Me(h)/r,4),this.imageSize_[1]=wi(Pe(h)/r,4);const d=this.getRequestUrl_(h,this.imageSize_,i,n,u);return this.image_=new ts(h,e,i,d,this.crossOrigin_,this.imageLoadFunction_,this.context_),this.renderedRevision_=this.getRevision(),this.image_.addEventListener(E,this.handleImageChange.bind(this)),this.image_}getImageLoadFunction(){return this.imageLoadFunction_}getRequestUrl_(t,e,i,n,r){if(Mt(void 0!==this.url_,9),r[this.v13_?"CRS":"SRS"]=n.getCode(),"STYLES"in this.params_||(r.STYLES=""),1!=i)switch(this.serverType_){case"geoserver":const t=90*i+.5|0;"FORMAT_OPTIONS"in r?r.FORMAT_OPTIONS+=";dpi:"+t:r.FORMAT_OPTIONS="dpi:"+t;break;case"mapserver":r.MAP_RESOLUTION=90*i;break;case"carmentaserver":case"qgis":r.DPI=90*i;break;default:Mt(!1,8)}r.WIDTH=e[0],r.HEIGHT=e[1];const s=n.getAxisOrientation();let o;return o=this.v13_&&"ne"==s.substr(0,2)?[t[1],t[0],t[3],t[2]]:t,r.BBOX=o.join(","),Kc(this.url_,r)}getUrl(){return this.url_}setImageLoadFunction(t){this.image_=null,this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.image_=null,this.changed())}updateParams(t){Object.assign(this.params_,t),this.updateV13_(),this.image_=null,this.changed()}updateV13_(){const t=this.params_.VERSION||Qc;this.v13_=Ri(t,"1.3")>=0}};const iu={"image/png":!0,"image/jpeg":!0,"image/gif":!0,"image/webp":!0},nu={"application/vnd.mapbox-vector-tile":!0,"application/geo+json":!0};function ru(t,e){let i,n;for(let r=0;r<t.length;++r){const s=t[r];if("item"===s.rel){if(s.type===e){i=s.href;break}(iu[s.type]||!n&&s.type.startsWith("image/"))&&(n=s.href)}}if(!i){if(!n)throw new Error('Could not find "item" link');i=n}return i}function su(t,e,i){let n,r;const s={};for(let i=0;i<t.length;++i){const o=t[i];if(s[o.type]=o.href,"item"===o.rel){if(o.type===e){n=o.href;break}nu[o.type]&&(r=o.href)}}if(!n&&i)for(let t=0;t<i.length;++t){const e=i[t];if(s[e]){n=s[e];break}}if(!n){if(!r)throw new Error('Could not find "item" link');n=r}return n}function ou(t,e,i,n){let r=t.projection;if(!r&&(r=nn(e.crs),!r))throw new Error(`Unsupported CRS: ${e.crs}`);const s="en"!==r.getAxisOrientation().substr(0,2),o=e.tileMatrices,a={};for(let t=0;t<o.length;++t){const e=o[t];a[e.id]=e}const l={},h=[];if(n)for(let t=0;t<n.length;++t){const e=n[t],i=e.tileMatrix;h.push(i),l[i]=e}else for(let t=0;t<o.length;++t){const e=o[t].id;h.push(e)}const c=h.length,u=new Array(c),d=new Array(c),g=new Array(c),f=new Array(c),p=[-1/0,-1/0,1/0,1/0];for(let t=0;t<c;++t){const e=h[t],i=a[e],n=i.pointOfOrigin;u[t]=s?[n[1],n[0]]:n,d[t]=i.cellSize,g[t]=[i.matrixWidth,i.matrixHeight],f[t]=[i.tileWidth,i.tileHeight];const r=l[e];if(r){const e=i.cellSize*i.tileWidth,n=u[t][0]+r.minTileCol*e,s=u[t][0]+(r.maxTileCol+1)*e,o=i.cellSize*i.tileHeight;let a,l;"bottomLeft"===i.cornerOfOrigin?(a=u[t][1]+r.minTileRow*o,l=u[t][1]+(r.maxTileRow+1)*o):(a=u[t][1]-(r.maxTileRow+1)*o,l=u[t][1]-r.minTileRow*o),Ie(p,[n,a,s,l],p)}}const m=new fh({origins:u,resolutions:d,sizes:g,tileSizes:f,extent:n?p:void 0}),_=t.context,y=t.url;return{grid:m,urlTemplate:i,urlFunction:function(t,e,r){if(!t)return;const s=h[t[0]],o=a[s],c="bottomLeft"===o.cornerOfOrigin,u={tileMatrix:s,tileCol:t[1],tileRow:c?-t[2]-1:t[2]};if(n){const t=l[o.id];if(u.tileCol<t.minTileCol||u.tileCol>t.maxTileCol||u.tileRow<t.minTileRow||u.tileRow>t.maxTileRow)return}Object.assign(u,_);const d=i.replace(/\{(\w+?)\}/g,(function(t,e){return u[e]}));return Ul(y,d)}}}function au(t){return Bl(t.url).then((function(e){return function(t,e){const i=e.tileMatrixSetLimits;let n;if("map"===e.dataType)n=ru(e.links,t.mediaType);else{if("vector"!==e.dataType)throw new Error('Expected tileset data type to be "map" or "vector"');n=su(e.links,t.mediaType,t.supportedMediaTypes)}if(e.tileMatrixSet)return ou(t,e.tileMatrixSet,n,i);const r=e.links.find((t=>"http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme"===t.rel));if(!r)throw new Error("Expected http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme link or tileMatrixSet");const s=r.href;return Bl(Ul(t.url,s)).then((function(e){return ou(t,e,n,i)}))}(t,e)}))}var lu=class extends Mh{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition});au({url:t.url,projection:this.getProjection(),mediaType:t.mediaType,context:t.context||null}).then(this.handleTileSetInfo_.bind(this)).catch(this.handleError_.bind(this))}handleTileSetInfo_(t){this.tileGrid=t.grid,this.setTileUrlFunction(t.urlFunction,t.urlTemplate),this.setState("ready")}handleError_(t){Hi(t),this.setState("error")}};var hu=class extends Fh{constructor(t){const e=t.projection||"EPSG:3857",i=t.extent||Sh(e),n=t.tileGrid||yh({extent:i,maxResolution:t.maxResolution,maxZoom:void 0!==t.maxZoom?t.maxZoom:22,minZoom:t.minZoom,tileSize:t.tileSize||512});super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,interpolate:!0,opaque:!1,projection:e,state:t.state,tileGrid:n,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:cu,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:void 0===t.zDirection?1:t.zDirection}),this.format_=t.format?t.format:null,this.sourceTileCache=new Tl(this.tileCache.highWaterMark),this.overlaps_=null==t.overlaps||t.overlaps,this.tileClass=t.tileClass?t.tileClass:Fl,this.tileGrids_={}}getFeaturesInExtent(t){const e=[],i=this.tileCache;if(0===i.getCount())return e;const n=Sl(i.peekFirstKey())[0],r=this.tileGrid;return i.forEach((function(i){if(i.tileCoord[0]!==n||i.getState()!==tt)return;const s=i.getSourceTiles();for(let i=0,n=s.length;i<n;++i){const n=s[i],o=n.tileCoord;if(Ae(t,r.getTileCoordExtent(o))){const i=n.getFeatures();if(i)for(let n=0,r=i.length;n<r;++n){const r=i[n],s=r.getGeometry();Ae(t,s.getExtent())&&e.push(r)}}}})),e}getOverlaps(){return this.overlaps_}clear(){this.tileCache.clear(),this.sourceTileCache.clear()}expireCache(t,e){const i=this.getTileCacheForProjection(t),n=Object.keys(e).reduce(((t,e)=>{const n=vl(e),r=i.peek(n);if(r){const e=r.sourceTiles;for(let i=0,n=e.length;i<n;++i)t[e[i].getKey()]=!0}return t}),{});super.expireCache(t,e),this.sourceTileCache.expireCache(n)}getSourceTiles(t,e,i){if(i.getState()===J){i.setState(Q);const n=i.wrappedTileCoord,r=this.getTileGridForProjection(e),s=r.getTileCoordExtent(n),o=n[0],a=r.getResolution(o);te(s,-a,s);const l=this.tileGrid,h=l.getExtent();h&&Ie(s,h,s);const c=l.getZForResolution(a,this.zDirection);l.forEachTileCoord(s,c,(n=>{const r=this.tileUrlFunction(n,t,e),s=this.sourceTileCache.containsKey(r)?this.sourceTileCache.get(r):new this.tileClass(n,r?J:it,r,this.format_,this.tileLoadFunction);i.sourceTiles.push(s);const o=s.getState();if(o<tt){const t=e=>{this.handleTileChange(e);const n=s.getState();if(n===tt||n===et){const e=s.getKey();e in i.errorTileKeys?s.getState()===tt&&delete i.errorTileKeys[e]:i.loadingSourceTiles--,n===et?i.errorTileKeys[e]=!0:s.removeEventListener(E,t),0===i.loadingSourceTiles&&i.setState(S(i.errorTileKeys)?tt:et)}};s.addEventListener(E,t),i.loadingSourceTiles++}o===J&&(s.extent=l.getTileCoordExtent(n),s.projection=e,s.resolution=l.getResolution(n[0]),this.sourceTileCache.set(r,s),s.load())})),i.loadingSourceTiles||i.setState(i.sourceTiles.some((t=>t.getState()===et))?et:tt)}return i.sourceTiles}getTile(t,e,i,n,r){const s=yl(t,e,i),o=this.getKey();let a;if(this.tileCache.containsKey(s)&&(a=this.tileCache.get(s),a.key===o))return a;const l=[t,e,i];let h=this.getTileCoordForTileUrlFunction(l,r);const c=this.getTileGrid().getExtent(),u=this.getTileGridForProjection(r);if(h&&c){const e=u.getTileCoordExtent(h);te(e,-u.getResolution(t),e),Ae(c,e)||(h=null)}let d=!0;if(null!==h){const e=this.tileGrid,i=u.getResolution(t),s=e.getZForResolution(i,1),o=u.getTileCoordExtent(h);te(o,-i,o),e.forEachTileCoord(o,s,(t=>{d=d&&!this.tileUrlFunction(t,n,r)}))}const g=new Il(l,d?it:J,h,this.getSourceTiles.bind(this,n,r));return g.key=o,a?(g.interimTile=a,g.refreshInterimChain(),this.tileCache.replace(s,g)):this.tileCache.set(s,g),g}getTileGridForProjection(t){const e=t.getCode();let i=this.tileGrids_[e];if(!i){const t=this.tileGrid,n=t.getResolutions().slice(),r=n.map((function(e,i){return t.getOrigin(i)})),s=n.map((function(e,i){return t.getTileSize(i)})),o=Ds+1;for(let t=n.length;t<o;++t)n.push(n[t-1]/2),r.push(r[t-1]),s.push(s[t-1]);i=new fh({extent:t.getExtent(),origins:r,resolutions:n,tileSizes:s}),this.tileGrids_[e]=i}return i}getTilePixelRatio(t){return t}getTilePixelSize(t,e,i){const n=ol(this.getTileGridForProjection(i).getTileSize(t),this.tmpSize);return[Math.round(n[0]*e),Math.round(n[1]*e)]}updateCacheSize(t,e){super.updateCacheSize(2*t,e),this.sourceTileCache.highWaterMark=this.getTileCacheForProjection(e).highWaterMark}};function cu(t,e){t.setLoader((function(i,n,r){Ol(e,t.getFormat(),i,n,r,t.onLoad.bind(t),t.onError.bind(t))}))}var uu=class extends hu{constructor(t){super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,format:t.format,overlaps:t.overlaps,projection:t.projection,tileClass:t.tileClass,transition:t.transition,wrapX:t.wrapX,zDirection:t.zDirection,state:"loading"});au({url:t.url,projection:this.getProjection(),mediaType:t.mediaType,supportedMediaTypes:t.format.supportedMediaTypes,context:t.context||null}).then(this.handleTileSetInfo_.bind(this)).catch(this.handleError_.bind(this))}handleTileSetInfo_(t){this.tileGrid=t.grid,this.setTileUrlFunction(t.urlFunction,t.urlTemplate),this.setState("ready")}handleError_(t){Hi(t),this.setState("error")}};const du='&#169; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';var gu=class extends Nh{constructor(t){let e;e=void 0!==(t=t||{}).attributions?t.attributions:[du];const i=void 0!==t.crossOrigin?t.crossOrigin:"anonymous",n=void 0!==t.url?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:i,interpolate:t.interpolate,maxZoom:void 0!==t.maxZoom?t.maxZoom:19,opaque:void 0===t.opaque||t.opaque,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:n,wrapX:t.wrapX,zDirection:t.zDirection})}};var fu=class extends no{constructor(t){super(t=t||{})}};var pu=class extends U{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.declutterExecutorGroup=null}getFeatures(t){return z()}getData(t){return null}prepareFrame(t){return z()}renderFrame(t,e){return z()}loadedTileCallback(t,e,i){t[e]||(t[e]={}),t[e][i.tileCoord.toString()]=i}createLoadedTileFinder(t,e,i){return(n,r)=>{const s=this.loadedTileCallback.bind(this,i,n);return t.forEachLoadedTile(e,n,r,s)}}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;e.getState()!==qr&&e.getState()!==$r||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=qr&&e!=$r&&t.addEventListener(E,this.boundHandleImageChange_),e==Kr&&(t.load(),e=t.getState()),e==qr}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}disposeInternal(){delete this.layer_,super.disposeInternal()}};const mu=[];let _u=null;var yu=class extends pu{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=[1,0,0,1,0,0],this.pixelTransform=[1,0,0,1,0,0],this.inversePixelTransform=[1,0,0,1,0,0],this.context=null,this.containerReused=!1,this.pixelContext_=null,this.frameState=null}getImageData(t,e,i){let n;_u||(_u=yt(1,1,void 0,{willReadFrequently:!0})),_u.clearRect(0,0,1,1);try{_u.drawImage(t,e,i,1,1,0,0,1,1),n=_u.getImageData(0,0,1,1).data}catch(t){return _u=null,null}return n}getBackground(t){let e=this.getLayer().getBackground();return"function"==typeof e&&(e=e(t.viewState.resolution)),e||void 0}useContainer(t,e,i){const n=this.getLayer().getClassName();let r,s;if(t&&t.className===n&&(!i||t&&t.style.backgroundColor&&g(hs(t.style.backgroundColor),hs(i)))){const e=t.firstElementChild;e instanceof HTMLCanvasElement&&(s=e.getContext("2d"))}if(s&&s.canvas.style.transform===e?(this.container=t,this.context=s,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=n;let t=r.style;t.position="absolute",t.width="100%",t.height="100%",s=yt();const e=s.canvas;r.appendChild(e),t=e.style,t.position="absolute",t.left="0",t.transformOrigin="top left",this.container=r,this.context=s}this.containerReused||!i||this.container.style.backgroundColor||(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const n=Fe(i),r=Le(i),s=Ee(i),o=we(i);zt(e.coordinateToPixelTransform,n),zt(e.coordinateToPixelTransform,r),zt(e.coordinateToPixelTransform,s),zt(e.coordinateToPixelTransform,o);const a=this.inversePixelTransform;zt(a,n),zt(a,r),zt(a,s),zt(a,o),t.save(),t.beginPath(),t.moveTo(Math.round(n[0]),Math.round(n[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.clip()}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){const r=new oo(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,this.dispatchRenderEvent_(Ps,t,e)}postRender(t,e){this.dispatchRenderEvent_(Is,t,e)}getRenderTransform(t,e,i,n,r,s,o){const a=r/2,l=s/2,h=n/e,c=-h,u=-t[0]+o,d=-t[1];return Yt(this.tempTransform,a,l,h,c,-i,u,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}};var xu=class extends yu{constructor(t){super(t),this.image_=null}getImage(){return this.image_?this.image_.getImage():null}prepareFrame(t){const e=t.layerStatesArray[t.layerIndex],i=t.pixelRatio,n=t.viewState,r=n.resolution,s=this.getLayer().getSource(),o=t.viewHints;let a=t.extent;if(void 0!==e.extent&&(a=Ie(a,Sn(e.extent,n.projection))),!o[As]&&!o[Os]&&!Oe(a))if(s){const t=n.projection,e=s.getImage(a,r,i,t);e&&(this.loadImage(e)?this.image_=e:e.getState()===Jr&&(this.image_=null))}else this.image_=null;return!!this.image_}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=zt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!ne(r,n))return null;const s=this.image_.getExtent(),o=this.getImage(),a=Me(s),l=Math.floor(o.width*((n[0]-s[0])/a));if(l<0||l>=o.width)return null;const h=Pe(s),c=Math.floor(o.height*((s[3]-n[1])/h));return c<0||c>=o.height?null:this.getImageData(o,l,c)}renderFrame(t,e){const i=this.image_,n=i.getExtent(),r=i.getResolution(),s=i.getPixelRatio(),o=t.layerStatesArray[t.layerIndex],a=t.pixelRatio,l=t.viewState,h=l.center,c=a*r/(l.resolution*s),u=t.extent,d=l.resolution,g=l.rotation,f=Math.round(Me(u)/d*a),p=Math.round(Pe(u)/d*a);Yt(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/a,1/a,g,-f/2,-p/2),Kt(this.inversePixelTransform,this.pixelTransform);const m=$t(this.pixelTransform);this.useContainer(e,m,this.getBackground(t));const _=this.context,y=_.canvas;y.width!=f||y.height!=p?(y.width=f,y.height=p):this.containerReused||_.clearRect(0,0,f,p);let x=!1,v=!0;if(o.extent){const e=Sn(o.extent,l.projection);v=Ae(e,t.extent),x=v&&!re(e,t.extent),x&&this.clipUnrotated(_,t,e)}const S=this.getImage(),w=Yt(this.tempTransform,f/2,p/2,c,c,0,s*(n[0]-h[0])/r,s*(h[1]-n[3])/r);this.renderedResolution=r*a/s;const E=S.width*w[0],T=S.height*w[3];if(this.getLayer().getSource().getInterpolate()||(_.imageSmoothingEnabled=!1),this.preRender(_,t),v&&E>=.5&&T>=.5){const t=w[4],e=w[5],i=o.opacity;let n;1!==i&&(n=_.globalAlpha,_.globalAlpha=i),_.drawImage(S,0,0,+S.width,+S.height,t,e,E,T),1!==i&&(_.globalAlpha=n)}return this.postRender(_,t),x&&_.restore(),_.imageSmoothingEnabled=!0,m!==y.style.transform&&(y.style.transform=m),this.container}};var vu=class extends fu{constructor(t){super(t)}createRenderer(){return new xu(this)}getData(t){return super.getData(t)}},Su="preload",wu="useInterimTilesOnError";var Eu=class extends no{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.setPreload(void 0!==t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError)}getPreload(){return this.get(Su)}setPreload(t){this.set(Su,t)}getUseInterimTilesOnError(){return this.get(wu)}setUseInterimTilesOnError(t){this.set(wu,t)}getData(t){return super.getData(t)}};var Tu=class extends yu{constructor(t){super(t),this.extentChanged=!0,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.newTiles_=!1,this.tmpExtent=[1/0,1/0,-1/0,-1/0],this.tmpTileRange_=new bl(0,0,0,0)}isDrawableTile(t){const e=this.getLayer(),i=t.getState(),n=e.getUseInterimTilesOnError();return i==tt||i==it||i==et&&!n}getTile(t,e,i,n){const r=n.pixelRatio,s=n.viewState.projection,o=this.getLayer();let a=o.getSource().getTile(t,e,i,r,s);return a.getState()==et&&o.getUseInterimTilesOnError()&&o.getPreload()>0&&(this.newTiles_=!0),this.isDrawableTile(a)||(a=a.getInterimTile()),a}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=zt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!ne(r,n))return null;const s=e.pixelRatio,o=e.viewState.projection,a=e.viewState,l=i.getRenderSource(),h=l.getTileGridForProjection(a.projection),c=l.getTilePixelRatio(e.pixelRatio);for(let t=h.getZForResolution(a.resolution);t>=h.getMinZoom();--t){const e=h.getTileCoordForCoordAndZ(n,t),i=l.getTile(t,e[1],e[2],s,o);if(!(i instanceof is||i instanceof ah)||i instanceof ah&&i.getState()===it)return null;if(i.getState()!==tt)continue;const r=h.getOrigin(t),u=ol(h.getTileSize(t)),d=h.getResolution(t),g=Math.floor(c*((n[0]-r[0])/d-e[1]*u[0])),f=Math.floor(c*((r[1]-n[1])/d-e[2]*u[1])),p=Math.round(c*l.getGutterForProjection(a.projection));return this.getImageData(i.getImage(),g+p,f+p)}return null}loadedTileCallback(t,e,i){return!!this.isDrawableTile(i)&&super.loadedTileCallback(t,e,i)}prepareFrame(t){return!!this.getLayer().getSource()}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex],n=t.viewState,r=n.projection,s=n.resolution,o=n.center,a=n.rotation,h=t.pixelRatio,c=this.getLayer(),u=c.getSource(),d=u.getRevision(),g=u.getTileGridForProjection(r),f=g.getZForResolution(s,u.zDirection),p=g.getResolution(f);let m=t.extent;const _=t.viewState.resolution,y=u.getTilePixelRatio(h),x=Math.round(Me(m)/_*h),v=Math.round(Pe(m)/_*h),S=i.extent&&Sn(i.extent,r);S&&(m=Ie(m,Sn(i.extent,r)));const w=p*x/2/y,E=p*v/2/y,T=[o[0]-w,o[1]-E,o[0]+w,o[1]+E],C=g.getTileRangeForExtentAndZ(m,f),R={};R[f]={};const b=this.createLoadedTileFinder(u,r,R),P=this.tmpExtent,I=this.tmpTileRange_;this.newTiles_=!1;const F=a?be(n.center,_,a,t.size):void 0;for(let e=C.minX;e<=C.maxX;++e)for(let n=C.minY;n<=C.maxY;++n){if(a&&!g.tileCoordIntersectsViewport([f,e,n],F))continue;const r=this.getTile(f,e,n,t);if(this.isDrawableTile(r)){const e=V(this);if(r.getState()==tt){R[f][r.tileCoord.toString()]=r;let t=r.inTransition(e);t&&1!==i.opacity&&(r.endTransition(e),t=!1),this.newTiles_||!t&&this.renderedTiles.includes(r)||(this.newTiles_=!0)}if(1===r.getAlpha(e,t.time))continue}const s=g.getTileCoordChildTileRange(r.tileCoord,I,P);let o=!1;s&&(o=b(f+1,s)),o||g.forEachTileCoordParentTileRange(r.tileCoord,b,I,P)}const L=p/s*h/y;Yt(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/h,1/h,a,-x/2,-v/2);const M=$t(this.pixelTransform);this.useContainer(e,M,this.getBackground(t));const A=this.context,O=A.canvas;Kt(this.inversePixelTransform,this.pixelTransform),Yt(this.tempTransform,x/2,v/2,L,L,0,-x/2,-v/2),O.width!=x||O.height!=v?(O.width=x,O.height=v):this.containerReused||A.clearRect(0,0,x,v),S&&this.clipUnrotated(A,t,S),u.getInterpolate()||(A.imageSmoothingEnabled=!1),this.preRender(A,t),this.renderedTiles.length=0;let N,D,k,G=Object.keys(R).map(Number);G.sort(l),1!==i.opacity||this.containerReused&&!u.getOpaque(t.viewState.projection)?(N=[],D=[]):G=G.reverse();for(let e=G.length-1;e>=0;--e){const i=G[e],n=u.getTilePixelSize(i,h,r),s=g.getResolution(i)/p,o=n[0]*s*L,a=n[1]*s*L,l=g.getTileCoordForCoordAndZ(Fe(T),i),c=g.getTileCoordExtent(l),d=zt(this.tempTransform,[y*(c[0]-T[0])/p,y*(T[3]-c[3])/p]),m=y*u.getGutterForProjection(r),_=R[i];for(const e in _){const n=_[e],r=n.tileCoord,s=l[1]-r[1],h=Math.round(d[0]-(s-1)*o),c=l[2]-r[2],g=Math.round(d[1]-(c-1)*a),p=Math.round(d[0]-s*o),y=Math.round(d[1]-c*a),x=h-p,v=g-y,S=f===i,w=S&&1!==n.getAlpha(V(this),t.time);let E=!1;if(!w)if(N){k=[p,y,p+x,y,p+x,y+v,p,y+v];for(let t=0,e=N.length;t<e;++t)if(f!==i&&i<D[t]){const e=N[t];Ae([p,y,p+x,y+v],[e[0],e[3],e[4],e[7]])&&(E||(A.save(),E=!0),A.beginPath(),A.moveTo(k[0],k[1]),A.lineTo(k[2],k[3]),A.lineTo(k[4],k[5]),A.lineTo(k[6],k[7]),A.moveTo(e[6],e[7]),A.lineTo(e[4],e[5]),A.lineTo(e[2],e[3]),A.lineTo(e[0],e[1]),A.clip())}N.push(k),D.push(i)}else A.clearRect(p,y,x,v);this.drawTileImage(n,t,p,y,x,v,m,S),N&&!w?(E&&A.restore(),this.renderedTiles.unshift(n)):this.renderedTiles.push(n),this.updateUsedTiles(t.usedTiles,u,n)}}return this.renderedRevision=d,this.renderedResolution=p,this.extentChanged=!this.renderedExtent_||!de(this.renderedExtent_,T),this.renderedExtent_=T,this.renderedPixelRatio=h,this.renderedProjection=r,this.manageTilePyramid(t,u,g,h,r,m,f,c.getPreload()),this.scheduleExpireCache(t,u),this.postRender(A,t),i.extent&&A.restore(),A.imageSmoothingEnabled=!0,M!==O.style.transform&&(O.style.transform=M),this.container}drawTileImage(t,e,i,n,r,s,o,a){const l=this.getTileImage(t);if(!l)return;const h=V(this),c=e.layerStatesArray[e.layerIndex],u=c.opacity*(a?t.getAlpha(h,e.time):1),d=u!==this.context.globalAlpha;d&&(this.context.save(),this.context.globalAlpha=u),this.context.drawImage(l,o,o,l.width-2*o,l.height-2*o,i,n,r,s),d&&this.context.restore(),u!==c.opacity?e.animate=!0:a&&t.endTransition(h)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}scheduleExpireCache(t,e){if(e.canExpireCache()){const i=function(t,e,i){const n=V(t);n in i.usedTiles&&t.expireCache(i.viewState.projection,i.usedTiles[n])}.bind(null,e);t.postRenderFunctions.push(i)}}updateUsedTiles(t,e,i){const n=V(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}manageTilePyramid(t,e,i,n,r,s,o,a,l){const h=V(e);h in t.wantedTiles||(t.wantedTiles[h]={});const c=t.wantedTiles[h],u=t.tileQueue,d=i.getMinZoom(),g=t.viewState.rotation,f=g?be(t.viewState.center,t.viewState.resolution,g,t.size):void 0;let p,m,_,y,x,v,S=0;for(v=d;v<=o;++v)for(m=i.getTileRangeForExtentAndZ(s,v,m),_=i.getResolution(v),y=m.minX;y<=m.maxX;++y)for(x=m.minY;x<=m.maxY;++x)g&&!i.tileCoordIntersectsViewport([v,y,x],f)||(o-v<=a?(++S,p=e.getTile(v,y,x,n,r),p.getState()==J&&(c[p.getKey()]=!0,u.isKeyQueued(p.getKey())||u.enqueue([p,h,i.getTileCoordCenter(p.tileCoord),_])),void 0!==l&&l(p)):e.useTile(v,y,x,r));e.updateCacheSize(S,r)}};var Cu=class extends Eu{constructor(t){super(t)}createRenderer(){return new Tu(this)}};let Ru,bu=!0;try{new ImageData(10,10)}catch(t){bu=!1}function Pu(t,e,i){if(bu)return new ImageData(t,e,i);Ru||(Ru=document.createElement("canvas").getContext("2d"));const n=Ru.createImageData(e,i);return n.data.set(t),n}function Iu(t){let e=!0;try{new ImageData(10,10)}catch(t){e=!1}function i(t,i,n){return e?new ImageData(t,i,n):{data:t,width:i,height:n}}return function(e){const n=e.buffers,r=e.meta,s=e.imageOps,o=e.width,a=e.height,l=n.length,h=n[0].byteLength;if(s){const e=new Array(l);for(let t=0;t<l;++t)e[t]=i(new Uint8ClampedArray(n[t]),o,a);return t(e,r).data.buffer}const c=new Uint8ClampedArray(h),u=new Array(l),d=new Array(l);for(let t=0;t<l;++t)u[t]=new Uint8ClampedArray(n[t]),d[t]=[0,0,0,0];for(let e=0;e<h;e+=4){for(let t=0;t<l;++t){const i=u[t];d[t][0]=i[e],d[t][1]=i[e+1],d[t][2]=i[e+2],d[t][3]=i[e+3]}const i=t(d,r);c[e]=i[0],c[e+1]=i[1],c[e+2]=i[2],c[e+3]=i[3]}return c.buffer}}function Fu(t,e){const i=Object.keys(t.lib||{}).map((function(e){return"const "+e+" = "+t.lib[e].toString()+";"})).concat(["const __minion__ = ("+Iu.toString()+")(",t.operation.toString(),");",'self.addEventListener("message", function(event) {'," const buffer = __minion__(event.data);"," self.postMessage({buffer: buffer, meta: event.data.meta}, [buffer]);","});"]),n=new Worker("undefined"==typeof Blob?"data:text/javascript;base64,"+Buffer.from(i.join("\n"),"binary").toString("base64"):URL.createObjectURL(new Blob(i,{type:"text/javascript"})));return n.addEventListener("message",e),n}class Lu extends o{constructor(t){let e;super(),this._imageOps=!!t.imageOps,e=0===t.threads?0:this._imageOps?1:t.threads||1;const i=new Array(e);if(e)for(let n=0;n<e;++n)i[n]=Fu(t,this._onWorkerMessage.bind(this,n));else i[0]=function(t,e){const i=Iu(t.operation);let n=!1;return{postMessage:function(t){setTimeout((function(){n||e({data:{buffer:i(t),meta:t.meta}})}),0)},terminate:function(){n=!0}}}(t,this._onWorkerMessage.bind(this,0));this._workers=i,this._queue=[],this._maxQueueLength=t.queue||1/0,this._running=0,this._dataLookup={},this._job=null}process(t,e,i){this._enqueue({inputs:t,meta:e,callback:i}),this._dispatch()}_enqueue(t){for(this._queue.push(t);this._queue.length>this._maxQueueLength;)this._queue.shift().callback(null,null)}_dispatch(){if(this._running||0===this._queue.length)return;const t=this._queue.shift();this._job=t;const e=t.inputs[0].width,i=t.inputs[0].height,n=t.inputs.map((function(t){return t.data.buffer})),r=this._workers.length;if(this._running=r,1===r)return void this._workers[0].postMessage({buffers:n,meta:t.meta,imageOps:this._imageOps,width:e,height:i},n);const s=t.inputs[0].data.length,o=4*Math.ceil(s/4/r);for(let s=0;s<r;++s){const r=s*o,a=[];for(let t=0,e=n.length;t<e;++t)a.push(n[t].slice(r,r+o));this._workers[s].postMessage({buffers:a,meta:t.meta,imageOps:this._imageOps,width:e,height:i},a)}}_onWorkerMessage(t,e){this.disposed||(this._dataLookup[t]=e.data,--this._running,0===this._running&&this._resolveJob())}_resolveJob(){const t=this._job,e=this._workers.length;let i,n;if(1===e)i=new Uint8ClampedArray(this._dataLookup[0].buffer),n=this._dataLookup[0].meta;else{const r=t.inputs[0].data.length;i=new Uint8ClampedArray(r),n=new Array(e);const s=4*Math.ceil(r/4/e);for(let t=0;t<e;++t){const e=this._dataLookup[t].buffer,r=t*s;i.set(new Uint8ClampedArray(e),r),n[t]=this._dataLookup[t].meta}}this._job=null,this._dataLookup={},t.callback(null,Pu(i,t.inputs[0].width,t.inputs[0].height),n),this._dispatch()}disposeInternal(){for(let t=0;t<this._workers.length;++t)this._workers[t].terminate();this._workers.length=0}}const Mu="beforeoperations",Au="afteroperations";class Ou extends r{constructor(t,e,i){super(t),this.extent=e.extent,this.resolution=e.viewState.resolution/e.pixelRatio,this.data=i}}class Nu extends Yc{constructor(t){super({projection:null}),this.on,this.once,this.un,this.processor_=null,this.operationType_=void 0!==t.operationType?t.operationType:"pixel",this.threads_=void 0!==t.threads?t.threads:1,this.layers_=function(t){const e=t.length,i=new Array(e);for(let n=0;n<e;++n)i[n]=Gu(t[n]);return i}(t.sources);const e=this.changed.bind(this);for(let t=0,i=this.layers_.length;t<i;++t)this.layers_[t].addEventListener(E,e);var i;this.useResolutions_=null!==t.resolutions,this.tileQueue_=new la((function(){return 1}),this.processSources_.bind(this)),this.requestedFrameState_,this.renderedImageCanvas_=null,this.renderedRevision_,this.frameState_={animate:!1,coordinateToPixelTransform:[1,0,0,1,0,0],declutterTree:null,extent:null,index:0,layerIndex:0,layerStatesArray:(i=this.layers_,i.map((function(t){return t.getLayerState()}))),pixelRatio:1,pixelToCoordinateTransform:[1,0,0,1,0,0],postRenderFunctions:[],size:[0,0],tileQueue:this.tileQueue_,time:Date.now(),usedTiles:{},viewState:{rotation:0},viewHints:[],wantedTiles:{},mapId:V(this),renderTargets:{}},this.setAttributions((function(e){const i=[];for(let n=0,r=t.sources.length;n<r;++n){const r=t.sources[n],s=r instanceof dh?r:r.getSource();if(!s)continue;const o=s.getAttributions();if("function"==typeof o){const t=o(e);i.push.apply(i,t)}}return 0!==i.length?i:null})),void 0!==t.operation&&this.setOperation(t.operation,t.lib)}setOperation(t,e){this.processor_&&this.processor_.dispose(),this.processor_=new Lu({operation:t,imageOps:"image"===this.operationType_,queue:1,lib:e,threads:this.threads_}),this.changed()}updateFrameState_(t,e,i){const n=Object.assign({},this.frameState_);n.viewState=Object.assign({},n.viewState);const r=Te(t);n.size[0]=Math.ceil(Me(t)/e),n.size[1]=Math.ceil(Pe(t)/e),n.extent=[r[0]-n.size[0]*e/2,r[1]-n.size[1]*e/2,r[0]+n.size[0]*e/2,r[1]+n.size[1]*e/2],n.time=Date.now();const s=n.viewState;return s.center=r,s.projection=i,s.resolution=e,n}allSourcesReady_(){let t,e=!0;for(let i=0,n=this.layers_.length;i<n;++i)if(t=this.layers_[i].getSource(),!t||"ready"!==t.getState()){e=!1;break}return e}getImage(t,e,i,n){if(!this.allSourcesReady_())return null;this.tileQueue_.loadMoreTiles(16,16),e=this.findNearestResolution(e);const r=this.updateFrameState_(t,e,n);if(this.requestedFrameState_=r,this.renderedImageCanvas_){const t=this.renderedImageCanvas_.getResolution(),i=this.renderedImageCanvas_.getExtent();e===t&&de(r.extent,i)||(this.renderedImageCanvas_=null)}return this.renderedImageCanvas_&&this.getRevision()===this.renderedRevision_||this.processSources_(),r.animate&&requestAnimationFrame(this.changed.bind(this)),this.renderedImageCanvas_}processSources_(){const t=this.requestedFrameState_,e=this.layers_.length,i=new Array(e);for(let n=0;n<e;++n){t.layerIndex=n,t.renderTargets={};const e=ku(this.layers_[n],t);if(!e)return;i[n]=e}const n={};this.dispatchEvent(new Ou(Mu,t,n)),this.processor_.process(i,n,this.onWorkerComplete_.bind(this,t))}onWorkerComplete_(t,e,i,n){if(e||!i)return;const r=t.extent,s=t.viewState.resolution;if(s!==this.requestedFrameState_.viewState.resolution||!de(r,this.requestedFrameState_.extent))return;let o;if(this.renderedImageCanvas_)o=this.renderedImageCanvas_.getImage().getContext("2d");else{o=yt(Math.round(Me(r)/s),Math.round(Pe(r)/s)),this.renderedImageCanvas_=new es(r,s,1,o.canvas)}o.putImageData(i,0,0),t.animate?requestAnimationFrame(this.changed.bind(this)):this.changed(),this.renderedRevision_=this.getRevision(),this.dispatchEvent(new Ou(Au,t,n))}getResolutions(t){if(!this.useResolutions_)return null;let e=super.getResolutions();if(!e)for(let i=0,n=this.layers_.length;i<n;++i){if(e=this.layers_[i].getSource().getResolutions(t),e)break}return e}disposeInternal(){this.processor_&&this.processor_.dispose(),super.disposeInternal()}}Nu.prototype.dispose;let Du=null;function ku(t,e){const i=t.getRenderer();if(!i)throw new Error("Unsupported layer type: "+t);if(!i.prepareFrame(e))return null;const n=e.size[0],r=e.size[1];if(0===n||0===r)return null;const s=i.renderFrame(e,null);let o;if(s instanceof HTMLCanvasElement)o=s;else{if(s&&(o=s.firstElementChild),!(o instanceof HTMLCanvasElement))throw new Error("Unsupported rendered element: "+o);if(o.width===n&&o.height===r){return o.getContext("2d").getImageData(0,0,n,r)}}if(Du){const t=Du.canvas;t.width!==n||t.height!==r?Du=yt(n,r,void 0,{willReadFrequently:!0}):Du.clearRect(0,0,n,r)}else Du=yt(n,r,void 0,{willReadFrequently:!0});return Du.drawImage(o,0,0,n,r),Du.getImageData(0,0,n,r)}function Gu(t){let e;return t instanceof dh?t instanceof Eh?e=new Cu({source:t}):t instanceof Yc&&(e=new vu({source:t})):e=t,e}var ju=Nu;const Bu=['Map tiles by <a href="https://stamen.com/" target="_blank">Stamen Design</a>, under <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC BY 3.0</a>.',du],Uu={terrain:{extension:"png",opaque:!0},"terrain-background":{extension:"png",opaque:!0},"terrain-labels":{extension:"png",opaque:!1},"terrain-lines":{extension:"png",opaque:!1},"toner-background":{extension:"png",opaque:!0},toner:{extension:"png",opaque:!0},"toner-hybrid":{extension:"png",opaque:!1},"toner-labels":{extension:"png",opaque:!1},"toner-lines":{extension:"png",opaque:!1},"toner-lite":{extension:"png",opaque:!0},watercolor:{extension:"jpg",opaque:!0}},zu={terrain:{minZoom:0,maxZoom:18},toner:{minZoom:0,maxZoom:20},watercolor:{minZoom:0,maxZoom:18}};var Xu=class extends Nh{constructor(t){const e=t.layer.indexOf("-"),i=-1==e?t.layer:t.layer.slice(0,e),n=zu[i],r=Uu[t.layer],s=void 0!==t.url?t.url:"https://stamen-tiles-{a-d}.a.ssl.fastly.net/"+t.layer+"/{z}/{x}/{y}."+r.extension;super({attributions:Bu,cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,maxZoom:null!=t.maxZoom?t.maxZoom:n.maxZoom,minZoom:null!=t.minZoom?t.minZoom:n.minZoom,opaque:r.opaque,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:s,wrapX:t.wrapX,zDirection:t.zDirection})}};var Vu=class extends Mh{constructor(t){super({attributions:(t=t||{}).attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.params_=t.params||{},this.hidpi_=void 0===t.hidpi||t.hidpi,this.tmpExtent_=[1/0,1/0,-1/0,-1/0],this.setKey(this.getKeyForParams_())}getKeyForParams_(){let t=0;const e=[];for(const i in this.params_)e[t++]=i+"-"+this.params_[i];return e.join("/")}getParams(){return this.params_}getRequestUrl_(t,e,i,n,r,s){const o=this.urls;if(!o)return;const a=r.getCode().split(/:(?=\d+$)/).pop();let l;if(s.SIZE=e[0]+","+e[1],s.BBOX=i.join(","),s.BBOXSR=a,s.IMAGESR=a,s.DPI=Math.round(s.DPI?s.DPI*n:90*n),1==o.length)l=o[0];else{l=o[xi(wl(t),o.length)]}return Kc(l.replace(/MapServer\/?$/,"MapServer/export").replace(/ImageServer\/?$/,"ImageServer/exportImage"),s)}getTilePixelRatio(t){return this.hidpi_?t:1}updateParams(t){Object.assign(this.params_,t),this.setKey(this.getKeyForParams_())}tileUrlFunction(t,e,i){let n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(i)),n.getResolutions().length<=t[0])return;1==e||this.hidpi_||(e=1);const r=n.getTileCoordExtent(t,this.tmpExtent_);let s=ol(n.getTileSize(t[0]),this.tmpSize);1!=e&&(s=sl(s,e,this.tmpSize));const o={F:"image",FORMAT:"PNG32",TRANSPARENT:!0};return Object.assign(o,this.params_),this.getRequestUrl_(t,s,r,e,i,o)}};var Wu=class extends Nh{constructor(t){super({opaque:!1,projection:(t=t||{}).projection,tileGrid:t.tileGrid,wrapX:void 0===t.wrapX||t.wrapX,zDirection:t.zDirection,url:t.template||"z:{z} x:{x} y:{y}",tileLoadFunction:(t,e)=>{const i=t.getTileCoord()[0],n=ol(this.tileGrid.getTileSize(i)),r=yt(n[0],n[1]);r.strokeStyle="grey",r.strokeRect(.5,.5,n[0]+.5,n[1]+.5),r.fillStyle="grey",r.strokeStyle="white",r.textAlign="center",r.textBaseline="middle",r.font="24px sans-serif",r.lineWidth=4,r.strokeText(e,n[0]/2,n[1]/2,n[0]),r.fillText(e,n[0]/2,n[1]/2,n[0]),t.setImage(r.canvas)}})}};var Zu=class extends Mh{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:nn("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.tileJSON_=null,this.tileSize_=t.tileSize,t.url)if(t.jsonp)kl(t.url,this.handleTileJSONResponse.bind(this),this.handleTileJSONError.bind(this));else{const e=new XMLHttpRequest;e.addEventListener("load",this.onXHRLoad_.bind(this)),e.addEventListener("error",this.onXHRError_.bind(this)),e.open("GET",t.url),e.send()}else t.tileJSON?this.handleTileJSONResponse(t.tileJSON):Mt(!1,51)}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch(t){return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(t){const e=nn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=un(e,i);n=Ge(t.bounds,r)}const r=Sh(i),s=t.minzoom||0,o=yh({extent:r,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=Ch(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==n?n:r;this.setAttributions((function(i){return Ae(e,i.extent)?[t.attribution]:null}))}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}};var Yu=class extends Mh{constructor(t){t=t||{};const e=Object.assign({},t.params),i=!("TRANSPARENT"in e)||e.TRANSPARENT;super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,opaque:!i,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileClass:t.tileClass,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction,url:t.url,urls:t.urls,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0,this.params_=e,this.v13_=!0,this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.tmpExtent_=[1/0,1/0,-1/0,-1/0],this.updateV13_(),this.setKey(this.getKeyForParams_())}getFeatureInfoUrl(t,e,i,n){const r=nn(i),s=this.getProjection();let o=this.getTileGrid();o||(o=this.getTileGridForProjection(r));const a=o.getZForResolution(e,this.zDirection),l=o.getTileCoordForCoordAndZ(t,a);if(o.getResolutions().length<=l[0])return;let h=o.getResolution(l[0]),c=o.getTileCoordExtent(l,this.tmpExtent_),u=ol(o.getTileSize(l[0]),this.tmpSize);const d=this.gutter_;0!==d&&(u=nl(u,d,this.tmpSize),c=te(c,h*d,c)),s&&s!==r&&(h=ih(s,r,t,h),c=fn(c,r,s),t=gn(t,r,s));const g={SERVICE:"WMS",VERSION:Qc,REQUEST:"GetFeatureInfo",FORMAT:"image/png",TRANSPARENT:!0,QUERY_LAYERS:this.params_.LAYERS};Object.assign(g,this.params_,n);const f=Math.floor((t[0]-c[0])/h),p=Math.floor((c[3]-t[1])/h);return g[this.v13_?"I":"X"]=f,g[this.v13_?"J":"Y"]=p,this.getRequestUrl_(l,u,c,1,s||r,g)}getLegendUrl(t,e){if(void 0===this.urls[0])return;const i={SERVICE:"WMS",VERSION:Qc,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0===e||void 0===e.LAYER){const t=this.params_.LAYERS;if(!(!Array.isArray(t)||1===t.length))return;i.LAYER=t}if(void 0!==t){const e=this.getProjection()?this.getProjection().getMetersPerUnit():1,n=28e-5;i.SCALE=t*e/n}return Object.assign(i,e),Kc(this.urls[0],i)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(t,e,i,n,r,s){const o=this.urls;if(!o)return;if(s.WIDTH=e[0],s.HEIGHT=e[1],s[this.v13_?"CRS":"SRS"]=r.getCode(),"STYLES"in this.params_||(s.STYLES=""),1!=n)switch(this.serverType_){case"geoserver":const t=90*n+.5|0;"FORMAT_OPTIONS"in s?s.FORMAT_OPTIONS+=";dpi:"+t:s.FORMAT_OPTIONS="dpi:"+t;break;case"mapserver":s.MAP_RESOLUTION=90*n;break;case"carmentaserver":case"qgis":s.DPI=90*n;break;default:Mt(!1,52)}const a=r.getAxisOrientation(),l=i;if(this.v13_&&"ne"==a.substr(0,2)){let t;t=i[0],l[0]=i[1],l[1]=t,t=i[2],l[2]=i[3],l[3]=t}let h;if(s.BBOX=l.join(","),1==o.length)h=o[0];else{h=o[xi(wl(t),o.length)]}return Kc(h,s)}getTilePixelRatio(t){return this.hidpi_&&void 0!==this.serverType_?t:1}getKeyForParams_(){let t=0;const e=[];for(const i in this.params_)e[t++]=i+"-"+this.params_[i];return e.join("/")}updateParams(t){Object.assign(this.params_,t),this.updateV13_(),this.setKey(this.getKeyForParams_())}updateV13_(){const t=this.params_.VERSION||Qc;this.v13_=Ri(t,"1.3")>=0}tileUrlFunction(t,e,i){let n=this.getTileGrid();if(n||(n=this.getTileGridForProjection(i)),n.getResolutions().length<=t[0])return;1==e||this.hidpi_&&void 0!==this.serverType_||(e=1);const r=n.getResolution(t[0]);let s=n.getTileCoordExtent(t,this.tmpExtent_),o=ol(n.getTileSize(t[0]),this.tmpSize);const a=this.gutter_;0!==a&&(o=nl(o,a,this.tmpSize),s=te(s,r*a,s)),1!=e&&(o=sl(o,e,this.tmpSize));const l={SERVICE:"WMS",VERSION:Qc,REQUEST:"GetMap",FORMAT:"image/png",TRANSPARENT:!0};return Object.assign(l,this.params_),this.getRequestUrl_(t,o,s,e,i,l)}};class Ku extends at{constructor(t,e,i,n,r,s){super(t,e),this.src_=i,this.extent_=n,this.preemptive_=r,this.grid_=null,this.keys_=null,this.data_=null,this.jsonp_=s}getImage(){return null}getData(t){if(!this.grid_||!this.keys_)return null;const e=(t[0]-this.extent_[0])/(this.extent_[2]-this.extent_[0]),i=(t[1]-this.extent_[1])/(this.extent_[3]-this.extent_[1]),n=this.grid_[Math.floor((1-i)*this.grid_.length)];if("string"!=typeof n)return null;let r=n.charCodeAt(Math.floor(e*n.length));r>=93&&r--,r>=35&&r--,r-=32;let s=null;if(r in this.keys_){const t=this.keys_[r];s=this.data_&&t in this.data_?this.data_[t]:t}return s}forDataAtCoordinate(t,e,i){this.state==it&&!0===i?(this.state=J,k(this,E,(function(i){e(this.getData(t))}),this),this.loadInternal_()):!0===i?setTimeout((()=>{e(this.getData(t))}),0):e(this.getData(t))}getKey(){return this.src_}handleError_(){this.state=et,this.changed()}handleLoad_(t){this.grid_=t.grid,this.keys_=t.keys,this.data_=t.data,this.state=tt,this.changed()}loadInternal_(){if(this.state==J)if(this.state=Q,this.jsonp_)kl(this.src_,this.handleLoad_.bind(this),this.handleError_.bind(this));else{const t=new XMLHttpRequest;t.addEventListener("load",this.onXHRLoad_.bind(this)),t.addEventListener("error",this.onXHRError_.bind(this)),t.open("GET",this.src_),t.send()}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch(t){return void this.handleError_()}this.handleLoad_(t)}else this.handleError_()}onXHRError_(t){this.handleError_()}load(){this.preemptive_?this.loadInternal_():this.setState(it)}}var Hu=class extends Eh{constructor(t){if(super({projection:nn("EPSG:3857"),state:"loading",zDirection:t.zDirection}),this.preemptive_=void 0===t.preemptive||t.preemptive,this.tileUrlFunction_=bh,this.template_=void 0,this.jsonp_=t.jsonp||!1,t.url)if(this.jsonp_)kl(t.url,this.handleTileJSONResponse.bind(this),this.handleTileJSONError.bind(this));else{const e=new XMLHttpRequest;e.addEventListener("load",this.onXHRLoad_.bind(this)),e.addEventListener("error",this.onXHRError_.bind(this)),e.open("GET",t.url),e.send()}else t.tileJSON?this.handleTileJSONResponse(t.tileJSON):Mt(!1,51)}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch(t){return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTemplate(){return this.template_}forDataAtCoordinateAndResolution(t,e,i,n){if(this.tileGrid){const r=this.tileGrid.getZForResolution(e,this.zDirection),s=this.tileGrid.getTileCoordForCoordAndZ(t,r);this.getTile(s[0],s[1],s[2],1,this.getProjection()).forDataAtCoordinate(t,i,n)}else!0===n?setTimeout((function(){i(null)}),0):i(null)}handleTileJSONError(){this.setState("error")}handleTileJSONResponse(t){const e=nn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=un(e,i);n=Ge(t.bounds,r)}const r=Sh(i),s=t.minzoom||0,o=yh({extent:r,maxZoom:t.maxzoom||22,minZoom:s});this.tileGrid=o,this.template_=t.template;const a=t.grids;if(a){if(this.tileUrlFunction_=Ch(a,o),void 0!==t.attribution){const e=void 0!==n?n:r;this.setAttributions((function(i){return Ae(e,i.extent)?[t.attribution]:null}))}this.setState("ready")}else this.setState("error")}getTile(t,e,i,n,r){const s=yl(t,e,i);if(this.tileCache.containsKey(s))return this.tileCache.get(s);const o=[t,e,i],a=this.getTileCoordForTileUrlFunction(o,r),l=this.tileUrlFunction_(a,n,r),h=new Ku(o,void 0!==l?J:it,void 0!==l?l:"",this.tileGrid.getTileCoordExtent(o),this.preemptive_,this.jsonp_);return this.tileCache.set(s,h),h}useTile(t,e,i){const n=yl(t,e,i);this.tileCache.containsKey(n)&&this.tileCache.get(n)}};class qu extends fh{constructor(t){super({extent:t.extent,origin:t.origin,origins:t.origins,resolutions:t.resolutions,tileSize:t.tileSize,tileSizes:t.tileSizes,sizes:t.sizes}),this.matrixIds_=t.matrixIds}getMatrixId(t){return this.matrixIds_[t]}getMatrixIds(){return this.matrixIds_}}var $u=qu;function Ju(t,e,i){const n=[],r=[],s=[],o=[],a=[];i=void 0!==i?i:[];const l="TileMatrix",h="Identifier",c="ScaleDenominator",u="TopLeftCorner",d=nn(t.SupportedCRS),g=d.getMetersPerUnit(),f="ne"==d.getAxisOrientation().substr(0,2);return t[l].sort((function(t,e){return e[c]-t[c]})),t[l].forEach((function(e){let d;if(d=!(i.length>0)||i.find((function(i){return e[h]==i[l]||!e[h].includes(":")&&t[h]+":"+e[h]===i[l]})),d){r.push(e[h]);const t=28e-5*e[c]/g,i=e.TileWidth,l=e.TileHeight;f?s.push([e[u][1],e[u][0]]):s.push(e[u]),n.push(t),o.push(i==l?i:[i,l]),a.push([e.MatrixWidth,e.MatrixHeight])}})),new qu({extent:e,origins:s,resolutions:n,matrixIds:r,tileSizes:o,sizes:a})}var Qu=class extends Mh{constructor(t){const e=void 0!==t.requestEncoding?t.requestEncoding:"KVP",i=t.tileGrid;let n=t.urls;void 0===n&&void 0!==t.url&&(n=Ph(t.url)),super({attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:t.projection,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileClass:t.tileClass,tileGrid:i,tileLoadFunction:t.tileLoadFunction,tilePixelRatio:t.tilePixelRatio,urls:n,wrapX:void 0!==t.wrapX&&t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.version_=void 0!==t.version?t.version:"1.0.0",this.format_=void 0!==t.format?t.format:"image/jpeg",this.dimensions_=void 0!==t.dimensions?t.dimensions:{},this.layer_=t.layer,this.matrixSet_=t.matrixSet,this.style_=t.style,this.requestEncoding_=e,this.setKey(this.getKeyForDimensions_()),n&&n.length>0&&(this.tileUrlFunction=Rh(n.map(this.createFromWMTSTemplate.bind(this))))}setUrls(t){this.urls=t;const e=t.join("\n");this.setTileUrlFunction(Rh(t.map(this.createFromWMTSTemplate.bind(this))),e)}getDimensions(){return this.dimensions_}getFormat(){return this.format_}getLayer(){return this.layer_}getMatrixSet(){return this.matrixSet_}getRequestEncoding(){return this.requestEncoding_}getStyle(){return this.style_}getVersion(){return this.version_}getKeyForDimensions_(){const t=this.urls?this.urls.slice(0):[];for(const e in this.dimensions_)t.push(e+"-"+this.dimensions_[e]);return t.join("/")}updateDimensions(t){Object.assign(this.dimensions_,t),this.setKey(this.getKeyForDimensions_())}createFromWMTSTemplate(t){const e=this.requestEncoding_,i={layer:this.layer_,style:this.style_,tilematrixset:this.matrixSet_};"KVP"==e&&Object.assign(i,{Service:"WMTS",Request:"GetTile",Version:this.version_,Format:this.format_}),t="KVP"==e?Kc(t,i):t.replace(/\{(\w+?)\}/g,(function(t,e){return e.toLowerCase()in i?i[e.toLowerCase()]:t}));const n=this.tileGrid,r=this.dimensions_;return function(i,s,o){if(!i)return;const a={TileMatrix:n.getMatrixId(i[0]),TileCol:i[1],TileRow:i[2]};Object.assign(a,r);let l=t;return l="KVP"==e?Kc(l,a):l.replace(/\{(\w+?)\}/g,(function(t,e){return a[e]})),l}}};const td=34962,ed=34963,id=35044,nd=35048,rd=5126,sd=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function od(t,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!ut},e);const i=sd.length;for(let n=0;n<i;++n)try{const i=t.getContext(sd[n],e);if(i)return i}catch(t){}return null}let ad;const ld="http://www.w3.org/2001/XMLSchema-instance";function hd(t,e){return Ad().createElementNS(t,e)}function cd(t,e){return ud(t,e,[]).join("")}function ud(t,e,i){if(t.nodeType==Node.CDATA_SECTION_NODE||t.nodeType==Node.TEXT_NODE)e?i.push(String(t.nodeValue).replace(/(\r\n|\r|\n)/g,"")):i.push(t.nodeValue);else{let n;for(n=t.firstChild;n;n=n.nextSibling)ud(n,e,i)}return i}function dd(t){return"documentElement"in t}function gd(t,e,i){return t.getAttributeNS(e,i)||""}function fd(t){return(new DOMParser).parseFromString(t,"application/xml")}function pd(t,e){return function(i,n){const r=t.call(void 0!==e?e:this,i,n);if(void 0!==r){d(n[n.length-1],r)}}}function md(t,e){return function(i,n){const r=t.call(void 0!==e?e:this,i,n);if(void 0!==r){n[n.length-1].push(r)}}}function _d(t,e){return function(i,n){const r=t.call(void 0!==e?e:this,i,n);void 0!==r&&(n[n.length-1]=r)}}function yd(t,e,i){return function(n,r){const s=t.call(void 0!==i?i:this,n,r);if(void 0!==s){const t=r[r.length-1],i=void 0!==e?e:n.localName;let o;i in t?o=t[i]:(o=[],t[i]=o),o.push(s)}}}function xd(t,e,i){return function(n,r){const s=t.call(void 0!==i?i:this,n,r);if(void 0!==s){r[r.length-1][void 0!==e?e:n.localName]=s}}}function vd(t,e){return function(i,n,r){t.call(void 0!==e?e:this,i,n,r);r[r.length-1].node.appendChild(i)}}function Sd(t,e){let i,n;return function(e,r,s){if(void 0===i){i={};const r={};r[e.localName]=t,i[e.namespaceURI]=r,n=wd(e.localName)}Pd(i,n,r,s)}}function wd(t,e){return function(i,n,r){const s=n[n.length-1].node;let o=t;void 0===o&&(o=r);return hd(void 0!==e?e:s.namespaceURI,o)}}const Ed=wd();function Td(t,e){const i=e.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=t[e[r]];return n}function Cd(t,e,i){let n,r;for(i=void 0!==i?i:{},n=0,r=t.length;n<r;++n)i[t[n]]=e;return i}function Rd(t,e,i,n){let r;for(r=e.firstElementChild;r;r=r.nextElementSibling){const e=t[r.namespaceURI];if(void 0!==e){const t=e[r.localName];void 0!==t&&t.call(n,r,i)}}}function bd(t,e,i,n,r){return n.push(t),Rd(e,i,n,r),n.pop()}function Pd(t,e,i,n,r,s){const o=(void 0!==r?r:i).length;let a,l;for(let h=0;h<o;++h)a=i[h],void 0!==a&&(l=e.call(void 0!==s?s:this,a,n,void 0!==r?r[h]:void 0),void 0!==l&&t[l.namespaceURI][l.localName].call(s,l,a,n))}function Id(t,e,i,n,r,s,o){return r.push(t),Pd(e,i,n,r,s,o),r.pop()}let Fd,Ld;function Md(){return void 0===Fd&&"undefined"!=typeof XMLSerializer&&(Fd=new XMLSerializer),Fd}function Ad(){return void 0===Ld&&"undefined"!=typeof document&&(Ld=document.implementation.createDocument("","",null)),Ld}var Od=class extends w{constructor(t){super(),this.tile,this.handleTileChange_=this.handleTileChange_.bind(this),this.gutter_=t.gutter||0,this.helper_=t.helper,this.loaded=!1,this.ready=!1}setTile(t){if(t!==this.tile)if(this.tile&&this.tile.removeEventListener(E,this.handleTileChange_),this.tile=t,this.loaded=t.getState()===tt,this.loaded)this.uploadTile();else{if(t instanceof is){const e=t.getImage();e instanceof Image&&!e.crossOrigin&&(e.crossOrigin="anonymous")}t.addEventListener(E,this.handleTileChange_)}}uploadTile(){z()}setReady(){this.ready=!0,this.dispatchEvent(E)}handleTileChange_(){this.tile.getState()===tt&&(this.loaded=!0,this.uploadTile())}disposeInternal(){this.tile.removeEventListener(E,this.handleTileChange_)}};const Nd=id;function Dd(t){switch(t){case td:return Float32Array;case ed:return Uint32Array;default:return Float32Array}}var kd=class{constructor(t,e){this.array=null,this.type=t,Mt(t===td||t===ed,62),this.usage=void 0!==e?e:Nd}ofSize(t){return this.array=new(Dd(this.type))(t),this}fromArray(t){return this.array=Dd(this.type).from(t),this}fromArrayBuffer(t){return this.array=new(Dd(this.type))(t),this}getType(){return this.type}getArray(){return this.array}getUsage(){return this.usage}getSize(){return this.array?this.array.length:0}},Gd="webglcontextlost",jd="webglcontextrestored";var Bd=class{constructor(t){this.gl_=t.webGlContext;const e=this.gl_;this.scaleRatio_=t.scaleRatio||1,this.renderTargetTexture_=e.createTexture(),this.renderTargetTextureSize_=null,this.frameBuffer_=e.createFramebuffer(),this.depthBuffer_=e.createRenderbuffer();const i=e.createShader(e.VERTEX_SHADER);e.shaderSource(i,t.vertexShader||"\n precision mediump float;\n \n attribute vec2 a_position;\n varying vec2 v_texCoord;\n varying vec2 v_screenCoord;\n \n uniform vec2 u_screenSize;\n \n void main() {\n v_texCoord = a_position * 0.5 + 0.5;\n v_screenCoord = v_texCoord * u_screenSize;\n gl_Position = vec4(a_position, 0.0, 1.0);\n }\n"),e.compileShader(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,t.fragmentShader||"\n precision mediump float;\n \n uniform sampler2D u_image;\n uniform float u_opacity;\n \n varying vec2 v_texCoord;\n \n void main() {\n gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;\n }\n"),e.compileShader(n),this.renderTargetProgram_=e.createProgram(),e.attachShader(this.renderTargetProgram_,i),e.attachShader(this.renderTargetProgram_,n),e.linkProgram(this.renderTargetProgram_),this.renderTargetVerticesBuffer_=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,-1,1,1,-1,1]),e.STATIC_DRAW),this.renderTargetAttribLocation_=e.getAttribLocation(this.renderTargetProgram_,"a_position"),this.renderTargetUniformLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_screenSize"),this.renderTargetOpacityLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_opacity"),this.renderTargetTextureLocation_=e.getUniformLocation(this.renderTargetProgram_,"u_image"),this.uniforms_=[],t.uniforms&&Object.keys(t.uniforms).forEach((i=>{this.uniforms_.push({value:t.uniforms[i],location:e.getUniformLocation(this.renderTargetProgram_,i)})}))}getGL(){return this.gl_}init(t){const e=this.getGL(),i=[e.drawingBufferWidth*this.scaleRatio_,e.drawingBufferHeight*this.scaleRatio_];if(e.bindFramebuffer(e.FRAMEBUFFER,this.getFrameBuffer()),e.bindRenderbuffer(e.RENDERBUFFER,this.getDepthBuffer()),e.viewport(0,0,i[0],i[1]),!this.renderTargetTextureSize_||this.renderTargetTextureSize_[0]!==i[0]||this.renderTargetTextureSize_[1]!==i[1]){this.renderTargetTextureSize_=i;const t=0,n=e.RGBA,r=0,s=e.RGBA,o=e.UNSIGNED_BYTE,a=null;e.bindTexture(e.TEXTURE_2D,this.renderTargetTexture_),e.texImage2D(e.TEXTURE_2D,t,n,i[0],i[1],r,s,o,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.renderTargetTexture_,0),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i[0],i[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthBuffer_)}}apply(t,e,i,n){const r=this.getGL(),s=t.size;if(r.bindFramebuffer(r.FRAMEBUFFER,e?e.getFrameBuffer():null),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.renderTargetTexture_),!e){const e=V(r.canvas);if(!t.renderTargets[e]){const i=r.getContextAttributes();i&&i.preserveDrawingBuffer&&(r.clearColor(0,0,0,0),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT)),t.renderTargets[e]=!0}}r.disable(r.DEPTH_TEST),r.enable(r.BLEND),r.blendFunc(r.ONE,r.ONE_MINUS_SRC_ALPHA),r.viewport(0,0,r.drawingBufferWidth,r.drawingBufferHeight),r.bindBuffer(r.ARRAY_BUFFER,this.renderTargetVerticesBuffer_),r.useProgram(this.renderTargetProgram_),r.enableVertexAttribArray(this.renderTargetAttribLocation_),r.vertexAttribPointer(this.renderTargetAttribLocation_,2,r.FLOAT,!1,0,0),r.uniform2f(this.renderTargetUniformLocation_,s[0],s[1]),r.uniform1i(this.renderTargetTextureLocation_,0);const o=t.layerStatesArray[t.layerIndex].opacity;r.uniform1f(this.renderTargetOpacityLocation_,o),this.applyUniforms(t),i&&i(r,t),r.drawArrays(r.TRIANGLES,0,6),n&&n(r,t)}getFrameBuffer(){return this.frameBuffer_}getDepthBuffer(){return this.depthBuffer_}applyUniforms(t){const e=this.getGL();let i,n=1;this.uniforms_.forEach((function(r){if(i="function"==typeof r.value?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof ImageData)r.texture||(r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i instanceof ImageData?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,i.width,i.height,0,e.UNSIGNED_BYTE,new Uint8Array(i.data)):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i),e.uniform1i(r.location,n++);else if(Array.isArray(i))switch(i.length){case 2:return void e.uniform2f(r.location,i[0],i[1]);case 3:return void e.uniform3f(r.location,i[0],i[1],i[2]);case 4:return void e.uniform4f(r.location,i[0],i[1],i[2],i[3]);default:return}else"number"==typeof i&&e.uniform1f(r.location,i)}))}};function Ud(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function zd(t,e){return t[0]=e[0],t[1]=e[1],t[4]=e[2],t[5]=e[3],t[12]=e[4],t[13]=e[5],t}const Xd={PROJECTION_MATRIX:"u_projectionMatrix",OFFSET_SCALE_MATRIX:"u_offsetScaleMatrix",OFFSET_ROTATION_MATRIX:"u_offsetRotateMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},Vd={UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:rd},Wd={};function Zd(t){return"shared/"+t}let Yd=0;function Kd(t){let e=0;for(let i=0;i<t.length;i++){const n=t[i];e+=n.size*Hd(n.type)}return e}function Hd(t){switch(t){case Vd.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Vd.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Vd.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case Vd.FLOAT:default:return Float32Array.BYTES_PER_ELEMENT}}var qd=class extends o{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?Zd(t.canvasCacheKey):function(){const t="unique/"+Yd;return Yd+=1,t}(),this.gl_=function(t){let e=Wd[t];if(!e){const i=document.createElement("canvas");i.width=1,i.height=1,i.style.position="absolute",i.style.left="0",e={users:0,context:od(i)},Wd[t]=e}return e.users+=1,e.context}(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null;const e=this.gl_.canvas;e.addEventListener(Gd,this.boundHandleWebGLContextLost_),e.addEventListener(jd,this.boundHandleWebGLContextRestored_),this.offsetRotateMatrix_=[1,0,0,1,0,0],this.offsetScaleMatrix_=[1,0,0,1,0,0],this.tmpMat4_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.uniformLocationsByProgram_={},this.attribLocationsByProgram_={},this.uniforms_=[],t.uniforms&&this.setUniforms(t.uniforms),this.postProcessPasses_=t.postProcesses?t.postProcesses.map((t=>new Bd({webGlContext:this.gl_,scaleRatio:t.scaleRatio,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms}))):[new Bd({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now()}setUniforms(t){this.uniforms_=[];for(const e in t)this.uniforms_.push({name:e,value:t[e]})}canvasCacheKeyMatches(t){return this.canvasCacheKey_===Zd(t)}getExtension(t){if(t in this.extensionCache_)return this.extensionCache_[t];const e=this.gl_.getExtension(t);return this.extensionCache_[t]=e,e}bindBuffer(t){const e=this.gl_,i=V(t);let n=this.bufferCache_[i];if(!n){n={buffer:t,webGlBuffer:e.createBuffer()},this.bufferCache_[i]=n}e.bindBuffer(t.getType(),n.webGlBuffer)}flushBufferData(t){const e=this.gl_;this.bindBuffer(t),e.bufferData(t.getType(),t.getArray(),t.getUsage())}deleteBuffer(t){const e=this.gl_,i=V(t),n=this.bufferCache_[i];n&&!e.isContextLost()&&e.deleteBuffer(n.webGlBuffer),delete this.bufferCache_[i]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(Gd,this.boundHandleWebGLContextLost_),t.removeEventListener(jd,this.boundHandleWebGLContextRestored_),function(t){const e=Wd[t];if(!e)return;if(e.users-=1,e.users>0)return;const i=e.context,n=i.getExtension("WEBGL_lose_context");n&&n.loseContext();const r=i.canvas;r.width=1,r.height=1,delete Wd[t]}(this.canvasCacheKey_),delete this.gl_}prepareDraw(t,e,i){const n=this.gl_,r=this.getCanvas(),s=t.size,o=t.pixelRatio;r.width===s[0]*o&&r.height===s[1]*o||(r.width=s[0]*o,r.height=s[1]*o,r.style.width=s[0]+"px",r.style.height=s[1]+"px");for(let e=this.postProcessPasses_.length-1;e>=0;e--)this.postProcessPasses_[e].init(t);n.bindTexture(n.TEXTURE_2D,null),n.clearColor(0,0,0,0),n.depthRange(0,1),n.clearDepth(1),n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.ONE,e?n.ZERO:n.ONE_MINUS_SRC_ALPHA),i?(n.enable(n.DEPTH_TEST),n.depthFunc(n.LEQUAL)):n.disable(n.DEPTH_TEST)}bindTexture(t,e,i){const n=this.gl_;n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,t),n.uniform1i(this.getUniformLocation(i),e)}prepareDrawToRenderTarget(t,e,i,n){const r=this.gl_,s=e.getSize();r.bindFramebuffer(r.FRAMEBUFFER,e.getFramebuffer()),r.bindRenderbuffer(r.RENDERBUFFER,e.getDepthbuffer()),r.viewport(0,0,s[0],s[1]),r.bindTexture(r.TEXTURE_2D,e.getTexture()),r.clearColor(0,0,0,0),r.depthRange(0,1),r.clearDepth(1),r.clear(r.COLOR_BUFFER_BIT|r.DEPTH_BUFFER_BIT),r.enable(r.BLEND),r.blendFunc(r.ONE,i?r.ZERO:r.ONE_MINUS_SRC_ALPHA),n?(r.enable(r.DEPTH_TEST),r.depthFunc(r.LEQUAL)):r.disable(r.DEPTH_TEST)}drawElements(t,e){const i=this.gl_;this.getExtension("OES_element_index_uint");const n=i.UNSIGNED_INT,r=e-t,s=4*t;i.drawElements(i.TRIANGLES,r,n,s)}finalizeDraw(t,e,i){for(let n=0,r=this.postProcessPasses_.length;n<r;n++)n===r-1?this.postProcessPasses_[n].apply(t,null,e,i):this.postProcessPasses_[n].apply(t,this.postProcessPasses_[n+1])}getCanvas(){return this.gl_.canvas}getGL(){return this.gl_}applyFrameState(t){const e=t.size,i=t.viewState.rotation,n=t.pixelRatio,r=Gt(this.offsetScaleMatrix_);Vt(r,2/e[0],2/e[1]);const s=Gt(this.offsetRotateMatrix_);0!==i&&Xt(s,-i),this.setUniformMatrixValue(Xd.OFFSET_SCALE_MATRIX,zd(this.tmpMat4_,r)),this.setUniformMatrixValue(Xd.OFFSET_ROTATION_MATRIX,zd(this.tmpMat4_,s)),this.setUniformFloatValue(Xd.TIME,.001*(Date.now()-this.startTime_)),this.setUniformFloatValue(Xd.ZOOM,t.viewState.zoom),this.setUniformFloatValue(Xd.RESOLUTION,t.viewState.resolution),this.setUniformFloatValue(Xd.PIXEL_RATIO,n),this.setUniformFloatVec2(Xd.VIEWPORT_SIZE_PX,[e[0],e[1]])}applyHitDetectionUniform(t){const e=this.getUniformLocation(Xd.HIT_DETECTION);this.getGL().uniform1i(e,t?1:0)}applyUniforms(t){const e=this.gl_;let i,n=0;this.uniforms_.forEach((r=>{if(i="function"==typeof r.value?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData){r.texture||(r.prevValue=void 0,r.texture=e.createTexture()),e.activeTexture(e[`TEXTURE${n}`]),e.bindTexture(e.TEXTURE_2D,r.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);(!(i instanceof HTMLImageElement)||i.complete)&&r.prevValue!==i&&(r.prevValue=i,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i)),e.uniform1i(this.getUniformLocation(r.name),n++)}else if(Array.isArray(i)&&6===i.length)this.setUniformMatrixValue(r.name,zd(this.tmpMat4_,i));else if(Array.isArray(i)&&i.length<=4)switch(i.length){case 2:return void e.uniform2f(this.getUniformLocation(r.name),i[0],i[1]);case 3:return void e.uniform3f(this.getUniformLocation(r.name),i[0],i[1],i[2]);case 4:return void e.uniform4f(this.getUniformLocation(r.name),i[0],i[1],i[2],i[3]);default:return}else"number"==typeof i&&e.uniform1f(this.getUniformLocation(r.name),i)}))}useProgram(t,e){this.gl_.useProgram(t),this.currentProgram_=t,this.applyFrameState(e),this.applyUniforms(e)}compileShader(t,e){const i=this.gl_,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}getProgram(t,e){const i=this.gl_,n=this.compileShader(t,i.FRAGMENT_SHADER),r=this.compileShader(e,i.VERTEX_SHADER),s=i.createProgram();if(i.attachShader(s,n),i.attachShader(s,r),i.linkProgram(s),!i.getShaderParameter(n,i.COMPILE_STATUS)){const t=`Fragment shader compilation failed: ${i.getShaderInfoLog(n)}`;throw new Error(t)}if(i.deleteShader(n),!i.getShaderParameter(r,i.COMPILE_STATUS)){const t=`Vertex shader compilation failed: ${i.getShaderInfoLog(r)}`;throw new Error(t)}if(i.deleteShader(r),!i.getProgramParameter(s,i.LINK_STATUS)){const t=`GL program linking failed: ${i.getProgramInfoLog(s)}`;throw new Error(t)}return s}getUniformLocation(t){const e=V(this.currentProgram_);return void 0===this.uniformLocationsByProgram_[e]&&(this.uniformLocationsByProgram_[e]={}),void 0===this.uniformLocationsByProgram_[e][t]&&(this.uniformLocationsByProgram_[e][t]=this.gl_.getUniformLocation(this.currentProgram_,t)),this.uniformLocationsByProgram_[e][t]}getAttributeLocation(t){const e=V(this.currentProgram_);return void 0===this.attribLocationsByProgram_[e]&&(this.attribLocationsByProgram_[e]={}),void 0===this.attribLocationsByProgram_[e][t]&&(this.attribLocationsByProgram_[e][t]=this.gl_.getAttribLocation(this.currentProgram_,t)),this.attribLocationsByProgram_[e][t]}makeProjectionTransform(t,e){const i=t.size,n=t.viewState.rotation,r=t.viewState.resolution,s=t.viewState.center;return Yt(e,0,0,2/(r*i[0]),2/(r*i[1]),-n,-s[0],-s[1]),e}setUniformFloatValue(t,e){this.gl_.uniform1f(this.getUniformLocation(t),e)}setUniformFloatVec2(t,e){this.gl_.uniform2fv(this.getUniformLocation(t),e)}setUniformFloatVec4(t,e){this.gl_.uniform4fv(this.getUniformLocation(t),e)}setUniformMatrixValue(t,e){this.gl_.uniformMatrix4fv(this.getUniformLocation(t),!1,e)}enableAttributeArray_(t,e,i,n,r){const s=this.getAttributeLocation(t);s<0||(this.gl_.enableVertexAttribArray(s),this.gl_.vertexAttribPointer(s,e,i,!1,n,r))}enableAttributes(t){const e=Kd(t);let i=0;for(let n=0;n<t.length;n++){const r=t[n];this.enableAttributeArray_(r.name,r.size,r.type||rd,e,i),i+=r.size*Hd(r.type)}}handleWebGLContextLost(){v(this.bufferCache_),this.currentProgram_=null}handleWebGLContextRestored(){}createTexture(t,e,i){const n=this.gl_;i=i||n.createTexture();const r=n.RGBA,s=n.RGBA,o=n.UNSIGNED_BYTE;return n.bindTexture(n.TEXTURE_2D,i),e?n.texImage2D(n.TEXTURE_2D,0,r,s,o,e):n.texImage2D(n.TEXTURE_2D,0,r,t[0],t[1],0,s,o,null),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),i}};var $d=class{constructor(t,e){this.name=t,this.data=e,this.texture_=null}getTexture(t){if(!this.texture_){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,this.data.length/4,1,0,t.RGBA,t.UNSIGNED_BYTE,this.data),this.texture_=e}return this.texture_}};const Jd=new Uint8Array(4);var Qd=class{constructor(t,e){this.helper_=t;const i=t.getGL();this.texture_=i.createTexture(),this.framebuffer_=i.createFramebuffer(),this.depthbuffer_=i.createRenderbuffer(),this.size_=e||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(t){g(t,this.size_)||(this.size_[0]=t[0],this.size_[1]=t[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const t=this.size_,e=this.helper_.getGL();e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.readPixels(0,0,t[0],t[1],e.RGBA,e.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(t,e){if(t<0||e<0||t>this.size_[0]||e>=this.size_[1])return Jd[0]=0,Jd[1]=0,Jd[2]=0,Jd[3]=0,Jd;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return Jd[0]=this.data_[4*i],Jd[1]=this.data_[4*i+1],Jd[2]=this.data_[4*i+2],Jd[3]=this.data_[4*i+3],Jd}getTexture(){return this.texture_}getFramebuffer(){return this.framebuffer_}getDepthbuffer(){return this.depthbuffer_}updateSize_(){const t=this.size_,e=this.helper_.getGL();this.texture_=this.helper_.createTexture(t,null,this.texture_),e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.viewport(0,0,t[0],t[1]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture_,0),e.bindRenderbuffer(e.RENDERBUFFER,this.depthbuffer_),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t[0],t[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,this.depthbuffer_),this.data_=new Uint8Array(t[0]*t[1]*4)}};function tg(t,e,i){const n=i?t.LINEAR:t.NEAREST;t.bindTexture(t.TEXTURE_2D,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n)}function eg(t,e,i,n,r,s){const o=t.getGL();let a,l;if(i instanceof Float32Array){a=o.FLOAT,t.getExtension("OES_texture_float");l=null!==t.getExtension("OES_texture_float_linear")}else a=o.UNSIGNED_BYTE,l=!0;tg(o,e,s&&l);const h=i.byteLength/n[1];let c,u=1;switch(h%8==0?u=8:h%4==0?u=4:h%2==0&&(u=2),r){case 1:c=o.LUMINANCE;break;case 2:c=o.LUMINANCE_ALPHA;break;case 3:c=o.RGB;break;case 4:c=o.RGBA;break;default:throw new Error(`Unsupported number of bands: ${r}`)}const d=o.getParameter(o.UNPACK_ALIGNMENT);o.pixelStorei(o.UNPACK_ALIGNMENT,u),o.texImage2D(o.TEXTURE_2D,0,c,n[0],n[1],0,c,a,i),o.pixelStorei(o.UNPACK_ALIGNMENT,d)}let ig=null;var ng=class extends Od{constructor(t){super(t),this.textures=[],this.renderSize_=ol(t.grid.getTileSize(t.tile.tileCoord[0])),this.bandCount=NaN;const e=new kd(td,id);e.fromArray([0,1,1,1,1,0,0,0]),this.helper_.flushBufferData(e),this.coords=e,this.setTile(t.tile)}uploadTile(){const t=this.helper_,e=t.getGL(),i=this.tile;let n;this.textures.length=0,n=i instanceof is||i instanceof ah?i.getImage():i.getData();const r=Rt(n);if(r){const t=e.createTexture();return this.textures.push(t),this.bandCount=4,function(t,e,i,n){tg(t,e,n),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i)}(e,t,r,i.interpolate),void this.setReady()}n=bt(n);const s=i.getSize(),o=[s[0]+2*this.gutter_,s[1]+2*this.gutter_],a=n instanceof Float32Array,l=o[0]*o[1],h=a?Float32Array:Uint8Array,c=h.BYTES_PER_ELEMENT,u=n.byteLength/o[1];this.bandCount=Math.floor(u/c/o[0]);const d=Math.ceil(this.bandCount/4);if(1===d){const r=e.createTexture();return this.textures.push(r),eg(t,r,n,o,this.bandCount,i.interpolate),void this.setReady()}const g=new Array(d);for(let t=0;t<d;++t){const i=e.createTexture();this.textures.push(i);const n=t<d-1?4:(this.bandCount-1)%4+1;g[t]=new h(l*n)}let f=0,p=0;const m=o[0]*this.bandCount;for(let t=0;t<o[1];++t){for(let t=0;t<m;++t){const e=n[p+t],i=Math.floor(f/this.bandCount),r=t%this.bandCount,s=g[Math.floor(r/4)];s[i*(s.length/l)+r%4]=e,++f}p+=u/c}for(let e=0;e<d;++e){const n=this.textures[e],r=g[e];eg(t,n,r,o,r.length/l,i.interpolate)}this.setReady()}disposeInternal(){const t=this.helper_.getGL();this.helper_.deleteBuffer(this.coords);for(let e=0;e<this.textures.length;++e)t.deleteTexture(this.textures[e]);this.tile.removeEventListener(E,this.handleTileChange_)}getImagePixelData_(t,e,i){const n=this.gutter_,r=this.renderSize_[0],s=this.renderSize_[1];ig||(ig=yt(1,1,void 0,{willReadFrequently:!0})),ig.clearRect(0,0,1,1);const o=t.width-2*n,a=t.height-2*n,l=n+Math.floor(o*(e/r)),h=n+Math.floor(a*(i/s));let c;try{ig.drawImage(t,l,h,1,1,0,0,1,1),c=ig.getImageData(0,0,1,1).data}catch(t){return ig=null,null}return c}getArrayPixelData_(t,e,i,n){const r=this.gutter_,s=this.renderSize_[0],o=this.renderSize_[1],a=e[0],l=e[1],h=a+2*r,c=l+2*r,u=r+Math.floor(a*(i/s)),d=r+Math.floor(l*(n/o));if(t instanceof DataView){const e=t.byteLength/(h*c),i=e*(d*h+u),n=t.buffer.slice(i,i+e);return new DataView(n)}const g=this.bandCount*(d*h+u);return t.slice(g,g+this.bandCount)}getPixelData(t,e){if(!this.loaded)return null;if(this.tile instanceof Lt){const i=this.tile.getData(),n=bt(i);if(n){const i=this.tile.getSize();return this.getArrayPixelData_(n,i,t,e)}return this.getImagePixelData_(Rt(i),t,e)}return this.getImagePixelData_(this.tile.getImage(),t,e)}};class rg extends pu{constructor(t,e){super(t),e=e||{},this.inversePixelTransform_=[1,0,0,1,0,0],this.pixelContext_=null,this.postProcesses_=e.postProcesses,this.uniforms_=e.uniforms,this.helper,t.addChangeListener(Rs,this.removeHelper.bind(this)),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Fs)){const n=new oo(Fs,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Ls)){const n=new oo(Ls,void 0,e,t);i.dispatchEvent(n)}}reset(t){this.uniforms_=t.uniforms,this.helper&&this.helper.setUniforms(this.uniforms_)}removeHelper(){this.helper&&(this.helper.dispose(),delete this.helper)}prepareFrame(t){if(this.getLayer().getRenderSource()){let e,i=!0,n=-1;for(let r=0,s=t.layerStatesArray.length;r<s;r++){const s=t.layerStatesArray[r].layer,o=s.getRenderer();if(!(o instanceof rg)){i=!0;continue}const a=s.getClassName();if((i||a!==e)&&(n+=1,i=!1),e=a,o===this)break}const r="map/"+t.mapId+"/group/"+n;this.helper&&this.helper.canvasCacheKeyMatches(r)||(this.removeHelper(),this.helper=new qd({postProcesses:this.postProcesses_,uniforms:this.uniforms_,canvasCacheKey:r}),e&&(this.helper.getCanvas().className=e),this.afterHelperCreated())}return this.prepareFrameInternal(t)}afterHelperCreated(){}prepareFrameInternal(t){return!0}disposeInternal(){this.removeHelper(),super.disposeInternal()}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){Yt(this.inversePixelTransform_,0,0,i.pixelRatio,-i.pixelRatio,0,0,-i.size[1]);const r=new oo(t,this.inversePixelTransform_,i,e);n.dispatchEvent(r)}}preRender(t,e){this.dispatchRenderEvent_(Ps,t,e)}postRender(t,e){this.dispatchRenderEvent_(Is,t,e)}}var sg=rg;const og={TILE_TRANSFORM:"u_tileTransform",TRANSITION_ALPHA:"u_transitionAlpha",DEPTH:"u_depth",RENDER_EXTENT:"u_renderExtent",RESOLUTION:"u_resolution",ZOOM:"u_zoom",GLOBAL_ALPHA:"u_globalAlpha",PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix"},ag={};function lg(){return{tileIds:new Set,representationsByZ:{}}}function hg(t,e){return t.tileIds.has(V(e))}function cg(t,e,i){const n=t.representationsByZ;i in n||(n[i]=new Set),n[i].add(e),t.tileIds.add(V(e.tile))}function ug(t,e){const i=t.layerStatesArray[t.layerIndex];i.extent&&(e=Ie(e,Sn(i.extent,t.viewState.projection)));const n=i.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(t.viewState.projection).getExtent();i&&(e=Ie(e,i))}return e}function dg(t,e){return`${t.getKey()},${xl(e)}`}var gg=class extends sg{constructor(t,e){super(t,{uniforms:e.uniforms,postProcesses:e.postProcesses}),this.renderComplete=!1,this.tileTransform_=[1,0,0,1,0,0],this.tempMat4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.tempTileRange_=new bl(0,0,0,0),this.tempTileCoord_=_l(0,0,0),this.tempSize_=[0,0];const i=void 0!==e.cacheSize?e.cacheSize:512;this.tileRepresentationCache=new ml(i),this.frameState=null,this.projection_=void 0}reset(t){super.reset({uniforms:t.uniforms})}isDrawableTile_(t){const e=this.getLayer(),i=t.getState(),n=e.getUseInterimTilesOnError();return i==tt||i==it||i==et&&!n}prepareFrameInternal(t){this.projection_?t.viewState.projection!==this.projection_&&(this.clearCache(),this.projection_=t.viewState.projection):this.projection_=t.viewState.projection;const e=this.getLayer().getRenderSource();return!!e&&(!Oe(ug(t,t.extent))&&"ready"===e.getState())}createTileRepresentation(t){return z()}enqueueTiles(t,e,i,n,r){const s=t.viewState,o=this.getLayer(),a=o.getRenderSource(),l=a.getTileGridForProjection(s.projection),h=a.getGutterForProjection(s.projection),c=V(a);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],d=this.tileRepresentationCache,g=o.getMapInternal(),f=Math.max(i-r,l.getMinZoom(),l.getZForResolution(Math.min(o.getMaxResolution(),g?g.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):l.getResolution(0)),a.zDirection));for(let r=i;r>=f;--r){const i=l.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),o=l.getResolution(r);for(let e=i.minX;e<=i.maxX;++e)for(let g=i.minY;g<=i.maxY;++g){const i=_l(r,e,g,this.tempTileCoord_),f=dg(a,i);let p,m;if(d.containsKey(f)&&(p=d.get(f),m=p.tile),p&&p.tile.key===a.getKey()||(m=a.getTile(r,e,g,t.pixelRatio,s.projection)),hg(n,m))continue;if(p)if(this.isDrawableTile_(m))p.setTile(m);else{const t=m.getInterimTile();p.setTile(t)}else p=this.createTileRepresentation({tile:m,grid:l,helper:this.helper,gutter:h}),d.set(f,p);cg(n,p,r);const _=m.getKey();u[_]=!0,m.getState()===J&&(t.tileQueue.isKeyQueued(_)||t.tileQueue.enqueue([m,c,l.getTileCoordCenter(i),o]))}}}beforeTilesRender(t,e){this.helper.prepareDraw(this.frameState,!e,!0)}renderTile(t,e,i,n,r,s,o,a,l,h,c){}drawTile_(t,e,i,n,r,s,o){if(!e.loaded)return;const a=e.tile.tileCoord,l=xl(a),h=l in s?s[l]:1,c=o.getResolution(i),u=ol(o.getTileSize(i),this.tempSize_),d=o.getOrigin(i),g=o.getTileCoordExtent(a),f=h<1?-1:1/(i+2);h<1&&(t.animate=!0);const p=t.viewState,m=p.center[0],_=p.center[1],y=u[0]+2*n,x=u[1]+2*n,v=y/x,S=(m-d[0])/(u[0]*c),w=(d[1]-_)/(u[1]*c),E=p.resolution/c,T=a[1],C=a[2];Gt(this.tileTransform_),Vt(this.tileTransform_,2/(t.size[0]*E/y),-2/(t.size[1]*E/y)),Xt(this.tileTransform_,p.rotation),Vt(this.tileTransform_,1,1/v),Zt(this.tileTransform_,(u[0]*(T-S)-n)/y,(u[1]*(C-w)-n)/x),this.renderTile(e,this.tileTransform_,t,r,c,u,d,g,f,n,h)}renderFrame(t){this.frameState=t,this.renderComplete=!0;const e=this.helper.getGL();this.preRender(e,t);const i=t.viewState,n=this.getLayer(),r=n.getRenderSource(),s=r.getTileGridForProjection(i.projection),o=r.getGutterForProjection(i.projection),a=ug(t,t.extent),l=s.getZForResolution(i.resolution,r.zDirection),c=lg(),u=n.getPreload();if(t.nextExtent){const e=s.getZForResolution(i.nextResolution,r.zDirection),n=ug(t,t.nextExtent);this.enqueueTiles(t,n,e,c,u)}this.enqueueTiles(t,a,l,c,0),u>0&&setTimeout((()=>{this.enqueueTiles(t,a,l-1,c,u-1)}),0);const d={},g=V(this),f=t.time;let p=!1;for(const t of c.representationsByZ[l]){const e=t.tile;if((e instanceof ah||e instanceof dc)&&e.getState()===it)continue;const i=e.tileCoord;if(t.loaded){const t=e.getAlpha(g,f);if(1===t){e.endTransition(g);continue}p=!0;d[xl(i)]=t}this.renderComplete=!1;if(this.findAltTiles_(s,i,l+1,c))continue;const n=s.getMinZoom();for(let t=l-1;t>=n;--t){if(this.findAltTiles_(s,i,t,c))break}}this.beforeTilesRender(t,p);const m=c.representationsByZ,_=Object.keys(m).map(Number).sort(h);for(let e=0,i=_.length;e<i;++e){const i=_[e];for(const e of m[i]){xl(e.tile.tileCoord)in d||this.drawTile_(t,e,i,o,a,d,s)}}for(const e of m[l]){xl(e.tile.tileCoord)in d&&this.drawTile_(t,e,l,o,a,d,s)}this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const y=this.helper.getCanvas(),x=this.tileRepresentationCache;for(;x.canExpireCache();){x.pop().dispose()}return t.postRenderFunctions.push((function(t,e){r.updateCacheSize(.1,e.viewState.projection),r.expireCache(e.viewState.projection,ag)})),this.postRender(e,t),y}findAltTiles_(t,e,i,n){const r=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!r)return!1;let s=!0;const o=this.tileRepresentationCache,a=this.getLayer().getRenderSource();for(let t=r.minX;t<=r.maxX;++t)for(let e=r.minY;e<=r.maxY;++e){const r=dg(a,[i,t,e]);let l=!1;if(o.containsKey(r)){const t=o.get(r);t.loaded&&!hg(n,t.tile)&&(cg(n,t,i),l=!0)}l||(s=!1)}return s}clearCache(){const t=this.tileRepresentationCache;t.forEach((t=>t.dispose())),t.clear()}removeHelper(){this.helper&&this.clearCache(),super.removeHelper()}disposeInternal(){super.disposeInternal(),delete this.frameState}};const fg={...og,TILE_TEXTURE_ARRAY:"u_tileTextures",TEXTURE_PIXEL_WIDTH:"u_texturePixelWidth",TEXTURE_PIXEL_HEIGHT:"u_texturePixelHeight",TEXTURE_RESOLUTION:"u_textureResolution",TEXTURE_ORIGIN_X:"u_textureOriginX",TEXTURE_ORIGIN_Y:"u_textureOriginY"},pg={TEXTURE_COORD:"a_textureCoord"},mg=[{name:pg.TEXTURE_COORD,size:2,type:Vd.FLOAT}];var _g=class extends gg{constructor(t,e){super(t,e),this.program_,this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.indices_=new kd(ed,id),this.indices_.fromArray([0,1,3,1,2,3]),this.paletteTextures_=e.paletteTextures||[]}reset(t){super.reset(t),this.vertexShader_=t.vertexShader,this.fragmentShader_=t.fragmentShader,this.helper&&(this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_))}afterHelperCreated(){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.helper.flushBufferData(this.indices_)}createTileRepresentation(t){return new ng(t)}beforeTilesRender(t,e){super.beforeTilesRender(t,e),this.helper.useProgram(this.program_,t)}renderTile(t,e,i,n,r,s,o,a,l,h,c){const u=this.helper.getGL();this.helper.bindBuffer(t.coords),this.helper.bindBuffer(this.indices_),this.helper.enableAttributes(mg);let d=0;for(;d<t.textures.length;){const e=`${fg.TILE_TEXTURE_ARRAY}[${d}]`;this.helper.bindTexture(t.textures[d],d,e),++d}for(let t=0;t<this.paletteTextures_.length;++t){const e=this.paletteTextures_[t],i=e.getTexture(u);this.helper.bindTexture(i,d,e.name),++d}const g=i.viewState,f=s[0]+2*h,p=s[1]+2*h,m=t.tile.tileCoord,_=m[1],y=m[2];this.helper.setUniformMatrixValue(fg.TILE_TRANSFORM,zd(this.tempMat4,e)),this.helper.setUniformFloatValue(fg.TRANSITION_ALPHA,c),this.helper.setUniformFloatValue(fg.DEPTH,l);let x=n;h>0&&(x=a,Ie(x,n,x)),this.helper.setUniformFloatVec4(fg.RENDER_EXTENT,x),this.helper.setUniformFloatValue(fg.RESOLUTION,g.resolution),this.helper.setUniformFloatValue(fg.ZOOM,g.zoom),this.helper.setUniformFloatValue(fg.TEXTURE_PIXEL_WIDTH,f),this.helper.setUniformFloatValue(fg.TEXTURE_PIXEL_HEIGHT,p),this.helper.setUniformFloatValue(fg.TEXTURE_RESOLUTION,r),this.helper.setUniformFloatValue(fg.TEXTURE_ORIGIN_X,o[0]+_*s[0]*r-h*r),this.helper.setUniformFloatValue(fg.TEXTURE_ORIGIN_Y,o[1]-y*s[1]*r+h*r),this.helper.drawElements(0,this.indices_.getSize())}getData(t){if(!this.helper.getGL())return null;const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=zt(e.pixelToCoordinateTransform,t.slice()),r=e.viewState,s=i.getExtent();if(s&&!ne(Sn(s,r.projection),n))return null;const o=i.getSources(Qt([n]),r.resolution);let a,l,h;for(a=o.length-1;a>=0;--a)if(l=o[a],"ready"===l.getState()){if(h=l.getTileGridForProjection(r.projection),l.getWrapX())break;const t=h.getExtent();if(!t||ne(t,n))break}if(a<0)return null;const c=this.tileRepresentationCache;for(let t=h.getZForResolution(r.resolution);t>=h.getMinZoom();--t){const e=h.getTileCoordForCoordAndZ(n,t),i=dg(l,e);if(!c.containsKey(i))continue;const r=c.get(i),s=r.tile;if((s instanceof ah||s instanceof dc)&&s.getState()===it)return null;if(!r.loaded)continue;const o=h.getOrigin(t),a=ol(h.getTileSize(t)),u=h.getResolution(t),d=(n[0]-o[0])/u-e[1]*a[0],g=(o[1]-n[1])/u-e[2]*a[1];return r.getPixelData(d,g)}return null}disposeInternal(){const t=this.helper;if(t){t.getGL().deleteProgram(this.program_),delete this.program_,t.deleteBuffer(this.indices_)}super.disposeInternal(),delete this.indices_}};const yg={NUMBER:1,STRING:2,COLOR:4,BOOLEAN:8,NUMBER_ARRAY:16,ANY:31,NONE:0};const xg={};function vg(t){if("number"==typeof t)return yg.NUMBER;if("boolean"==typeof t)return yg.BOOLEAN;if("string"==typeof t)return ds(t)?yg.COLOR|yg.STRING:yg.STRING;if(!Array.isArray(t))throw new Error(`Unhandled value type: ${JSON.stringify(t)}`);const e=t;if(e.every((function(t){return"number"==typeof t})))return 3===e.length||4===e.length?yg.COLOR|yg.NUMBER_ARRAY:yg.NUMBER_ARRAY;if("string"!=typeof e[0])throw new Error(`Expected an expression operator but received: ${JSON.stringify(e)}`);const i=xg[e[0]];if(void 0===i)throw new Error(`Unrecognized expression operator: ${JSON.stringify(e)}`);return i.getReturnType(e.slice(1))}function Sg(t){return Math.log2(t)%1==0}function wg(t){const e=[];return(t&yg.NUMBER)>0&&e.push("number"),(t&yg.COLOR)>0&&e.push("color"),(t&yg.BOOLEAN)>0&&e.push("boolean"),(t&yg.NUMBER_ARRAY)>0&&e.push("number[]"),(t&yg.STRING)>0&&e.push("string"),e.length>0?e.join(", "):"(no type)"}function Eg(t){const e=t.toString();return e.includes(".")?e:e+".0"}function Tg(t){if(t.length<2||t.length>4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${t.length}(${t.map(Eg).join(", ")})`}function Cg(t){const e=hs(t),i=e.length>3?e[3]:1;return Tg([e[0]/255*i,e[1]/255*i,e[2]/255*i,i])}function Rg(t,e){return void 0===t.stringLiteralsMap[e]&&(t.stringLiteralsMap[e]=Object.keys(t.stringLiteralsMap).length),t.stringLiteralsMap[e]}function bg(t,e){return Eg(Rg(t,e))}function Pg(t,e,i){const n=void 0!==i?i:yg.NUMBER;if(Array.isArray(e)&&"string"==typeof e[0]){const i=xg[e[0]];if(void 0===i)throw new Error(`Unrecognized expression operator: ${JSON.stringify(e)}`);return i.toGlsl(t,e.slice(1),n)}const r=vg(e)&n;if(kg(e,r,""),(r&yg.NUMBER)>0)return Eg(e);if((r&yg.BOOLEAN)>0)return e.toString();if((r&yg.STRING)>0)return bg(t,e.toString());if((r&yg.COLOR)>0)return Cg(e);if((r&yg.NUMBER_ARRAY)>0)return Tg(e);throw new Error(`Unexpected expression ${e} (expected type ${wg(n)})`)}function Ig(t){if(0==(vg(t)&yg.NUMBER))throw new Error(`A numeric value was expected, got ${JSON.stringify(t)} instead`)}function Fg(t){for(let e=0;e<t.length;e++)Ig(t[e])}function Lg(t){if(0==(vg(t)&yg.STRING))throw new Error(`A string value was expected, got ${JSON.stringify(t)} instead`)}function Mg(t){if(0==(vg(t)&yg.BOOLEAN))throw new Error(`A boolean value was expected, got ${JSON.stringify(t)} instead`)}function Ag(t,e){if(t.length!==e)throw new Error(`Exactly ${e} arguments were expected, got ${t.length} instead`)}function Og(t,e){if(t.length<e)throw new Error(`At least ${e} arguments were expected, got ${t.length} instead`)}function Ng(t,e){if(t.length>e)throw new Error(`At most ${e} arguments were expected, got ${t.length} instead`)}function Dg(t){if(t.length%2!=0)throw new Error(`An even amount of arguments was expected, got ${JSON.stringify(t)} instead`)}function kg(t,e,i){if(e===yg.NONE)throw new Error(`No matching type was found for the following expression ${i}: ${JSON.stringify(t)}`)}function Gg(t,e,i){if(kg(t,e,i),!Sg(e))throw new Error(`Expected to have a unique type for the following expression ${i}: ${JSON.stringify(t)}\nGot the following types instead: ${wg(e)}`)}function jg(t,e,i,n){if((e&i)===yg.NONE)throw new Error(`Expected the ${n} type of the following expression: ${JSON.stringify(t)} to be of the following types: ${wg(i)}\nGot these types instead: ${wg(e)}`)}function Bg(t){return"u_var_"+t}xg.get={getReturnType:function(t){if(2===t.length){return function(t){switch(t){case"string":return yg.STRING;case"color":return yg.COLOR;case"number":return yg.NUMBER;case"boolean":return yg.BOOLEAN;case"number[]":return yg.NUMBER_ARRAY;default:throw new Error(`Unrecognized type hint: ${t}`)}}(t[1])}return yg.ANY},toGlsl:function(t,e,i){Og(e,1),Ng(e,2),Lg(e[0]);const n=i&xg.get.getReturnType(e);Gg(["get",...e],n,"");const r=e[0].toString(),s=t.attributes.find((t=>t.name===r));if(s){if(n!==s.type)throw new Error(`The following attribute was used in different places with incompatible types: ${r}\nTypes were: ${wg(s.type)} and ${wg(n)}`)}else t.attributes.push({name:r,type:n});return(t.inFragmentShader?"v_":"a_")+r}},xg.var={getReturnType:function(){return yg.ANY},toGlsl:function(t,e,i){Ag(e,1),Lg(e[0]);const n=e[0].toString();if(!t.style.variables||void 0===t.style.variables[n])throw new Error(`The following variable is missing from the style: ${n}`);const r=i&vg(t.style.variables[n]);Gg(["var",...e],r,"");const s=t.variables.find((t=>t.name===n));if(s){if(r!==s.type)throw new Error(`The following variable was used in different places with incompatible types: ${n}\nTypes were: ${wg(s.type)} and ${wg(r)}`)}else t.variables.push({name:n,type:r});return Bg(n)}};const Ug="u_paletteTextures";xg.palette={getReturnType:function(){return yg.COLOR},toGlsl:function(t,e){Ag(e,2),Ig(e[0]);const i=Pg(t,e[0]),n=e[1];if(!Array.isArray(n))throw new Error("The second argument of palette must be an array");const r=n.length,s=new Uint8Array(4*r);for(let t=0;t<r;t++){const e=n[t];let i;if("string"==typeof e)i=ls(e);else{if(!Array.isArray(e))throw new Error("The second argument of palette must be an array of strings or colors");const t=e.length;if(4===t)i=e;else{if(3!==t)throw new Error(`Expected palette color to have 3 or 4 values, got ${t}`);i=[e[0],e[1],e[2],1]}}const r=4*t;s[r]=i[0],s[r+1]=i[1],s[r+2]=i[2],s[r+3]=255*i[3]}t.paletteTextures||(t.paletteTextures=[]);const o=`${Ug}[${t.paletteTextures.length}]`,a=new $d(o,s);return t.paletteTextures.push(a),`texture2D(${o}, vec2((${i} + 0.5) / ${r}.0, 0.5))`}};const zg="getBandValue";function Xg(t){return{getReturnType:function(){return yg.BOOLEAN},toGlsl:function(e,i){Ag(i,2);let n=yg.ANY;for(let t=0;t<i.length;t++)n&=vg(i[t]);if(n===yg.NONE)throw new Error(`All arguments should be of compatible type, got ${JSON.stringify(i)} instead`);return n&=~yg.COLOR,`(${Pg(e,i[0],n)} ${t} ${Pg(e,i[1],n)})`}}}function Vg(t){return{getReturnType:function(){return yg.BOOLEAN},toGlsl:function(e,i){Og(i,2);for(let t=0;t<i.length;t++)Mg(i[t]);let n=i.map((t=>Pg(e,t,yg.BOOLEAN))).join(` ${t} `);return n=`(${n})`,n}}}xg.band={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){Og(e,1),Ng(e,3);const i=e[0];if(!(zg in t.functions)){let e="";const i=t.bandCount||1;for(let t=0;t<i;t++){const n=Math.floor(t/4);let r=t%4;t===i-1&&1===r&&(r=3);e+=`\n if (band == ${t+1}.0) {\n return texture2D(${`${fg.TILE_TEXTURE_ARRAY}[${n}]`}, v_textureCoord + vec2(dx, dy))[${r}];\n }\n `}t.functions[zg]=`\n float getBandValue(float band, float xOffset, float yOffset) {\n float dx = xOffset / ${fg.TEXTURE_PIXEL_WIDTH};\n float dy = yOffset / ${fg.TEXTURE_PIXEL_HEIGHT};\n ${e}\n }\n `}const n=Pg(t,i),r=Pg(t,e[1]||0),s=Pg(t,e[2]||0);return`${zg}(${n}, ${r}, ${s})`}},xg.time={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,0),"u_time"}},xg.zoom={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,0),"u_zoom"}},xg.resolution={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,0),"u_resolution"}},xg["geometry-type"]={getReturnType:function(){return yg.STRING},toGlsl:function(t,e){Ag(e,0);const i="geometryType",n=t=>{const e=t.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return n(t.getGeometries()[0])}};t.attributes.find((t=>t.name===i))||t.attributes.push({name:i,type:yg.STRING,callback:t=>n(t.getGeometry())});return(t.inFragmentShader?"v_":"a_")+i}},xg["*"]={getReturnType:function(t){let e=yg.NUMBER|yg.COLOR;for(let i=0;i<t.length;i++)e&=vg(t[i]);return e},toGlsl:function(t,e,i){Og(e,2);let n=i;for(let t=0;t<e.length;t++)n&=vg(e[t]);return jg(e,n,yg.NUMBER|yg.COLOR,"output"),`(${e.map((e=>Pg(t,e,n))).join(" * ")})`}},xg["/"]={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,2),Fg(e),`(${Pg(t,e[0])} / ${Pg(t,e[1])})`}},xg["+"]={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Og(e,2),Fg(e),`(${e.map((e=>Pg(t,e))).join(" + ")})`}},xg["-"]={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,2),Fg(e),`(${Pg(t,e[0])} - ${Pg(t,e[1])})`}},xg.clamp={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){Ag(e,3),Fg(e);const i=Pg(t,e[1]),n=Pg(t,e[2]);return`clamp(${Pg(t,e[0])}, ${i}, ${n})`}},xg["%"]={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,2),Fg(e),`mod(${Pg(t,e[0])}, ${Pg(t,e[1])})`}},xg["^"]={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,2),Fg(e),`pow(${Pg(t,e[0])}, ${Pg(t,e[1])})`}},xg.abs={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`abs(${Pg(t,e[0])})`}},xg.floor={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`floor(${Pg(t,e[0])})`}},xg.round={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`floor(${Pg(t,e[0])} + 0.5)`}},xg.ceil={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`ceil(${Pg(t,e[0])})`}},xg.sin={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`sin(${Pg(t,e[0])})`}},xg.cos={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`cos(${Pg(t,e[0])})`}},xg.atan={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Og(e,1),Ng(e,2),Fg(e),2===e.length?`atan(${Pg(t,e[0])}, ${Pg(t,e[1])})`:`atan(${Pg(t,e[0])})`}},xg.sqrt={getReturnType:function(){return yg.NUMBER},toGlsl:function(t,e){return Ag(e,1),Fg(e),`sqrt(${Pg(t,e[0])})`}},xg[">"]={getReturnType:function(){return yg.BOOLEAN},toGlsl:function(t,e){return Ag(e,2),Fg(e),`(${Pg(t,e[0])} > ${Pg(t,e[1])})`}},xg[">="]={getReturnType:function(){return yg.BOOLEAN},toGlsl:function(t,e){return Ag(e,2),Fg(e),`(${Pg(t,e[0])} >= ${Pg(t,e[1])})`}},xg["<"]={getReturnType:function(){return yg.BOOLEAN},toGlsl:function(t,e){return Ag(e,2),Fg(e),`(${Pg(t,e[0])} < ${Pg(t,e[1])})`}},xg["<="]={getReturnType:function(){return yg.BOOLEAN},toGlsl:function(t,e){return Ag(e,2),Fg(e),`(${Pg(t,e[0])} <= ${Pg(t,e[1])})`}},xg["=="]=Xg("=="),xg["!="]=Xg("!="),xg["!"]={getReturnType:function(){return yg.BOOLEAN},toGlsl:function(t,e){return Ag(e,1),Mg(e[0]),`(!${Pg(t,e[0],yg.BOOLEAN)})`}},xg.all=Vg("&&"),xg.any=Vg("||"),xg.between={getReturnType:function(){return yg.BOOLEAN},toGlsl:function(t,e){Ag(e,3),Fg(e);const i=Pg(t,e[1]),n=Pg(t,e[2]),r=Pg(t,e[0]);return`(${r} >= ${i} && ${r} <= ${n})`}},xg.array={getReturnType:function(){return yg.NUMBER_ARRAY},toGlsl:function(t,e){Og(e,2),Ng(e,4),Fg(e);const i=e.map((function(e){return Pg(t,e)}));return`vec${e.length}(${i.join(", ")})`}},xg.color={getReturnType:function(){return yg.COLOR},toGlsl:function(t,e){Og(e,3),Ng(e,4),Fg(e);const i=e.slice(0,3).map((e=>`${Pg(t,e)} / 255.0`));if(3===e.length)return`vec4(${i.join(", ")}, 1.0)`;return`(${Pg(t,e[3])} * vec4(${i.join(", ")}, 1.0))`}},xg.interpolate={getReturnType:function(t){let e=yg.COLOR|yg.NUMBER;for(let i=3;i<t.length;i+=2)e&=vg(t[i]);return e},toGlsl:function(t,e,i){Dg(e),Og(e,6);const n=e[0];let r;switch(n[0]){case"linear":r=1;break;case"exponential":r=n[1];break;default:r=null}if(!r)throw new Error(`Invalid interpolation type for "interpolate" operator, received: ${JSON.stringify(n)}`);const s=yg.NUMBER,o=xg.interpolate.getReturnType(e)&i;Gg(["interpolate",...e],o,"output");const a=Pg(t,e[1],s),l=Eg(r);let h="";for(let i=2;i<e.length-2;i+=2){const n=Pg(t,e[i],s),c=h||Pg(t,e[i+1],o),u=Pg(t,e[i+2],s);let d;d=1===r?`(${a} - ${n}) / (${u} - ${n})`:`(pow(${l}, (${a} - ${n})) - 1.0) / (pow(${l}, (${u} - ${n})) - 1.0)`,h=`mix(${c}, ${Pg(t,e[i+3],o)}, clamp(${d}, 0.0, 1.0))`}return h}},xg.match={getReturnType:function(t){let e=yg.ANY;for(let i=2;i<t.length;i+=2)e&=vg(t[i]);return e&=vg(t[t.length-1]),e},toGlsl:function(t,e,i){Dg(e),Og(e,4);let n=vg(e[0]);for(let t=1;t<e.length-1;t+=2)n&=vg(e[t]);jg(["match",...e],n,yg.STRING|yg.NUMBER|yg.BOOLEAN,"input"),n=(yg.STRING|yg.NUMBER|yg.BOOLEAN)&n;const r=xg.match.getReturnType(e)&i;Gg(["match",...e],r,"output");const s=Pg(t,e[0],n),o=Pg(t,e[e.length-1],r);let a=null;for(let i=e.length-3;i>=1;i-=2){a=`(${s} == ${Pg(t,e[i],n)} ? ${Pg(t,e[i+1],r)} : ${a||o})`}return a}},xg.case={getReturnType:function(t){let e=yg.ANY;for(let i=1;i<t.length;i+=2)e&=vg(t[i]);return e&=vg(t[t.length-1]),e},toGlsl:function(t,e,i){!function(t){if(t.length%2==0)throw new Error(`An odd amount of arguments was expected, got ${JSON.stringify(t)} instead`)}(e),Og(e,3);const n=xg.case.getReturnType(e)&i;Gg(["case",...e],n,"output");for(let t=0;t<e.length-1;t+=2)Mg(e[t]);const r=Pg(t,e[e.length-1],n);let s=null;for(let i=e.length-3;i>=0;i-=2){s=`(${Pg(t,e[i],yg.BOOLEAN)} ? ${Pg(t,e[i+1],n)} : ${s||r})`}return s}},xg.in={getReturnType:function(t){return yg.BOOLEAN},toGlsl:function(t,e){Ag(e,2);const i=e[0];let n=e[1];if(!Array.isArray(n))throw new Error('The "in" operator expects an array literal as its second argument.');if("string"==typeof n[0]){if("literal"!==n[0])throw new Error('For the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions.');if(!Array.isArray(n[1]))throw new Error('The "in" operator was provided a literal value which was not an array as second argument.');n=n[1]}let r=vg(i);for(let t=0;t<n.length-1;t+=1)r&=vg(n[t]);jg(["match",...e],r,yg.STRING|yg.NUMBER|yg.BOOLEAN,"input"),r=(yg.STRING|yg.NUMBER|yg.BOOLEAN)&r;const s=function(t,e){return`operator_${t}_${Object.keys(e.functions).length}`}("in",t),o=[];for(let e=0;e<n.length;e+=1)o.push(` if (inputValue == ${Pg(t,n[e],r)}) { return true; }`);return t.functions[s]=`bool ${s}(float inputValue) {\n${o.join("\n")}\n return false;\n}`,`${s}(${Pg(t,i,r)})`}};class Wg{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=ol(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Wg({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return z()}getImage(t){return z()}getHitDetectionImage(){return z()}getPixelRatio(t){return 1}getImageState(){return z()}getImageSize(){return z()}getOrigin(){return z()}getSize(){return z()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ol(t)}listenImageChange(t){z()}load(){z()}unlistenImageChange(t){z()}}var Zg=Wg;class Yg extends Zg{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.canvas_=void 0,this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius_=void 0!==t.radius?t.radius:t.radius1,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_=null,this.renderOptions_=null,this.render()}clone(){const t=this.getScale(),e=new Yg({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_;if(!t)return null;const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||this.createHitDetectionCanvas_(this.renderOptions_),this.hitDetectionCanvas_}getImage(t){let e=this.canvas_[t];if(!e){const i=this.renderOptions_,n=yt(i.size*t,i.size*t);this.draw_(i,n,t),e=n.canvas,this.canvas_[t]=e}return e}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return qr}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(0===e||this.points_===1/0||"bevel"!==t&&"miter"!==t)return e;let n=this.radius_,r=void 0===this.radius2_?n:this.radius2_;if(n<r){const t=n;n=r,r=t}const s=void 0===this.radius2_?this.points_:2*this.points_,o=2*Math.PI/s,a=r*Math.sin(o),l=n-Math.sqrt(r*r-a*a),h=Math.sqrt(a*a+l*l),c=h/a;if("miter"===t&&c<=i)return c*e;const u=e/2/c,d=e/2*(l/h),g=Math.sqrt((n+u)*(n+u)+d*d)-n;if(void 0===this.radius2_||"bevel"===t)return 2*g;const f=n*Math.sin(o),p=r-Math.sqrt(n*n-f*f),m=Math.sqrt(f*f+p*p)/f;if(m<=i){const t=m*e/2-r-n;return 2*Math.max(g,t)}return 2*g}createRenderOptions(){let t,e=So,i=0,n=null,r=0,s=0;this.stroke_&&(t=this.stroke_.getColor(),null===t&&(t=Eo),t=Ll(t),s=this.stroke_.getWidth(),void 0===s&&(s=1),n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset(),e=this.stroke_.getLineJoin(),void 0===e&&(e=So),i=this.stroke_.getMiterLimit(),void 0===i&&(i=wo));const o=this.calculateLineJoinSize_(e,s,i),a=Math.max(this.radius_,this.radius2_||0);return{strokeStyle:t,strokeWidth:s,size:Math.ceil(2*a+o),lineDash:n,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.canvas_={},this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let t=this.fill_.getColor();null===t&&(t=yo),e.fillStyle=Ll(t),e.fill()}this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){if(this.fill_){let e=this.fill_.getColor(),i=0;if("string"==typeof e&&(e=hs(e)),null===e?i=1:Array.isArray(e)&&(i=4===e.length?e[3]:1),0===i){const e=yt(t.size,t.size);this.hitDetectionCanvas_=e.canvas,this.drawHitDetectionCanvas_(t,e)}}this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.getImage(1))}createPath_(t){let e=this.points_;const i=this.radius_;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const n=void 0===this.radius2_?i:this.radius2_;void 0!==this.radius2_&&(e*=2);const r=this.angle_-Math.PI/2,s=2*Math.PI/e;for(let o=0;o<e;o++){const e=r+o*s,a=o%2==0?i:n;t.lineTo(a*Math.cos(e),a*Math.sin(e))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=yo,e.fill(),this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}}var Kg=Yg;class Hg extends Kg{constructor(t){super({points:1/0,fill:(t=t||{radius:5}).fill,radius:t.radius,stroke:t.stroke,scale:void 0!==t.scale?t.scale:1,rotation:void 0!==t.rotation?t.rotation:0,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new Hg({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius_=t,this.render()}}var qg=Hg;class $g{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null}clone(){const t=this.getColor();return new $g({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){this.color_=t}}var Jg=$g;let Qg=null;class tf extends w{constructor(t,e,i,n,r,s){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=n,this.canvas_={},this.color_=s,this.unlisten_=null,this.imageState_=r,this.size_=i,this.src_=e,this.tainted_}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(void 0===this.tainted_&&this.imageState_===qr){Qg||(Qg=yt(1,1,void 0,{willReadFrequently:!0})),Qg.drawImage(this.image_,0,0);try{Qg.getImageData(0,0,1,1),this.tainted_=!1}catch(t){Qg=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(E)}handleImageError_(){this.imageState_=$r,this.unlistenImage_(),this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=qr,this.size_?(this.image_.width=this.size_[0],this.image_.height=this.size_[1]):this.size_=[this.image_.width,this.image_.height],this.unlistenImage_(),this.dispatchChangeEvent_()}getImage(t){return this.image_||this.initializeImage_(),this.replaceColor_(t),this.canvas_[t]?this.canvas_[t]:this.image_}getPixelRatio(t){return this.replaceColor_(t),this.canvas_[t]?t:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const t=this.size_[0],e=this.size_[1],i=yt(t,e);i.fillRect(0,0,t,e),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===Kr){this.image_||this.initializeImage_(),this.imageState_=Hr;try{this.image_.src=this.src_}catch(t){this.handleImageError_()}this.unlisten_=Qr(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==qr)return;const e=this.image_,i=document.createElement("canvas");i.width=Math.ceil(e.width*t),i.height=Math.ceil(e.height*t);const n=i.getContext("2d");n.scale(t,t),n.drawImage(e,0,0),n.globalCompositeOperation="multiply",n.fillStyle=os(this.color_),n.fillRect(0,0,i.width/t,i.height/t),n.globalCompositeOperation="destination-in",n.drawImage(e,0,0),this.canvas_[t]=i}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}function ef(t,e,i,n,r,s){let o=ms.get(e,n,s);return o||(o=new tf(t,e,i,n,r,s),ms.set(e,n,s,o)),o}var nf=tf;function rf(t,e,i,n){return void 0!==i&&void 0!==n?[i/t,n/e]:void 0!==i?i/t:void 0!==n?n/e:1}class sf extends Zg{constructor(t){const e=void 0!==(t=t||{}).opacity?t.opacity:1,i=void 0!==t.rotation?t.rotation:0,n=void 0!==t.scale?t.scale:1,r=void 0!==t.rotateWithView&&t.rotateWithView;super({opacity:e,rotation:i,scale:n,displacement:void 0!==t.displacement?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=void 0!==t.anchor?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=void 0!==t.anchorOrigin?t.anchorOrigin:"top-left",this.anchorXUnits_=void 0!==t.anchorXUnits?t.anchorXUnits:"fraction",this.anchorYUnits_=void 0!==t.anchorYUnits?t.anchorYUnits:"fraction",this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null;const s=void 0!==t.img?t.img:null;this.imgSize_=t.imgSize;let o=t.src;Mt(!(void 0!==o&&s),4),Mt(!s||s&&this.imgSize_,5),void 0!==o&&0!==o.length||!s||(o=s.src||V(s)),Mt(void 0!==o&&o.length>0,6),Mt(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),69);const a=void 0!==t.src?Kr:qr;if(this.color_=void 0!==t.color?hs(t.color):null,this.iconImage_=ef(s,o,void 0!==this.imgSize_?this.imgSize_:null,this.crossOrigin_,a,this.color_),this.offset_=void 0!==t.offset?t.offset:[0,0],this.offsetOrigin_=void 0!==t.offsetOrigin?t.offsetOrigin:"top-left",this.origin_=null,this.size_=void 0!==t.size?t.size:null,void 0!==t.width||void 0!==t.height){let e,i;if(t.size)[e,i]=t.size;else{const n=this.getImage(1);if(!(n instanceof HTMLCanvasElement||n.src&&n.complete)){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const i=this.iconImage_.getSize();this.setScale(rf(i[0],i[1],t.width,t.height))};return void this.listenImageChange(e)}e=n.width,i=n.height}void 0!==e&&this.setScale(rf(e,i,t.width,t.height))}}clone(){let t,e,i;this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t);return new sf({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,imgSize:this.imgSize_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:e,height:i,size:null!==this.size_?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;const e=this.getSize();if("fraction"==this.anchorXUnits_||"fraction"==this.anchorYUnits_){if(!e)return null;t=this.anchor_.slice(),"fraction"==this.anchorXUnits_&&(t[0]*=e[0]),"fraction"==this.anchorYUnits_&&(t[1]*=e[1])}if("top-left"!=this.anchorOrigin_){if(!e)return null;t===this.anchor_&&(t=this.anchor_.slice()),"top-right"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[0]=-t[0]+e[0]),"bottom-left"!=this.anchorOrigin_&&"bottom-right"!=this.anchorOrigin_||(t[1]=-t[1]+e[1])}this.normalizedAnchor_=t}const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]-e[0]/i[0],t[1]+e[1]/i[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if("top-left"!=this.offsetOrigin_){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),"top-right"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[0]=i[0]-e[0]-t[0]),"bottom-left"!=this.offsetOrigin_&&"bottom-right"!=this.offsetOrigin_||(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();return this.size_?this.size_[0]*t[0]:this.iconImage_.getImageState()==qr?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:this.iconImage_.getImageState()==qr?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(E,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(E,t)}}var of=sf;class af{constructor(t){t=t||{},this.color_=void 0!==t.color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new af({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}var lf=af;class hf{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=ff,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new hf({geometry:t,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer(),stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=ff,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function cf(t){let e;if("function"==typeof t)e=t;else{let i;if(Array.isArray(t))i=t;else{Mt("function"==typeof t.getZIndex,41);i=[t]}e=function(){return i}}return e}let uf=null;function df(t,e){if(!uf){const t=new Jg({color:"rgba(255,255,255,0.4)"}),e=new lf({color:"#3399CC",width:1.25});uf=[new hf({image:new qg({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return uf}function gf(){const t={},e=[255,255,255,1],i=[0,153,255,1];return t.Polygon=[new hf({fill:new Jg({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new hf({stroke:new lf({color:e,width:5})}),new hf({stroke:new lf({color:i,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new hf({image:new qg({radius:6,fill:new Jg({color:i}),stroke:new lf({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function ff(t){return t.getGeometry()}var pf=hf;class mf{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.scale_=t.scale,this.scaleArray_=ol(void 0!==t.scale?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=void 0!==t.fill?t.fill:new Jg({color:"#333"}),this.maxAngle_=void 0!==t.maxAngle?t.maxAngle:Math.PI/4,this.placement_=void 0!==t.placement?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=void 0!==t.stroke?t.stroke:null,this.offsetX_=void 0!==t.offsetX?t.offsetX:0,this.offsetY_=void 0!==t.offsetY?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=void 0===t.padding?null:t.padding}clone(){const t=this.getScale();return new mf({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=ol(void 0!==t?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}}var _f=mf;function yf(t){return new pf({fill:xf(t,""),stroke:vf(t,""),text:Sf(t),image:wf(t)})}function xf(t,e){const i=t[e+"fill-color"];if(i)return"none"===i?null:new Jg({color:i})}function vf(t,e){const i=t[e+"stroke-width"],n=t[e+"stroke-color"];if(i||n)return new lf({width:i,color:n,lineCap:t[e+"stroke-line-cap"],lineJoin:t[e+"stroke-line-join"],lineDash:t[e+"stroke-line-dash"],lineDashOffset:t[e+"stroke-line-dash-offset"],miterLimit:t[e+"stroke-miter-limit"]})}function Sf(t){const e=t["text-value"];if(!e)return;return new _f({text:e,font:t["text-font"],maxAngle:t["text-max-angle"],offsetX:t["text-offset-x"],offsetY:t["text-offset-y"],overflow:t["text-overflow"],placement:t["text-placement"],repeat:t["text-repeat"],scale:t["text-scale"],rotateWithView:t["text-rotate-with-view"],rotation:t["text-rotation"],textAlign:t["text-align"],justify:t["text-justify"],textBaseline:t["text-baseline"],padding:t["text-padding"],fill:xf(t,"text-"),backgroundFill:xf(t,"text-background-"),stroke:vf(t,"text-"),backgroundStroke:vf(t,"text-background-")})}function wf(t){const e=t["icon-src"],i=t["icon-img"];if(e||i){return new of({src:e,img:i,imgSize:t["icon-img-size"],anchor:t["icon-anchor"],anchorOrigin:t["icon-anchor-origin"],anchorXUnits:t["icon-anchor-x-units"],anchorYUnits:t["icon-anchor-y-units"],color:t["icon-color"],crossOrigin:t["icon-cross-origin"],offset:t["icon-offset"],displacement:t["icon-displacement"],opacity:t["icon-opacity"],scale:t["icon-scale"],width:t["icon-width"],height:t["icon-height"],rotation:t["icon-rotation"],rotateWithView:t["icon-rotate-with-view"],size:t["icon-size"],declutterMode:t["icon-declutter-mode"]})}const n=t["shape-points"];if(n){const e="shape-";return new Kg({points:n,fill:xf(t,e),stroke:vf(t,e),radius:t["shape-radius"],radius1:t["shape-radius1"],radius2:t["shape-radius2"],angle:t["shape-angle"],displacement:t["shape-displacement"],rotation:t["shape-rotation"],rotateWithView:t["shape-rotate-with-view"],scale:t["shape-scale"],declutterMode:t["shape-declutter-mode"]})}const r=t["circle-radius"];if(r){const e="circle-";return new qg({radius:r,fill:xf(t,e),stroke:vf(t,e),displacement:t["circle-displacement"],scale:t["circle-scale"],rotation:t["circle-rotation"],rotateWithView:t["circle-rotate-with-view"],declutterMode:t["circle-declutter-mode"]})}}function Ef(){return{"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"}}const Tf="uniform mat4 u_projectionMatrix;\nuniform mat4 u_screenToWorldMatrix;\nuniform vec2 u_viewportSizePx;\nuniform float u_pixelRatio;\nuniform float u_globalAlpha;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform vec4 u_renderExtent;\nuniform mediump int u_hitDetection;\n",Cf={"fill-color":"rgba(255,255,255,0.4)","stroke-color":"#3399CC","stroke-width":1.25,"circle-radius":5,"circle-fill-color":"rgba(255,255,255,0.4)","circle-stroke-width":1.25,"circle-stroke-color":"#3399CC"};class Rf{constructor(){this.uniforms_=[],this.attributes_=[],this.varyings_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${Eg(Cf["circle-radius"])})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=Cg(Cf["circle-fill-color"]),this.texCoordExpression_="vec4(0.0, 0.0, 1.0, 1.0)",this.discardExpression_="false",this.symbolRotateWithView_=!1,this.hasStroke_=!1,this.strokeWidthExpression_=Eg(Cf["stroke-width"]),this.strokeColorExpression_=Cg(Cf["stroke-color"]),this.hasFill_=!1,this.fillColorExpression_=Cg(Cf["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t){return this.uniforms_.push(t),this}addAttribute(t){return this.attributes_.push(t),this}addVarying(t,e,i){return this.varyings_.push({name:t,type:e,expression:i}),this}setSymbolSizeExpression(t){return this.hasSymbol_=!0,this.symbolSizeExpression_=t,this}getSymbolSizeExpression(){return this.symbolSizeExpression_}setSymbolRotationExpression(t){return this.symbolRotationExpression_=t,this}setSymbolOffsetExpression(t){return this.symbolOffsetExpression_=t,this}setSymbolColorExpression(t){return this.hasSymbol_=!0,this.symbolColorExpression_=t,this}getSymbolColorExpression(){return this.symbolColorExpression_}setTextureCoordinateExpression(t){return this.texCoordExpression_=t,this}setFragmentDiscardExpression(t){return this.discardExpression_=t,this}setSymbolRotateWithView(t){return this.symbolRotateWithView_=t,this}setStrokeWidthExpression(t){return this.hasStroke_=!0,this.strokeWidthExpression_=t,this}setStrokeColorExpression(t){return this.hasStroke_=!0,this.strokeColorExpression_=t,this}setFillColorExpression(t){return this.hasFill_=!0,this.fillColorExpression_=t,this}addVertexShaderFunction(t){this.vertexShaderFunctions_.includes(t)||this.vertexShaderFunctions_.push(t)}addFragmentShaderFunction(t){this.fragmentShaderFunctions_.includes(t)||this.fragmentShaderFunctions_.push(t)}getSymbolVertexShader(){if(!this.hasSymbol_)return null;const t=this.symbolRotateWithView_?"u_offsetScaleMatrix * u_offsetRotateMatrix":"u_offsetScaleMatrix";return`precision mediump float;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform mediump int u_hitDetection;\n\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute float a_index;\nattribute vec4 a_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec2 v_quadCoord;\nvarying vec4 v_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvoid main(void) {\n mat4 offsetMatrix = ${t};\n vec2 halfSize = ${this.symbolSizeExpression_} * 0.5;\n vec2 offset = ${this.symbolOffsetExpression_};\n float angle = ${this.symbolRotationExpression_};\n float offsetX;\n float offsetY;\n if (a_index == 0.0) {\n offsetX = (offset.x - halfSize.x) * cos(angle) + (offset.y - halfSize.y) * sin(angle);\n offsetY = (offset.y - halfSize.y) * cos(angle) - (offset.x - halfSize.x) * sin(angle);\n } else if (a_index == 1.0) {\n offsetX = (offset.x + halfSize.x) * cos(angle) + (offset.y - halfSize.y) * sin(angle);\n offsetY = (offset.y - halfSize.y) * cos(angle) - (offset.x + halfSize.x) * sin(angle);\n } else if (a_index == 2.0) {\n offsetX = (offset.x + halfSize.x) * cos(angle) + (offset.y + halfSize.y) * sin(angle);\n offsetY = (offset.y + halfSize.y) * cos(angle) - (offset.x + halfSize.x) * sin(angle);\n } else {\n offsetX = (offset.x - halfSize.x) * cos(angle) + (offset.y + halfSize.y) * sin(angle);\n offsetY = (offset.y + halfSize.y) * cos(angle) - (offset.x - halfSize.x) * sin(angle);\n }\n vec4 offsets = offsetMatrix * vec4(offsetX, offsetY, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n vec4 texCoord = ${this.texCoordExpression_};\n float u = a_index == 0.0 || a_index == 3.0 ? texCoord.s : texCoord.p;\n float v = a_index == 2.0 || a_index == 3.0 ? texCoord.t : texCoord.q;\n v_texCoord = vec2(u, v);\n u = a_index == 0.0 || a_index == 3.0 ? 0.0 : 1.0;\n v = a_index == 2.0 || a_index == 3.0 ? 0.0 : 1.0;\n v_quadCoord = vec2(u, v);\n v_hitColor = a_hitColor;\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`}getSymbolFragmentShader(){return this.hasSymbol_?`precision mediump float;\nuniform float u_time;\nuniform float u_zoom;\nuniform float u_resolution;\nuniform mediump int u_hitDetection;\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec2 v_quadCoord;\nvarying vec4 v_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\nvoid main(void) {\n if (${this.discardExpression_}) { discard; }\n gl_FragColor = ${this.symbolColorExpression_};\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getStrokeVertexShader(){return this.hasStroke_?`#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n${Tf}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute float a_index;\nattribute vec2 a_segmentStart;\nattribute vec2 a_segmentEnd;\nattribute float a_parameters;\nattribute vec4 a_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec2 v_segmentStart;\nvarying vec2 v_segmentEnd;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvec2 worldToPx(vec2 worldPos) {\n vec4 screenPos = u_projectionMatrix * vec4(worldPos, 0.0, 1.0);\n return (0.5 * screenPos.xy + 0.5) * u_viewportSizePx;\n}\n\nvec4 pxToScreen(vec2 pxPos) {\n vec2 screenPos = pxPos * 4.0 / u_viewportSizePx;\n return vec4(screenPos.xy, 0.0, 0.0);\n}\n\nvec2 getOffsetDirection(vec2 normalPx, vec2 tangentPx, float joinAngle) {\n if (cos(joinAngle) > 0.93) return normalPx - tangentPx;\n float halfAngle = joinAngle / 2.0;\n vec2 angleBisectorNormal = vec2(\n sin(halfAngle) * normalPx.x + cos(halfAngle) * normalPx.y,\n -cos(halfAngle) * normalPx.x + sin(halfAngle) * normalPx.y\n );\n float length = 1.0 / sin(halfAngle);\n return angleBisectorNormal * length;\n}\n\nvoid main(void) {\n float lineWidth = ${this.strokeWidthExpression_};\n float anglePrecision = 1500.0;\n float paramShift = 10000.0;\n v_angleStart = fract(a_parameters / paramShift) * paramShift / anglePrecision;\n v_angleEnd = fract(floor(a_parameters / paramShift + 0.5) / paramShift) * paramShift / anglePrecision;\n float vertexNumber = floor(a_parameters / paramShift / paramShift + 0.0001);\n vec2 tangentPx = worldToPx(a_segmentEnd) - worldToPx(a_segmentStart);\n tangentPx = normalize(tangentPx);\n vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);\n float normalDir = vertexNumber < 0.5 || (vertexNumber > 1.5 && vertexNumber < 2.5) ? 1.0 : -1.0;\n float tangentDir = vertexNumber < 1.5 ? 1.0 : -1.0;\n float angle = vertexNumber < 1.5 ? v_angleStart : v_angleEnd;\n vec2 offsetPx = getOffsetDirection(normalPx * normalDir, tangentDir * tangentPx, angle) * lineWidth * 0.5;\n vec2 position = vertexNumber < 1.5 ? a_segmentStart : a_segmentEnd;\n gl_Position = u_projectionMatrix * vec4(position, 0.0, 1.0) + pxToScreen(offsetPx);\n v_segmentStart = worldToPx(a_segmentStart);\n v_segmentEnd = worldToPx(a_segmentEnd);\n v_width = lineWidth;\n v_hitColor = a_hitColor;\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getStrokeFragmentShader(){return this.hasStroke_?`#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n${Tf}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec2 v_segmentStart;\nvarying vec2 v_segmentEnd;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\nvec2 pxToWorld(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;\n}\n\nfloat segmentDistanceField(vec2 point, vec2 start, vec2 end, float radius) {\n vec2 startToPoint = point - start;\n vec2 startToEnd = end - start;\n float ratio = clamp(dot(startToPoint, startToEnd) / dot(startToEnd, startToEnd), 0.0, 1.0);\n float dist = length(startToPoint - ratio * startToEnd);\n return 1.0 - smoothstep(radius - 1.0, radius, dist);\n}\n\nvoid main(void) {\n vec2 v_currentPoint = gl_FragCoord.xy / u_pixelRatio;\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 v_worldPos = pxToWorld(v_currentPoint);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n v_worldPos[0] < u_renderExtent[0] ||\n v_worldPos[1] < u_renderExtent[1] ||\n v_worldPos[0] > u_renderExtent[2] ||\n v_worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n #endif\n if (${this.discardExpression_}) { discard; }\n gl_FragColor = ${this.strokeColorExpression_} * u_globalAlpha;\n gl_FragColor *= segmentDistanceField(v_currentPoint, v_segmentStart, v_segmentEnd, v_width);\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getFillVertexShader(){return this.hasFill_?`#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n${Tf}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nattribute vec2 a_position;\nattribute vec4 a_hitColor;\n${this.attributes_.map((function(t){return"attribute "+t+";"})).join("\n")}\nvarying vec4 v_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n${this.varyings_.map((function(t){return" "+t.name+" = "+t.expression+";"})).join("\n")}\n}`:null}getFillFragmentShader(){return this.hasFill_?`#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n${Tf}\n${this.uniforms_.map((function(t){return"uniform "+t+";"})).join("\n")}\nvarying vec4 v_hitColor;\n${this.varyings_.map((function(t){return"varying "+t.type+" "+t.name+";"})).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\nvec2 pxToWorld(vec2 pxPos) {\n vec2 screenPos = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return (u_screenToWorldMatrix * vec4(screenPos, 0.0, 1.0)).xy;\n}\n\nvoid main(void) {\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 v_worldPos = pxToWorld(gl_FragCoord.xy / u_pixelRatio);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n v_worldPos[0] < u_renderExtent[0] ||\n v_worldPos[1] < u_renderExtent[1] ||\n v_worldPos[0] > u_renderExtent[2] ||\n v_worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n #endif\n if (${this.discardExpression_}) { discard; }\n gl_FragColor = ${this.fillColorExpression_} * u_globalAlpha;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.1) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}}var bf=class{constructor(){this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(t){for(let e=0;e<t.length;e++)this.addFeature(t[e])}addFeature(t){const e=t.getGeometry();e&&this.addGeometry_(e,t)}clearFeatureEntryInPointBatch_(t){const e=this.pointBatch.entries[V(t)];e&&(this.pointBatch.geometriesCount-=e.flatCoordss.length,delete this.pointBatch.entries[V(t)])}clearFeatureEntryInLineStringBatch_(t){const e=this.lineStringBatch.entries[V(t)];e&&(this.lineStringBatch.verticesCount-=e.verticesCount,this.lineStringBatch.geometriesCount-=e.flatCoordss.length,delete this.lineStringBatch.entries[V(t)])}clearFeatureEntryInPolygonBatch_(t){const e=this.polygonBatch.entries[V(t)];e&&(this.polygonBatch.verticesCount-=e.verticesCount,this.polygonBatch.ringsCount-=e.ringsCount,this.polygonBatch.geometriesCount-=e.flatCoordss.length,delete this.polygonBatch.entries[V(t)])}addGeometry_(t,e){const i=t.getType();switch(i){case"GeometryCollection":const n=t.getGeometriesArray();for(const t of n)this.addGeometry_(t,e);break;case"MultiPolygon":const r=t;this.addCoordinates_(i,r.getFlatCoordinates(),r.getEndss(),e,V(e));break;case"MultiLineString":const s=t;this.addCoordinates_(i,s.getFlatCoordinates(),s.getEnds(),e,V(e));break;case"MultiPoint":const o=t;this.addCoordinates_(i,o.getFlatCoordinates(),null,e,V(e));break;case"Polygon":const a=t;this.addCoordinates_(i,a.getFlatCoordinates(),a.getEnds(),e,V(e));break;case"Point":const l=t;this.addCoordinates_(i,l.getFlatCoordinates(),null,e,V(e));break;case"LineString":case"LinearRing":const h=t;this.addCoordinates_(i,h.getFlatCoordinates(),null,e,V(e))}}addCoordinates_(t,e,i,n,r){let s;switch(t){case"MultiPolygon":const t=i;for(let i=0,s=t.length;i<s;i++){let s=t[i];const o=i>0?t[i-1]:null,a=o?o[o.length-1]:0,l=s[s.length-1],h=e.slice(a,l);s=a>0?s.map((t=>t-a)):s,this.addCoordinates_("Polygon",h,s,n,r)}break;case"MultiLineString":const o=i;for(let t=0,i=o.length;t<i;t++){const i=t>0?o[t-1]:0,s=e.slice(i,o[t]);this.addCoordinates_("LinearRing",s,null,n,r)}break;case"MultiPoint":for(let t=0,i=e.length;t<i;t+=2)this.addCoordinates_("Point",e.slice(t,t+2),null,n,r);break;case"Polygon":const a=i;for(let t=1,i=a.length;t<i;t++){const i=a[t-1];if(t>0&&wr(e,i,a[t],2))return this.addCoordinates_("Polygon",e.slice(0,i),a.slice(0,t),n,r),void this.addCoordinates_("Polygon",e.slice(i),a.slice(t).map((e=>e-a[t-1])),n,r)}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]={feature:n,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]}),s=e.length/2;const l=i.length,h=i.map(((t,e,i)=>e>0?(t-i[e-1])/2:t/2));this.polygonBatch.verticesCount+=s,this.polygonBatch.ringsCount+=l,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(e),this.polygonBatch.entries[r].ringsVerticesCounts.push(h),this.polygonBatch.entries[r].verticesCount+=s,this.polygonBatch.entries[r].ringsCount+=l;for(let t=0,i=a.length;t<i;t++){const i=t>0?a[t-1]:0,s=e.slice(i,a[t]);this.addCoordinates_("LinearRing",s,null,n,r)}break;case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]={feature:n,flatCoordss:[]}),this.pointBatch.geometriesCount++,this.pointBatch.entries[r].flatCoordss.push(e);break;case"LineString":case"LinearRing":this.lineStringBatch.entries[r]||(this.lineStringBatch.entries[r]={feature:n,flatCoordss:[],verticesCount:0}),s=e.length/2,this.lineStringBatch.verticesCount+=s,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(e),this.lineStringBatch.entries[r].verticesCount+=s}}changeFeature(t){this.clearFeatureEntryInPointBatch_(t),this.clearFeatureEntryInPolygonBatch_(t),this.clearFeatureEntryInLineStringBatch_(t);const e=t.getGeometry();e&&this.addGeometry_(e,t)}removeFeature(t){this.clearFeatureEntryInPointBatch_(t),this.clearFeatureEntryInPolygonBatch_(t),this.clearFeatureEntryInLineStringBatch_(t)}clear(){this.polygonBatch.entries={},this.polygonBatch.geometriesCount=0,this.polygonBatch.verticesCount=0,this.polygonBatch.ringsCount=0,this.lineStringBatch.entries={},this.lineStringBatch.geometriesCount=0,this.lineStringBatch.verticesCount=0,this.pointBatch.entries={},this.pointBatch.geometriesCount=0}};var Pf=class extends Od{constructor(t,e){super(t),this.batch_=new bf,this.styleRenderers_=e,this.buffers=[],this.setTile(t.tile)}uploadTile(){this.batch_.clear();const t=this.tile.getSourceTiles(),e=t.reduce(((t,e)=>t.concat(e.getFeatures())),[]);this.batch_.addFeatures(e);const i=Zt([1,0,0,1,0,0],-t[0].extent[0],-t[0].extent[1]),n=this.styleRenderers_.map(((t,e)=>t.generateBuffers(this.batch_,i).then((t=>{this.buffers[e]=t}))));Promise.all(n).then((()=>{this.setReady()}))}};function If(t,e){switch(t){case"square":case"image":return"1.0";case"circle":return`(1.0-smoothstep(1.-4./${e},1.,dot(v_quadCoord-.5,v_quadCoord-.5)*4.))`;case"triangle":const i="(v_quadCoord*2.-1.)",n=`(atan(${i}.x,${i}.y))`;return`(1.0-smoothstep(.5-3./${e},.5,cos(floor(.5+${n}/2.094395102)*2.094395102-${n})*length(${i})))`;default:throw new Error(`Unexpected symbol type: ${t}`)}}function Ff(t){const e=hs(t);return[256*e[0]+e[1],256*e[2]+Math.round(255*e[3])]}function Lf(t){return t===yg.COLOR?2:t===yg.NUMBER_ARRAY?4:1}function Mf(t){const e=Lf(t);return e>1?`vec${e}`:"float"}function Af(t){const e={inFragmentShader:!1,variables:[],attributes:[],stringLiteralsMap:{},functions:{},style:t},i={inFragmentShader:!0,variables:e.variables,attributes:[],stringLiteralsMap:e.stringLiteralsMap,functions:{},style:t},n=new Rf,r={};if(function(t,e,i,n,r){if(!("symbol"in t))return;const s=t.symbol;if("color"in s){const t=s.color,i=void 0!==s.opacity?s.opacity:1,n=Pg(r,t,yg.COLOR),o=Pg(r,i,yg.NUMBER);e.setSymbolColorExpression(`vec4(${n}.rgb, ${n}.a * ${o})`)}if("image"===s.symbolType&&s.src){const t=new Image;t.crossOrigin=void 0===s.crossOrigin?"anonymous":s.crossOrigin,t.src=s.src,e.addUniform("sampler2D u_texture").setSymbolColorExpression(`${e.getSymbolColorExpression()} * texture2D(u_texture, v_texCoord)`),i.u_texture=t}else if("symbolType"in s){let t=e.getSymbolSizeExpression();"size"in s&&(t=Pg(r,s.size,yg.NUMBER_ARRAY|yg.NUMBER));const i=If(s.symbolType,`vec2(${t}).x`);e.setSymbolColorExpression(`${e.getSymbolColorExpression()} * vec4(1.0, 1.0, 1.0, ${i})`)}if("size"in s){const t=Pg(n,s.size,yg.NUMBER_ARRAY|yg.NUMBER);e.setSymbolSizeExpression(`vec2(${t})`)}"textureCoord"in s&&e.setTextureCoordinateExpression(Pg(n,s.textureCoord,yg.NUMBER_ARRAY)),"offset"in s&&e.setSymbolOffsetExpression(Pg(n,s.offset,yg.NUMBER_ARRAY)),"rotation"in s&&e.setSymbolRotationExpression(Pg(n,s.rotation,yg.NUMBER)),"rotateWithView"in s&&e.setSymbolRotateWithView(!!s.rotateWithView)}(t,n,r,e,i),function(t,e,i,n,r){"stroke-color"in t&&e.setStrokeColorExpression(Pg(r,t["stroke-color"],yg.COLOR)),"stroke-width"in t&&e.setStrokeWidthExpression(Pg(n,t["stroke-width"],yg.NUMBER))}(t,n,0,e,i),function(t,e,i,n,r){"fill-color"in t&&e.setFillColorExpression(Pg(r,t["fill-color"],yg.COLOR))}(t,n,0,0,i),t.filter){const e=Pg(i,t.filter,yg.BOOLEAN);n.setFragmentDiscardExpression(`!${e}`)}i.variables.forEach((function(i){const s=Bg(i.name);let o;n.addUniform(`${Mf(i.type)} ${s}`),o=i.type===yg.STRING?()=>Rg(e,t.variables[i.name]):i.type===yg.COLOR?()=>Ff([...hs(t.variables[i.name]||"#eee")]):i.type===yg.BOOLEAN?()=>t.variables[i.name]?1:0:()=>t.variables[i.name],r[s]=o})),i.attributes.forEach((function(t){e.attributes.find((e=>e.name===t.name))||e.attributes.push(t);let i=Mf(t.type),r=`a_${t.name}`;t.type===yg.COLOR&&(i="vec4",r=`unpackColor(${r})`,n.addVertexShaderFunction("vec4 unpackColor(vec2 packedColor) {\n return fract(packedColor[1] / 256.0) * vec4(\n fract(floor(packedColor[0] / 256.0) / 256.0),\n fract(packedColor[0] / 256.0),\n fract(floor(packedColor[1] / 256.0) / 256.0),\n 1.0\n );\n}")),n.addVarying(`v_${t.name}`,i,r)})),e.attributes.forEach((function(t){n.addAttribute(`${Mf(t.type)} a_${t.name}`)}));const s=e.attributes.map((function(t){let i;return i=t.callback?t.callback:t.type===yg.STRING?i=>Rg(e,i.get(t.name)):t.type===yg.COLOR?e=>Ff([...hs(e.get(t.name)||"#eee")]):t.type===yg.BOOLEAN?e=>e.get(t.name)?1:0:e=>e.get(t.name),{name:t.name,size:Lf(t.type),callback:i}}));for(const t in e.functions)n.addVertexShaderFunction(e.functions[t]);for(const t in i.functions)n.addFragmentShaderFunction(i.functions[t]);return{builder:n,attributes:s.reduce(((t,e)=>({...t,[e.name]:{callback:e.callback,size:e.size}})),{}),uniforms:r}}var Of=class{constructor(t){this.first_,this.last_,this.head_,this.circular_=void 0===t||t,this.length_=0}insertItem(t){const e={prev:void 0,next:void 0,data:t},i=this.head_;if(i){const t=i.next;e.prev=i,e.next=t,i.next=e,t&&(t.prev=e),i===this.last_&&(this.last_=e)}else this.first_=e,this.last_=e,this.circular_&&(e.next=e,e.prev=e);this.head_=e,this.length_++}removeItem(){const t=this.head_;if(t){const e=t.next,i=t.prev;e&&(e.prev=i),i&&(i.next=e),this.head_=e||i,this.first_===this.last_?(this.head_=void 0,this.first_=void 0,this.last_=void 0):this.first_===t?this.first_=this.head_:this.last_===t&&(this.last_=i?this.head_.prev:this.head_),this.length_--}}firstItem(){if(this.head_=this.first_,this.head_)return this.head_.data}lastItem(){if(this.head_=this.last_,this.head_)return this.head_.data}nextItem(){if(this.head_&&this.head_.next)return this.head_=this.head_.next,this.head_.data}getNextItem(){if(this.head_&&this.head_.next)return this.head_.next.data}prevItem(){if(this.head_&&this.head_.prev)return this.head_=this.head_.prev,this.head_.data}getPrevItem(){if(this.head_&&this.head_.prev)return this.head_.prev.data}getCurrItem(){if(this.head_)return this.head_.data}setFirstItem(){this.circular_&&this.head_&&(this.first_=this.head_,this.last_=this.head_.prev)}concat(t){if(t.head_){if(this.head_){const e=this.head_.next;this.head_.next=t.first_,t.first_.prev=this.head_,e.prev=t.last_,t.last_.next=e,this.length_+=t.length_}else this.head_=t.head_,this.first_=t.first_,this.last_=t.last_,this.length_=t.length_;t.head_=void 0,t.first_=void 0,t.last_=void 0,t.length_=0}}getLength(){return this.length_}};const Nf="renderOrder";var Df=class extends no{constructor(t){t=t||{};const e=Object.assign({},t);delete e.style,delete e.renderBuffer,delete e.updateWhileAnimating,delete e.updateWhileInteracting,super(e),this.declutter_=void 0!==t.declutter&&t.declutter,this.renderBuffer_=void 0!==t.renderBuffer?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=void 0!==t.updateWhileAnimating&&t.updateWhileAnimating,this.updateWhileInteracting_=void 0!==t.updateWhileInteracting&&t.updateWhileInteracting}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Nf)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t){t.declutterTree||(t.declutterTree=new Uh(9)),this.getRenderer().renderDeclutter(t)}setRenderOrder(t){this.set(Nf,t)}setStyle(t){let e;if(void 0===t)e=df;else if(null===t)e=null;else if("function"==typeof t)e=t;else if(t instanceof pf)e=t;else if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let e=0;e<i;++e){const i=t[e];n[e]=i instanceof pf?i:yf(i)}e=n}else e=yf(t);this.style_=e,this.styleFunction_=null===t?void 0:cf(this.style_),this.changed()}};const kf="GENERATE_POLYGON_BUFFERS",Gf="GENERATE_POINT_BUFFERS",jf="GENERATE_LINE_STRING_BUFFERS";function Bf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Uf={exports:{}};function zf(t,e,i){i=i||2;var n,r,s,o,a,l,h,c=e&&e.length,u=c?e[0]*i:t.length,d=Xf(t,0,u,i,!0),g=[];if(!d||d.next===d.prev)return g;if(c&&(d=function(t,e,i,n){var r,s,o,a=[];for(r=0,s=e.length;r<s;r++)(o=Xf(t,e[r]*n,r<s-1?e[r+1]*n:t.length,n,!1))===o.next&&(o.steiner=!0),a.push(tp(o));for(a.sort(qf),r=0;r<a.length;r++)i=$f(a[r],i);return i}(t,e,d,i)),t.length>80*i){n=s=t[0],r=o=t[1];for(var f=i;f<u;f+=i)(a=t[f])<n&&(n=a),(l=t[f+1])<r&&(r=l),a>s&&(s=a),l>o&&(o=l);h=0!==(h=Math.max(s-n,o-r))?32767/h:0}return Wf(d,g,i,n,r,h,0),g}function Xf(t,e,i,n,r){var s,o;if(r===gp(t,e,i,n)>0)for(s=e;s<i;s+=n)o=cp(s,t[s],t[s+1],o);else for(s=i-n;s>=e;s-=n)o=cp(s,t[s],t[s+1],o);return o&&rp(o,o.next)&&(up(o),o=o.next),o}function Vf(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!rp(n,n.next)&&0!==np(n.prev,n,n.next))n=n.next;else{if(up(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function Wf(t,e,i,n,r,s,o){if(t){!o&&s&&function(t,e,i,n){var r=t;do{0===r.z&&(r.z=Qf(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,i,n,r,s,o,a,l,h=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e<h&&(a++,n=n.nextZ);e++);for(l=h;a>0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,h*=2}while(o>1)}(r)}(t,n,r,s);for(var a,l,h=t;t.prev!==t.next;)if(a=t.prev,l=t.next,s?Yf(t,n,r,s):Zf(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),up(t),t=l.next,h=l.next;else if((t=l)===h){o?1===o?Wf(t=Kf(Vf(t),e,i),e,i,n,r,s,2):2===o&&Hf(t,e,i,n,r,s):Wf(Vf(t),e,i,n,r,s,1);break}}}function Zf(t){var e=t.prev,i=t,n=t.next;if(np(e,i,n)>=0)return!1;for(var r=e.x,s=i.x,o=n.x,a=e.y,l=i.y,h=n.y,c=r<s?r<o?r:o:s<o?s:o,u=a<l?a<h?a:h:l<h?l:h,d=r>s?r>o?r:o:s>o?s:o,g=a>l?a>h?a:h:l>h?l:h,f=n.next;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=g&&ep(r,a,s,l,o,h,f.x,f.y)&&np(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Yf(t,e,i,n){var r=t.prev,s=t,o=t.next;if(np(r,s,o)>=0)return!1;for(var a=r.x,l=s.x,h=o.x,c=r.y,u=s.y,d=o.y,g=a<l?a<h?a:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,p=a>l?a>h?a:h:l>h?l:h,m=c>u?c>d?c:d:u>d?u:d,_=Qf(g,f,e,i,n),y=Qf(p,m,e,i,n),x=t.prevZ,v=t.nextZ;x&&x.z>=_&&v&&v.z<=y;){if(x.x>=g&&x.x<=p&&x.y>=f&&x.y<=m&&x!==r&&x!==o&&ep(a,c,l,u,h,d,x.x,x.y)&&np(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=g&&v.x<=p&&v.y>=f&&v.y<=m&&v!==r&&v!==o&&ep(a,c,l,u,h,d,v.x,v.y)&&np(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=g&&x.x<=p&&x.y>=f&&x.y<=m&&x!==r&&x!==o&&ep(a,c,l,u,h,d,x.x,x.y)&&np(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=g&&v.x<=p&&v.y>=f&&v.y<=m&&v!==r&&v!==o&&ep(a,c,l,u,h,d,v.x,v.y)&&np(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Kf(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!rp(r,s)&&sp(r,n,n.next,s)&&lp(r,s)&&lp(s,r)&&(e.push(r.i/i|0),e.push(n.i/i|0),e.push(s.i/i|0),up(n),up(n.next),n=t=s),n=n.next}while(n!==t);return Vf(n)}function Hf(t,e,i,n,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&ip(o,a)){var l=hp(o,a);return o=Vf(o,o.next),l=Vf(l,l.next),Wf(o,e,i,n,r,s,0),void Wf(l,e,i,n,r,s,0)}a=a.next}o=o.next}while(o!==t)}function qf(t,e){return t.x-e.x}function $f(t,e){var i=function(t,e){var i,n=e,r=t.x,s=t.y,o=-1/0;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){var a=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>o&&(o=a,i=n.x<n.next.x?n:n.next,a===r))return i}n=n.next}while(n!==e);if(!i)return null;var l,h=i,c=i.x,u=i.y,d=1/0;n=i;do{r>=n.x&&n.x>=c&&r!==n.x&&ep(s<u?r:o,s,c,u,s<u?o:r,s,n.x,n.y)&&(l=Math.abs(s-n.y)/(r-n.x),lp(n,t)&&(l<d||l===d&&(n.x>i.x||n.x===i.x&&Jf(i,n)))&&(i=n,d=l)),n=n.next}while(n!==h);return i}(t,e);if(!i)return e;var n=hp(i,t);return Vf(n,n.next),Vf(i,i.next)}function Jf(t,e){return np(t.prev,t,e.prev)<0&&np(e.next,t,t.next)<0}function Qf(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function tp(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function ep(t,e,i,n,r,s,o,a){return(r-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function ip(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&sp(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(lp(t,e)&&lp(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(np(t.prev,t,e.prev)||np(t,e.prev,e))||rp(t,e)&&np(t.prev,t,t.next)>0&&np(e.prev,e,e.next)>0)}function np(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function rp(t,e){return t.x===e.x&&t.y===e.y}function sp(t,e,i,n){var r=ap(np(t,e,i)),s=ap(np(t,e,n)),o=ap(np(i,n,t)),a=ap(np(i,n,e));return r!==s&&o!==a||(!(0!==r||!op(t,i,e))||(!(0!==s||!op(t,n,e))||(!(0!==o||!op(i,t,n))||!(0!==a||!op(i,e,n)))))}function op(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function ap(t){return t>0?1:t<0?-1:0}function lp(t,e){return np(t.prev,t,t.next)<0?np(t,e,t.next)>=0&&np(t,t.prev,e)>=0:np(t,e,t.prev)<0||np(t,t.next,e)<0}function hp(t,e){var i=new dp(t.i,t.x,t.y),n=new dp(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function cp(t,e,i,n){var r=new dp(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function up(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function dp(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function gp(t,e,i,n){for(var r=0,s=e,o=i-n;s<i;s+=n)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}Uf.exports=zf,Uf.exports.default=zf,zf.deviation=function(t,e,i,n){var r=e&&e.length,s=r?e[0]*i:t.length,o=Math.abs(gp(t,0,s,i));if(r)for(var a=0,l=e.length;a<l;a++){var h=e[a]*i,c=a<l-1?e[a+1]*i:t.length;o-=Math.abs(gp(t,h,c,i))}var u=0;for(a=0;a<n.length;a+=3){var d=n[a]*i,g=n[a+1]*i,f=n[a+2]*i;u+=Math.abs((t[d]-t[f])*(t[g+1]-t[d+1])-(t[d]-t[g])*(t[f+1]-t[d+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},zf.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,r=0;r<t.length;r++){for(var s=0;s<t[r].length;s++)for(var o=0;o<e;o++)i.vertices.push(t[r][s][o]);r>0&&(n+=t[r-1].length,i.holes.push(n))}return i};var fp=Bf(Uf.exports);const pp=[],mp={vertexPosition:0,indexPosition:0};function _p(t,e,i,n,r){t[e+0]=i,t[e+1]=n,t[e+2]=r}function yp(t,e){const i=256,n=255;return(e=e||[])[0]=Math.floor(t/i/i/i)/n,e[1]=Math.floor(t/i/i)%i/n,e[2]=Math.floor(t/i)%i/n,e[3]=t%i/n,e}function xp(t){let e=0;const i=256,n=255;return e+=Math.round(t[0]*i*i*i*n),e+=Math.round(t[1]*i*i*n),e+=Math.round(t[2]*i*n),e+=Math.round(t[3]*n),e}function vp(){const t='const e="GENERATE_POLYGON_BUFFERS",t="GENERATE_POINT_BUFFERS",n="GENERATE_LINE_STRING_BUFFERS",r={1:"The view center is not defined",2:"The view resolution is not defined",3:"The view rotation is not defined",4:"`image` and `src` cannot be provided at the same time",5:"`imgSize` must be set when `image` is provided",7:"`format` must be set when `url` is set",8:"Unknown `serverType` configured",9:"`url` must be configured or set using `#setUrl()`",10:"The default `geometryFunction` can only handle `Point` geometries",11:"`options.featureTypes` must be an Array",12:"`options.geometryName` must also be provided when `options.bbox` is set",13:"Invalid corner",14:"Invalid color",15:"Tried to get a value for a key that does not exist in the cache",16:"Tried to set a value for a key that is used already",17:"`resolutions` must be sorted in descending order",18:"Either `origin` or `origins` must be configured, never both",19:"Number of `tileSizes` and `resolutions` must be equal",20:"Number of `origins` and `resolutions` must be equal",22:"Either `tileSize` or `tileSizes` must be configured, never both",24:"Invalid extent or geometry provided as `geometry`",25:"Cannot fit empty extent provided as `geometry`",26:"Features must have an id set",27:"Features must have an id set",28:\'`renderMode` must be `"hybrid"` or `"vector"`\',30:"The passed `feature` was already added to the source",31:"Tried to enqueue an `element` that was already added to the queue",32:"Transformation matrix cannot be inverted",33:"Invalid units",34:"Invalid geometry layout",36:"Unknown SRS type",37:"Unknown geometry type found",38:"`styleMapValue` has an unknown type",39:"Unknown geometry type",40:"Expected `feature` to have a geometry",41:"Expected an `ol/style/Style` or an array of `ol/style/Style.js`",42:"Question unknown, the answer is 42",43:"Expected `layers` to be an array or a `Collection`",47:"Expected `controls` to be an array or an `ol/Collection`",48:"Expected `interactions` to be an array or an `ol/Collection`",49:"Expected `overlays` to be an array or an `ol/Collection`",50:"`options.featureTypes` should be an Array",51:"Either `url` or `tileJSON` options must be provided",52:"Unknown `serverType` configured",53:"Unknown `tierSizeCalculation` configured",55:"The {-y} placeholder requires a tile grid with extent",56:"mapBrowserEvent must originate from a pointer event",57:"At least 2 conditions are required",59:"Invalid command found in the PBF",60:"Missing or invalid `size`",61:"Cannot determine IIIF Image API version from provided image information JSON",62:"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",64:"Layer opacity must be a number",66:"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",67:"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",68:"A VectorTile source can only be rendered if it has a projection compatible with the view projection",69:"`width` or `height` cannot be provided together with `scale`"};class o extends Error{constructor(e){const t=r[e];super(t),this.code=e,this.name="AssertionError",this.message=t}}var i=o;function a(e,t){const n=t[0],r=t[1];return t[0]=e[0]*n+e[2]*r+e[4],t[1]=e[1]*n+e[3]*r+e[5],t}function s(e,t){const n=(r=t)[0]*r[3]-r[1]*r[2];var r;!function(e,t){if(!e)throw new i(t)}(0!==n,32);const o=t[0],a=t[1],s=t[2],u=t[3],f=t[4],x=t[5];return e[0]=u/n,e[1]=-a/n,e[2]=-s/n,e[3]=o/n,e[4]=(s*x-u*f)/n,e[5]=-(o*x-a*f)/n,e}function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}new Array(6);var f={exports:{}};function x(e,t,n){n=n||2;var r,o,i,a,s,u,f,x=t&&t.length,h=x?t[0]*n:e.length,v=l(e,0,h,n,!0),d=[];if(!v||v.next===v.prev)return d;if(x&&(v=function(e,t,n,r){var o,i,a,s=[];for(o=0,i=t.length;o<i;o++)(a=l(e,t[o]*r,o<i-1?t[o+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(A(a));for(s.sort(b),o=0;o<s.length;o++)n=g(s[o],n);return n}(e,t,v,n)),e.length>80*n){r=i=e[0],o=a=e[1];for(var y=n;y<h;y+=n)(s=e[y])<r&&(r=s),(u=e[y+1])<o&&(o=u),s>i&&(i=s),u>a&&(a=u);f=0!==(f=Math.max(i-r,a-o))?32767/f:0}return c(v,d,n,r,o,f,0),d}function l(e,t,n,r,o){var i,a;if(o===P(e,t,n,r)>0)for(i=t;i<n;i+=r)a=k(i,e[i],e[i+1],a);else for(i=n-r;i>=t;i-=r)a=k(i,e[i],e[i+1],a);return a&&F(a,a.next)&&(R(a),a=a.next),a}function h(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!F(r,r.next)&&0!==Z(r.prev,r,r.next))r=r.next;else{if(R(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function c(e,t,n,r,o,i,a){if(e){!a&&i&&function(e,t,n,r){var o=e;do{0===o.z&&(o.z=w(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,function(e){var t,n,r,o,i,a,s,u,f=1;do{for(n=e,e=null,i=null,a=0;n;){for(a++,r=n,s=0,t=0;t<f&&(s++,r=r.nextZ);t++);for(u=f;s>0||u>0&&r;)0!==s&&(0===u||!r||n.z<=r.z)?(o=n,n=n.nextZ,s--):(o=r,r=r.nextZ,u--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=r}i.nextZ=null,f*=2}while(a>1)}(o)}(e,r,o,i);for(var s,u,f=e;e.prev!==e.next;)if(s=e.prev,u=e.next,i?d(e,r,o,i):v(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(u.i/n|0),R(e),e=u.next,f=u.next;else if((e=u)===f){a?1===a?c(e=y(h(e),t,n),t,n,r,o,i,2):2===a&&p(e,t,n,r,o,i):c(h(e),t,n,r,o,i,1);break}}}function v(e){var t=e.prev,n=e,r=e.next;if(Z(t,n,r)>=0)return!1;for(var o=t.x,i=n.x,a=r.x,s=t.y,u=n.y,f=r.y,x=o<i?o<a?o:a:i<a?i:a,l=s<u?s<f?s:f:u<f?u:f,h=o>i?o>a?o:a:i>a?i:a,c=s>u?s>f?s:f:u>f?u:f,v=r.next;v!==t;){if(v.x>=x&&v.x<=h&&v.y>=l&&v.y<=c&&E(o,s,i,u,a,f,v.x,v.y)&&Z(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function d(e,t,n,r){var o=e.prev,i=e,a=e.next;if(Z(o,i,a)>=0)return!1;for(var s=o.x,u=i.x,f=a.x,x=o.y,l=i.y,h=a.y,c=s<u?s<f?s:f:u<f?u:f,v=x<l?x<h?x:h:l<h?l:h,d=s>u?s>f?s:f:u>f?u:f,y=x>l?x>h?x:h:l>h?l:h,p=w(c,v,t,n,r),b=w(d,y,t,n,r),g=e.prevZ,m=e.nextZ;g&&g.z>=p&&m&&m.z<=b;){if(g.x>=c&&g.x<=d&&g.y>=v&&g.y<=y&&g!==o&&g!==a&&E(s,x,u,l,f,h,g.x,g.y)&&Z(g.prev,g,g.next)>=0)return!1;if(g=g.prevZ,m.x>=c&&m.x<=d&&m.y>=v&&m.y<=y&&m!==o&&m!==a&&E(s,x,u,l,f,h,m.x,m.y)&&Z(m.prev,m,m.next)>=0)return!1;m=m.nextZ}for(;g&&g.z>=p;){if(g.x>=c&&g.x<=d&&g.y>=v&&g.y<=y&&g!==o&&g!==a&&E(s,x,u,l,f,h,g.x,g.y)&&Z(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;m&&m.z<=b;){if(m.x>=c&&m.x<=d&&m.y>=v&&m.y<=y&&m!==o&&m!==a&&E(s,x,u,l,f,h,m.x,m.y)&&Z(m.prev,m,m.next)>=0)return!1;m=m.nextZ}return!0}function y(e,t,n){var r=e;do{var o=r.prev,i=r.next.next;!F(o,i)&&T(o,r,r.next,i)&&z(o,i)&&z(i,o)&&(t.push(o.i/n|0),t.push(r.i/n|0),t.push(i.i/n|0),R(r),R(r.next),r=e=i),r=r.next}while(r!==e);return h(r)}function p(e,t,n,r,o,i){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&M(a,s)){var u=U(a,s);return a=h(a,a.next),u=h(u,u.next),c(a,t,n,r,o,i,0),void c(u,t,n,r,o,i,0)}s=s.next}a=a.next}while(a!==e)}function b(e,t){return e.x-t.x}function g(e,t){var n=function(e,t){var n,r=t,o=e.x,i=e.y,a=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var s=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=o&&s>a&&(a=s,n=r.x<r.next.x?r:r.next,s===o))return n}r=r.next}while(r!==t);if(!n)return null;var u,f=n,x=n.x,l=n.y,h=1/0;r=n;do{o>=r.x&&r.x>=x&&o!==r.x&&E(i<l?o:a,i,x,l,i<l?a:o,i,r.x,r.y)&&(u=Math.abs(i-r.y)/(o-r.x),z(r,e)&&(u<h||u===h&&(r.x>n.x||r.x===n.x&&m(n,r)))&&(n=r,h=u)),r=r.next}while(r!==f);return n}(e,t);if(!n)return t;var r=U(n,e);return h(r,r.next),h(n,n.next)}function m(e,t){return Z(e.prev,e,t.prev)<0&&Z(t.next,e,e.next)<0}function w(e,t,n,r,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function A(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function E(e,t,n,r,o,i,a,s){return(o-a)*(t-s)>=(e-a)*(i-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(i-s)>=(o-a)*(r-s)}function M(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&T(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(z(e,t)&&z(t,e)&&function(e,t){var n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Z(e.prev,e,t.prev)||Z(e,t.prev,t))||F(e,t)&&Z(e.prev,e,e.next)>0&&Z(t.prev,t,t.next)>0)}function Z(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function F(e,t){return e.x===t.x&&e.y===t.y}function T(e,t,n,r){var o=S(Z(e,t,n)),i=S(Z(e,t,r)),a=S(Z(n,r,e)),s=S(Z(n,r,t));return o!==i&&a!==s||(!(0!==o||!I(e,n,t))||(!(0!==i||!I(e,r,t))||(!(0!==a||!I(n,e,r))||!(0!==s||!I(n,t,r)))))}function I(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function S(e){return e>0?1:e<0?-1:0}function z(e,t){return Z(e.prev,e,e.next)<0?Z(e,t,e.next)>=0&&Z(e,e.prev,t)>=0:Z(e,t,e.prev)<0||Z(e,e.next,t)<0}function U(e,t){var n=new B(e.i,e.x,e.y),r=new B(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function k(e,t,n,r){var o=new B(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function R(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function B(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function P(e,t,n,r){for(var o=0,i=t,a=n-r;i<n;i+=r)o+=(e[a]-e[i])*(e[i+1]+e[a+1]),a=i;return o}f.exports=x,f.exports.default=x,x.deviation=function(e,t,n,r){var o=t&&t.length,i=o?t[0]*n:e.length,a=Math.abs(P(e,0,i,n));if(o)for(var s=0,u=t.length;s<u;s++){var f=t[s]*n,x=s<u-1?t[s+1]*n:e.length;a-=Math.abs(P(e,f,x,n))}var l=0;for(s=0;s<r.length;s+=3){var h=r[s]*n,c=r[s+1]*n,v=r[s+2]*n;l+=Math.abs((e[h]-e[v])*(e[c+1]-e[h+1])-(e[h]-e[c])*(e[v+1]-e[h+1]))}return 0===a&&0===l?0:Math.abs((l-a)/a)},x.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,o=0;o<e.length;o++){for(var i=0;i<e[o].length;i++)for(var a=0;a<t;a++)n.vertices.push(e[o][i][a]);o>0&&(r+=e[o-1].length,n.holes.push(r))}return n};var N=u(f.exports);const _=[],O={vertexPosition:0,indexPosition:0};function q(e,t,n,r,o){e[t+0]=n,e[t+1]=r,e[t+2]=o}function L(e,t,n,r,o,i){const a=3+o,s=e[t+0],u=e[t+1],f=_;f.length=o;for(let n=0;n<f.length;n++)f[n]=e[t+2+n];let x=i?i.vertexPosition:0,l=i?i.indexPosition:0;const h=x/a;return q(n,x,s,u,0),f.length&&n.set(f,x+3),x+=a,q(n,x,s,u,1),f.length&&n.set(f,x+3),x+=a,q(n,x,s,u,2),f.length&&n.set(f,x+3),x+=a,q(n,x,s,u,3),f.length&&n.set(f,x+3),x+=a,r[l++]=h,r[l++]=h+1,r[l++]=h+3,r[l++]=h+1,r[l++]=h+2,r[l++]=h+3,O.vertexPosition=x,O.indexPosition=l,O}function C(e,t,n,r,o,i,s,u,f,x){const l=5+u.length,h=i.length/l,c=[e[t+0],e[t+1]],v=[e[n],e[n+1]],d=a(x,[...c]),y=a(x,[...v]);function p(e,t,n){const r=1e4;return Math.round(1500*t)+Math.round(1500*n)*r+e*r*r}function b(e,t,n){const r=Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])),o=[(t[0]-e[0])/r,(t[1]-e[1])/r],i=[-o[1],o[0]],a=Math.sqrt((n[0]-e[0])*(n[0]-e[0])+(n[1]-e[1])*(n[1]-e[1])),s=[(n[0]-e[0])/a,(n[1]-e[1])/a],u=0===r||0===a?0:Math.acos((f=s[0]*o[0]+s[1]*o[1],x=-1,l=1,Math.min(Math.max(f,x),l)));var f,x,l;return s[0]*i[0]+s[1]*i[1]>0?u:2*Math.PI-u}const g=null!==o;let m=0,w=0;if(null!==r){m=b(d,y,a(x,[...[e[r],e[r+1]]]))}if(g){w=b(y,d,a(x,[...[e[o],e[o+1]]]))}i.push(c[0],c[1],v[0],v[1],p(0,m,w)),i.push(...u),i.push(c[0],c[1],v[0],v[1],p(1,m,w)),i.push(...u),i.push(c[0],c[1],v[0],v[1],p(2,m,w)),i.push(...u),i.push(c[0],c[1],v[0],v[1],p(3,m,w)),i.push(...u),s.push(h,h+1,h+2,h+1,h+3,h+2)}function G(e,t,n,r,o){const i=2+o;let a=t;const s=e.slice(a,a+o);a+=o;const u=e[a++];let f=0;const x=new Array(u-1);for(let t=0;t<u;t++)f+=e[a++],t<u-1&&(x[t]=f);const l=e.slice(a,a+2*f),h=N(l,x,2);for(let e=0;e<h.length;e++)r.push(h[e]+n.length/i);for(let e=0;e<l.length;e+=2)n.push(l[e],l[e+1],...s);return a+2*f}const j=self;j.onmessage=r=>{const o=r.data;switch(o.type){case t:{const e=3,t=2,n=o.customAttributesSize,r=t+n,i=new Float32Array(o.renderInstructions),a=i.length/r,s=4*a*(n+e),u=new Uint32Array(6*a),f=new Float32Array(s);let x;for(let e=0;e<i.length;e+=r)x=L(i,e,f,u,n,x);const l=Object.assign({vertexBuffer:f.buffer,indexBuffer:u.buffer,renderInstructions:i.buffer},o);j.postMessage(l,[f.buffer,u.buffer,i.buffer]);break}case n:{const e=[],t=[],n=o.customAttributesSize,r=2,i=new Float32Array(o.renderInstructions);let a=0;const u=o.renderInstructionsTransform,f=[1,0,0,1,0,0];let x,l;for(s(f,u);a<i.length;){l=Array.from(i.slice(a,a+n)),a+=n,x=i[a++];for(let n=0;n<x-1;n++)C(i,a+n*r,a+(n+1)*r,n>0?a+(n-1)*r:null,n<x-2?a+(n+2)*r:null,e,t,l,0,f);a+=x*r}const h=Uint32Array.from(t),c=Float32Array.from(e),v=Object.assign({vertexBuffer:c.buffer,indexBuffer:h.buffer,renderInstructions:i.buffer},o);j.postMessage(v,[c.buffer,h.buffer,i.buffer]);break}case e:{const e=[],t=[],n=o.customAttributesSize,r=new Float32Array(o.renderInstructions);let i=0;for(;i<r.length;)i=G(r,i,e,t,n);const a=Uint32Array.from(t),s=Float32Array.from(e),u=Object.assign({vertexBuffer:s.buffer,indexBuffer:a.buffer,renderInstructions:r.buffer},o);j.postMessage(u,[s.buffer,a.buffer,r.buffer]);break}}};';return new Worker("undefined"==typeof Blob?"data:application/javascript;base64,"+Buffer.from(t,"binary").toString("base64"):URL.createObjectURL(new Blob([t],{type:"application/javascript"})))}var Sp=class extends sg{constructor(t,e){const i=e.uniforms||{},n=[1,0,0,1,0,0];i[Xd.PROJECTION_MATRIX]=n,super(t,{uniforms:i,postProcesses:e.postProcesses}),this.sourceRevision_=-1,this.verticesBuffer_=new kd(td,nd),this.indicesBuffer_=new kd(ed,nd),this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.program_,this.hitDetectionEnabled_=e.hitDetectionEnabled??!0;const r=e.attributes?e.attributes.map((function(t){return{name:"a_"+t.name,size:1,type:Vd.FLOAT}})):[];this.attributes=[{name:"a_position",size:2,type:Vd.FLOAT},{name:"a_index",size:1,type:Vd.FLOAT}],this.hitDetectionEnabled_&&(this.attributes.push({name:"a_hitColor",size:4,type:Vd.FLOAT}),this.attributes.push({name:"a_featureUid",size:1,type:Vd.FLOAT})),this.attributes.push(...r),this.customAttributes=e.attributes?e.attributes:[],this.previousExtent_=[1/0,1/0,-1/0,-1/0],this.currentTransform_=n,this.renderTransform_=[1,0,0,1,0,0],this.invertRenderTransform_=[1,0,0,1,0,0],this.renderInstructions_=new Float32Array(0),this.hitRenderTarget_,this.lastSentId=0,this.worker_=vp(),this.worker_.addEventListener("message",(t=>{const e=t.data;if(e.type===Gf){const i=e.projectionTransform;this.verticesBuffer_.fromArrayBuffer(e.vertexBuffer),this.helper.flushBufferData(this.verticesBuffer_),this.indicesBuffer_.fromArrayBuffer(e.indexBuffer),this.helper.flushBufferData(this.indicesBuffer_),this.renderTransform_=i,Kt(this.invertRenderTransform_,this.renderTransform_),this.renderInstructions_=new Float32Array(t.data.renderInstructions),e.id===this.lastSentId&&(this.ready=!0),this.getLayer().changed()}})),this.featureCache_={},this.featureCount_=0;const s=this.getLayer().getSource();this.sourceListenKeys_=[D(s,ic,this.handleSourceFeatureAdded_,this),D(s,nc,this.handleSourceFeatureChanged_,this),D(s,sc,this.handleSourceFeatureDelete_,this),D(s,rc,this.handleSourceFeatureClear_,this)],s.forEachFeature((t=>{this.featureCache_[V(t)]={feature:t,properties:t.getProperties(),geometry:t.getGeometry()},this.featureCount_++}))}afterHelperCreated(){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new Qd(this.helper))}handleSourceFeatureAdded_(t){const e=t.feature;this.featureCache_[V(e)]={feature:e,properties:e.getProperties(),geometry:e.getGeometry()},this.featureCount_++}handleSourceFeatureChanged_(t){const e=t.feature;this.featureCache_[V(e)]={feature:e,properties:e.getProperties(),geometry:e.getGeometry()}}handleSourceFeatureDelete_(t){const e=t.feature;delete this.featureCache_[V(e)],this.featureCount_--}handleSourceFeatureClear_(){this.featureCache_={},this.featureCount_=0}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=this.getWorldParameters_(t);this.renderWorlds(t,!1,i,n,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent);const s=this.helper.getCanvas();return this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,i,n,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t),s}getWorldParameters_(t){const e=t.viewState.projection,i=this.getLayer().getSource().getWrapX()&&e.canWrapX(),n=e.getExtent(),r=t.extent,s=i?Me(n):null,o=i?Math.ceil((r[2]-n[2])/s)+1:1;return[i?Math.floor((r[0]-n[0])/s):0,o,s]}prepareFrameInternal(t){const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[As]&&!t.viewHints[Os],s=!de(this.previousExtent_,t.extent),o=this.sourceRevision_<i.getRevision();if(o&&(this.sourceRevision_=i.getRevision()),r&&(s||o)){const r=n.projection,s=n.resolution,o=e instanceof Df?e.getRenderBuffer():0,a=te(t.extent,o*s);i.loadFeatures(a,s,r),this.rebuildBuffers_(t),this.previousExtent_=t.extent.slice()}return this.helper.useProgram(this.program_,t),this.helper.prepareDraw(t),this.helper.bindBuffer(this.verticesBuffer_),this.helper.bindBuffer(this.indicesBuffer_),this.helper.enableAttributes(this.attributes),!0}rebuildBuffers_(t){const e=[1,0,0,1,0,0];this.helper.makeProjectionTransform(t,e);const i=(this.hitDetectionEnabled_?7:2)+this.customAttributes.length,n=i*this.featureCount_;let r,s;this.renderInstructions_&&this.renderInstructions_.length===n||(this.renderInstructions_=new Float32Array(n));const o=[],a=[];let l=-1;for(const t in this.featureCache_)if(r=this.featureCache_[t],s=r.geometry,s&&"Point"===s.getType()){if(o[0]=s.getFlatCoordinates()[0],o[1]=s.getFlatCoordinates()[1],zt(e,o),this.renderInstructions_[++l]=o[0],this.renderInstructions_[++l]=o[1],this.hitDetectionEnabled_){const e=yp(l+5,a);this.renderInstructions_[++l]=e[0],this.renderInstructions_[++l]=e[1],this.renderInstructions_[++l]=e[2],this.renderInstructions_[++l]=e[3],this.renderInstructions_[++l]=Number(t)}for(let t=0;t<this.customAttributes.length;t++){const e=this.customAttributes[t].callback(r.feature,r.properties);this.renderInstructions_[++l]=e}}const h={id:++this.lastSentId,type:Gf,renderInstructions:this.renderInstructions_.buffer,customAttributesSize:i-2};h.projectionTransform=e,this.ready=!1,this.worker_.postMessage(h,[this.renderInstructions_.buffer]),this.renderInstructions_=null}forEachFeatureAtCoordinate(t,e,i,n,r){if(Mt(this.hitDetectionEnabled_,66),!this.renderInstructions_||!this.hitDetectionEnabled_)return;const s=zt(e.coordinateToPixelTransform,t.slice()),o=this.hitRenderTarget_.readPixel(s[0]/2,s[1]/2),a=xp([o[0]/255,o[1]/255,o[2]/255,o[3]/255]),l=this.renderInstructions_[a],h=Math.floor(l).toString(),c=this.getLayer().getSource().getFeatureByUid(h);return c?n(c,this.getLayer(),null):void 0}renderWorlds(t,e,i,n,r){let s=i;this.helper.useProgram(this.program_,t),e&&(this.hitRenderTarget_.setSize([Math.floor(t.size[0]/2),Math.floor(t.size[1]/2)]),this.helper.prepareDrawToRenderTarget(t,this.hitRenderTarget_,!0)),this.helper.bindBuffer(this.verticesBuffer_),this.helper.bindBuffer(this.indicesBuffer_),this.helper.enableAttributes(this.attributes);do{this.helper.makeProjectionTransform(t,this.currentTransform_),Zt(this.currentTransform_,s*r,0),jt(this.currentTransform_,this.invertRenderTransform_),this.helper.applyUniforms(t),this.helper.applyHitDetectionUniform(e);const i=this.indicesBuffer_.getSize();this.helper.drawElements(0,i)}while(++s<n)}disposeInternal(){this.worker_.terminate(),this.layer_=null,this.sourceListenKeys_.forEach((function(t){G(t)})),this.sourceListenKeys_=null,super.disposeInternal()}};function wp(t,e,i,n){let r=0;for(const s in e){const o=e[s],a=o.callback(i.feature);t[n+r++]=a[0]||a,o.size&&1!==o.size&&(t[n+r++]=a[1],o.size<3||(t[n+r++]=a[2],o.size<4||(t[n+r++]=a[3])))}return r}function Ep(t){return Object.keys(t).reduce(((e,i)=>e+(t[i].size||1)),0)}function Tp(t,e,i,n){const r=(2+Ep(i))*t.geometriesCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t<r;t++)s[0]=a.flatCoordss[t][0],s[1]=a.flatCoordss[t][1],zt(n,s),e[o++]=s[0],e[o++]=s[1],o+=wp(e,i,a,o)}return e}function Cp(t,e,i,n){const r=2*t.verticesCount+(1+Ep(i))*t.geometriesCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t<r;t++){s.length=a.flatCoordss[t].length,Rn(a.flatCoordss[t],0,s.length,2,n,s),o+=wp(e,i,a,o),e[o++]=s.length/2;for(let t=0,i=s.length;t<i;t+=2)e[o++]=s[t],e[o++]=s[t+1]}}return e}function Rp(t,e,i,n){const r=2*t.verticesCount+(1+Ep(i))*t.geometriesCount+t.ringsCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t<r;t++){s.length=a.flatCoordss[t].length,Rn(a.flatCoordss[t],0,s.length,2,n,s),o+=wp(e,i,a,o),e[o++]=a.ringsVerticesCounts[t].length;for(let i=0,n=a.ringsVerticesCounts[t].length;i<n;i++)e[o++]=a.ringsVerticesCounts[t][i];for(let t=0,i=s.length;t<i;t+=2)e[o++]=s[t],e[o++]=s[t+1]}}return e}const bp=vp();let Pp=0;const Ip="a_position",Fp="a_index",Lp="a_segmentStart",Mp="a_segmentEnd",Ap="a_parameters";var Op=class{constructor(t,e){this.helper_=e;let i=t;if(!("fill"in t||"stroke"in t||"symbol"in t&&"vertex"in t.symbol)){const e=Af(t);i={fill:{vertex:e.builder.getFillVertexShader(),fragment:e.builder.getFillFragmentShader()},stroke:{vertex:e.builder.getStrokeVertexShader(),fragment:e.builder.getStrokeFragmentShader()},symbol:{vertex:e.builder.getSymbolVertexShader(),fragment:e.builder.getSymbolFragmentShader()},attributes:e.attributes,uniforms:e.uniforms}}this.hasFill_=!!i.fill?.vertex,this.hasFill_&&(this.fillVertexShader_=i.fill.vertex,this.fillFragmentShader_=i.fill.fragment,this.fillProgram_=this.helper_.getProgram(this.fillFragmentShader_,this.fillVertexShader_)),this.hasStroke_=!!i.stroke?.vertex,this.hasStroke_&&(this.strokeVertexShader_=i.stroke&&i.stroke.vertex,this.strokeFragmentShader_=i.stroke&&i.stroke.fragment,this.strokeProgram_=this.helper_.getProgram(this.strokeFragmentShader_,this.strokeVertexShader_)),this.hasSymbol_=!!i.symbol?.vertex,this.hasSymbol_&&(this.symbolVertexShader_=i.symbol&&i.symbol.vertex,this.symbolFragmentShader_=i.symbol&&i.symbol.fragment,this.symbolProgram_=this.helper_.getProgram(this.symbolFragmentShader_,this.symbolVertexShader_)),this.customAttributes_=i.attributes,this.uniforms_=i.uniforms;const n=Object.keys(this.customAttributes_).map((t=>({name:`a_${t}`,size:this.customAttributes_[t].size||1,type:Vd.FLOAT})));this.polygonAttributesDesc_=[{name:Ip,size:2,type:Vd.FLOAT},...n],this.lineStringAttributesDesc_=[{name:Lp,size:2,type:Vd.FLOAT},{name:Mp,size:2,type:Vd.FLOAT},{name:Ap,size:1,type:Vd.FLOAT},...n],this.pointAttributesDesc_=[{name:Ip,size:2,type:Vd.FLOAT},{name:Fp,size:1,type:Vd.FLOAT},...n]}async generateBuffers(t,e){const i=this.generateRenderInstructions_(t,e),[n,r,s]=await Promise.all([this.generateBuffersForType_(i.polygonInstructions,"Polygon",e),this.generateBuffersForType_(i.lineStringInstructions,"LineString",e),this.generateBuffersForType_(i.pointInstructions,"Point",e)]);return{polygonBuffers:n,lineStringBuffers:r,pointBuffers:s,invertVerticesTransform:Kt([1,0,0,1,0,0],e)}}generateRenderInstructions_(t,e){return{polygonInstructions:this.hasFill_?Rp(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,lineStringInstructions:this.hasStroke_?Cp(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,pointInstructions:this.hasSymbol_?Tp(t.pointBatch,new Float32Array(0),this.customAttributes_,e):null}}generateBuffersForType_(t,e,i){if(null===t)return null;const n=Pp++;let r;switch(e){case"Polygon":r=kf;break;case"LineString":r=jf;break;case"Point":r=Gf}const s={id:n,type:r,renderInstructions:t.buffer,renderInstructionsTransform:i,customAttributesSize:Ep(this.customAttributes_)};return bp.postMessage(s,[t.buffer]),t=null,new Promise((t=>{const e=i=>{const r=i.data;if(r.id!==n)return;if(bp.removeEventListener("message",e),!this.helper_.getGL())return;const s=new kd(td,nd).fromArrayBuffer(r.vertexBuffer),o=new kd(ed,nd).fromArrayBuffer(r.indexBuffer);this.helper_.flushBufferData(s),this.helper_.flushBufferData(o),t([o,s])};bp.addEventListener("message",e)}))}render(t,e,i){this.hasFill_&&this.renderInternal_(t.polygonBuffers[0],t.polygonBuffers[1],this.fillProgram_,this.polygonAttributesDesc_,e,i),this.hasStroke_&&this.renderInternal_(t.lineStringBuffers[0],t.lineStringBuffers[1],this.strokeProgram_,this.lineStringAttributesDesc_,e,i),this.hasSymbol_&&this.renderInternal_(t.pointBuffers[0],t.pointBuffers[1],this.symbolProgram_,this.pointAttributesDesc_,e,i)}renderInternal_(t,e,i,n,r,s){this.helper_.useProgram(i,r),this.helper_.bindBuffer(e),this.helper_.bindBuffer(t),this.helper_.enableAttributes(n),s();const o=t.getSize();this.helper_.drawElements(0,o)}};const Np={...Xd,RENDER_EXTENT:"u_renderExtent",GLOBAL_ALPHA:"u_globalAlpha"};var Dp=class extends sg{constructor(t,e){super(t,{uniforms:{[Np.RENDER_EXTENT]:[0,0,0,0],[Np.GLOBAL_ALPHA]:1},postProcesses:e.postProcesses}),this.sourceRevision_=-1,this.previousExtent_=[1/0,1/0,-1/0,-1/0],this.currentTransform_=[1,0,0,1,0,0],this.tmpTransform_=[1,0,0,1,0,0],this.tmpMat4_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.currentFrameStateTransform_=[1,0,0,1,0,0],this.styles_=[],this.styleRenderers_=[],this.buffers_=[],this.applyOptions_(e),this.batch_=new bf;const i=this.getLayer().getSource();this.batch_.addFeatures(i.getFeatures()),this.sourceListenKeys_=[D(i,ic,this.handleSourceFeatureAdded_,this),D(i,nc,this.handleSourceFeatureChanged_,this),D(i,sc,this.handleSourceFeatureDelete_,this),D(i,rc,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styles_=Array.isArray(t.style)?t.style:[t.style]}createRenderers_(){this.buffers_=[],this.styleRenderers_=this.styles_.map((t=>new Op(t,this.helper)))}reset(t){this.applyOptions_(t),this.helper&&this.createRenderers_(),super.reset(t)}afterHelperCreated(){this.createRenderers_()}handleSourceFeatureAdded_(t){const e=t.feature;this.batch_.addFeature(e)}handleSourceFeatureChanged_(t){const e=t.feature;this.batch_.changeFeature(e)}handleSourceFeatureDelete_(t){const e=t.feature;this.batch_.removeFeature(e)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(t){Ut(this.tmpTransform_,this.currentFrameStateTransform_),jt(this.tmpTransform_,t),this.helper.setUniformMatrixValue(Np.PROJECTION_MATRIX,zd(this.tmpMat4_,this.tmpTransform_))}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t),this.helper.prepareDraw(t),this.currentFrameStateTransform_=this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_);const i=this.getLayer().getSource(),n=t.viewState.projection,r=i.getWrapX()&&n.canWrapX(),s=n.getExtent(),o=t.extent,a=r?Me(s):null,l=r?Math.ceil((o[2]-s[2])/a)+1:1;let h=r?Math.floor((o[0]-s[0])/a):0;Zt(this.currentFrameStateTransform_,h*a,0);do{for(let e=0,i=this.styleRenderers_.length;e<i;e++){const i=this.styleRenderers_[e],n=this.buffers_[e];n&&i.render(n,t,(()=>{this.applyUniforms_(n.invertVerticesTransform)}))}Zt(this.currentFrameStateTransform_,a,0)}while(++h<l);this.helper.finalizeDraw(t);const c=this.helper.getCanvas(),u=t.layerStatesArray[t.layerIndex].opacity;return u!==parseFloat(c.style.opacity)&&(c.style.opacity=String(u)),this.postRender(e,t),c}prepareFrameInternal(t){const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[As]&&!t.viewHints[Os],s=!de(this.previousExtent_,t.extent),o=this.sourceRevision_<i.getRevision();if(o&&(this.sourceRevision_=i.getRevision()),r&&(s||o)){const r=n.projection,s=n.resolution,o=e instanceof Df?e.getRenderBuffer():0,a=te(t.extent,o*s);i.loadFeatures(a,s,r),this.ready=!1;const l=this.helper.makeProjectionTransform(t,[1,0,0,1,0,0]),h=this.styleRenderers_.map(((t,e)=>t.generateBuffers(this.batch_,l).then((t=>{this.buffers_[e]=t}))));Promise.all(h).then((()=>{this.ready=!0,this.getLayer().changed()})),this.previousExtent_=t.extent.slice()}return!0}forEachFeatureAtCoordinate(t,e,i,n,r){}disposeInternal(){this.sourceListenKeys_.forEach((function(t){G(t)})),this.sourceListenKeys_=null,super.disposeInternal()}};var kp=class extends gg{constructor(t,e){super(t,e),this.styles_=[],this.styleRenderers_=[],this.currentFrameStateTransform_=[1,0,0,1,0,0],this.tmpTransform_=[1,0,0,1,0,0],this.tmpMat4_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this.applyOptions_(e)}reset(t){super.reset(t),this.applyOptions_(t),this.helper&&this.createRenderers_()}applyOptions_(t){this.styles_=Array.isArray(t.style)?t.style:[t.style]}createRenderers_(){this.styleRenderers_=this.styles_.map((t=>new Op(t,this.helper)))}afterHelperCreated(){this.createRenderers_()}createTileRepresentation(t){const e=new Pf(t,this.styleRenderers_),i=()=>{e.ready&&(this.getLayer().changed(),e.removeEventListener(E,i))};return e.addEventListener(E,i),e}beforeTilesRender(t,e){super.beforeTilesRender(t,!0),this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_)}applyUniforms_(t,e,i){Ut(this.tmpTransform_,this.currentFrameStateTransform_),jt(this.tmpTransform_,i),this.helper.setUniformMatrixValue(og.PROJECTION_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),Kt(this.tmpTransform_,this.currentFrameStateTransform_),this.helper.setUniformMatrixValue(og.SCREEN_TO_WORLD_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),this.helper.setUniformFloatValue(og.GLOBAL_ALPHA,t),this.helper.setUniformFloatVec4(og.RENDER_EXTENT,e)}renderTile(t,e,i,n,r,s,o,a,l,h,c){const u=Ie(a,n,a);for(let e=0,n=this.styleRenderers_.length;e<n;e++){const n=this.styleRenderers_[e],r=t.buffers[e];r&&n.render(r,i,(()=>{this.applyUniforms_(c,u,r.invertVerticesTransform)}))}}renderDeclutter(t){}disposeInternal(){super.disposeInternal()}};const Gp=0,jp=1,Bp=2,Up=3,zp=4,Xp=5,Vp=6,Wp=7,Zp=8,Yp=9,Kp=10,Hp=11,qp=12,$p=[Zp],Jp=[qp],Qp=[jp],tm=[Up];var em=class extends zl{constructor(t,e,i,n){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=n,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return 1==e?t:t.map((function(t){return t*e}))}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),n=this.tmpCoordinate_,r=this.coordinates;let s=r.length;for(let o=0,a=t.length;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],ne(i,n)&&(r[s++]=n[0],r[s++]=n[1]);return s}appendFlatLineCoordinates(t,e,i,n,r,s){const o=this.coordinates;let a=o.length;const l=this.getBufferedMaxExtent();s&&(e+=n);let h=t[e],c=t[e+1];const u=this.tmpCoordinate_;let d,g,f,p=!0;for(d=e+n;d<i;d+=n)u[0]=t[d],u[1]=t[d+1],f=oe(l,u),f!==g?(p&&(o[a++]=h,o[a++]=c,p=!1),o[a++]=u[0],o[a++]=u[1]):f===Jt.INTERSECTING?(o[a++]=u[0],o[a++]=u[1],p=!1):p=!0,h=u[0],c=u[1],g=f;return(r&&p||d===e+n)&&(o[a++]=h,o[a++]=c),a}drawCustomCoordinates_(t,e,i,n,r){for(let s=0,o=i.length;s<o;++s){const o=i[s],a=this.appendFlatLineCoordinates(t,e,o,n,!1,!1);r.push(a),e=o}return e}drawCustom(t,e,i,n){this.beginGeometry(t,e);const r=t.getType(),s=t.getStride(),o=this.coordinates.length;let a,l,h,c,u;switch(r){case"MultiPolygon":a=t.getOrientedFlatCoordinates(),c=[];const e=t.getEndss();u=0;for(let t=0,i=e.length;t<i;++t){const i=[];u=this.drawCustomCoordinates_(a,u,e[t],s,i),c.push(i)}this.instructions.push([zp,o,c,t,i,er]),this.hitDetectionInstructions.push([zp,o,c,t,n||i,er]);break;case"Polygon":case"MultiLineString":h=[],a="Polygon"==r?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),u=this.drawCustomCoordinates_(a,0,t.getEnds(),s,h),this.instructions.push([zp,o,h,t,i,tr]),this.hitDetectionInstructions.push([zp,o,h,t,n||i,tr]);break;case"LineString":case"Circle":a=t.getFlatCoordinates(),l=this.appendFlatLineCoordinates(a,0,a.length,s,!1,!1),this.instructions.push([zp,o,l,t,i,Qn]),this.hitDetectionInstructions.push([zp,o,l,t,n||i,Qn]);break;case"MultiPoint":a=t.getFlatCoordinates(),l=this.appendFlatPointCoordinates(a,s),l>o&&(this.instructions.push([zp,o,l,t,i,Qn]),this.hitDetectionInstructions.push([zp,o,l,t,n||i,Qn]));break;case"Point":a=t.getFlatCoordinates(),this.coordinates.push(a[0],a[1]),l=this.coordinates.length,this.instructions.push([zp,o,l,t,i]),this.hitDetectionInstructions.push([zp,o,l,t,n||i])}this.endGeometry(e)}beginGeometry(t,e){this.beginGeometryInstruction1_=[Gp,e,0,t],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Gp,e,0,t],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const t=this.hitDetectionInstructions;let e;t.reverse();const i=t.length;let n,r,s=-1;for(e=0;e<i;++e)n=t[e],r=n[0],r==Wp?s=e:r==Gp&&(n[2]=e,u(this.hitDetectionInstructions,s,e),s=-1)}setFillStrokeStyle(t,e){const i=this.state;if(t){const e=t.getColor();i.fillStyle=Ll(e||yo)}else i.fillStyle=void 0;if(e){const t=e.getColor();i.strokeStyle=Ll(t||Eo);const n=e.getLineCap();i.lineCap=void 0!==n?n:xo;const r=e.getLineDash();i.lineDash=r?r.slice():vo;const s=e.getLineDashOffset();i.lineDashOffset=s||0;const o=e.getLineJoin();i.lineJoin=void 0!==o?o:So;const a=e.getWidth();i.lineWidth=void 0!==a?a:1;const l=e.getMiterLimit();i.miterLimit=void 0!==l?l:wo,i.lineWidth>this.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(t){const e=t.fillStyle,i=[Kp,e];return"string"!=typeof e&&i.push(!0),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Hp,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;"string"==typeof i&&t.currentFillStyle==i||(void 0!==i&&this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,n=t.lineCap,r=t.lineDash,s=t.lineDashOffset,o=t.lineJoin,a=t.lineWidth,l=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=n||r!=t.currentLineDash&&!g(t.currentLineDash,r)||t.currentLineDashOffset!=s||t.currentLineJoin!=o||t.currentLineWidth!=a||t.currentMiterLimit!=l)&&(void 0!==i&&e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=n,t.currentLineDash=r,t.currentLineDashOffset=s,t.currentLineJoin=o,t.currentLineWidth=a,t.currentMiterLimit=l)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[Wp,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=ee(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;te(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}};var im=class extends em{constructor(t,e,i,n){super(t,e,i,n),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e){if(!this.image_)return;this.beginGeometry(t,e);const i=t.getFlatCoordinates(),n=t.getStride(),r=this.coordinates.length,s=this.appendFlatPointCoordinates(i,n);this.instructions.push([Vp,r,s,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([Vp,r,s,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}drawMultiPoint(t,e){if(!this.image_)return;this.beginGeometry(t,e);const i=t.getFlatCoordinates(),n=t.getStride(),r=this.coordinates.length,s=this.appendFlatPointCoordinates(i,n);this.instructions.push([Vp,r,s,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([Vp,r,s,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),n=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=n[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=n[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}};var nm=class extends em{constructor(t,e,i,n){super(t,e,i,n)}drawFlatCoordinates_(t,e,i,n){const r=this.coordinates.length,s=this.appendFlatLineCoordinates(t,e,i,n,!1,!1),o=[Yp,r,s];return this.instructions.push(o),this.hitDetectionInstructions.push(o),i}drawLineString(t,e){const i=this.state,n=i.strokeStyle,r=i.lineWidth;if(void 0===n||void 0===r)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([Hp,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,vo,0],Qp);const s=t.getFlatCoordinates(),o=t.getStride();this.drawFlatCoordinates_(s,0,s.length,o),this.hitDetectionInstructions.push(Jp),this.endGeometry(e)}drawMultiLineString(t,e){const i=this.state,n=i.strokeStyle,r=i.lineWidth;if(void 0===n||void 0===r)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(t,e),this.hitDetectionInstructions.push([Hp,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,vo,0],Qp);const s=t.getEnds(),o=t.getFlatCoordinates(),a=t.getStride();let l=0;for(let t=0,e=s.length;t<e;++t)l=this.drawFlatCoordinates_(o,l,s[t],a);this.hitDetectionInstructions.push(Jp),this.endGeometry(e)}finish(){const t=this.state;return null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Jp),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){null!=t.lastStroke&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Jp),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Qp)}};var rm=class extends em{constructor(t,e,i,n){super(t,e,i,n)}drawFlatCoordinatess_(t,e,i,n){const r=this.state,s=void 0!==r.fillStyle,o=void 0!==r.strokeStyle,a=i.length;this.instructions.push(Qp),this.hitDetectionInstructions.push(Qp);for(let r=0;r<a;++r){const s=i[r],a=this.coordinates.length,l=this.appendFlatLineCoordinates(t,e,s,n,!0,!o),h=[Yp,a,l];this.instructions.push(h),this.hitDetectionInstructions.push(h),o&&(this.instructions.push(tm),this.hitDetectionInstructions.push(tm)),e=s}return s&&(this.instructions.push($p),this.hitDetectionInstructions.push($p)),o&&(this.instructions.push(Jp),this.hitDetectionInstructions.push(Jp)),e}drawCircle(t,e){const i=this.state,n=i.fillStyle,r=i.strokeStyle;if(void 0===n&&void 0===r)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Kp,yo]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Hp,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,vo,0]);const s=t.getFlatCoordinates(),o=t.getStride(),a=this.coordinates.length;this.appendFlatLineCoordinates(s,0,s.length,o,!1,!1);const l=[Bp,a];this.instructions.push(Qp,l),this.hitDetectionInstructions.push(Qp,l),void 0!==i.fillStyle&&(this.instructions.push($p),this.hitDetectionInstructions.push($p)),void 0!==i.strokeStyle&&(this.instructions.push(Jp),this.hitDetectionInstructions.push(Jp)),this.endGeometry(e)}drawPolygon(t,e){const i=this.state,n=i.fillStyle,r=i.strokeStyle;if(void 0===n&&void 0===r)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Kp,yo]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Hp,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,vo,0]);const s=t.getEnds(),o=t.getOrientedFlatCoordinates(),a=t.getStride();this.drawFlatCoordinatess_(o,0,s,a),this.endGeometry(e)}drawMultiPolygon(t,e){const i=this.state,n=i.fillStyle,r=i.strokeStyle;if(void 0===n&&void 0===r)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e),void 0!==i.fillStyle&&this.hitDetectionInstructions.push([Kp,yo]),void 0!==i.strokeStyle&&this.hitDetectionInstructions.push([Hp,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,vo,0]);const s=t.getEndss(),o=t.getOrientedFlatCoordinates(),a=t.getStride();let l=0;for(let t=0,e=s.length;t<e;++t)l=this.drawFlatCoordinatess_(o,l,s[t],a);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(0!==t){const e=this.coordinates;for(let i=0,n=e.length;i<n;++i)e[i]=Hn(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;void 0!==t.fillStyle&&this.updateFillStyle(t,this.createFill),void 0!==t.strokeStyle&&this.updateStrokeStyle(t,this.applyStroke)}};function sm(t,e,i,n,r){const s=[];let o=i,a=0,l=e.slice(i,2);for(;a<t&&o+r<n;){const[i,n]=l.slice(-2),h=e[o+r],c=e[o+r+1],u=Math.sqrt((h-i)*(h-i)+(c-n)*(c-n));if(a+=u,a>=t){const e=(t-a+u)/u,d=vi(i,h,e),g=vi(n,c,e);l.push(d,g),s.push(l),l=[d,g],a==t&&(o+=r),a=0}else if(a<t)l.push(e[o+r],e[o+r+1]),o+=r;else{const t=u-a,e=vi(i,h,t/u),d=vi(n,c,t/u);l.push(e,d),s.push(l),l=[e,d],a=0,o+=r}}return a>0&&s.push(l),s}function om(t,e,i,n,r){let s,o,a,l,h,c,u,d,g,f,p=i,m=i,_=0,y=0,x=i;for(o=i;o<n;o+=r){const i=e[o],n=e[o+1];void 0!==h&&(g=i-h,f=n-c,l=Math.sqrt(g*g+f*f),void 0!==u&&(y+=a,s=Math.acos((u*g+d*f)/(a*l)),s>t&&(y>_&&(_=y,p=x,m=o),y=0,x=o-r)),a=l,u=g,d=f),h=i,c=n}return y+=l,y>_?[x,o]:[p,m]}const am={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};var lm=class extends em{constructor(t,e,i,n){super(t,e,i,n),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[yo]={fillStyle:yo},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e){const i=this.textFillState_,n=this.textStrokeState_,r=this.textState_;if(""===this.text_||!r||!i&&!n)return;const s=this.coordinates;let o=s.length;const a=t.getType();let l=null,h=t.getStride();if("line"!==r.placement||"LineString"!=a&&"MultiLineString"!=a&&"Polygon"!=a&&"MultiPolygon"!=a){let i=r.overflow?null:[];switch(a){case"Point":case"MultiPoint":l=t.getFlatCoordinates();break;case"LineString":l=t.getFlatMidpoint();break;case"Circle":l=t.getCenter();break;case"MultiLineString":l=t.getFlatMidpoints(),h=2;break;case"Polygon":l=t.getFlatInteriorPoint(),r.overflow||i.push(l[2]/this.resolution),h=3;break;case"MultiPolygon":const e=t.getFlatInteriorPoints();l=[];for(let t=0,n=e.length;t<n;t+=3)r.overflow||i.push(e[t+2]/this.resolution),l.push(e[t],e[t+1]);if(0===l.length)return;h=2}const n=this.appendFlatPointCoordinates(l,h);if(n===o)return;if(i&&(n-o)/2!=l.length/h){let t=o/2;i=i.filter(((e,i)=>{const n=s[2*(t+i)]===l[i*h]&&s[2*(t+i)+1]===l[i*h+1];return n||--t,n}))}this.saveTextStates_(),(r.backgroundFill||r.backgroundStroke)&&(this.setFillStrokeStyle(r.backgroundFill,r.backgroundStroke),r.backgroundFill&&this.updateFillStyle(this.state,this.createFill),r.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e);let c=r.padding;if(c!=Ro&&(r.scale[0]<0||r.scale[1]<0)){let t=r.padding[0],e=r.padding[1],i=r.padding[2],n=r.padding[3];r.scale[0]<0&&(e=-e,n=-n),r.scale[1]<0&&(t=-t,i=-i),c=[t,e,i,n]}const u=this.pixelRatio;this.instructions.push([Vp,o,n,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,void 0,this.declutterImageWithText_,c==Ro?Ro:c.map((function(t){return t*u})),!!r.backgroundFill,!!r.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]);const d=1/u,g=this.state.fillStyle;r.backgroundFill&&(this.state.fillStyle=yo,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([Vp,o,n,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[d,d],NaN,void 0,this.declutterImageWithText_,c,!!r.backgroundFill,!!r.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?yo:this.fillKey_,this.textOffsetX_,this.textOffsetY_,i]),r.backgroundFill&&(this.state.fillStyle=g,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}else{if(!Ae(this.getBufferedMaxExtent(),t.getExtent()))return;let i;if(l=t.getFlatCoordinates(),"LineString"==a)i=[l.length];else if("MultiLineString"==a)i=t.getEnds();else if("Polygon"==a)i=t.getEnds().slice(0,1);else if("MultiPolygon"==a){const e=t.getEndss();i=[];for(let t=0,n=e.length;t<n;++t)i.push(e[t][0])}this.beginGeometry(t,e);const n=r.repeat,c=n?void 0:r.textAlign;let u=0;for(let t=0,e=i.length;t<e;++t){let e;e=n?sm(n*this.resolution,l,u,i[t],h):[l.slice(u,i[t])];for(let n=0,a=e.length;n<a;++n){const a=e[n];let l=0,d=a.length;if(null==c){const t=om(r.maxAngle,a,0,a.length,2);l=t[0],d=t[1]}for(let t=l;t<d;t+=h)s.push(a[t],a[t+1]);const g=s.length;u=i[t],this.drawChars_(o,g),o=g}}this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,n=this.strokeKey_;t&&(n in this.strokeStates||(this.strokeStates[n]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||To,justify:e.justify,textBaseline:e.textBaseline||Co,scale:e.scale});const s=this.fillKey_;i&&(s in this.fillStates||(this.fillStates[s]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,n=this.textState_,r=this.strokeKey_,s=this.textKey_,o=this.fillKey_;this.saveTextStates_();const a=this.pixelRatio,l=am[n.textBaseline],h=this.textOffsetY_*a,c=this.text_,u=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([Xp,t,e,l,n.overflow,o,n.maxAngle,a,h,r,u*a,c,s,1]),this.hitDetectionInstructions.push([Xp,t,e,l,n.overflow,o?yo:o,n.maxAngle,1,h,r,u,c,s,1/a])}setTextStyle(t,e){let i,n,r;if(t){const e=t.getFill();e?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=Ll(e.getColor()||yo)):(n=null,this.textFillState_=n);const s=t.getStroke();if(s){r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const t=s.getLineDash(),e=s.getLineDashOffset(),i=s.getWidth(),n=s.getMiterLimit();r.lineCap=s.getLineCap()||xo,r.lineDash=t?t.slice():vo,r.lineDashOffset=void 0===e?0:e,r.lineJoin=s.getLineJoin()||So,r.lineWidth=void 0===i?1:i,r.miterLimit=void 0===n?wo:n,r.strokeStyle=Ll(s.getColor()||Eo)}else r=null,this.textStrokeState_=r;i=this.textState_;const o=t.getFont()||_o;Lo(o);const a=t.getScaleArray();i.overflow=t.getOverflow(),i.font=o,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||Co,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Ro,i.scale=void 0===a?[1,1]:a;const l=t.getOffsetX(),h=t.getOffsetY(),c=t.getRotateWithView(),u=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=void 0===l?0:l,this.textOffsetY_=void 0===h?0:h,this.textRotateWithView_=void 0!==c&&c,this.textRotation_=void 0===u?0:u,this.strokeKey_=r?("string"==typeof r.strokeStyle?r.strokeStyle:V(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=n?"string"==typeof n.fillStyle?n.fillStyle:"|"+V(n.fillStyle):""}else this.text_="";this.declutterImageWithText_=e}};const hm={Circle:rm,Default:em,Image:im,LineString:nm,Polygon:rm,Text:lm};var cm=class{constructor(t,e,i,n){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=n,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const n in i){const r=i[n].finish();t[e][n]=r}}return t}getBuilder(t,e){const i=void 0!==t?t.toString():"0";let n=this.buildersByZIndex_[i];void 0===n&&(n={},this.buildersByZIndex_[i]=n);let r=n[e];if(void 0===r){r=new(0,hm[e])(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[e]=r}return r}};function um(t,e,i,n,r,s,o,a,l,h,c,u){let d=t[e],g=t[e+1],f=0,p=0,m=0,_=0;function y(){f=d,p=g,d=t[e+=n],g=t[e+1],_+=m,m=Math.sqrt((d-f)*(d-f)+(g-p)*(g-p))}do{y()}while(e<i-n&&_+m<s);let x=0===m?0:(s-_)/m;const v=vi(f,d,x),S=vi(p,g,x),w=e-n,E=_,T=s+a*l(h,r,c);for(;e<i-n&&_+m<T;)y();x=0===m?0:(T-_)/m;const C=vi(f,d,x),R=vi(p,g,x);let b;if(u){const t=[v,S,C,R];bn(t,0,4,2,u,t,t),b=t[0]>t[2]}else b=v>C;const P=Math.PI,I=[],F=w+n===e;let L;if(m=0,_=E,d=t[e=w],g=t[e+1],F){y(),L=Math.atan2(g-p,d-f),b&&(L+=L>0?-P:P);const t=(C+v)/2,e=(R+S)/2;return I[0]=[t,e,(T-s)/2,L,r],I}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t<u;){y();let v=Math.atan2(g-p,d-f);if(b&&(v+=v>0?-P:P),void 0!==L){let t=v-L;if(t+=t>P?-2*P:t<-P?2*P:0,Math.abs(t)>o)return null}L=v;const S=t;let w=0;for(;t<u;++t){const o=a*l(h,r[b?u-t-1:t],c);if(e+n<i&&_+m<s+w+o/2)break;w+=o}if(t===S)continue;const E=b?r.substring(u-S,u-t):r.substring(S,t);x=0===m?0:(s+w/2-_)/m;const T=vi(f,d,x),C=vi(p,g,x);I.push([T,C,w/2,v,E]),s+=w}return I}function dm(t,e,i,n){let r=t[e],s=t[e+1],o=0;for(let a=e+n;a<i;a+=n){const e=t[a],i=t[a+1];o+=Math.sqrt((e-r)*(e-r)+(i-s)*(i-s)),r=e,s=i}return o}const gm=[1/0,1/0,-1/0,-1/0],fm=[],pm=[],mm=[],_m=[];function ym(t){return t[3].declutterBox}const xm=new RegExp("["+String.fromCharCode(1425)+"-"+String.fromCharCode(2303)+String.fromCharCode(64285)+"-"+String.fromCharCode(65023)+String.fromCharCode(65136)+"-"+String.fromCharCode(65276)+String.fromCharCode(67584)+"-"+String.fromCharCode(69631)+String.fromCharCode(124928)+"-"+String.fromCharCode(126975)+"]");function vm(t,e){return"start"===e?e=xm.test(t)?"right":"left":"end"===e&&(e=xm.test(t)?"left":"right"),am[e]}function Sm(t,e,i){return i>0&&t.push("\n",""),t.push(e,""),t}var wm=class{constructor(t,e,i,n){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=[1,0,0,1,0,0],this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={}}createLabel(t,e,i,n){const r=t+e+i+n;if(this.labels_[r])return this.labels_[r];const s=n?this.strokeStates[n]:null,o=i?this.fillStates[i]:null,a=this.textStates[e],l=this.pixelRatio,h=[a.scale[0]*l,a.scale[1]*l],c=Array.isArray(t),u=a.justify?am[a.justify]:vm(Array.isArray(t)?t[0]:t,a.textAlign||To),d=n&&s.lineWidth?s.lineWidth:0,g=c?t:t.split("\n").reduce(Sm,[]),{width:f,height:p,widths:m,heights:_,lineWidths:y}=Do(a,g),x=f+d,v=[],S=(x+2)*h[0],w=(p+d)*h[1],E={width:S<0?Math.floor(S):Math.ceil(S),height:w<0?Math.floor(w):Math.ceil(w),contextInstructions:v};1==h[0]&&1==h[1]||v.push("scale",h),n&&(v.push("strokeStyle",s.strokeStyle),v.push("lineWidth",d),v.push("lineCap",s.lineCap),v.push("lineJoin",s.lineJoin),v.push("miterLimit",s.miterLimit),v.push("setLineDash",[s.lineDash]),v.push("lineDashOffset",s.lineDashOffset)),i&&v.push("fillStyle",o.fillStyle),v.push("textBaseline","middle"),v.push("textAlign","center");const T=.5-u;let C=u*x+T*d;const R=[],b=[];let P,I=0,F=0,L=0,M=0;for(let t=0,e=g.length;t<e;t+=2){const e=g[t];if("\n"===e){F+=I,I=0,C=u*x+T*d,++M;continue}const r=g[t+1]||a.font;r!==P&&(n&&R.push("font",r),i&&b.push("font",r),P=r),I=Math.max(I,_[L]);const s=[e,C+T*m[L]+u*(m[L]-y[M]),.5*(d+I)+F];C+=m[L],n&&R.push("strokeText",s),i&&b.push("fillText",s),++L}return Array.prototype.push.apply(v,R),Array.prototype.push.apply(v,b),this.labels_[r]=E,E}replayTextBackground_(t,e,i,n,r,s,o){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,n),t.lineTo.apply(t,r),t.lineTo.apply(t,e),s&&(this.alignFill_=s[2],this.fill_(t)),o&&(this.setStrokeStyle_(t,o),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,n,r,s,o,a,l,h,c,u,d,g,f,p){let m=i-(o*=u[0]),_=n-(a*=u[1]);const y=r+l>t?t-l:r,x=s+h>e?e-h:s,v=g[3]+y*u[0]+g[1],S=g[0]+x*u[1]+g[2],w=m-g[3],E=_-g[0];let T;return(f||0!==c)&&(fm[0]=w,_m[0]=w,fm[1]=E,pm[1]=E,pm[0]=w+v,mm[0]=pm[0],mm[1]=E+S,_m[1]=mm[1]),0!==c?(T=Yt([1,0,0,1,0,0],i,n,1,1,c,-i,-n),zt(T,fm),zt(T,pm),zt(T,mm),zt(T,_m),le(Math.min(fm[0],pm[0],mm[0],_m[0]),Math.min(fm[1],pm[1],mm[1],_m[1]),Math.max(fm[0],pm[0],mm[0],_m[0]),Math.max(fm[1],pm[1],mm[1],_m[1]),gm)):le(Math.min(w,w+v),Math.min(E,E+S),Math.max(w,w+v),Math.max(E,E+S),gm),d&&(m=Math.round(m),_=Math.round(_)),{drawImageX:m,drawImageY:_,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:gm[0],minY:gm[1],maxX:gm[2],maxY:gm[3],value:p},canvasTransform:T,scale:u}}replayImageOrLabel_(t,e,i,n,r,s,o){const a=!(!s&&!o),l=n.declutterBox,h=t.canvas,c=o?o[2]*n.scale[0]/2:0;return l.minX-c<=h.width/e&&l.maxX+c>=0&&l.minY-c<=h.height/e&&l.maxY+c>=0&&(a&&this.replayTextBackground_(t,fm,pm,mm,_m,s,o),ko(t,n.canvasTransform,r,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(t){if(this.alignFill_){const e=zt(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;t.save(),t.translate(e[0]%i,e[1]%i),t.rotate(this.viewRotation_)}t.fill(),this.alignFill_&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6])}drawLabelWithPointPlacement_(t,e,i,n){const r=this.textStates[e],s=this.createLabel(t,e,n,i),o=this.strokeStates[i],a=this.pixelRatio,l=vm(Array.isArray(t)?t[0]:t,r.textAlign||To),h=am[r.textBaseline||Co],c=o&&o.lineWidth?o.lineWidth:0;return{label:s,anchorX:l*(s.width/a-2*r.scale[0])+2*(.5-l)*c,anchorY:h*s.height/a+2*(.5-h)*c}}execute_(t,e,i,n,r,s,o,a){let l;this.pixelCoordinates_&&g(i,this.renderedTransform_)?l=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),l=Rn(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Ut(this.renderedTransform_,i));let h=0;const c=n.length;let u,d,f,p,m,_,y,x,v,S,w,E,T=0,C=0,R=0,b=null,P=null;const I=this.coordinateCache_,F=this.viewRotation_,L=Math.round(1e12*Math.atan2(-i[1],i[0]))/1e12,M={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:F},A=this.instructions!=n||this.overlaps?0:200;let O,N,D,k;for(;h<c;){const i=n[h];switch(i[0]){case Gp:O=i[1],k=i[3],O.getGeometry()?void 0===o||Ae(o,k.getExtent())?++h:h=i[2]+1:h=i[2];break;case jp:C>A&&(this.fill_(t),C=0),R>A&&(t.stroke(),R=0),C||R||(t.beginPath(),p=NaN,m=NaN),++h;break;case Bp:T=i[1];const n=l[T],c=l[T+1],g=l[T+2]-n,G=l[T+3]-c,j=Math.sqrt(g*g+G*G);t.moveTo(n+j,c),t.arc(n,c,j,0,2*Math.PI,!0),++h;break;case Up:t.closePath(),++h;break;case zp:T=i[1],u=i[2];const B=i[3],U=i[4],z=6==i.length?i[5]:void 0;M.geometry=B,M.feature=O,h in I||(I[h]=[]);const X=I[h];z?z(l,T,u,2,X):(X[0]=l[T],X[1]=l[T+1],X.length=2),U(X,M),++h;break;case Vp:T=i[1],u=i[2],x=i[3],d=i[4],f=i[5];let V=i[6];const W=i[7],Z=i[8],Y=i[9],K=i[10];let H=i[11];const q=i[12];let $=i[13];const J=i[14],Q=i[15];if(!x&&i.length>=20){v=i[19],S=i[20],w=i[21],E=i[22];const t=this.drawLabelWithPointPlacement_(v,S,w,E);x=t.label,i[3]=x;const e=i[23];d=(t.anchorX-e)*this.pixelRatio,i[4]=d;const n=i[24];f=(t.anchorY-n)*this.pixelRatio,i[5]=f,V=x.height,i[6]=V,$=x.width,i[13]=$}let tt,et,it,nt;i.length>25&&(tt=i[25]),i.length>17?(et=i[16],it=i[17],nt=i[18]):(et=Ro,it=!1,nt=!1),K&&L?H+=F:K||L||(H-=F);let rt=0;for(;T<u;T+=2){if(tt&&tt[rt++]<$/this.pixelRatio)continue;const i=this.calculateImageOrLabelDimensions_(x.width,x.height,l[T],l[T+1],$,V,d,f,Z,Y,H,q,r,et,it||nt,O),n=[t,e,x,i,W,it?b:null,nt?P:null];if(a){if("none"===J)continue;if("obstacle"===J){a.insert(i.declutterBox);continue}{let t,e;if(Q){const i=u-T;if(!Q[i]){Q[i]=n;continue}if(t=Q[i],delete Q[i],e=ym(t),a.collides(e))continue}if(a.collides(i.declutterBox))continue;t&&(a.insert(e),this.replayImageOrLabel_.apply(this,t)),a.insert(i.declutterBox)}}this.replayImageOrLabel_.apply(this,n)}++h;break;case Xp:const st=i[1],ot=i[2],at=i[3],lt=i[4];E=i[5];const ht=i[6],ct=i[7],ut=i[8];w=i[9];const dt=i[10];v=i[11],S=i[12];const gt=[i[13],i[13]],ft=this.textStates[S],pt=ft.font,mt=[ft.scale[0]*ct,ft.scale[1]*ct];let _t;pt in this.widths_?_t=this.widths_[pt]:(_t={},this.widths_[pt]=_t);const yt=dm(l,st,ot,2),xt=Math.abs(mt[0])*No(pt,v,_t);if(lt||xt<=yt){const i=um(l,st,ot,2,v,(yt-xt)*vm(v,this.textStates[S].textAlign),ht,Math.abs(mt[0]),No,pt,_t,L?0:this.viewRotation_);t:if(i){const n=[];let r,s,o,l,h;if(w)for(r=0,s=i.length;r<s;++r){h=i[r],o=h[4],l=this.createLabel(o,S,"",w),d=h[2]+(mt[0]<0?-dt:dt),f=at*l.height+2*(.5-at)*dt*mt[1]/mt[0]-ut;const s=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,d,f,0,0,h[3],gt,!1,Ro,!1,O);if(a&&a.collides(s.declutterBox))break t;n.push([t,e,l,s,1,null,null])}if(E)for(r=0,s=i.length;r<s;++r){h=i[r],o=h[4],l=this.createLabel(o,S,E,""),d=h[2],f=at*l.height-ut;const s=this.calculateImageOrLabelDimensions_(l.width,l.height,h[0],h[1],l.width,l.height,d,f,0,0,h[3],gt,!1,Ro,!1,O);if(a&&a.collides(s.declutterBox))break t;n.push([t,e,l,s,1,null,null])}a&&a.load(n.map(ym));for(let t=0,e=n.length;t<e;++t)this.replayImageOrLabel_.apply(this,n[t])}}++h;break;case Wp:if(void 0!==s){O=i[1];const t=s(O,k);if(t)return t}++h;break;case Zp:A?C++:this.fill_(t),++h;break;case Yp:for(T=i[1],u=i[2],N=l[T],D=l[T+1],_=N+.5|0,y=D+.5|0,_===p&&y===m||(t.moveTo(N,D),p=_,m=y),T+=2;T<u;T+=2)N=l[T],D=l[T+1],_=N+.5|0,y=D+.5|0,T!=u-2&&_===p&&y===m||(t.lineTo(N,D),p=_,m=y);++h;break;case Kp:b=i,this.alignFill_=i[2],C&&(this.fill_(t),C=0,R&&(t.stroke(),R=0)),t.fillStyle=i[1],++h;break;case Hp:P=i,R&&(t.stroke(),R=0),this.setStrokeStyle_(t,i),++h;break;case qp:A?R++:t.stroke(),++h;break;default:++h}}C&&this.fill_(t),R&&t.stroke()}execute(t,e,i,n,r,s){this.viewRotation_=n,this.execute_(t,e,i,this.instructions,r,void 0,void 0,s)}executeHitDetection(t,e,i,n,r){return this.viewRotation_=i,this.execute_(t,1,e,this.hitDetectionInstructions,!0,n,r)}};const Em=["Polygon","Circle","LineString","Image","Text","Default"];const Tm={};function Cm(t){if(void 0!==Tm[t])return Tm[t];const e=2*t+1,i=t*t,n=new Array(i+1);for(let r=0;r<=t;++r)for(let s=0;s<=t;++s){const o=r*r+s*s;if(o>i)break;let a=n[o];a||(a=[],n[o]=a),a.push(4*((t+r)*e+(t+s))+3),r>0&&a.push(4*((t-r)*e+(t+s))+3),s>0&&(a.push(4*((t+r)*e+(t-s))+3),r>0&&a.push(4*((t-r)*e+(t-s))+3))}const r=[];for(let t=0,e=n.length;t<e;++t)n[t]&&r.push(...n[t]);return Tm[t]=r,r}var Rm=class{constructor(t,e,i,n,r,s){this.maxExtent_=t,this.overlaps_=n,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=s,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=[1,0,0,1,0,0],this.createExecutors_(r)}clip(t,e){const i=this.getClipCoords(e);t.beginPath(),t.moveTo(i[0],i[1]),t.lineTo(i[2],i[3]),t.lineTo(i[4],i[5]),t.lineTo(i[6],i[7]),t.clip()}createExecutors_(t){for(const e in t){let i=this.executorsByZIndex_[e];void 0===i&&(i={},this.executorsByZIndex_[e]=i);const n=t[e];for(const t in n){const e=n[t];i[t]=new wm(this.resolution_,this.pixelRatio_,this.overlaps_,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let e=0,n=t.length;e<n;++e)if(t[e]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,n,r,s){const o=2*(n=Math.round(n))+1,a=Yt(this.hitDetectionTransform_,n+.5,n+.5,1/e,-1/e,-i,-t[0],-t[1]),h=!this.hitDetectionContext_;h&&(this.hitDetectionContext_=yt(o,o,void 0,{willReadFrequently:!0}));const c=this.hitDetectionContext_;let u;c.canvas.width!==o||c.canvas.height!==o?(c.canvas.width=o,c.canvas.height=o):h||c.clearRect(0,0,o,o),void 0!==this.renderBuffer_&&(u=[1/0,1/0,-1/0,-1/0],pe(u,t),te(u,e*(this.renderBuffer_+n),u));const d=Cm(n);let g;function f(t,e){const i=c.getImageData(0,0,o,o).data;for(let a=0,l=d.length;a<l;a++)if(i[d[a]]>0){if(!s||"Image"!==g&&"Text"!==g||s.includes(t)){const i=(d[a]-3)/4,s=n-i%o,l=n-(i/o|0),h=r(t,e,s*s+l*l);if(h)return h}c.clearRect(0,0,o,o);break}}const p=Object.keys(this.executorsByZIndex_).map(Number);let m,_,y,x,v;for(p.sort(l),m=p.length-1;m>=0;--m){const t=p[m].toString();for(y=this.executorsByZIndex_[t],_=Em.length-1;_>=0;--_)if(g=Em[_],x=y[g],void 0!==x&&(v=x.executeHitDetection(c,a,i,f,u),v))return v}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],n=e[1],r=e[2],s=e[3],o=[i,n,i,s,r,s,r,n];return Rn(o,0,8,2,t,o),o}isEmpty(){return S(this.executorsByZIndex_)}execute(t,e,i,n,r,s,o){const a=Object.keys(this.executorsByZIndex_).map(Number);let h,c,u,d,g,f;for(a.sort(l),this.maxExtent_&&(t.save(),this.clip(t,i)),s=s||Em,o&&a.reverse(),h=0,c=a.length;h<c;++h){const l=a[h].toString();for(g=this.executorsByZIndex_[l],u=0,d=s.length;u<d;++u){f=g[s[u]],void 0!==f&&f.execute(t,e,i,n,r,o)}}this.maxExtent_&&t.restore()}};const bm=.5;function Pm(t,e,i,n,r,s,o){const a=yt(t[0]*bm,t[1]*bm);a.imageSmoothingEnabled=!1;const h=a.canvas,c=new Xl(a,bm,r,null,o),u=i.length,d=Math.floor(16777215/u),g={};for(let t=1;t<=u;++t){const e=i[t-1],o=e.getStyleFunction()||n;if(!o)continue;let a=o(e,s);if(!a)continue;Array.isArray(a)||(a=[a]);const l=(t*d).toString(16).padStart(7,"#00000");for(let t=0,i=a.length;t<i;++t){const i=a[t],n=i.getGeometryFunction()(e);if(!n||!Ae(r,n.getExtent()))continue;const s=i.clone(),o=s.getFill();o&&o.setColor(l);const h=s.getStroke();h&&(h.setColor(l),h.setLineDash(null)),s.setText(void 0);const c=i.getImage();if(c){const t=c.getImageSize();if(!t)continue;const e=yt(t[0],t[1],void 0,{alpha:!1}),i=e.canvas;e.fillStyle=l,e.fillRect(0,0,i.width,i.height),s.setImage(new of({img:i,imgSize:t,anchor:c.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:c.getOrigin(),opacity:1,size:c.getSize(),scale:c.getScale(),rotation:c.getRotation(),rotateWithView:c.getRotateWithView()}))}const u=s.getZIndex()||0;let d=g[u];d||(d={},g[u]=d,d.Polygon=[],d.Circle=[],d.LineString=[],d.Point=[]);const f=n.getType();if("GeometryCollection"===f){const t=n.getGeometriesArrayRecursive();for(let e=0,i=t.length;e<i;++e){const i=t[e];d[i.getType().replace("Multi","")].push(i,s)}}else d[f.replace("Multi","")].push(n,s)}}const f=Object.keys(g).map(Number).sort(l);for(let t=0,i=f.length;t<i;++t){const i=g[f[t]];for(const t in i){const n=i[t];for(let t=0,i=n.length;t<i;t+=2){c.setStyle(n[t+1]);for(let i=0,r=e.length;i<r;++i)c.setTransform(e[i]),c.drawGeometry(n[t])}}}return a.getImageData(0,0,h.width,h.height)}function Im(t,e,i){const n=[];if(i){const r=Math.floor(Math.round(t[0])*bm),s=Math.floor(Math.round(t[1])*bm),o=4*(gi(r,0,i.width-1)+gi(s,0,i.height-1)*i.width),a=i.data[o],l=i.data[o+1],h=i.data[o+2]+256*(l+256*a),c=Math.floor(16777215/e.length);h&&h%c==0&&n.push(e[h/c-1])}return n}var Fm=class extends yu{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=[1/0,1/0,-1/0,-1/0],this.wrappedRenderedExtent_=[1/0,1/0,-1/0,-1/0],this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedRenderOrder_=null,this.replayGroup_=null,this.replayGroupChanged=!0,this.declutterExecutorGroup=null,this.clipping=!0,this.compositionContext_=null,this.opacity_=1}renderWorlds(t,e,i){const n=e.extent,r=e.viewState,s=r.center,o=r.resolution,a=r.projection,l=r.rotation,h=a.getExtent(),c=this.getLayer().getSource(),u=e.pixelRatio,d=e.viewHints,g=!(d[As]||d[Os]),f=this.compositionContext_,p=Math.round(e.size[0]*u),m=Math.round(e.size[1]*u),_=c.getWrapX()&&a.canWrapX(),y=_?Me(h):null,x=_?Math.ceil((n[2]-h[2])/y)+1:1;let v=_?Math.floor((n[0]-h[0])/y):0;do{const e=this.getRenderTransform(s,o,l,u,p,m,v*y);t.execute(f,1,e,l,g,void 0,i)}while(++v<x)}setupCompositionContext_(){if(1!==this.opacity_){const t=yt(this.context.canvas.width,this.context.canvas.height,mu);this.compositionContext_=t}else this.compositionContext_=this.context}releaseCompositionContext_(){if(1!==this.opacity_){const t=this.context.globalAlpha;this.context.globalAlpha=this.opacity_,this.context.drawImage(this.compositionContext_.canvas,0,0),this.context.globalAlpha=t,xt(this.compositionContext_),mu.push(this.compositionContext_.canvas),this.compositionContext_=null}}renderDeclutter(t){this.declutterExecutorGroup&&(this.setupCompositionContext_(),this.renderWorlds(this.declutterExecutorGroup,t,t.declutterTree),this.releaseCompositionContext_())}renderFrame(t,e){const i=t.pixelRatio,n=t.layerStatesArray[t.layerIndex];Wt(this.pixelTransform,1/i,1/i),Kt(this.inversePixelTransform,this.pixelTransform);const r=$t(this.pixelTransform);this.useContainer(e,r,this.getBackground(t));const s=this.context,o=s.canvas,a=this.replayGroup_,l=this.declutterExecutorGroup;let h=a&&!a.isEmpty()||l&&!l.isEmpty();if(!h){if(!(this.getLayer().hasListener(Ps)||this.getLayer().hasListener(Is)))return null}const c=Math.round(t.size[0]*i),u=Math.round(t.size[1]*i);o.width!=c||o.height!=u?(o.width=c,o.height=u,o.style.transform!==r&&(o.style.transform=r)):this.containerReused||s.clearRect(0,0,c,u),this.preRender(s,t);const d=t.viewState,g=d.projection;this.opacity_=n.opacity,this.setupCompositionContext_();let f=!1;if(h&&n.extent&&this.clipping){const e=Sn(n.extent,g);h=Ae(e,t.extent),f=h&&!re(e,t.extent),f&&this.clipUnrotated(this.compositionContext_,t,e)}return h&&this.renderWorlds(a,t),f&&this.compositionContext_.restore(),this.releaseCompositionContext_(),this.postRender(s,t),this.renderedRotation_!==d.rotation&&(this.renderedRotation_=d.rotation,this.hitDetectionImageData_=null),this.container}getFeatures(t){return new Promise((e=>{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=[this.context.canvas.width,this.context.canvas.height];zt(this.pixelTransform,t);const e=this.renderedCenter_,i=this.renderedResolution_,n=this.renderedRotation_,r=this.renderedProjection_,s=this.wrappedRenderedExtent_,o=this.getLayer(),a=[],l=t[0]*bm,h=t[1]*bm;a.push(this.getRenderTransform(e,i,n,bm,l,h,0).slice());const c=o.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!re(u,s)){let t=s[0];const r=Me(u);let o,c=0;for(;t<u[0];)--c,o=r*c,a.push(this.getRenderTransform(e,i,n,bm,l,h,o).slice()),t+=r;for(c=0,t=s[2];t>u[2];)++c,o=r*c,a.push(this.getRenderTransform(e,i,n,bm,l,h,o).slice()),t-=r}this.hitDetectionImageData_=Pm(t,a,this.renderedFeatures_,o.getStyleFunction(),s,i,n)}e(Im(t,this.renderedFeatures_,this.hitDetectionImageData_))}))}forEachFeatureAtCoordinate(t,e,i,n,r){if(!this.replayGroup_)return;const s=e.viewState.resolution,o=e.viewState.rotation,a=this.getLayer(),l={},h=function(t,e,i){const s=V(t),o=l[s];if(o){if(!0!==o&&i<o.distanceSq){if(0===i)return l[s]=!0,r.splice(r.lastIndexOf(o),1),n(t,a,e);o.geometry=e,o.distanceSq=i}}else{if(0===i)return l[s]=!0,n(t,a,e);r.push(l[s]={feature:t,layer:a,geometry:e,distanceSq:i,callback:n})}};let c;const u=[this.replayGroup_];return this.declutterExecutorGroup&&u.push(this.declutterExecutorGroup),u.some((n=>c=n.forEachFeatureAtCoordinate(t,s,o,i,h,n===this.declutterExecutorGroup&&e.declutterTree?e.declutterTree.all().map((t=>t.value)):null))),c}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const n=t.viewHints[As],r=t.viewHints[Os],s=e.getUpdateWhileAnimating(),o=e.getUpdateWhileInteracting();if(this.ready&&!s&&n||!o&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const a=t.extent,l=t.viewState,h=l.projection,c=l.resolution,u=t.pixelRatio,d=e.getRevision(),f=e.getRenderBuffer();let p=e.getRenderOrder();void 0===p&&(p=Zl);const m=l.center.slice(),_=te(a,f*c),y=_.slice(),x=[_.slice()],v=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!re(v,t.extent)){const t=Me(v),e=Math.max(Me(_)/2,t);_[0]=v[0]-e,_[2]=v[2]+e,ji(m,h);const i=je(x[0],h);i[0]<v[0]&&i[2]<v[2]?x.push([i[0]+t,i[1],i[2]+t,i[3]]):i[0]>v[0]&&i[2]>v[2]&&x.push([i[0]-t,i[1],i[2]-t,i[3]])}if(this.ready&&this.renderedResolution_==c&&this.renderedRevision_==d&&this.renderedRenderOrder_==p&&re(this.wrappedRenderedExtent_,_))return g(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const S=new cm(Kl(c,u),_,c,u);let w;this.getLayer().getDeclutter()&&(w=new cm(Kl(c,u),_,c,u));const E=_n();let T;if(E){for(let t=0,e=x.length;t<e;++t){const e=vn(x[t],h);i.loadFeatures(e,wn(c,h),E)}T=un(E,h)}else for(let t=0,e=x.length;t<e;++t)i.loadFeatures(x[t],c,h);const C=Yl(c,u);let R=!0;const b=t=>{let i;const n=t.getStyleFunction()||e.getStyleFunction();if(n&&(i=n(t,c)),i){const e=this.renderFeature(t,C,i,S,T,w);R=R&&!e}},P=vn(_,h),I=i.getFeaturesInExtent(P);p&&I.sort(p);for(let t=0,e=I.length;t<e;++t)b(I[t]);this.renderedFeatures_=I,this.ready=R;const F=S.finish(),L=new Rm(_,c,u,i.getOverlaps(),F,e.getRenderBuffer());return w&&(this.declutterExecutorGroup=new Rm(_,c,u,i.getOverlaps(),w.finish(),e.getRenderBuffer())),this.renderedResolution_=c,this.renderedRevision_=d,this.renderedRenderOrder_=p,this.renderedExtent_=y,this.wrappedRenderedExtent_=_,this.renderedCenter_=m,this.renderedProjection_=h,this.replayGroup_=L,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,n,r,s){if(!i)return!1;let o=!1;if(Array.isArray(i))for(let a=0,l=i.length;a<l;++a)o=Hl(n,t,i[a],e,this.boundHandleStyleImageChange_,r,s)||o;else o=Hl(n,t,i,e,this.boundHandleStyleImageChange_,r,s);return o}};var Lm=class extends xu{constructor(t){super(t),this.vectorRenderer_=new Fm(t),this.layerImageRatio_=t.getImageRatio(),this.coordinateToVectorPixelTransform_=[1,0,0,1,0,0],this.renderedPixelToCoordinateTransform_=null}disposeInternal(){this.vectorRenderer_.dispose(),super.disposeInternal()}getFeatures(t){if(!this.vectorRenderer_)return Promise.resolve([]);const e=zt(this.coordinateToVectorPixelTransform_,zt(this.renderedPixelToCoordinateTransform_,t.slice()));return this.vectorRenderer_.getFeatures(e)}handleFontsChanged(){this.vectorRenderer_.handleFontsChanged()}prepareFrame(t){const e=t.pixelRatio,i=t.viewState,n=i.resolution,r=t.viewHints,s=this.vectorRenderer_;let o=t.extent;1!==this.layerImageRatio_&&(o=o.slice(0),De(o,this.layerImageRatio_));const a=Me(o)/n,l=Pe(o)/n;if(!r[As]&&!r[Os]&&!Oe(o)){s.useContainer(null,null);const r=s.context,h=t.layerStatesArray[t.layerIndex],c=Object.assign({},h,{opacity:1}),u=Object.assign({},t,{declutterTree:new Uh(9),extent:o,size:[a,l],viewState:Object.assign({},t.viewState,{rotation:0}),layerStatesArray:[c],layerIndex:0});let d=!0;const g=new es(o,n,e,r.canvas,(function(t){s.prepareFrame(u)&&s.replayGroupChanged&&(s.clipping=!1,s.renderFrame(u,null)&&(s.renderDeclutter(u),d=!1),t())}));g.addEventListener(E,(()=>{if(g.getState()!==qr)return;this.image_=d?null:g;const t=g.getResolution(),n=g.getPixelRatio(),r=t*e/n;this.renderedResolution=r,this.coordinateToVectorPixelTransform_=Yt(this.coordinateToVectorPixelTransform_,a/2,l/2,1/r,-1/r,0,-i.center[0],-i.center[1])})),g.load()}return this.image_&&(this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice()),!!this.image_}preRender(){}postRender(){}renderDeclutter(){}forEachFeatureAtCoordinate(t,e,i,n,r){return this.vectorRenderer_?this.vectorRenderer_.forEachFeatureAtCoordinate(t,e,i,n,r):super.forEachFeatureAtCoordinate(t,e,i,n,r)}};const Mm={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},Am={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};var Om=class extends Tu{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.tmpTransform_=[1,0,0,1,0,0]}prepareTile(t,e,i){let n;const r=t.getState();return r!==tt&&r!==et||(this.updateExecutorGroup_(t,e,i),this.tileImageNeedsRender_(t)&&(n=!0)),n}getTile(t,e,i,n){const r=n.pixelRatio,s=n.viewState,o=s.resolution,a=s.projection,l=this.getLayer(),h=l.getSource().getTile(t,e,i,r,a),c=n.viewHints,u=!(c[As]||c[Os]);!u&&h.wantedResolution||(h.wantedResolution=o);return this.prepareTile(h,r,a)&&(u||Date.now()-n.time<8)&&"vector"!==l.getRenderMode()&&this.renderTileImage_(h,n),super.getTile(t,e,i,n)}isDrawableTile(t){const e=this.getLayer();return super.isDrawableTile(t)&&("vector"===e.getRenderMode()?V(e)in t.executorGroups:t.hasContext(e))}getTileImage(t){return t.getImage(this.getLayer())}prepareFrame(t){const e=this.getLayer().getRevision();return this.renderedLayerRevision_!==e&&(this.renderedLayerRevision_=e,this.renderedTiles.length=0),super.prepareFrame(t)}updateExecutorGroup_(t,e,i){const n=this.getLayer(),r=n.getRevision(),s=n.getRenderOrder()||null,o=t.wantedResolution,a=t.getReplayState(n);if(!a.dirty&&a.renderedResolution===o&&a.renderedRevision==r&&a.renderedRenderOrder==s)return;const l=n.getSource(),h=n.getDeclutter(),c=l.getTileGrid(),u=l.getTileGridForProjection(i).getTileCoordExtent(t.wrappedTileCoord),d=l.getSourceTiles(e,i,t),g=V(n);delete t.hitDetectionImageData[g],t.executorGroups[g]=[],h&&(t.declutterExecutorGroups[g]=[]),a.dirty=!1;for(let i=0,r=d.length;i<r;++i){const r=d[i];if(r.getState()!=tt)continue;const f=r.tileCoord,p=c.getTileCoordExtent(f),m=Ie(u,p),_=te(m,n.getRenderBuffer()*o,this.tmpExtent),y=de(p,m)?null:_,x=new cm(0,_,o,e),v=h?new cm(0,m,o,e):void 0,S=Yl(o,e),w=function(t){let e;const i=t.getStyleFunction()||n.getStyleFunction();if(i&&(e=i(t,o)),e){const i=this.renderFeature(t,S,e,x,v);a.dirty=a.dirty||i}},E=r.getFeatures();s&&s!==a.renderedRenderOrder&&E.sort(s);for(let t=0,e=E.length;t<e;++t){const e=E[t];y&&!Ae(y,e.getGeometry().getExtent())||w.call(this,e)}const T=x.finish(),C="vector"!==n.getRenderMode()&&h&&1===d.length?null:m,R=new Rm(C,o,e,l.getOverlaps(),T,n.getRenderBuffer());if(t.executorGroups[g].push(R),v){const i=new Rm(null,o,e,l.getOverlaps(),v.finish(),n.getRenderBuffer());t.declutterExecutorGroups[g].push(i)}}a.renderedRevision=r,a.renderedRenderOrder=s,a.renderedResolution=o}forEachFeatureAtCoordinate(t,e,i,n,r){const s=e.viewState.resolution,o=e.viewState.rotation;i=null==i?0:i;const a=this.getLayer(),l=a.getSource().getTileGridForProjection(e.viewState.projection),h=Qt([t]);te(h,s*i,h);const c={},u=function(t,e,i){let s=t.getId();void 0===s&&(s=V(t));const o=c[s];if(o){if(!0!==o&&i<o.distanceSq){if(0===i)return c[s]=!0,r.splice(r.lastIndexOf(o),1),n(t,a,e);o.geometry=e,o.distanceSq=i}}else{if(0===i)return c[s]=!0,n(t,a,e);r.push(c[s]={feature:t,layer:a,geometry:e,distanceSq:i,callback:n})}},d=this.renderedTiles;let g;for(let n=0,r=d.length;!g&&n<r;++n){const r=d[n];if(!Ae(l.getTileCoordExtent(r.wrappedTileCoord),h))continue;const c=V(a),f=[r.executorGroups[c]],p=r.declutterExecutorGroups[c];p&&f.push(p),f.some((n=>{const r=n===p?e.declutterTree.all().map((t=>t.value)):null;for(let e=0,a=n.length;e<a;++e){const a=n[e];if(g=a.forEachFeatureAtCoordinate(t,s,o,i,u,r),g)return!0}}))}return g}getFeatures(t){return new Promise(((e,i)=>{const n=this.getLayer(),r=V(n),s=n.getSource(),o=this.renderedProjection,a=o.getExtent(),l=this.renderedResolution,h=s.getTileGridForProjection(o),c=zt(this.renderedPixelToCoordinateTransform_,t.slice()),u=h.getTileCoordForCoordAndResolution(c,l);let d;for(let t=0,e=this.renderedTiles.length;t<e;++t)if(u.toString()===this.renderedTiles[t].tileCoord.toString()){if(d=this.renderedTiles[t],d.getState()===tt){const t=h.getTileCoordExtent(d.tileCoord);s.getWrapX()&&o.canWrapX()&&!re(a,t)&&ji(c,o);break}d=void 0}if(!d||d.loadingSourceTiles>0)return void e([]);const g=Fe(h.getTileCoordExtent(d.wrappedTileCoord)),f=[(c[0]-g[0])/l,(g[1]-c[1])/l],p=d.getSourceTiles().reduce((function(t,e){return t.concat(e.getFeatures())}),[]);let m=d.hitDetectionImageData[r];if(!m){const t=ol(h.getTileSize(h.getZForResolution(l,s.zDirection))),e=this.renderedRotation_;m=Pm(t,[this.getRenderTransform(h.getTileCoordCenter(d.wrappedTileCoord),l,0,bm,t[0]*bm,t[1]*bm,0)],p,n.getStyleFunction(),h.getTileCoordExtent(d.wrappedTileCoord),d.getReplayState(n).renderedResolution,e),d.hitDetectionImageData[r]=m}e(Im(f,p,m))}))}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&void 0!==this.renderedLayerRevision_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}renderDeclutter(t){const e=this.context,i=e.globalAlpha;e.globalAlpha=this.getLayer().getOpacity();const n=t.viewHints,r=!(n[As]||n[Os]),s=this.renderedTiles;for(let e=0,i=s.length;e<i;++e){const i=s[e],n=i.declutterExecutorGroups[V(this.getLayer())];if(n)for(let e=n.length-1;e>=0;--e)n[e].execute(this.context,1,this.getTileRenderTransform(i,t),t.viewState.rotation,r,void 0,t.declutterTree)}e.globalAlpha=i}getTileRenderTransform(t,e){const i=e.pixelRatio,n=e.viewState,r=n.center,s=n.resolution,o=n.rotation,a=e.size,l=Math.round(a[0]*i),h=Math.round(a[1]*i),c=this.getLayer().getSource().getTileGridForProjection(e.viewState.projection),u=t.tileCoord,d=c.getTileCoordExtent(t.wrappedTileCoord),g=c.getTileCoordExtent(u,this.tmpExtent)[0]-d[0];return jt(Vt(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(r,s,o,i,l,h,g))}postRender(t,e){const i=e.viewHints,n=!(i[As]||i[Os]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation;const r=this.getLayer(),s=r.getRenderMode(),o=t.globalAlpha;t.globalAlpha=r.getOpacity();const a=Am[s],l=e.viewState,h=l.rotation,c=r.getSource(),u=c.getTileGridForProjection(l.projection).getZForResolution(l.resolution,c.zDirection),d=this.renderedTiles,g=[],f=[];let p=!0;for(let i=d.length-1;i>=0;--i){const s=d[i];p=p&&!s.getReplayState(r).dirty;const o=s.executorGroups[V(r)].filter((t=>t.hasExecutors(a)));if(0===o.length)continue;const l=this.getTileRenderTransform(s,e),c=s.tileCoord[0];let m=!1;const _=o[0].getClipCoords(l);if(_){for(let e=0,i=g.length;e<i;++e)if(u!==c&&c<f[e]){const i=g[e];Ae([_[0],_[3],_[4],_[7]],[i[0],i[3],i[4],i[7]])&&(m||(t.save(),m=!0),t.beginPath(),t.moveTo(_[0],_[1]),t.lineTo(_[2],_[3]),t.lineTo(_[4],_[5]),t.lineTo(_[6],_[7]),t.moveTo(i[6],i[7]),t.lineTo(i[4],i[5]),t.lineTo(i[2],i[3]),t.lineTo(i[0],i[1]),t.clip())}g.push(_),f.push(c)}for(let e=0,i=o.length;e<i;++e){o[e].execute(t,1,l,h,n,a)}m&&t.restore()}t.globalAlpha=o,this.ready=p,super.postRender(t,e)}renderFeature(t,e,i,n,r){if(!i)return!1;let s=!1;if(Array.isArray(i))for(let o=0,a=i.length;o<a;++o)s=Hl(n,t,i[o],e,this.boundHandleStyleImageChange_,void 0,r)||s;else s=Hl(n,t,i,e,this.boundHandleStyleImageChange_,void 0,r);return s}tileImageNeedsRender_(t){const e=this.getLayer();if("vector"===e.getRenderMode())return!1;const i=t.getReplayState(e),n=e.getRevision(),r=t.wantedResolution;return i.renderedTileResolution!==r||i.renderedTileRevision!==n}renderTileImage_(t,e){const i=this.getLayer(),n=t.getReplayState(i),r=i.getRevision(),s=t.executorGroups[V(i)];n.renderedTileRevision=r;const o=t.wrappedTileCoord,a=o[0],l=i.getSource();let h=e.pixelRatio;const c=e.viewState.projection,u=l.getTileGridForProjection(c),d=u.getResolution(t.tileCoord[0]),g=e.pixelRatio/t.wantedResolution*d,f=u.getResolution(a),p=t.getContext(i);h=Math.round(Math.max(h,g/h));const m=l.getTilePixelSize(a,h,c);p.canvas.width=m[0],p.canvas.height=m[1];const _=h/g;if(1!==_){const t=Gt(this.tmpTransform_);Vt(t,_,_),p.setTransform.apply(p,t)}const y=u.getTileCoordExtent(o,this.tmpExtent),x=g/f,v=Gt(this.tmpTransform_);Vt(v,x,-x),Zt(v,-y[0],-y[3]);for(let t=0,e=s.length;t<e;++t){s[t].execute(p,_,v,0,!0,Mm[i.getRenderMode()])}n.renderedTileResolution=t.wantedResolution}};class Nm extends On{constructor(t,e,i){super(),void 0!==i&&void 0===e?this.setFlatCoordinates(i,t):(e=e||0,this.setCenterAndRadius(t,e,i))}clone(){const t=new Nm(this.flatCoordinates.slice(),void 0,this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){const r=this.flatCoordinates,s=t-r[0],o=e-r[1],a=s*s+o*o;if(a<n){if(0===a)for(let t=0;t<this.stride;++t)i[t]=r[t];else{const t=this.getRadius()/Math.sqrt(a);i[0]=r[0]+t*s,i[1]=r[1]+t*o;for(let t=2;t<this.stride;++t)i[t]=r[t]}return i.length=this.stride,a}return n}containsXY(t,e){const i=this.flatCoordinates,n=t-i[0],r=e-i[1];return n*n+r*r<=this.getRadiusSquared_()}getCenter(){return this.flatCoordinates.slice(0,this.stride)}computeExtent(t){const e=this.flatCoordinates,i=e[this.stride]-e[0];return le(e[0]-i,e[1]-i,e[0]+i,e[1]+i,t)}getRadius(){return Math.sqrt(this.getRadiusSquared_())}getRadiusSquared_(){const t=this.flatCoordinates[this.stride]-this.flatCoordinates[0],e=this.flatCoordinates[this.stride+1]-this.flatCoordinates[1];return t*t+e*e}getType(){return"Circle"}intersectsExtent(t){if(Ae(t,this.getExtent())){const e=this.getCenter();return t[0]<=e[0]&&t[2]>=e[0]||(t[1]<=e[1]&&t[3]>=e[1]||ve(t,this.intersectsCoordinate.bind(this)))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],n=t.slice();n[e]=n[0]+i;for(let i=1;i<e;++i)n[e+i]=t[i];this.setFlatCoordinates(this.layout,n),this.changed()}setCenterAndRadius(t,e,i){this.setLayout(i,t,0),this.flatCoordinates||(this.flatCoordinates=[]);const n=this.flatCoordinates;let r=zn(n,0,t,this.stride);n[r++]=n[0]+e;for(let t=1,e=this.stride;t<e;++t)n[r++]=n[t];n.length=r,this.changed()}getCoordinates(){return null}setCoordinates(t,e){}setRadius(t){this.flatCoordinates[this.stride]=this.flatCoordinates[0]+t,this.changed()}rotate(t,e){const i=this.getCenter(),n=this.getStride();this.setCenter(bn(i,0,i.length,n,t,e,i)),this.changed()}}Nm.prototype.transform;var Dm=Nm;class km extends Ln{constructor(t){super(),this.geometries_=t||null,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(G),this.changeEventsKeys_.length=0}listenGeometriesChange_(){if(this.geometries_)for(let t=0,e=this.geometries_.length;t<e;++t)this.changeEventsKeys_.push(D(this.geometries_[t],E,this.changed,this))}clone(){const t=new km(null);return t.setGeometries(this.geometries_),t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<ie(this.getExtent(),t,e))return n;const r=this.geometries_;for(let s=0,o=r.length;s<o;++s)n=r[s].closestPointXY(t,e,i,n);return n}containsXY(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)if(i[n].containsXY(t,e))return!0;return!1}computeExtent(t){he(t);const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)fe(t,e[i].getExtent());return t}getGeometries(){return Gm(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let t=[];const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)e[i].getType()===this.getType()?t=t.concat(e[i].getGeometriesArrayRecursive()):t.push(e[i]);return t}getSimplifiedGeometry(t){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),t<0||0!==this.simplifiedGeometryMaxMinSquaredTolerance&&t<this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=[],i=this.geometries_;let n=!1;for(let r=0,s=i.length;r<s;++r){const s=i[r],o=s.getSimplifiedGeometry(t);e.push(o),o!==s&&(n=!0)}if(n){const t=new km(null);return t.setGeometriesArray(e),t}return this.simplifiedGeometryMaxMinSquaredTolerance=t,this}getType(){return"GeometryCollection"}intersectsExtent(t){const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)if(e[i].intersectsExtent(t))return!0;return!1}isEmpty(){return 0===this.geometries_.length}rotate(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)i[n].rotate(t,e);this.changed()}scale(t,e,i){i||(i=Te(this.getExtent()));const n=this.geometries_;for(let r=0,s=n.length;r<s;++r)n[r].scale(t,e,i);this.changed()}setGeometries(t){this.setGeometriesArray(Gm(t))}setGeometriesArray(t){this.unlistenGeometriesChange_(),this.geometries_=t,this.listenGeometriesChange_(),this.changed()}applyTransform(t){const e=this.geometries_;for(let i=0,n=e.length;i<n;++i)e[i].applyTransform(t);this.changed()}translate(t,e){const i=this.geometries_;for(let n=0,r=i.length;n<r;++n)i[n].translate(t,e);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}}function Gm(t){const e=[];for(let i=0,n=t.length;i<n;++i)e.push(t[i].clone());return e}var jm=km;function Bm(t,e,i,n,r,s,o){let l,h;const c=(i-e)/n;if(1===c)l=e;else if(2===c)l=e,h=r;else if(0!==c){let s=t[e],o=t[e+1],c=0;const u=[0];for(let r=e+n;r<i;r+=n){const e=t[r],i=t[r+1];c+=Math.sqrt((e-s)*(e-s)+(i-o)*(i-o)),u.push(c),s=e,o=i}const d=r*c,g=a(u,d);g<0?(h=(d-u[-g-2])/(u[-g-1]-u[-g-2]),l=e+(-g-2)*n):l=e+g*n}o=o>1?o:2,s=s||new Array(o);for(let e=0;e<o;++e)s[e]=void 0===l?NaN:void 0===h?t[l+e]:vi(t[l+e],t[l+n+e],h);return s}function Um(t,e,i,n,r,s){if(i==e)return null;let o;if(r<t[e+n-1])return s?(o=t.slice(e,e+n),o[n-1]=r,o):null;if(t[i-1]<r)return s?(o=t.slice(i-n,i),o[n-1]=r,o):null;if(r==t[e+n-1])return t.slice(e,e+n);let a=e/n,l=i/n;for(;a<l;){const e=a+l>>1;r<t[(e+1)*n-1]?l=e:a=e+1}const h=t[a*n-1];if(r==h)return t.slice((a-1)*n,(a-1)*n+n);const c=(r-h)/(t[(a+1)*n-1]-h);o=[];for(let e=0;e<n-1;++e)o.push(vi(t[(a-1)*n+e],t[a*n+e],c));return o.push(r),o}function zm(t,e,i,n,r,s,o){if(o)return Um(t,e,i[i.length-1],n,r,s);let a;if(r<t[n-1])return s?(a=t.slice(0,n),a[n-1]=r,a):null;if(t[t.length-1]<r)return s?(a=t.slice(t.length-n),a[n-1]=r,a):null;for(let s=0,o=i.length;s<o;++s){const o=i[s];if(e!=o){if(r<t[e+n-1])return null;if(r<=t[o-1])return Um(t,e,o,n,r,!1);e=o}}return null}class Xm extends On{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,void 0===e||Array.isArray(t[0])?this.setCoordinates(t,e):this.setFlatCoordinates(e,t)}appendCoordinate(t){this.flatCoordinates?d(this.flatCoordinates,t):this.flatCoordinates=t.slice(),this.changed()}clone(){const t=new Xm(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<ie(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Dn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),jn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,n))}forEachSegment(t){return pr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return"XYM"!=this.layout&&"XYZM"!=this.layout?null:(e=void 0!==e&&e,Um(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return Qn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return Bm(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return dm(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=Zn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Xm(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return mr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Xn(this.flatCoordinates,0,t,this.stride),this.changed()}}var Vm=Xm;class Wm extends On{constructor(t,e,i){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(t[0]))this.setCoordinates(t,e);else if(void 0!==e&&i)this.setFlatCoordinates(e,t),this.ends_=i;else{let e=this.getLayout();const i=t,n=[],r=[];for(let t=0,s=i.length;t<s;++t){const s=i[t];0===t&&(e=s.getLayout()),d(n,s.getFlatCoordinates()),r.push(n.length)}this.setFlatCoordinates(e,n),this.ends_=r}}appendLineString(t){this.flatCoordinates?d(this.flatCoordinates,t.getFlatCoordinates().slice()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Wm(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,n){return n<ie(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kn(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Bn(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,t,e,i,n))}getCoordinateAtM(t,e,i){return"XYM"!=this.layout&&"XYZM"!=this.layout||0===this.flatCoordinates.length?null:(e=void 0!==e&&e,i=void 0!==i&&i,zm(this.flatCoordinates,0,this.ends_,this.stride,t,e,i))}getCoordinates(){return tr(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(t){return t<0||this.ends_.length<=t?null:new Vm(this.flatCoordinates.slice(0===t?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLineStrings(){const t=this.flatCoordinates,e=this.ends_,i=this.layout,n=[];let r=0;for(let s=0,o=e.length;s<o;++s){const o=e[s],a=new Vm(t.slice(r,o),i);n.push(a),r=o}return n}getFlatMidpoints(){const t=[],e=this.flatCoordinates;let i=0;const n=this.ends_,r=this.stride;for(let s=0,o=n.length;s<o;++s){const o=n[s];d(t,Bm(e,i,o,r,.5)),i=o}return t}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Yn(this.flatCoordinates,0,this.ends_,this.stride,t,e,0,i),new Wm(e,"XY",i)}getType(){return"MultiLineString"}intersectsExtent(t){return _r(this.flatCoordinates,0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=Vn(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=0===i.length?0:i[i.length-1],this.changed()}}var Zm=Wm;class Ym extends On{constructor(t,e){super(),e&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendPoint(t){this.flatCoordinates?d(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.changed()}clone(){const t=new Ym(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,n){if(n<ie(this.getExtent(),t,e))return n;const r=this.flatCoordinates,s=this.stride;for(let o=0,a=r.length;o<a;o+=s){const a=pi(t,e,r[o],r[o+1]);if(a<n){n=a;for(let t=0;t<s;++t)i[t]=r[o+t];i.length=s}}return n}getCoordinates(){return Qn(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(t){const e=this.flatCoordinates?this.flatCoordinates.length/this.stride:0;return t<0||e<=t?null:new lr(this.flatCoordinates.slice(t*this.stride,(t+1)*this.stride),this.layout)}getPoints(){const t=this.flatCoordinates,e=this.layout,i=this.stride,n=[];for(let r=0,s=t.length;r<s;r+=i){const s=new lr(t.slice(r,r+i),e);n.push(s)}return n}getType(){return"MultiPoint"}intersectsExtent(t){const e=this.flatCoordinates,i=this.stride;for(let n=0,r=e.length;n<r;n+=i){if(se(t,e[n],e[n+1]))return!0}return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Xn(this.flatCoordinates,0,t,this.stride),this.changed()}}var Km=Ym;function Hm(t,e,i,n){const r=[];let s=[1/0,1/0,-1/0,-1/0];for(let o=0,a=i.length;o<a;++o){const a=i[o];s=ue(t,e,a[0],n),r.push((s[0]+s[2])/2,(s[1]+s[3])/2),e=a[a.length-1]}return r}class qm extends On{constructor(t,e,i){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!i&&!Array.isArray(t[0])){let n=this.getLayout();const r=t,s=[],o=[];for(let t=0,e=r.length;t<e;++t){const e=r[t];0===t&&(n=e.getLayout());const i=s.length,a=e.getEnds();for(let t=0,e=a.length;t<e;++t)a[t]+=i;d(s,e.getFlatCoordinates()),o.push(a)}e=n,t=s,i=o}void 0!==e&&i?(this.setFlatCoordinates(e,t),this.endss_=i):this.setCoordinates(t,e)}appendPolygon(t){let e;if(this.flatCoordinates){const i=this.flatCoordinates.length;d(this.flatCoordinates,t.getFlatCoordinates()),e=t.getEnds().slice();for(let t=0,n=e.length;t<n;++t)e[t]+=i}else this.flatCoordinates=t.getFlatCoordinates().slice(),e=t.getEnds().slice(),this.endss_.push();this.endss_.push(e),this.changed()}clone(){const t=this.endss_.length,e=new Array(t);for(let i=0;i<t;++i)e[i]=this.endss_[i].slice();const i=new qm(this.flatCoordinates.slice(),this.layout,e);return i.applyProperties(this),i}closestPointXY(t,e,i,n){return n<ie(this.getExtent(),t,e)?n:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Gn(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Un(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,t,e,i,n))}containsXY(t,e){return dr(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t,e)}getArea(){return rr(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(t){let e;return void 0!==t?(e=this.getOrientedFlatCoordinates().slice(),Rr(e,0,this.endss_,this.stride,t)):e=this.flatCoordinates,er(e,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){const t=Hm(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=fr(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Km(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;Tr(t,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Rr(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=Jn(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(t),e,0,i),new qm(e,"XY",i)}getPolygon(t){if(t<0||this.endss_.length<=t)return null;let e;if(0===t)e=0;else{const i=this.endss_[t-1];e=i[i.length-1]}const i=this.endss_[t].slice(),n=i[i.length-1];if(0!==e)for(let t=0,n=i.length;t<n;++t)i[t]-=e;return new Ir(this.flatCoordinates.slice(e,n),this.layout,i)}getPolygons(){const t=this.layout,e=this.flatCoordinates,i=this.endss_,n=[];let r=0;for(let s=0,o=i.length;s<o;++s){const o=i[s].slice(),a=o[o.length-1];if(0!==r)for(let t=0,e=o.length;t<e;++t)o[t]-=r;const l=new Ir(e.slice(r,a),t,o);n.push(l),r=a}return n}getType(){return"MultiPolygon"}intersectsExtent(t){return vr(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,3),this.flatCoordinates||(this.flatCoordinates=[]);const i=Wn(this.flatCoordinates,0,t,this.stride,this.endss_);if(0===i.length)this.flatCoordinates.length=0;else{const t=i[i.length-1];this.flatCoordinates.length=0===t.length?0:t[t.length-1]}this.changed()}}var $m=qm;const Jm=[1,0,0,1,0,0];class Qm{constructor(t,e,i,n,r){this.styleFunction,this.extent_,this.id_=r,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i,this.properties_=n}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_="Point"===this.type_?ce(this.flatCoordinates_):ue(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Te(this.getExtent());this.flatInteriorPoints_=gr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=Hm(this.flatCoordinates_,0,this.ends_,2);this.flatInteriorPoints_=fr(this.flatCoordinates_,0,this.ends_,2,t)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Bm(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let n=0,r=i.length;n<r;++n){const r=i[n],s=Bm(t,e,r,2,.5);d(this.flatMidpoints_,s),e=r}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getStride(){return 2}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){const e=(t=nn(t)).getExtent(),i=t.getWorldExtent();if(e&&i){const t=Pe(i)/Pe(e);Yt(Jm,i[0],i[3],t,-t,0,0,0),Rn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Jm,this.flatCoordinates_)}}getEnds(){return this.ends_}}function t_(t){const e=t.getType();switch(e){case"Point":return new lr(t.getFlatCoordinates());case"MultiPoint":return new Km(t.getFlatCoordinates(),"XY");case"LineString":return new Vm(t.getFlatCoordinates(),"XY");case"MultiLineString":return new Zm(t.getFlatCoordinates(),"XY",t.getEnds());case"Polygon":const i=t.getFlatCoordinates(),n=t.getEnds(),r=br(i,n);return r.length>1?new $m(i,"XY",r):new Ir(i,"XY",n);default:throw new Error("Invalid geometry type:"+e)}}Qm.prototype.getEndss=Qm.prototype.getEnds,Qm.prototype.getFlatCoordinates=Qm.prototype.getOrientedFlatCoordinates;var e_=Qm;let i_=null;function n_(t){i_=t;const e=Object.keys(t.defs),i=e.length;let n,r;for(n=0;n<i;++n){const i=e[n];if(!nn(i)){const e=t.defs(i);let n=e.units;n||"longlat"!==e.projName||(n="degrees"),tn(new Ve({code:i,axisOrientation:e.axis,metersPerUnit:e.to_meter,units:n}))}}for(n=0;n<i;++n){const s=e[n],o=nn(s);for(r=0;r<i;++r){const i=e[r],n=nn(i);if(!di(s,i))if(t.defs[s]===t.defs[i])sn([o,n]);else{const e=t(s,i);hn(o,n,Tn(o,n,e.forward),Tn(n,o,e.inverse))}}}}let r_=async function(t){const e=await fetch(`https://epsg.io/${t}.proj4`);if(!e.ok)throw new Error(`Unexpected response from epsg.io: ${e.status}`);return e.text()};var s_=class extends Df{constructor(t){super(t)}createRenderer(){return new Fm(this)}};function o_(t,e,i){const n=[];let r=t(0),s=t(1),o=e(r),a=e(s);const l=[s,r],h=[a,o],c=[1,0],u={};let d,g,f,p,m,_,y=1e5;for(;--y>0&&c.length>0;)f=c.pop(),r=l.pop(),o=h.pop(),_=f.toString(),_ in u||(n.push(o[0],o[1]),u[_]=!0),p=c.pop(),s=l.pop(),a=h.pop(),m=(f+p)/2,d=t(m),g=e(d),fi(g[0],g[1],o[0],o[1],a[0],a[1])<i?(n.push(a[0],a[1]),_=p.toString(),u[_]=!0):(c.push(p,m,m,f),h.push(a,g,g,o),l.push(s,d,d,r));return n}function a_(t,e,i,n,r){return o_((function(n){return[t,e+(i-e)*n]}),dn(nn("EPSG:4326"),n),r)}function l_(t,e,i,n,r){return o_((function(n){return[e+(i-e)*n,t]}),dn(nn("EPSG:4326"),n),r)}const h_=new lf({color:"rgba(0,0,0,0.2)"}),c_=[90,45,30,20,10,5,2,1,.5,20/60,10/60,5/60,2/60,1/60,30/3600,20/3600,10/3600,5/3600,2/3600,1/3600];var u_=class extends s_{constructor(t){t=t||{};const e=Object.assign({updateWhileAnimating:!0,updateWhileInteracting:!0,renderBuffer:0},t);delete e.maxLines,delete e.strokeStyle,delete e.targetSize,delete e.showLabels,delete e.lonLabelFormatter,delete e.latLabelFormatter,delete e.lonLabelPosition,delete e.latLabelPosition,delete e.lonLabelStyle,delete e.latLabelStyle,delete e.intervals,super(e),this.projection_=null,this.maxLat_=1/0,this.maxLon_=1/0,this.minLat_=-1/0,this.minLon_=-1/0,this.maxX_=1/0,this.maxY_=1/0,this.minX_=-1/0,this.minY_=-1/0,this.targetSize_=void 0!==t.targetSize?t.targetSize:100,this.maxLines_=void 0!==t.maxLines?t.maxLines:100,this.meridians_=[],this.parallels_=[],this.strokeStyle_=void 0!==t.strokeStyle?t.strokeStyle:h_,this.fromLonLatTransform_=void 0,this.toLonLatTransform_=void 0,this.projectionCenterLonLat_=null,this.bottomLeft_=null,this.bottomRight_=null,this.topLeft_=null,this.topRight_=null,this.meridiansLabels_=null,this.parallelsLabels_=null,t.showLabels&&(this.lonLabelFormatter_=null==t.lonLabelFormatter?Fi.bind(this,"EW"):t.lonLabelFormatter,this.latLabelFormatter_=null==t.latLabelFormatter?Fi.bind(this,"NS"):t.latLabelFormatter,this.lonLabelPosition_=null==t.lonLabelPosition?0:t.lonLabelPosition,this.latLabelPosition_=null==t.latLabelPosition?1:t.latLabelPosition,this.lonLabelStyleBase_=new pf({text:void 0!==t.lonLabelStyle?t.lonLabelStyle.clone():new _f({font:"12px Calibri,sans-serif",textBaseline:"bottom",fill:new Jg({color:"rgba(0,0,0,1)"}),stroke:new lf({color:"rgba(255,255,255,1)",width:3})})}),this.lonLabelStyle_=t=>{const e=t.get("graticule_label");return this.lonLabelStyleBase_.getText().setText(e),this.lonLabelStyleBase_},this.latLabelStyleBase_=new pf({text:void 0!==t.latLabelStyle?t.latLabelStyle.clone():new _f({font:"12px Calibri,sans-serif",textAlign:"right",fill:new Jg({color:"rgba(0,0,0,1)"}),stroke:new lf({color:"rgba(255,255,255,1)",width:3})})}),this.latLabelStyle_=t=>{const e=t.get("graticule_label");return this.latLabelStyleBase_.getText().setText(e),this.latLabelStyleBase_},this.meridiansLabels_=[],this.parallelsLabels_=[],this.addEventListener(Is,this.drawLabels_.bind(this))),this.intervals_=void 0!==t.intervals?t.intervals:c_,this.setSource(new cc({loader:this.loaderFunction.bind(this),strategy:this.strategyFunction.bind(this),features:new $,overlaps:!1,useSpatialIndex:!1,wrapX:t.wrapX})),this.featurePool_=[],this.lineStyle_=new pf({stroke:this.strokeStyle_}),this.loadedExtent_=null,this.renderedExtent_=null,this.renderedResolution_=null,this.setRenderOrder(null)}strategyFunction(t,e){let i=t.slice();return this.projection_&&this.getSource().getWrapX()&&je(i,this.projection_),this.loadedExtent_&&(ge(this.loadedExtent_,i,e)?i=this.loadedExtent_.slice():this.getSource().removeLoadedExtent(this.loadedExtent_)),[i]}loaderFunction(t,e,i){this.loadedExtent_=t;const n=this.getSource(),r=Ie(this.getExtent()||[-1/0,-1/0,1/0,1/0],t);if(this.renderedExtent_&&de(this.renderedExtent_,r)&&this.renderedResolution_===e)return;if(this.renderedExtent_=r,this.renderedResolution_=e,Oe(r))return;const s=Te(r),o=e*e/4;(!this.projection_||!cn(this.projection_,i))&&this.updateProjectionInfo_(i),this.createGraticule_(r,s,e,o);let a,l=this.meridians_.length+this.parallels_.length;for(this.meridiansLabels_&&(l+=this.meridians_.length),this.parallelsLabels_&&(l+=this.parallels_.length);l>this.featurePool_.length;)a=new Nt,this.featurePool_.push(a);const h=n.getFeaturesCollection();h.clear();let c,u,d=0;for(c=0,u=this.meridians_.length;c<u;++c)a=this.featurePool_[d++],a.setGeometry(this.meridians_[c]),a.setStyle(this.lineStyle_),h.push(a);for(c=0,u=this.parallels_.length;c<u;++c)a=this.featurePool_[d++],a.setGeometry(this.parallels_[c]),a.setStyle(this.lineStyle_),h.push(a)}addMeridian_(t,e,i,n,r,s){const o=this.getMeridian_(t,e,i,n,s);if(Ae(o.getExtent(),r)){if(this.meridiansLabels_){const e=this.lonLabelFormatter_(t);s in this.meridiansLabels_?this.meridiansLabels_[s].text=e:this.meridiansLabels_[s]={geom:new lr([]),text:e}}this.meridians_[s++]=o}return s}addParallel_(t,e,i,n,r,s){const o=this.getParallel_(t,e,i,n,s);if(Ae(o.getExtent(),r)){if(this.parallelsLabels_){const e=this.latLabelFormatter_(t);s in this.parallelsLabels_?this.parallelsLabels_[s].text=e:this.parallelsLabels_[s]={geom:new lr([]),text:e}}this.parallels_[s++]=o}return s}drawLabels_(t){const e=t.frameState.viewState.rotation,i=t.frameState.viewState.resolution,n=t.frameState.size,r=t.frameState.extent,s=Te(r);let o=r;if(e){const t=n[0]*i,e=n[1]*i;o=[s[0]-t/2,s[1]-e/2,s[0]+t/2,s[1]+e/2]}let a=0,l=0,h=this.latLabelPosition_<.5;const c=this.projection_.getExtent(),u=Me(c);if(this.getSource().getWrapX()&&this.projection_.canWrapX()&&!re(c,r)){a=Math.floor((r[0]-c[0])/u),l=Math.ceil((r[2]-c[2])/u);h=h!==Math.abs(e)>Math.PI/2}const d=$l(t);for(let t=a;t<=l;++t){let i,n,c,g,f=this.meridians_.length+this.parallels_.length;if(this.meridiansLabels_)for(n=0,c=this.meridiansLabels_.length;n<c;++n){const a=this.meridians_[n];if(e||0!==t){const i=a.clone();i.translate(t*u,0),i.rotate(-e,s),g=this.getMeridianPoint_(i,o,n),g.rotate(e,s)}else g=this.getMeridianPoint_(a,r,n);i=this.featurePool_[f++],i.setGeometry(g),i.set("graticule_label",this.meridiansLabels_[n].text),d.drawFeature(i,this.lonLabelStyle_(i))}if(this.parallelsLabels_&&(t===a&&h||t===l&&!h))for(n=0,c=this.parallels_.length;n<c;++n){const a=this.parallels_[n];if(e||0!==t){const i=a.clone();i.translate(t*u,0),i.rotate(-e,s),g=this.getParallelPoint_(i,o,n),g.rotate(e,s)}else g=this.getParallelPoint_(a,r,n);i=this.featurePool_[f++],i.setGeometry(g),i.set("graticule_label",this.parallelsLabels_[n].text),d.drawFeature(i,this.latLabelStyle_(i))}}}createGraticule_(t,e,i,n){const r=this.getInterval_(i);if(-1==r)return this.meridians_.length=0,this.parallels_.length=0,this.meridiansLabels_&&(this.meridiansLabels_.length=0),void(this.parallelsLabels_&&(this.parallelsLabels_.length=0));let s=!1;const o=this.projection_.getExtent(),a=Me(o);this.getSource().getWrapX()&&this.projection_.canWrapX()&&!re(o,t)&&(Me(t)>=a?(t[0]=o[0],t[2]=o[2]):s=!0);const l=[gi(e[0],this.minX_,this.maxX_),gi(e[1],this.minY_,this.maxY_)],h=this.toLonLatTransform_(l);isNaN(h[1])&&(h[1]=Math.abs(this.maxLat_)>=Math.abs(this.minLat_)?this.maxLat_:this.minLat_);let c=gi(h[0],this.minLon_,this.maxLon_),u=gi(h[1],this.minLat_,this.maxLat_);const d=this.maxLines_;let g,f,p,m,_=t;s||(_=[gi(t[0],this.minX_,this.maxX_),gi(t[1],this.minY_,this.maxY_),gi(t[2],this.minX_,this.maxX_),gi(t[3],this.minY_,this.maxY_)]);const y=Ge(_,this.toLonLatTransform_,void 0,8);let x=y[3],v=y[2],S=y[1],w=y[0];if(s||(ne(_,this.bottomLeft_)&&(w=this.minLon_,S=this.minLat_),ne(_,this.bottomRight_)&&(v=this.maxLon_,S=this.minLat_),ne(_,this.topLeft_)&&(w=this.minLon_,x=this.maxLat_),ne(_,this.topRight_)&&(v=this.maxLon_,x=this.maxLat_),x=gi(x,u,this.maxLat_),v=gi(v,c,this.maxLon_),S=gi(S,this.minLat_,u),w=gi(w,this.minLon_,c)),c=Math.floor(c/r)*r,m=gi(c,this.minLon_,this.maxLon_),f=this.addMeridian_(m,S,x,n,t,0),g=0,s)for(;(m-=r)>=w&&g++<d;)f=this.addMeridian_(m,S,x,n,t,f);else for(;m!=this.minLon_&&g++<d;)m=Math.max(m-r,this.minLon_),f=this.addMeridian_(m,S,x,n,t,f);if(m=gi(c,this.minLon_,this.maxLon_),g=0,s)for(;(m+=r)<=v&&g++<d;)f=this.addMeridian_(m,S,x,n,t,f);else for(;m!=this.maxLon_&&g++<d;)m=Math.min(m+r,this.maxLon_),f=this.addMeridian_(m,S,x,n,t,f);for(this.meridians_.length=f,this.meridiansLabels_&&(this.meridiansLabels_.length=f),u=Math.floor(u/r)*r,p=gi(u,this.minLat_,this.maxLat_),f=this.addParallel_(p,w,v,n,t,0),g=0;p!=this.minLat_&&g++<d;)p=Math.max(p-r,this.minLat_),f=this.addParallel_(p,w,v,n,t,f);for(p=gi(u,this.minLat_,this.maxLat_),g=0;p!=this.maxLat_&&g++<d;)p=Math.min(p+r,this.maxLat_),f=this.addParallel_(p,w,v,n,t,f);this.parallels_.length=f,this.parallelsLabels_&&(this.parallelsLabels_.length=f)}getInterval_(t){const e=this.projectionCenterLonLat_[0],i=this.projectionCenterLonLat_[1];let n=-1;const r=Math.pow(this.targetSize_*t,2),s=[],o=[];for(let t=0,a=this.intervals_.length;t<a;++t){const a=gi(this.intervals_[t]/2,0,90),l=gi(i,-90+a,90-a);s[0]=e-a,s[1]=l-a,o[0]=e+a,o[1]=l+a,this.fromLonLatTransform_(s,s),this.fromLonLatTransform_(o,o);if(Math.pow(o[0]-s[0],2)+Math.pow(o[1]-s[1],2)<=r)break;n=this.intervals_[t]}return n}getMeridian_(t,e,i,n,r){const s=a_(t,e,i,this.projection_,n);let o=this.meridians_[r];return o?(o.setFlatCoordinates("XY",s),o.changed()):(o=new Vm(s,"XY"),this.meridians_[r]=o),o}getMeridianPoint_(t,e,i){const n=t.getFlatCoordinates();let r=1,s=n.length-1;n[r]>n[s]&&(r=s,s=1);const o=Math.max(e[1],n[r]),a=Math.min(e[3],n[s]),l=gi(e[1]+Math.abs(e[1]-e[3])*this.lonLabelPosition_,o,a),h=[n[r-1]+(n[s-1]-n[r-1])*(l-n[r])/(n[s]-n[r]),l],c=this.meridiansLabels_[i].geom;return c.setCoordinates(h),c}getMeridians(){return this.meridians_}getParallel_(t,e,i,n,r){const s=l_(t,e,i,this.projection_,n);let o=this.parallels_[r];return o?(o.setFlatCoordinates("XY",s),o.changed()):o=new Vm(s,"XY"),o}getParallelPoint_(t,e,i){const n=t.getFlatCoordinates();let r=0,s=n.length-2;n[r]>n[s]&&(r=s,s=0);const o=Math.max(e[0],n[r]),a=Math.min(e[2],n[s]),l=gi(e[0]+Math.abs(e[0]-e[2])*this.latLabelPosition_,o,a),h=[l,n[r+1]+(n[s+1]-n[r+1])*(l-n[r])/(n[s]-n[r])],c=this.parallelsLabels_[i].geom;return c.setCoordinates(h),c}getParallels(){return this.parallels_}updateProjectionInfo_(t){const e=nn("EPSG:4326"),i=t.getWorldExtent();this.maxLat_=i[3],this.maxLon_=i[2],this.minLat_=i[1],this.minLon_=i[0];const n=dn(t,e);if(this.minLon_<this.maxLon_)this.toLonLatTransform_=n;else{const t=this.minLon_+this.maxLon_/2;this.maxLon_+=360,this.toLonLatTransform_=function(e,i,r){const s=n(e,i,r=r||2);for(let e=0,i=s.length;e<i;e+=r)s[e]<t&&(s[e]+=360);return s}}this.fromLonLatTransform_=dn(e,t);const r=Ge([this.minLon_,this.minLat_,this.maxLon_,this.maxLat_],this.fromLonLatTransform_,void 0,8);this.minX_=r[0],this.maxX_=r[2],this.minY_=r[1],this.maxY_=r[3],this.bottomLeft_=this.fromLonLatTransform_([this.minLon_,this.minLat_]),this.bottomRight_=this.fromLonLatTransform_([this.maxLon_,this.minLat_]),this.topLeft_=this.fromLonLatTransform_([this.minLon_,this.maxLat_]),this.topRight_=this.fromLonLatTransform_([this.maxLon_,this.maxLat_]),this.projectionCenterLonLat_=this.toLonLatTransform_(Te(t.getExtent())),isNaN(this.projectionCenterLonLat_[1])&&(this.projectionCenterLonLat_[1]=Math.abs(this.maxLat_)>=Math.abs(this.minLat_)?this.maxLat_:this.minLat_),this.projection_=t}};const d_="blur",g_="gradient",f_="radius",p_=["#00f","#0ff","#0f0","#ff0","#f00"];var m_=class extends Df{constructor(t){t=t||{};const e=Object.assign({},t);delete e.gradient,delete e.radius,delete e.blur,delete e.weight,super(e),this.gradient_=null,this.addChangeListener(g_,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:p_),this.setBlur(void 0!==t.blur?t.blur:15),this.setRadius(void 0!==t.radius?t.radius:8);const i=t.weight?t.weight:"weight";this.weightFunction_="string"==typeof i?function(t){return t.get(i)}:i,this.setRenderOrder(null)}getBlur(){return this.get(d_)}getGradient(){return this.get(g_)}getRadius(){return this.get(f_)}handleGradientChanged_(){this.gradient_=function(t){const e=1,i=256,n=yt(e,i),r=n.createLinearGradient(0,0,e,i),s=1/(t.length-1);for(let e=0,i=t.length;e<i;++e)r.addColorStop(e*s,t[e]);return n.fillStyle=r,n.fillRect(0,0,e,i),n.canvas}(this.getGradient())}setBlur(t){this.set(d_,t)}setGradient(t){this.set(g_,t)}setRadius(t){this.set(f_,t)}createRenderer(){return new Sp(this,{className:this.getClassName(),attributes:[{name:"weight",callback:t=>{const e=this.weightFunction_(t);return void 0!==e?gi(e,0,1):1}}],hitDetectionEnabled:!0,vertexShader:"\n precision mediump float;\n uniform mat4 u_projectionMatrix;\n uniform mat4 u_offsetScaleMatrix;\n uniform float u_size;\n attribute vec2 a_position;\n attribute float a_index;\n attribute float a_weight;\n attribute vec4 a_hitColor;\n\n varying vec2 v_texCoord;\n varying float v_weight;\n varying vec4 v_hitColor;\n\n void main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n float offsetX = a_index == 0.0 || a_index == 3.0 ? -u_size / 2.0 : u_size / 2.0;\n float offsetY = a_index == 0.0 || a_index == 1.0 ? -u_size / 2.0 : u_size / 2.0;\n vec4 offsets = offsetMatrix * vec4(offsetX, offsetY, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n float u = a_index == 0.0 || a_index == 3.0 ? 0.0 : 1.0;\n float v = a_index == 0.0 || a_index == 1.0 ? 0.0 : 1.0;\n v_texCoord = vec2(u, v);\n v_hitColor = a_hitColor;\n v_weight = a_weight;\n }",fragmentShader:"\n precision mediump float;\n uniform float u_blurSlope;\n uniform mediump int u_hitDetection;\n\n varying vec2 v_texCoord;\n varying float v_weight;\n varying vec4 v_hitColor;\n\n void main(void) {\n vec2 texCoord = v_texCoord * 2.0 - vec2(1.0, 1.0);\n float sqRadius = texCoord.x * texCoord.x + texCoord.y * texCoord.y;\n float value = (1.0 - sqrt(sqRadius)) * u_blurSlope;\n float alpha = smoothstep(0.0, 1.0, value) * v_weight;\n gl_FragColor = vec4(alpha, alpha, alpha, alpha);\n if (u_hitDetection > 0) {\n if (alpha < 0.05) {\n discard;\n }\n gl_FragColor = v_hitColor;\n }\n }",uniforms:{u_size:()=>2*(this.get(f_)+this.get(d_)),u_blurSlope:()=>this.get(f_)/Math.max(1,this.get(d_))},postProcesses:[{fragmentShader:"\n precision mediump float;\n\n uniform sampler2D u_image;\n uniform sampler2D u_gradientTexture;\n uniform float u_opacity;\n\n varying vec2 v_texCoord;\n\n void main() {\n vec4 color = texture2D(u_image, v_texCoord);\n gl_FragColor.a = color.a * u_opacity;\n gl_FragColor.rgb = texture2D(u_gradientTexture, vec2(0.5, color.a)).rgb;\n gl_FragColor.rgb *= gl_FragColor.a;\n }",uniforms:{u_gradientTexture:()=>this.gradient_,u_opacity:()=>this.getOpacity()}}]})}renderDeclutter(){}};var __=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?nn(e.dataProjection):this.readProjection(t);e.extent&&i&&"tile-pixels"===i.getUnits()&&(i=nn(i),i.setWorldExtent(e.extent)),e={dataProjection:i,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection},t)}getType(){return z()}readFeature(t,e){return z()}readFeatures(t,e){return z()}readGeometry(t,e){return z()}readProjection(t){return z()}writeFeature(t,e){return z()}writeFeatures(t,e){return z()}writeGeometry(t,e){return z()}};function y_(t,e,i){const n=i?nn(i.featureProjection):null,r=i?nn(i.dataProjection):null;let s;if(s=n&&r&&!cn(n,r)?(e?t.clone():t).transform(e?n:r,e?r:n):t,e&&i&&void 0!==i.decimals){const e=Math.pow(10,i.decimals),n=function(t){for(let i=0,n=t.length;i<n;++i)t[i]=Math.round(t[i]*e)/e;return t};s===t&&(s=t.clone()),s.applyTransform(n)}return s}function x_(t,e){const i=e?nn(e.featureProjection):null,n=e?nn(e.dataProjection):null;return i&&n&&!cn(i,n)?fn(t,n,i):t}var v_={
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
read:function(t,e,i,n,r){var s,o,a=8*r-n-1,l=(1<<a)-1,h=l>>1,c=-7,u=i?r-1:0,d=i?-1:1,g=t[e+u];for(u+=d,s=g&(1<<-c)-1,g>>=-c,c+=a;c>0;s=256*s+t[e+u],u+=d,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+u],u+=d,c-=8);if(0===s)s=1-h;else{if(s===l)return o?NaN:1/0*(g?-1:1);o+=Math.pow(2,n),s-=h}return(g?-1:1)*o*Math.pow(2,s-n)},write:function(t,e,i,n,r,s){var o,a,l,h=8*s-r-1,c=(1<<h)-1,u=c>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:s-1,f=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=c?(a=0,o=c):o+u>=1?(a=(e*l-1)*Math.pow(2,r),o+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;t[i+g]=255&a,g+=f,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[i+g]=255&o,g+=f,o/=256,h-=8);t[i+g-f]|=128*p}},S_=E_,w_=v_;function E_(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}E_.Varint=0,E_.Fixed64=1,E_.Bytes=2,E_.Fixed32=5;var T_=4294967296,C_=1/T_,R_="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function b_(t){return t.type===E_.Bytes?t.readVarint()+t.pos:t.pos+1}function P_(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function I_(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=t;r--)i.buf[r+n]=i.buf[r]}function F_(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function L_(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function M_(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function A_(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function O_(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function N_(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function D_(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function k_(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function G_(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function j_(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function B_(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function U_(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}E_.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),r=n>>3,s=this.pos;this.type=7&n,t(r,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=j_(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=U_(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=j_(this.buf,this.pos)+j_(this.buf,this.pos+4)*T_;return this.pos+=8,t},readSFixed64:function(){var t=j_(this.buf,this.pos)+U_(this.buf,this.pos+4)*T_;return this.pos+=8,t},readFloat:function(){var t=w_.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=w_.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(t,e,i){var n,r,s=i.buf;if(r=s[i.pos++],n=(112&r)>>4,r<128)return P_(t,n,e);if(r=s[i.pos++],n|=(127&r)<<3,r<128)return P_(t,n,e);if(r=s[i.pos++],n|=(127&r)<<10,r<128)return P_(t,n,e);if(r=s[i.pos++],n|=(127&r)<<17,r<128)return P_(t,n,e);if(r=s[i.pos++],n|=(127&r)<<24,r<128)return P_(t,n,e);if(r=s[i.pos++],n|=(1&r)<<31,r<128)return P_(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&R_?function(t,e,i){return R_.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){var n="",r=e;for(;r<i;){var s,o,a,l=t[r],h=null,c=l>239?4:l>223?3:l>191?2:1;if(r+c>i)break;1===c?l<128&&(h=l):2===c?128==(192&(s=t[r+1]))&&(h=(31&l)<<6|63&s)<=127&&(h=null):3===c?(s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&((h=(15&l)<<12|(63&s)<<6|63&o)<=2047||h>=55296&&h<=57343)&&(h=null)):4===c&&(s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&((h=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,c=1):h>65535&&(h-=65536,n+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),n+=String.fromCharCode(h),r+=c}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==E_.Bytes)return t.push(this.readVarint(e));var i=b_(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==E_.Bytes)return t.push(this.readSVarint());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==E_.Bytes)return t.push(this.readBoolean());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==E_.Bytes)return t.push(this.readFloat());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==E_.Bytes)return t.push(this.readDouble());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==E_.Bytes)return t.push(this.readFixed32());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==E_.Bytes)return t.push(this.readSFixed32());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==E_.Bytes)return t.push(this.readFixed64());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==E_.Bytes)return t.push(this.readSFixed64());var e=b_(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===E_.Varint)for(;this.buf[this.pos++]>127;);else if(e===E_.Bytes)this.pos=this.readVarint()+this.pos;else if(e===E_.Fixed32)this.pos+=4;else{if(e!==E_.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),B_(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),B_(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),B_(this.buf,-1&t,this.pos),B_(this.buf,Math.floor(t*C_),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),B_(this.buf,-1&t,this.pos),B_(this.buf,Math.floor(t*C_),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,n;t>=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos]=127&t}(i,0,e),function(t,e){var i=(7&t)<<4;if(e.buf[e.pos++]|=i|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var n,r,s=0;s<e.length;s++){if((n=e.charCodeAt(s))>55295&&n<57344){if(!r){n>56319||s+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(t[i++]=239,t[i++]=191,t[i++]=189,r=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&I_(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),w_.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),w_.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&I_(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,E_.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,F_,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,L_,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,O_,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,M_,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,A_,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,N_,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,D_,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,k_,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,G_,e)},writeBytesField:function(t,e){this.writeTag(t,E_.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,E_.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,E_.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,E_.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,E_.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,E_.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,E_.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,E_.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,E_.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,E_.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var z_=Bf(S_);function X_(t,e,i){if(3===t){const t={keys:[],values:[],features:[]},n=i.readVarint()+i.pos;i.readFields(V_,t,n),t.length=t.features.length,t.length&&(e[t.name]=t)}}function V_(t,e,i){if(15===t)e.version=i.readVarint();else if(1===t)e.name=i.readString();else if(5===t)e.extent=i.readVarint();else if(2===t)e.features.push(i.pos);else if(3===t)e.keys.push(i.readString());else if(4===t){let n=null;const r=i.readVarint()+i.pos;for(;i.pos<r;)n=1===(t=i.readVarint()>>3)?i.readString():2===t?i.readFloat():3===t?i.readDouble():4===t?i.readVarint64():5===t?i.readVarint():6===t?i.readSVarint():7===t?i.readBoolean():null;e.values.push(n)}}function W_(t,e,i){if(1==t)e.id=i.readVarint();else if(2==t){const t=i.readVarint()+i.pos;for(;i.pos<t;){const t=e.layer.keys[i.readVarint()],n=e.layer.values[i.readVarint()];e.properties[t]=n}}else 3==t?e.type=i.readVarint():4==t&&(e.geometry=i.pos)}function Z_(t,e,i){t.pos=e.features[i];const n=t.readVarint()+t.pos,r={layer:e,type:0,properties:{}};return t.readFields(W_,r,n),r}var Y_=class extends __{constructor(t){super(),t=t||{},this.dataProjection=new Ve({code:"",units:"tile-pixels"}),this.featureClass_=t.featureClass?t.featureClass:e_,this.geometryName_=t.geometryName,this.layerName_=t.layerName?t.layerName:"layer",this.layers_=t.layers?t.layers:null,this.idProperty_=t.idProperty,this.supportedMediaTypes=["application/vnd.mapbox-vector-tile","application/x-protobuf"]}readRawGeometry_(t,e,i,n){t.pos=e.geometry;const r=t.readVarint()+t.pos;let s=1,o=0,a=0,l=0,h=0,c=0;for(;t.pos<r;){if(!o){const e=t.readVarint();s=7&e,o=e>>3}o--,1===s||2===s?(a+=t.readSVarint(),l+=t.readSVarint(),1===s&&h>c&&(n.push(h),c=h),i.push(a,l),h+=2):7===s?h>c&&(i.push(i[c],i[c+1]),h+=2):Mt(!1,59)}h>c&&(n.push(h),c=h)}createFeature_(t,e,i){const n=e.type;if(0===n)return null;let r;const s=e.properties;let o;this.idProperty_?(o=s[this.idProperty_],delete s[this.idProperty_]):o=e.id,s[this.layerName_]=e.layer.name;const a=[],l=[];this.readRawGeometry_(t,e,a,l);const h=function(t,e){let i;1===t?i=1===e?"Point":"MultiPoint":2===t?i=1===e?"LineString":"MultiLineString":3===t&&(i="Polygon");return i}(n,l.length);if(this.featureClass_===e_)r=new this.featureClass_(h,a,l,s,o),r.transform(i.dataProjection);else{let t;if("Polygon"==h){const e=br(a,l);t=e.length>1?new $m(a,"XY",e):new Ir(a,"XY",l)}else t="Point"===h?new lr(a,"XY"):"LineString"===h?new Vm(a,"XY"):"MultiPoint"===h?new Km(a,"XY"):"MultiLineString"===h?new Zm(a,"XY",l):null;r=new(0,this.featureClass_),this.geometryName_&&r.setGeometryName(this.geometryName_);const e=y_(t,!1,i);r.setGeometry(e),void 0!==o&&r.setId(o),r.setProperties(s,!0)}return r}getType(){return"arraybuffer"}readFeatures(t,e){const i=this.layers_,n=nn((e=this.adaptOptions(e)).dataProjection);n.setWorldExtent(e.extent),e.dataProjection=n;const r=new z_(t),s=r.readFields(X_,{}),o=[];for(const t in s){if(i&&!i.includes(t))continue;const a=s[t],l=a?[0,0,a.extent,a.extent]:null;n.setExtent(l);for(let t=0,i=a.length;t<i;++t){const i=Z_(r,a,t),n=this.createFeature_(r,i,e);null!==n&&o.push(n)}}return o}readProjection(t){return this.dataProjection}setLayers(t){this.layers_=t}};var K_=class extends Df{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un;const i=t.renderMode||"hybrid";Mt("hybrid"==i||"vector"==i,28),this.renderMode_=i,this.setPreload(t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError),this.getBackground,this.setBackground}createRenderer(){return new Om(this)}getFeatures(t){return super.getFeatures(t)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(Su)}getUseInterimTilesOnError(){return this.get(wu)}setPreload(t){this.set(Su,t)}setUseInterimTilesOnError(t){this.set(wu,t)}};class H_ extends r{constructor(t){super(T),this.error=t}}var q_=class extends K_{constructor(t){const e=!("declutter"in t)||t.declutter,i=new hu({state:"loading",format:new Y_});super({source:i,background:t.background,declutter:e,className:t.className,opacity:t.opacity,visible:t.visible,zIndex:t.zIndex,minResolution:t.minResolution,maxResolution:t.maxResolution,minZoom:t.minZoom,maxZoom:t.maxZoom,renderOrder:t.renderOrder,renderBuffer:t.renderBuffer,renderMode:t.renderMode,map:t.map,updateWhileAnimating:t.updateWhileAnimating,updateWhileInteracting:t.updateWhileInteracting,preload:t.preload,useInterimTilesOnError:t.useInterimTilesOnError,properties:t.properties}),t.accessToken&&(this.accessToken=t.accessToken);const n=t.styleUrl;olms.applyStyle(this,n,t.layers||t.source,{accessToken:this.accessToken}).then((()=>{i.setState("ready")})).catch((t=>{this.dispatchEvent(new H_(t));this.getSource().setState("error")})),void 0===this.getBackground()&&olms.applyBackground(this,t.styleUrl,{accessToken:this.accessToken})}};var $_=class extends Df{constructor(t){t=t||{};const e=Object.assign({},t);delete e.imageRatio,super(e),this.imageRatio_=void 0!==t.imageRatio?t.imageRatio:1}getImageRatio(){return this.imageRatio_}createRenderer(){return new Lm(this)}};var J_=class extends no{constructor(t){super(Object.assign({},t)),this.parseResult_=Af(t.style),this.styleVariables_=t.style.variables||{},this.hitDetectionDisabled_=!!t.disableHitDetection}createRenderer(){const t=Object.keys(this.parseResult_.attributes).map((t=>({name:t,...this.parseResult_.attributes[t]})));return new Sp(this,{vertexShader:this.parseResult_.builder.getSymbolVertexShader(),fragmentShader:this.parseResult_.builder.getSymbolFragmentShader(),hitDetectionEnabled:!this.hitDetectionDisabled_,uniforms:this.parseResult_.uniforms,attributes:t})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}};function Q_(t,e){const i=`\n attribute vec2 ${pg.TEXTURE_COORD};\n uniform mat4 ${fg.TILE_TRANSFORM};\n uniform float ${fg.TEXTURE_PIXEL_WIDTH};\n uniform float ${fg.TEXTURE_PIXEL_HEIGHT};\n uniform float ${fg.TEXTURE_RESOLUTION};\n uniform float ${fg.TEXTURE_ORIGIN_X};\n uniform float ${fg.TEXTURE_ORIGIN_Y};\n uniform float ${fg.DEPTH};\n\n varying vec2 v_textureCoord;\n varying vec2 v_mapCoord;\n\n void main() {\n v_textureCoord = ${pg.TEXTURE_COORD};\n v_mapCoord = vec2(\n ${fg.TEXTURE_ORIGIN_X} + ${fg.TEXTURE_RESOLUTION} * ${fg.TEXTURE_PIXEL_WIDTH} * v_textureCoord[0],\n ${fg.TEXTURE_ORIGIN_Y} - ${fg.TEXTURE_RESOLUTION} * ${fg.TEXTURE_PIXEL_HEIGHT} * v_textureCoord[1]\n );\n gl_Position = ${fg.TILE_TRANSFORM} * vec4(${pg.TEXTURE_COORD}, ${fg.DEPTH}, 1.0);\n }\n `,n={inFragmentShader:!0,variables:[],attributes:[],stringLiteralsMap:{},functions:{},bandCount:e,style:t},r=[];if(void 0!==t.color){const e=Pg(n,t.color,yg.COLOR);r.push(`color = ${e};`)}if(void 0!==t.contrast){const e=Pg(n,t.contrast,yg.NUMBER);r.push(`color.rgb = clamp((${e} + 1.0) * color.rgb - (${e} / 2.0), vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));`)}if(void 0!==t.exposure){const e=Pg(n,t.exposure,yg.NUMBER);r.push(`color.rgb = clamp((${e} + 1.0) * color.rgb, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));`)}if(void 0!==t.saturation){const e=Pg(n,t.saturation,yg.NUMBER);r.push(`\n float saturation = ${e} + 1.0;\n float sr = (1.0 - saturation) * 0.2126;\n float sg = (1.0 - saturation) * 0.7152;\n float sb = (1.0 - saturation) * 0.0722;\n mat3 saturationMatrix = mat3(\n sr + saturation, sr, sr,\n sg, sg + saturation, sg,\n sb, sb, sb + saturation\n );\n color.rgb = clamp(saturationMatrix * color.rgb, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));\n `)}if(void 0!==t.gamma){const e=Pg(n,t.gamma,yg.NUMBER);r.push(`color.rgb = pow(color.rgb, vec3(1.0 / ${e}));`)}if(void 0!==t.brightness){const e=Pg(n,t.brightness,yg.NUMBER);r.push(`color.rgb = clamp(color.rgb + ${e}, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));`)}const s={},o=n.variables.length;if(o>1&&!t.variables)throw new Error(`Missing variables in style (expected ${n.variables})`);for(let e=0;e<o;++e){const i=n.variables[e];if(!(i.name in t.variables))throw new Error(`Missing '${i.name}' in style variables`);s[Bg(i.name)]=function(){let e=t.variables[i.name];return"string"==typeof e&&(e=Rg(n,e)),void 0!==e?e:-9999999}}const a=Object.keys(s).map((function(t){return`uniform float ${t};`})),l=Math.ceil(e/4);a.push(`uniform sampler2D ${fg.TILE_TEXTURE_ARRAY}[${l}];`),n.paletteTextures&&a.push(`uniform sampler2D ${Ug}[${n.paletteTextures.length}];`);const h=Object.keys(n.functions).map((function(t){return n.functions[t]}));return{vertexShader:i,fragmentShader:`\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n\n varying vec2 v_textureCoord;\n varying vec2 v_mapCoord;\n uniform vec4 ${fg.RENDER_EXTENT};\n uniform float ${fg.TRANSITION_ALPHA};\n uniform float ${fg.TEXTURE_PIXEL_WIDTH};\n uniform float ${fg.TEXTURE_PIXEL_HEIGHT};\n uniform float ${fg.RESOLUTION};\n uniform float ${fg.ZOOM};\n\n ${a.join("\n")}\n\n ${h.join("\n")}\n\n void main() {\n if (\n v_mapCoord[0] < ${fg.RENDER_EXTENT}[0] ||\n v_mapCoord[1] < ${fg.RENDER_EXTENT}[1] ||\n v_mapCoord[0] > ${fg.RENDER_EXTENT}[2] ||\n v_mapCoord[1] > ${fg.RENDER_EXTENT}[3]\n ) {\n discard;\n }\n\n vec4 color = texture2D(${fg.TILE_TEXTURE_ARRAY}[0], v_textureCoord);\n\n ${r.join("\n")}\n\n gl_FragColor = color;\n gl_FragColor.rgb *= gl_FragColor.a;\n gl_FragColor *= ${fg.TRANSITION_ALPHA};\n }`,uniforms:s,paletteTextures:n.paletteTextures}}class ty extends Eu{constructor(t){const e=(t=t?Object.assign({},t):{}).style||{};delete t.style;const i=t.cacheSize;delete t.cacheSize,super(t),this.sources_=t.sources,this.renderedSource_=null,this.renderedResolution_=NaN,this.style_=e,this.cacheSize_=i,this.styleVariables_=this.style_.variables||{},this.addChangeListener(Cs,this.handleSourceUpdate_)}getSources(t,e){const i=this.getSource();return this.sources_?"function"==typeof this.sources_?this.sources_(t,e):this.sources_:i?[i]:[]}getRenderSource(){return this.renderedSource_||this.getSource()}getSourceState(){const t=this.getRenderSource();return t?t.getState():"undefined"}handleSourceUpdate_(){this.hasRenderer()&&this.getRenderer().clearCache(),this.getSource()&&this.setStyle(this.style_)}getSourceBandCount_(){const t=Number.MAX_SAFE_INTEGER,e=this.getSources([-t,-t,t,t],t);return e&&e.length&&"bandCount"in e[0]?e[0].bandCount:4}createRenderer(){const t=Q_(this.style_,this.getSourceBandCount_());return new _g(this,{vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms,cacheSize:this.cacheSize_,paletteTextures:t.paletteTextures})}renderSources(t,e){const i=this.getRenderer();let n;for(let r=0,s=e.length;r<s;++r)this.renderedSource_=e[r],i.prepareFrame(t)&&(n=i.renderFrame(t));return n}render(t,e){this.rendered=!0;const i=t.viewState,n=this.getSources(t.extent,i.resolution);let r=!0;for(let t=0,e=n.length;t<e;++t){const e=n[t],i=e.getState();if("loading"==i){const t=()=>{"ready"==e.getState()&&(e.removeEventListener("change",t),this.changed())};e.addEventListener("change",t)}r=r&&"ready"==i}const s=this.renderSources(t,n);if(this.getRenderer().renderComplete&&r)return this.renderedResolution_=i.resolution,s;if(this.renderedResolution_>.5*i.resolution){const e=this.getSources(t.extent,this.renderedResolution_).filter((t=>!n.includes(t)));if(e.length>0)return this.renderSources(t,e)}return s}setStyle(t){this.styleVariables_=t.variables||{},this.style_=t;const e=Q_(this.style_,this.getSourceBandCount_());this.getRenderer().reset({vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,uniforms:e.uniforms}),this.changed()}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}}ty.prototype.dispose;var ey=ty;var iy=class extends ya{constructor(t){const e=t||{};super(e),e.stopDown&&(this.stopDown=e.stopDown),this.scaleDeltaByPixel_=e.delta?e.delta:.01,this.duration_=void 0!==e.duration?e.duration:250,this.handlingDownUpSequence_=!1,this.handlingDoubleDownSequence_=!1,this.doubleTapTimeoutId_=void 0,this.trackedPointers_={},this.targetPointers=[]}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence_){if(t.type==Wo.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Wo.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence_=e}}else if(t.type==Wo.POINTERDOWN)if(this.handlingDoubleDownSequence_){this.handlingDoubleDownSequence_=!1;const i=this.handleDownEvent(t);this.handlingDownUpSequence_=i,e=this.stopDown(i)}else e=this.stopDown(!1),this.waitForDblTap_();return!e}handleDragEvent(t){let e=1;const i=this.targetPointers[0],n=this.down_.originalEvent,r=i.clientY-n.clientY;void 0!==this.lastDistance_&&(e=1-(this.lastDistance_-r)*this.scaleDeltaByPixel_),this.lastDistance_=r,1!=e&&(this.lastScaleDelta_=e);const s=t.map,o=s.getView();s.render(),o.adjustResolutionInternal(e)}handleDownEvent(t){if(1==this.targetPointers.length){const e=t.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.down_=t,this.handlingDownUpSequence_||e.getView().beginInteraction(),!0}return!1}handleUpEvent(t){if(0==this.targetPointers.length){const e=t.map.getView(),i=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,i),this.handlingDownUpSequence_=!1,this.handlingDoubleDownSequence_=!1,!1}return!0}stopDown(t){return t}updateTrackedPointers_(t){if(function(t){const e=t.type;return e===Wo.POINTERDOWN||e===Wo.POINTERDRAG||e===Wo.POINTERUP}(t)){const e=t.originalEvent,i=e.pointerId.toString();t.type==Wo.POINTERUP?delete this.trackedPointers_[i]:(t.type==Wo.POINTERDOWN||i in this.trackedPointers_)&&(this.trackedPointers_[i]=e),this.targetPointers=Object.values(this.trackedPointers_)}}waitForDblTap_(){void 0!==this.doubleTapTimeoutId_?(clearTimeout(this.doubleTapTimeoutId_),this.doubleTapTimeoutId_=void 0):(this.handlingDoubleDownSequence_=!0,this.doubleTapTimeoutId_=setTimeout(this.endInteraction_.bind(this),250))}endInteraction_(){this.handlingDoubleDownSequence_=!1,this.doubleTapTimeoutId_=void 0}};const ny="addfeatures";class ry extends r{constructor(t,e,i,n){super(t),this.features=i,this.file=e,this.projection=n}}var sy=class extends ya{constructor(t){t=t||{},super({handleEvent:p}),this.on,this.once,this.un,this.readAsBuffer_=!1,this.formats_=[];const e=t.formatConstructors?t.formatConstructors:[];for(let t=0,i=e.length;t<i;++t){let i=e[t];"function"==typeof i&&(i=new i),this.formats_.push(i),this.readAsBuffer_=this.readAsBuffer_||"arraybuffer"===i.getType()}this.projection_=t.projection?nn(t.projection):null,this.dropListenKeys_=null,this.source_=t.source||null,this.target=t.target?t.target:null}handleResult_(t,e){const i=e.target.result,n=this.getMap();let r,s=this.projection_;if(!s&&(s=_n(),!s)){s=n.getView().getProjection()}const o=this.formats_;for(let e=0,n=o.length;e<n;++e){const n=o[e];let a=i;this.readAsBuffer_&&"arraybuffer"!==n.getType()&&(void 0===r&&(r=(new TextDecoder).decode(i)),a=r);const l=this.tryReadFeatures_(n,a,{featureProjection:s});if(l&&l.length>0){this.source_&&(this.source_.clear(),this.source_.addFeatures(l)),this.dispatchEvent(new ry(ny,t,l,s));break}}}registerListeners_(){const t=this.getMap();if(t){const e=this.target?this.target:t.getViewport();this.dropListenKeys_=[D(e,F,this.handleDrop,this),D(e,P,this.handleStop,this),D(e,I,this.handleStop,this),D(e,F,this.handleStop,this)]}}setActive(t){!this.getActive()&&t&&this.registerListeners_(),this.getActive()&&!t&&this.unregisterListeners_(),super.setActive(t)}setMap(t){this.unregisterListeners_(),super.setMap(t),this.getActive()&&this.registerListeners_()}tryReadFeatures_(t,e,i){try{return t.readFeatures(e,i)}catch(t){return null}}unregisterListeners_(){this.dropListenKeys_&&(this.dropListenKeys_.forEach(G),this.dropListenKeys_=null)}handleDrop(t){const e=t.dataTransfer.files;for(let t=0,i=e.length;t<i;++t){const i=e.item(t),n=new FileReader;n.addEventListener(A,this.handleResult_.bind(this,i)),this.readAsBuffer_?n.readAsArrayBuffer(i):n.readAsText(i)}}handleStop(t){t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy"}};var oy=class extends Sa{constructor(t){super(t=t||{}),this.condition_=t.condition?t.condition:Aa,this.lastAngle_=void 0,this.lastMagnitude_=void 0,this.lastScaleDelta_=0,this.duration_=void 0!==t.duration?t.duration:400}handleDragEvent(t){if(!Na(t))return;const e=t.map,i=e.getSize(),n=t.pixel,r=n[0]-i[0]/2,s=i[1]/2-n[1],o=Math.atan2(s,r),a=Math.sqrt(r*r+s*s),l=e.getView();if(void 0!==this.lastAngle_){const t=this.lastAngle_-o;l.adjustRotationInternal(t)}this.lastAngle_=o,void 0!==this.lastMagnitude_&&l.adjustResolutionInternal(this.lastMagnitude_/a),void 0!==this.lastMagnitude_&&(this.lastScaleDelta_=this.lastMagnitude_/a),this.lastMagnitude_=a}handleUpEvent(t){if(!Na(t))return!0;const e=t.map.getView(),i=this.lastScaleDelta_>1?1:-1;return e.endInteraction(this.duration_,i),this.lastScaleDelta_=0,!1}handleDownEvent(t){return!!Na(t)&&(!!this.condition_(t)&&(t.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0))}};const ay="drawstart",ly="drawend",hy="drawabort";class cy extends r{constructor(t,e){super(t),this.feature=e}}function uy(t,e){return pi(t[0],t[1],e[0],e[1])}function dy(t,e){const i=t.length;return e<0?t[e+i]:e>=i?t[e-i]:t[e]}function gy(t,e,i){let n,r;e<i?(n=e,r=i):(n=i,r=e);const s=Math.ceil(n),o=Math.floor(r);if(s>o){return uy(xy(t,n),xy(t,r))}let a=0;if(n<s){a+=uy(xy(t,n),dy(t,s))}if(o<r){a+=uy(dy(t,o),xy(t,r))}for(let e=s;e<o-1;++e){a+=uy(dy(t,e),dy(t,e+1))}return a}function fy(t,e,i){if(e instanceof Vm)my(t,e.getCoordinates(),!1,i);else if(e instanceof Zm){const n=e.getCoordinates();for(let e=0,r=n.length;e<r;++e)my(t,n[e],!1,i)}else if(e instanceof Ir){const n=e.getCoordinates();for(let e=0,r=n.length;e<r;++e)my(t,n[e],!0,i)}else if(e instanceof $m){const n=e.getCoordinates();for(let e=0,r=n.length;e<r;++e){const r=n[e];for(let e=0,n=r.length;e<n;++e)my(t,r[e],!0,i)}}else if(e instanceof jm){const n=e.getGeometries();for(let e=0;e<n.length;++e)fy(t,n[e],i)}else;}const py={index:-1,endIndex:NaN};function my(t,e,i,n){const r=t[0],s=t[1];for(let t=0,o=e.length-1;t<o;++t){const o=yy(r,s,e[t],e[t+1]);if(0===o.squaredDistance){const r=t+o.along;return void n.push({coordinates:e,ring:i,startIndex:r,endIndex:r})}}}const _y={along:0,squaredDistance:0};function yy(t,e,i,n){const r=i[0],s=i[1],o=n[0]-r,a=n[1]-s;let l=0,h=r,c=s;return 0===o&&0===a||(l=gi(((t-r)*o+(e-s)*a)/(o*o+a*a),0,1),h+=o*l,c+=a*l),_y.along=l,_y.squaredDistance=Si(pi(t,e,h,c),10),_y}function xy(t,e){const i=t.length;let n=Math.floor(e);const r=e-n;n>=i?n-=i:n<0&&(n+=i);let s=n+1;s>=i&&(s-=i);const o=t[n],a=o[0],l=o[1],h=t[s];return[a+(h[0]-a)*r,l+(h[1]-l)*r]}function vy(){const t=gf();return function(e,i){return t[e.getGeometry().getType()]}}var Sy=class extends Sa{constructor(t){const e=t;e.stopDown||(e.stopDown=m),super(e),this.on,this.once,this.un,this.shouldHandle_=!1,this.downPx_=null,this.downTimeout_,this.lastDragTime_,this.pointerType_,this.freehand_=!1,this.source_=t.source?t.source:null,this.features_=t.features?t.features:null,this.snapTolerance_=t.snapTolerance?t.snapTolerance:12,this.type_=t.type,this.mode_=function(t){switch(t){case"Point":case"MultiPoint":return"Point";case"LineString":case"MultiLineString":return"LineString";case"Polygon":case"MultiPolygon":return"Polygon";case"Circle":return"Circle";default:throw new Error("Invalid type: "+t)}}(this.type_),this.stopClick_=!!t.stopClick,this.minPoints_=t.minPoints?t.minPoints:"Polygon"===this.mode_?3:2,this.maxPoints_="Circle"===this.mode_?2:t.maxPoints?t.maxPoints:1/0,this.finishCondition_=t.finishCondition?t.finishCondition:p,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const t=this.mode_;if("Circle"===t)i=function(t,e,i){const n=e||new Dm([NaN,NaN]),r=xn(t[0],i),s=Ni(r,xn(t[t.length-1],i));n.setCenterAndRadius(r,Math.sqrt(s),this.geometryLayout_);const o=_n();return o&&n.transform(i,o),n};else{let e;"Point"===t?e=lr:"LineString"===t?e=Vm:"Polygon"===t&&(e=Ir),i=function(i,n,r){return n?"Polygon"===t?i[0].length?n.setCoordinates([i[0].concat([i[0][0]])],this.geometryLayout_):n.setCoordinates([],this.geometryLayout_):n.setCoordinates(i,this.geometryLayout_):n=new e(i,this.geometryLayout_),n}}}this.geometryFunction_=i,this.dragVertexDelay_=void 0!==t.dragVertexDelay?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new s_({source:new cc({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:vy(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:La,this.freehandCondition_,t.freehand?this.freehandCondition_=ba:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Aa,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(pa,this.updateState_)}setTrace(t){let e;e=t?!0===t?ba:t:Ia,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(t){t.originalEvent.type===C&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===Wo.POINTERMOVE,i=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===Wo.POINTERDRAG){Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&void 0!==this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)}return this.freehand_&&t.type===Wo.POINTERDRAG&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===Wo.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===Wo.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===Wo.POINTERDRAG&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):t.type===Wo.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout((()=>{this.handlePointerMove_(new Vo(Wo.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))}),this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return void this.deactivateTrace_();const e=this.getMap(),i=Qt([e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_])]),n=this.traceSource_.getFeaturesInExtent(i);if(0===n.length)return;const r=function(t,e){const i=[];for(let n=0;n<e.length;++n)fy(t,e[n].getGeometry(),i);return i}(t.coordinate,n);r.length&&(this.traceState_={active:!0,startPx:t.pixel.slice(),targets:r,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex;i===t.startIndex<=e?i&&e>t.endIndex||!i&&e<t.endIndex?this.addTracedCoordinates_(t,t.endIndex,e):(i&&e<t.endIndex||!i&&e>t.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t<e){const n=Math.ceil(t);let r=Math.floor(e);r===e&&(r-=1),i=r-n+1}else{const n=Math.floor(t);let r=Math.ceil(e);r===e&&(r+=1),i=n-r+1}i>0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e<i){const r=Math.ceil(e);let s=Math.floor(i);s===i&&(s-=1);for(let e=r;e<=s;++e)n.push(dy(t.coordinates,e))}else{const r=Math.floor(e);let s=Math.ceil(i);s===i&&(s+=1);for(let e=r;e>=s;--e)n.push(dy(t.coordinates,e))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&Di(e.startPx,t.pixel)<this.snapTolerance_)return;const i=function(t,e,i,n){const r=t[0],s=t[1];let o=1/0,a=-1,l=NaN;for(let t=0;t<e.targets.length;++t){const i=e.targets[t],n=i.coordinates;let h,c=1/0;for(let t=0;t<n.length-1;++t){const e=yy(r,s,n[t],n[t+1]);e.squaredDistance<c&&(c=e.squaredDistance,h=t+e.along)}c<o&&(o=c,i.ring&&e.targetIndex===t&&(i.endIndex>i.startIndex?h<i.startIndex&&(h+=n.length):i.endIndex<i.startIndex&&h>i.startIndex&&(h-=n.length)),l=h,a=t)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const t=xy(h.coordinates,l);Di(i.getPixelFromCoordinate(t),e.startPx)>n&&(c=!1)}if(c){const t=h.coordinates,e=t.length,i=h.startIndex,n=l;if(i<n){const r=gy(t,i,n);gy(t,i,n-e)<r&&(l-=e)}else{const r=gy(t,i,n);gy(t,i,n+e)<r&&(l+=e)}}return py.index=a,py.endIndex=l,py}(t.coordinate,e,this.getMap(),this.snapTolerance_);if(e.targetIndex!==i.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}const t=e.targets[i.index];this.addTracedCoordinates_(t,t.startIndex,i.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,i.endIndex)}e.targetIndex=i.index;const n=e.targets[e.targetIndex];n.endIndex=i.endIndex;const r=xy(n.coordinates,n.endIndex),s=this.getMap().getPixelFromCoordinate(r);t.coordinate=r,t.pixel=[Math.round(s[0]),Math.round(s[1])]}handleUpEvent(t){let e=!0;if(0===this.getPointerCount()){this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t);const i=this.traceState_.active;if(this.toggleTraceState_(t),this.shouldHandle_){const n=!this.finishCoordinate_;n&&this.startDrawing_(t.coordinate),!n&&this.freehand_?this.finishDrawing():this.freehand_||n&&"Point"!==this.mode_||(this.atFinish_(t.pixel,i)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),e=!1}else this.freehand_&&this.abortDrawing()}return!e&&this.stopClick_&&t.preventDefault(),e}handlePointerMove_(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){const e=this.downPx_,i=t.pixel,n=e[0]-i[0],r=e[1]-i[1],s=n*n+r*r;if(this.shouldHandle_=this.freehand_?s>this.squaredClickTolerance_:s<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?(this.updateTrace_(t),this.modifyDrawing_(t.coordinate)):this.createOrUpdateSketchPoint_(t.coordinate.slice())}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let n=!1,r=[this.finishCoordinate_];const s=this.mode_;if("Point"===s)i=!0;else if("Circle"===s)i=2===this.sketchCoords_.length;else if("LineString"===s)n=!e&&this.sketchCoords_.length>this.minPoints_;else if("Polygon"===s){const t=this.sketchCoords_;n=t[0].length>this.minPoints_,r=[t[0][0],t[0][t[0].length-2]],r=e?[t[0][0]]:[t[0][0],t[0][t[0].length-2]]}if(n){const e=this.getMap();for(let n=0,s=r.length;n<s;n++){const s=r[n],o=e.getPixelFromCoordinate(s),a=t[0]-o[0],l=t[1]-o[1],h=this.freehand_?1:this.snapTolerance_;if(i=Math.sqrt(a*a+l*l)<=h,i){this.finishCoordinate_=s;break}}}}return i}createOrUpdateSketchPoint_(t){if(this.sketchPoint_){this.sketchPoint_.getGeometry().setCoordinates(t)}else this.sketchPoint_=new Nt(new lr(t)),this.updateSketchFeatures_()}createOrUpdateCustomSketchLine_(t){this.sketchLine_||(this.sketchLine_=new Nt);const e=t.getLinearRing(0);let i=this.sketchLine_.getGeometry();i?(i.setFlatCoordinates(e.getLayout(),e.getFlatCoordinates()),i.changed()):(i=new Vm(e.getFlatCoordinates(),e.getLayout()),this.sketchLine_.setGeometry(i))}startDrawing_(t){const e=this.getMap().getView().getProjection(),i=Mn(this.geometryLayout_);for(;t.length<i;)t.push(0);this.finishCoordinate_=t,"Point"===this.mode_?this.sketchCoords_=t.slice():"Polygon"===this.mode_?(this.sketchCoords_=[[t.slice(),t.slice()]],this.sketchLineCoords_=this.sketchCoords_[0]):this.sketchCoords_=[t.slice(),t.slice()],this.sketchLineCoords_&&(this.sketchLine_=new Nt(new Vm(this.sketchLineCoords_)));const n=this.geometryFunction_(this.sketchCoords_,void 0,e);this.sketchFeature_=new Nt,this.geometryName_&&this.sketchFeature_.setGeometryName(this.geometryName_),this.sketchFeature_.setGeometry(n),this.updateSketchFeatures_(),this.dispatchEvent(new cy(ay,this.sketchFeature_))}modifyDrawing_(t){const e=this.getMap(),i=this.sketchFeature_.getGeometry(),n=e.getView().getProjection(),r=Mn(this.geometryLayout_);let s,o;for(;t.length<r;)t.push(0);if("Point"===this.mode_?o=this.sketchCoords_:"Polygon"===this.mode_?(s=this.sketchCoords_[0],o=s[s.length-1],this.atFinish_(e.getPixelFromCoordinate(t))&&(t=this.finishCoordinate_.slice())):(s=this.sketchCoords_,o=s[s.length-1]),o[0]=t[0],o[1]=t[1],this.geometryFunction_(this.sketchCoords_,i,n),this.sketchPoint_){this.sketchPoint_.getGeometry().setCoordinates(t)}if("Polygon"===i.getType()&&"Polygon"!==this.mode_)this.createOrUpdateCustomSketchLine_(i);else if(this.sketchLineCoords_){this.sketchLine_.getGeometry().setCoordinates(this.sketchLineCoords_)}this.updateSketchFeatures_()}addToDrawing_(t){const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection();let n,r;const s=this.mode_;"LineString"===s||"Circle"===s?(this.finishCoordinate_=t.slice(),r=this.sketchCoords_,r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):"Polygon"===s&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),n&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),n&&this.finishDrawing()}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let r=0;r<t;++r){let t;if("LineString"===n||"Circle"===n){if(t=this.sketchCoords_,t.splice(-2,1),t.length>=2){this.finishCoordinate_=t[t.length-2].slice();const e=this.finishCoordinate_.slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}this.geometryFunction_(t,e,i),"Polygon"===e.getType()&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if("Polygon"===n){t=this.sketchCoords_[0],t.splice(-2,1);const n=this.sketchLine_.getGeometry();if(t.length>=2){const e=t[t.length-2].slice();t[t.length-1]=e,this.createOrUpdateSketchPoint_(e)}n.setCoordinates(t),this.geometryFunction_(this.sketchCoords_,e,i)}if(1===t.length){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return;let e=this.sketchCoords_;const i=t.getGeometry(),n=this.getMap().getView().getProjection();"LineString"===this.mode_?(e.pop(),this.geometryFunction_(e,i,n)):"Polygon"===this.mode_&&(e[0].pop(),this.geometryFunction_(e,i,n),e=i.getCoordinates()),"MultiPoint"===this.type_?t.setGeometry(new Km([e])):"MultiLineString"===this.type_?t.setGeometry(new Zm([e])):"MultiPolygon"===this.type_&&t.setGeometry(new $m([e])),this.dispatchEvent(new cy(ly,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t)}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new cy(hy,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;let n;if(i&&this.startDrawing_(t[0]),"LineString"===e||"Circle"===e)n=this.sketchCoords_;else{if("Polygon"!==e)return;n=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[]}i&&n.shift(),n.pop();for(let e=0;e<t.length;e++)this.addToDrawing_(t[e]);const r=t[t.length-1];this.addToDrawing_(r),this.modifyDrawing_(r)}extend(t){const e=t.getGeometry();this.sketchFeature_=t,this.sketchCoords_=e.getCoordinates();const i=this.sketchCoords_[this.sketchCoords_.length-1];this.finishCoordinate_=i.slice(),this.sketchCoords_.push(i.slice()),this.sketchPoint_=new Nt(new lr(i)),this.updateSketchFeatures_(),this.dispatchEvent(new cy(ay,this.sketchFeature_))}updateSketchFeatures_(){const t=[];this.sketchFeature_&&t.push(this.sketchFeature_),this.sketchLine_&&t.push(this.sketchLine_),this.sketchPoint_&&t.push(this.sketchPoint_);const e=this.overlay_.getSource();e.clear(!0),e.addFeatures(t)}updateState_(){const t=this.getMap(),e=this.getActive();t&&e||this.abortDrawing(),this.overlay_.setMap(e?t:null)}};const wy="extentchanged";class Ey extends r{constructor(t){super(wy),this.extent=t}}function Ty(){const t=gf();return function(e,i){return t.Polygon}}function Cy(){const t=gf();return function(e,i){return t.Point}}function Ry(t){return function(e){return Qt([t,e])}}function by(t,e){return t[0]==e[0]?function(i){return Qt([t,[i[0],e[1]]])}:t[1]==e[1]?function(i){return Qt([t,[e[0],i[1]]])}:null}var Py=class extends Sa{constructor(t){super(t=t||{}),this.on,this.once,this.un,this.condition_=t.condition?t.condition:ba,this.extent_=null,this.pointerHandler_=null,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.extentFeature_=null,this.vertexFeature_=null,t||(t={}),this.extentOverlay_=new s_({source:new cc({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.boxStyle?t.boxStyle:Ty(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.vertexOverlay_=new s_({source:new cc({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.pointerStyle?t.pointerStyle:Cy(),updateWhileAnimating:!0,updateWhileInteracting:!0}),t.extent&&this.setExtent(t.extent)}snapToVertex_(t,e){const i=e.getCoordinateFromPixelInternal(t),n=function(t,e){return ki(i,t)-ki(i,e)},r=this.getExtentInternal();if(r){const s=function(t){return[[[t[0],t[1]],[t[0],t[3]]],[[t[0],t[3]],[t[2],t[3]]],[[t[2],t[3]],[t[2],t[1]]],[[t[2],t[1]],[t[0],t[1]]]]}(r);s.sort(n);const o=s[0];let a=Ii(i,o);const l=e.getPixelFromCoordinateInternal(a);if(Di(t,l)<=this.pixelTolerance_){const t=e.getPixelFromCoordinateInternal(o[0]),i=e.getPixelFromCoordinateInternal(o[1]),n=Ni(l,t),r=Ni(l,i),s=Math.sqrt(Math.min(n,r));return this.snappedToVertex_=s<=this.pixelTolerance_,this.snappedToVertex_&&(a=n>r?o[1]:o[0]),a}}return null}handlePointerMove_(t){const e=t.pixel,i=t.map;let n=this.snapToVertex_(e,i);n||(n=i.getCoordinateFromPixelInternal(e)),this.createOrUpdatePointerFeature_(n)}createOrUpdateExtentFeature_(t){let e=this.extentFeature_;return e?t?e.setGeometry(Lr(t)):e.setGeometry(void 0):(e=new Nt(t?Lr(t):{}),this.extentFeature_=e,this.extentOverlay_.getSource().addFeature(e)),e}createOrUpdatePointerFeature_(t){let e=this.vertexFeature_;if(e){e.getGeometry().setCoordinates(t)}else e=new Nt(new lr(t)),this.vertexFeature_=e,this.vertexOverlay_.getSource().addFeature(e);return e}handleEvent(t){return!t.originalEvent||!this.condition_(t)||(t.type!=Wo.POINTERMOVE||this.handlingDownUpSequence||this.handlePointerMove_(t),super.handleEvent(t),!1)}handleDownEvent(t){const e=t.pixel,i=t.map,n=this.getExtentInternal();let r=this.snapToVertex_(e,i);const s=function(t){let e=null,i=null;return t[0]==n[0]?e=n[2]:t[0]==n[2]&&(e=n[0]),t[1]==n[1]?i=n[3]:t[1]==n[3]&&(i=n[1]),null!==e&&null!==i?[e,i]:null};if(r&&n){const t=r[0]==n[0]||r[0]==n[2]?r[0]:null,e=r[1]==n[1]||r[1]==n[3]?r[1]:null;null!==t&&null!==e?this.pointerHandler_=Ry(s(r)):null!==t?this.pointerHandler_=by(s([t,n[1]]),s([t,n[3]])):null!==e&&(this.pointerHandler_=by(s([n[0],e]),s([n[2],e])))}else r=i.getCoordinateFromPixelInternal(e),this.setExtent([r[0],r[1],r[0],r[1]]),this.pointerHandler_=Ry(r);return!0}handleDragEvent(t){if(this.pointerHandler_){const e=t.coordinate;this.setExtent(this.pointerHandler_(e)),this.createOrUpdatePointerFeature_(e)}}handleUpEvent(t){this.pointerHandler_=null;const e=this.getExtentInternal();return e&&0!==Se(e)||this.setExtent(null),!1}setMap(t){this.extentOverlay_.setMap(t),this.vertexOverlay_.setMap(t),super.setMap(t)}getExtent(){return vn(this.getExtentInternal(),this.getMap().getView().getProjection())}getExtentInternal(){return this.extent_}setExtent(t){this.extent_=t||null,this.createOrUpdateExtentFeature_(t),this.dispatchEvent(new Ey(this.extent_))}};function Iy(t){return parseFloat(t)}function Fy(t){return function(t){return Si(t,5)}(t).toString()}function Ly(t,e){return!isNaN(t)&&t!==Iy(Fy(e))}var My=class extends ya{constructor(t){let e;super(),e=!0===(t=Object.assign({animate:!0,params:["x","y","z","r","l"],replace:!1,prefix:""},t||{})).animate?{duration:250}:t.animate?t.animate:null,this.animationOptions_=e,this.params_=t.params.reduce(((t,e)=>(t[e]=!0,t)),{}),this.replace_=t.replace,this.prefix_=t.prefix,this.listenerKeys_=[],this.initial_=!0,this.updateState_=this.updateState_.bind(this)}getParamName_(t){return this.prefix_?this.prefix_+t:t}get_(t,e){return t.get(this.getParamName_(e))}set_(t,e,i){e in this.params_&&t.set(this.getParamName_(e),i)}delete_(t,e){e in this.params_&&t.delete(this.getParamName_(e))}setMap(t){const e=this.getMap();super.setMap(t),t!==e&&(e&&this.unregisterListeners_(e),t&&(this.initial_=!0,this.updateState_(),this.registerListeners_(t)))}registerListeners_(t){this.listenerKeys_.push(D(t,Qo,this.updateUrl_,this),D(t.getLayerGroup(),E,this.updateUrl_,this),D(t,"change:layergroup",this.handleChangeLayerGroup_,this)),this.replace_||addEventListener("popstate",this.updateState_)}unregisterListeners_(t){for(let t=0,e=this.listenerKeys_.length;t<e;++t)G(this.listenerKeys_[t]);this.listenerKeys_.length=0,this.replace_||removeEventListener("popstate",this.updateState_);const e=new URL(window.location.href),i=e.searchParams;this.delete_(i,"x"),this.delete_(i,"y"),this.delete_(i,"z"),this.delete_(i,"r"),this.delete_(i,"l"),window.history.replaceState(null,"",e)}handleChangeLayerGroup_(){const t=this.getMap();t&&(this.unregisterListeners_(t),this.registerListeners_(t),this.initial_=!0,this.updateUrl_())}updateState_(){const t=this.getMap();if(!t)return;const e=t.getView();if(!e)return;const i=new URL(window.location.href).searchParams;let n=!1;const r={},s=Iy(this.get_(i,"z"));"z"in this.params_&&Ly(s,e.getZoom())&&(n=!0,r.zoom=s);const o=Iy(this.get_(i,"r"));"r"in this.params_&&Ly(o,e.getRotation())&&(n=!0,r.rotation=o);const a=[Iy(this.get_(i,"x")),Iy(this.get_(i,"y"))];var l,h;("x"in this.params_||"y"in this.params_)&&(l=a,h=e.getCenter(),Ly(l[0],h[0])||Ly(l[1],h[1]))&&(n=!0,r.center=a),n&&(!this.initial_&&this.animationOptions_?e.animate(Object.assign(r,this.animationOptions_)):(r.center&&e.setCenter(r.center),"zoom"in r&&e.setZoom(r.zoom),"rotation"in r&&e.setRotation(r.rotation)));const c=t.getAllLayers(),u=this.get_(i,"l");if("l"in this.params_&&u&&u.length===c.length)for(let t=0,e=c.length;t<e;++t){const e=parseInt(u[t]);if(!isNaN(e)){const i=Boolean(e),n=c[t];n.getVisible()!==i&&n.setVisible(i)}}}updateUrl_(){const t=this.getMap();if(!t)return;const e=t.getView();if(!e)return;const i=this.initial_;this.initial_=!1;const n=e.getCenter(),r=e.getZoom(),s=e.getRotation(),o=t.getAllLayers(),a=new Array(o.length);for(let t=0,e=o.length;t<e;++t)a[t]=o[t].getVisible()?"1":"0";const l=new URL(window.location.href),h=l.searchParams;this.set_(h,"x",Fy(n[0])),this.set_(h,"y",Fy(n[1])),this.set_(h,"z",Fy(r)),this.set_(h,"r",Fy(s)),this.set_(h,"l",a.join("")),l.href!==window.location.href&&(i||this.replace_?window.history.replaceState(history.state,"",l):window.history.pushState(null,"",l))}};const Ay=[0,0,0,0],Oy=[],Ny="modifystart",Dy="modifyend";class ky extends r{constructor(t,e,i){super(t),this.features=e,this.mapBrowserEvent=i}}function Gy(t,e){return t.index-e.index}function jy(t,e,i){const n=e.geometry;if("Circle"===n.getType()){let r=n;if(1===e.index){const e=_n();e&&(r=r.clone().transform(e,i));const n=Ni(r.getCenter(),xn(t,i)),s=Math.sqrt(n)-r.getRadius();return s*s}}const r=xn(t,i);return Oy[0]=xn(e.segment[0],i),Oy[1]=xn(e.segment[1],i),ki(r,Oy)}function By(t,e,i){const n=e.geometry;if("Circle"===n.getType()&&1===e.index){let e=n;const r=_n();return r&&(e=e.clone().transform(r,i)),yn(e.getClosestPoint(xn(t,i)),i)}const r=xn(t,i);return Oy[0]=xn(e.segment[0],i),Oy[1]=xn(e.segment[1],i),yn(Ii(r,Oy),i)}function Uy(){const t=gf();return function(e,i){return t.Point}}var zy=class extends Sa{constructor(t){let e;if(super(t),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=t.condition?t.condition:Da,this.defaultDeleteCondition_=function(t){return Ea(t)&&Fa(t)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:ba,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new ec,this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new s_({source:new cc({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:Uy(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null,t.features?e=t.features:t.source&&(this.source_=t.source,e=new $(this.source_.getFeatures()),this.source_.addEventListener(ic,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(sc,this.handleSourceRemove_.bind(this))),!e)throw new Error("The modify interaction requires features, a source or a layer");t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=e,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Y,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(K,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=void 0===t.snapToPointer?!this.hitDetection_:t.snapToPointer}addFeature_(t){const e=t.getGeometry();if(e){const i=this.SEGMENT_WRITERS_[e.getType()];i&&i(t,e)}const i=this.getMap();i&&i.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,i),t.addEventListener(E,this.boundHandleFeatureChange_)}willModifyFeatures_(t,e){if(!this.featuresBeingModified_){this.featuresBeingModified_=new $;const i=this.featuresBeingModified_.getArray();for(let t=0,n=e.length;t<n;++t){const n=e[t];for(let t=0,e=n.length;t<e;++t){const e=n[t].feature;e&&!i.includes(e)&&this.featuresBeingModified_.push(e)}}0===this.featuresBeingModified_.getLength()?this.featuresBeingModified_=null:this.dispatchEvent(new ky(Ny,this.featuresBeingModified_,t))}}removeFeature_(t){this.removeFeatureSegmentData_(t),this.vertexFeature_&&0===this.features_.getLength()&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.removeEventListener(E,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(t){const e=this.rBush_,i=[];e.forEach((function(e){t===e.feature&&i.push(e)}));for(let t=i.length-1;t>=0;--t){const n=i[t];for(let t=this.dragSegments_.length-1;t>=0;--t)this.dragSegments_[t][0]===n&&this.dragSegments_.splice(t,1);e.remove(n)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){t.feature&&this.features_.push(t.feature)}handleSourceRemove_(t){t.feature&&this.features_.remove(t.feature)}handleFeatureAdd_(t){this.addFeature_(t.element)}handleFeatureChange_(t){if(!this.changingFeature_){const e=t.target;this.removeFeature_(e),this.addFeature_(e)}}handleFeatureRemove_(t){this.removeFeature_(t.element)}writePointGeometry_(t,e){const i=e.getCoordinates(),n={feature:t,geometry:e,segment:[i,i]};this.rBush_.insert(e.getExtent(),n)}writeMultiPointGeometry_(t,e){const i=e.getCoordinates();for(let n=0,r=i.length;n<r;++n){const r=i[n],s={feature:t,geometry:e,depth:[n],index:n,segment:[r,r]};this.rBush_.insert(e.getExtent(),s)}}writeLineStringGeometry_(t,e){const i=e.getCoordinates();for(let n=0,r=i.length-1;n<r;++n){const r=i.slice(n,n+2),s={feature:t,geometry:e,index:n,segment:r};this.rBush_.insert(Qt(r),s)}}writeMultiLineStringGeometry_(t,e){const i=e.getCoordinates();for(let n=0,r=i.length;n<r;++n){const r=i[n];for(let i=0,s=r.length-1;i<s;++i){const s=r.slice(i,i+2),o={feature:t,geometry:e,depth:[n],index:i,segment:s};this.rBush_.insert(Qt(s),o)}}}writePolygonGeometry_(t,e){const i=e.getCoordinates();for(let n=0,r=i.length;n<r;++n){const r=i[n];for(let i=0,s=r.length-1;i<s;++i){const s=r.slice(i,i+2),o={feature:t,geometry:e,depth:[n],index:i,segment:s};this.rBush_.insert(Qt(s),o)}}}writeMultiPolygonGeometry_(t,e){const i=e.getCoordinates();for(let n=0,r=i.length;n<r;++n){const r=i[n];for(let i=0,s=r.length;i<s;++i){const s=r[i];for(let r=0,o=s.length-1;r<o;++r){const o=s.slice(r,r+2),a={feature:t,geometry:e,depth:[i,n],index:r,segment:o};this.rBush_.insert(Qt(o),a)}}}}writeCircleGeometry_(t,e){const i=e.getCenter(),n={feature:t,geometry:e,index:0,segment:[i,i]},r={feature:t,geometry:e,index:1,segment:[i,i]},s=[n,r];n.featureSegments=s,r.featureSegments=s,this.rBush_.insert(ce(i),n);let o=e;const a=_n();if(a&&this.getMap()){const t=this.getMap().getView().getProjection();o=o.clone().transform(a,t),o=Mr(o).transform(t,a)}this.rBush_.insert(o.getExtent(),r)}writeGeometryCollectionGeometry_(t,e){const i=e.getGeometriesArray();for(let e=0;e<i.length;++e){const n=i[e];(0,this.SEGMENT_WRITERS_[n.getType()])(t,n)}}createOrUpdateVertexFeature_(t,e,i){let n=this.vertexFeature_;if(n){n.getGeometry().setCoordinates(t)}else n=new Nt(new lr(t)),this.vertexFeature_=n,this.overlay_.getSource().addFeature(n);return n.set("features",e),n.set("geometries",i),n}handleEvent(t){if(!t.originalEvent)return!0;let e;return this.lastPointerEvent_=t,t.map.getView().getInteracting()||t.type!=Wo.POINTERMOVE||this.handlingDownUpSequence||this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(e=!(t.type!=Wo.SINGLECLICK||!this.ignoreNextSingleClick_)||this.removePoint()),t.type==Wo.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!e}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_);const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],i=[],n=[];for(let r=0,s=this.dragSegments_.length;r<s;++r){const s=this.dragSegments_[r],o=s[0],a=o.feature;i.includes(a)||i.push(a);const l=o.geometry;n.includes(l)||n.push(l);const h=o.depth;let c;const u=o.segment,d=s[1];for(;e.length<l.getStride();)e.push(u[d][e.length]);switch(l.getType()){case"Point":c=e,u[0]=e,u[1]=e;break;case"MultiPoint":c=l.getCoordinates(),c[o.index]=e,u[0]=e,u[1]=e;break;case"LineString":c=l.getCoordinates(),c[o.index+d]=e,u[d]=e;break;case"MultiLineString":case"Polygon":c=l.getCoordinates(),c[h[0]][o.index+d]=e,u[d]=e;break;case"MultiPolygon":c=l.getCoordinates(),c[h[1]][h[0]][o.index+d]=e,u[d]=e;break;case"Circle":if(u[0]=e,u[1]=e,0===o.index)this.changingFeature_=!0,l.setCenter(e),this.changingFeature_=!1;else{this.changingFeature_=!0;const i=t.map.getView().getProjection();let n=Di(xn(l.getCenter(),i),xn(e,i));const r=_n();if(r){const t=l.clone().transform(r,i);t.setRadius(n),n=t.transform(i,r).getRadius()}l.setRadius(n),this.changingFeature_=!1}}c&&this.setGeometryCoordinates_(l,c)}this.createOrUpdateVertexFeature_(e,i,n)}handleDownEvent(t){if(!this.condition_(t))return!1;const e=t.coordinate;this.handlePointerAtPixel_(t.pixel,t.map,e),this.dragSegments_.length=0,this.featuresBeingModified_=null;const i=this.vertexFeature_;if(i){const n=t.map.getView().getProjection(),r=[],s=i.getGeometry().getCoordinates(),o=Qt([s]),a=this.rBush_.getInExtent(o),l={};a.sort(Gy);for(let i=0,o=a.length;i<o;++i){const o=a[i],h=o.segment;let c=V(o.geometry);const u=o.depth;if(u&&(c+="-"+u.join("-")),l[c]||(l[c]=new Array(2)),"Circle"!==o.geometry.getType()||1!==o.index)if(!Mi(h[0],s)||l[c][0])if(!Mi(h[1],s)||l[c][1])V(h)in this.vertexSegments_&&!l[c][0]&&!l[c][1]&&this.insertVertexCondition_(t)&&r.push(o);else{if(l[c][0]&&0===l[c][0].index){let t=o.geometry.getCoordinates();switch(o.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":t=t[u[1]];case"Polygon":if(o.index!==t[u[0]].length-2)continue}}this.dragSegments_.push([o,1]),l[c][1]=o}else this.dragSegments_.push([o,0]),l[c][0]=o;else{Mi(By(e,o,n),s)&&!l[c][0]&&(this.dragSegments_.push([o,0]),l[c][0]=o)}}r.length&&this.willModifyFeatures_(t,[r]);for(let t=r.length-1;t>=0;--t)this.insertVertex_(r[t],s)}return!!this.vertexFeature_}handleUpEvent(t){for(let e=this.dragSegments_.length-1;e>=0;--e){const i=this.dragSegments_[e][0],n=i.geometry;if("Circle"===n.getType()){const e=n.getCenter(),r=i.featureSegments[0],s=i.featureSegments[1];r.segment[0]=e,r.segment[1]=e,s.segment[0]=e,s.segment[1]=e,this.rBush_.update(ce(e),r);let o=n;const a=_n();if(a){const e=t.map.getView().getProjection();o=o.clone().transform(a,e),o=Mr(o).transform(e,a)}this.rBush_.update(o.getExtent(),s)}else this.rBush_.update(Qt(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new ky(Dy,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.pixel,t.map,t.coordinate)}handlePointerAtPixel_(t,e,i){const n=i||e.getCoordinateFromPixel(t),r=e.getView().getProjection(),s=function(t,e){return jy(n,t,r)-jy(n,e,r)};let o,a;if(this.hitDetection_){const i="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(t,((t,e,i)=>{i&&(i=new lr(yn(i.getCoordinates(),r)));const n=i||t.getGeometry();if("Point"===n.getType()&&t instanceof Nt&&this.features_.getArray().includes(t)){a=n;const e=t.getGeometry().getFlatCoordinates().slice(0,2);o=[{feature:t,geometry:a,segment:[e,e]}]}return!0}),{layerFilter:i})}if(!o){const t=vn(te(Sn(ce(n,Ay),r),e.getView().getResolution()*this.pixelTolerance_,Ay),r);o=this.rBush_.getInExtent(t)}if(o&&o.length>0){const i=o.sort(s)[0],l=i.segment;let h=By(n,i,r);const c=e.getPixelFromCoordinate(h);let u=Di(t,c);if(a||u<=this.pixelTolerance_){const t={};if(t[V(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-n[0],this.delta_[1]=h[1]-n[1]),"Circle"===i.geometry.getType()&&1===i.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[i.feature],[i.geometry]);else{const n=e.getPixelFromCoordinate(l[0]),r=e.getPixelFromCoordinate(l[1]),s=Ni(c,n),a=Ni(c,r);u=Math.sqrt(Math.min(s,a)),this.snappedToVertex_=u<=this.pixelTolerance_,this.snappedToVertex_&&(h=s>a?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[i.feature],[i.geometry]);const d={};d[V(i.geometry)]=!0;for(let e=1,i=o.length;e<i;++e){const i=o[e].segment;if(!(Mi(l[0],i[0])&&Mi(l[1],i[1])||Mi(l[0],i[1])&&Mi(l[1],i[0])))break;{const n=V(o[e].geometry);n in d||(d[n]=!0,t[V(i)]=!0)}}}return void(this.vertexSegments_=t)}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,e){const i=t.segment,n=t.feature,r=t.geometry,s=t.depth,o=t.index;let a;for(;e.length<r.getStride();)e.push(0);switch(r.getType()){case"MultiLineString":case"Polygon":a=r.getCoordinates(),a[s[0]].splice(o+1,0,e);break;case"MultiPolygon":a=r.getCoordinates(),a[s[1]][s[0]].splice(o+1,0,e);break;case"LineString":a=r.getCoordinates(),a.splice(o+1,0,e);break;default:return}this.setGeometryCoordinates_(r,a);const l=this.rBush_;l.remove(t),this.updateSegmentIndices_(r,o,s,1);const h={segment:[i[0],e],feature:n,geometry:r,depth:s,index:o};l.insert(Qt(h.segment),h),this.dragSegments_.push([h,1]);const c={segment:[e,i[1]],feature:n,geometry:r,depth:s,index:o+1};l.insert(Qt(c.segment),c),this.dragSegments_.push([c,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=Wo.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_);const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new ky(Dy,this.featuresBeingModified_,t)),this.featuresBeingModified_=null,e}return!1}removeVertex_(){const t=this.dragSegments_,e={};let i,n,r,s,o,a,l,h,c,u,d,g=!1;for(o=t.length-1;o>=0;--o)r=t[o],u=r[0],d=V(u.feature),u.depth&&(d+="-"+u.depth.join("-")),d in e||(e[d]={}),0===r[1]?(e[d].right=u,e[d].index=u.index):1==r[1]&&(e[d].left=u,e[d].index=u.index+1);for(d in e){switch(c=e[d].right,l=e[d].left,a=e[d].index,h=a-1,u=void 0!==l?l:c,h<0&&(h=0),s=u.geometry,n=s.getCoordinates(),i=n,g=!1,s.getType()){case"MultiLineString":n[u.depth[0]].length>2&&(n[u.depth[0]].splice(a,1),g=!0);break;case"LineString":n.length>2&&(n.splice(a,1),g=!0);break;case"MultiPolygon":i=i[u.depth[1]];case"Polygon":i=i[u.depth[0]],i.length>4&&(a==i.length-1&&(a=0),i.splice(a,1),g=!0,0===a&&(i.pop(),i.push(i[0]),h=i.length-1))}if(g){this.setGeometryCoordinates_(s,n);const e=[];if(void 0!==l&&(this.rBush_.remove(l),e.push(l.segment[0])),void 0!==c&&(this.rBush_.remove(c),e.push(c.segment[1])),void 0!==l&&void 0!==c){const t={depth:u.depth,feature:u.feature,geometry:u.geometry,index:h,segment:e};this.rBush_.insert(Qt(t.segment),t)}this.updateSegmentIndices_(s,a,u.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return g}setGeometryCoordinates_(t,e){this.changingFeature_=!0,t.setCoordinates(e),this.changingFeature_=!1}updateSegmentIndices_(t,e,i,n){this.rBush_.forEachInExtent(t.getExtent(),(function(r){r.geometry===t&&(void 0===i||void 0===r.depth||g(r.depth,i))&&r.index>e&&(r.index+=n)}))}};const Xy="select";class Vy extends r{constructor(t,e,i,n){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=n}}const Wy={};class Zy extends ya{constructor(t){let e;if(super(),this.on,this.once,this.un,t=t||{},this.boundAddFeature_=this.addFeature_.bind(this),this.boundRemoveFeature_=this.removeFeature_.bind(this),this.condition_=t.condition?t.condition:Fa,this.addCondition_=t.addCondition?t.addCondition:Ia,this.removeCondition_=t.removeCondition?t.removeCondition:Ia,this.toggleCondition_=t.toggleCondition?t.toggleCondition:Aa,this.multi_=!!t.multi&&t.multi,this.filter_=t.filter?t.filter:p,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=void 0!==t.style?t.style:function(){const t=gf();return d(t.Polygon,t.LineString),d(t.GeometryCollection,t.LineString),function(e){return e.getGeometry()?t[e.getGeometry().getType()]:null}}(),this.features_=t.features||new $,t.layers)if("function"==typeof t.layers)e=t.layers;else{const i=t.layers;e=function(t){return i.includes(t)}}else e=p;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[V(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[V(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(t){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(t),t?(this.features_.addEventListener(Y,this.boundAddFeature_),this.features_.addEventListener(K,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(Y,this.boundAddFeature_),this.features_.removeEventListener(K,this.boundRemoveFeature_))}addFeature_(t){const e=t.element;if(this.style_&&this.applySelectedStyle_(e),!this.getLayer(e)){const t=this.getMap().getAllLayers().find((function(t){if(t instanceof s_&&t.getSource()&&t.getSource().hasFeature(e))return t}));t&&this.addFeatureLayerAssociation_(e,t)}}removeFeature_(t){this.style_&&this.restorePreviousStyle_(t.element)}getStyle(){return this.style_}applySelectedStyle_(t){const e=V(t);e in Wy||(Wy[e]=t.getStyle()),t.setStyle(this.style_)}restorePreviousStyle_(t){const e=this.getMap().getInteractions().getArray();for(let i=e.length-1;i>=0;--i){const n=e[i];if(n!==this&&n instanceof Zy&&n.getStyle()&&-1!==n.getFeatures().getArray().lastIndexOf(t))return void t.setStyle(n.getStyle())}const i=V(t);t.setStyle(Wy[i]),delete Wy[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[V(t)]}handleEvent(t){if(!this.condition_(t))return!0;const e=this.addCondition_(t),i=this.removeCondition_(t),n=this.toggleCondition_(t),r=!e&&!i&&!n,s=t.map,o=this.getFeatures(),a=[],l=[];if(r){v(this.featureLayerAssociation_),s.forEachFeatureAtPixel(t.pixel,((t,e)=>{if(t instanceof Nt&&this.filter_(t,e))return this.addFeatureLayerAssociation_(t,e),l.push(t),!this.multi_}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=o.getLength()-1;t>=0;--t){const e=o.item(t),i=l.indexOf(e);i>-1?l.splice(i,1):(o.remove(e),a.push(e))}0!==l.length&&o.extend(l)}else{s.forEachFeatureAtPixel(t.pixel,((t,r)=>{if(t instanceof Nt&&this.filter_(t,r))return!e&&!n||o.getArray().includes(t)?(i||n)&&o.getArray().includes(t)&&(a.push(t),this.removeFeatureLayerAssociation_(t)):(this.addFeatureLayerAssociation_(t,r),l.push(t)),!this.multi_}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=a.length-1;t>=0;--t)o.remove(a[t]);o.extend(l)}return(l.length>0||a.length>0)&&this.dispatchEvent(new Vy(Xy,l,a,t)),!0}}var Yy=Zy;const Ky="snap";class Hy extends r{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature}}function qy(t){return t.feature?t.feature:t.element?t.element:null}const $y=[];var Jy=class extends Sa{constructor(t){const e=t=t||{};e.handleDownEvent||(e.handleDownEvent=p),e.stopDown||(e.stopDown=m),super(e),this.on,this.once,this.un,this.source_=t.source?t.source:null,this.vertex_=void 0===t.vertex||t.vertex,this.edge_=void 0===t.edge||t.edge,this.features_=t.features?t.features:null,this.featuresListenerKeys_=[],this.featureChangeListenerKeys_={},this.indexedFeaturesExtents_={},this.pendingFeatures_={},this.pixelTolerance_=void 0!==t.pixelTolerance?t.pixelTolerance:10,this.rBush_=new ec,this.GEOMETRY_SEGMENTERS_={Point:this.segmentPointGeometry_.bind(this),LineString:this.segmentLineStringGeometry_.bind(this),LinearRing:this.segmentLineStringGeometry_.bind(this),Polygon:this.segmentPolygonGeometry_.bind(this),MultiPoint:this.segmentMultiPointGeometry_.bind(this),MultiLineString:this.segmentMultiLineStringGeometry_.bind(this),MultiPolygon:this.segmentMultiPolygonGeometry_.bind(this),GeometryCollection:this.segmentGeometryCollectionGeometry_.bind(this),Circle:this.segmentCircleGeometry_.bind(this)}}addFeature(t,e){e=void 0===e||e;const i=V(t),n=t.getGeometry();if(n){const e=this.GEOMETRY_SEGMENTERS_[n.getType()];if(e){this.indexedFeaturesExtents_[i]=n.getExtent([1/0,1/0,-1/0,-1/0]);const r=[];if(e(r,n),1===r.length)this.rBush_.insert(Qt(r[0]),{feature:t,segment:r[0]});else if(r.length>1){const e=r.map((t=>Qt(t))),i=r.map((e=>({feature:t,segment:e})));this.rBush_.load(e,i)}}}e&&(this.featureChangeListenerKeys_[i]=D(t,E,this.handleFeatureChange_,this))}getFeatures_(){let t;return this.features_?t=this.features_:this.source_&&(t=this.source_.getFeatures()),t}handleEvent(t){const e=this.snapTo(t.pixel,t.coordinate,t.map);return e&&(t.coordinate=e.vertex.slice(0,2),t.pixel=e.vertexPixel,this.dispatchEvent(new Hy(Ky,{vertex:t.coordinate,vertexPixel:t.pixel,feature:e.feature}))),super.handleEvent(t)}handleFeatureAdd_(t){const e=qy(t);e&&this.addFeature(e)}handleFeatureRemove_(t){const e=qy(t);e&&this.removeFeature(e)}handleFeatureChange_(t){const e=t.target;if(this.handlingDownUpSequence){const t=V(e);t in this.pendingFeatures_||(this.pendingFeatures_[t]=e)}else this.updateFeature_(e)}handleUpEvent(t){const e=Object.values(this.pendingFeatures_);return e.length&&(e.forEach(this.updateFeature_.bind(this)),this.pendingFeatures_={}),!1}removeFeature(t,e){const i=void 0===e||e,n=V(t),r=this.indexedFeaturesExtents_[n];if(r){const e=this.rBush_,i=[];e.forEachInExtent(r,(function(e){t===e.feature&&i.push(e)}));for(let t=i.length-1;t>=0;--t)e.remove(i[t])}i&&(G(this.featureChangeListenerKeys_[n]),delete this.featureChangeListenerKeys_[n])}setMap(t){const e=this.getMap(),i=this.featuresListenerKeys_,n=this.getFeatures_();e&&(i.forEach(G),i.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(G),this.featureChangeListenerKeys_={}),super.setMap(t),t&&(this.features_?i.push(D(this.features_,Y,this.handleFeatureAdd_,this),D(this.features_,K,this.handleFeatureRemove_,this)):this.source_&&i.push(D(this.source_,ic,this.handleFeatureAdd_,this),D(this.source_,sc,this.handleFeatureRemove_,this)),n.forEach((t=>this.addFeature(t))))}snapTo(t,e,i){const n=i.getView().getProjection(),r=xn(e,n),s=vn(te(Qt([r]),i.getView().getResolution()*this.pixelTolerance_),n),o=this.rBush_.getInExtent(s),a=o.length;if(0===a)return null;let l,h,c=1/0;const u=this.pixelTolerance_*this.pixelTolerance_,d=()=>{if(l){const e=i.getPixelFromCoordinate(l);if(Ni(t,e)<=u)return{vertex:l,vertexPixel:[Math.round(e[0]),Math.round(e[1])],feature:h}}return null};if(this.vertex_){for(let t=0;t<a;++t){const e=o[t];"Circle"!==e.feature.getGeometry().getType()&&e.segment.forEach((t=>{const i=xn(t,n),s=Ni(r,i);s<c&&(l=t,c=s,h=e.feature)}))}const t=d();if(t)return t}if(this.edge_){for(let t=0;t<a;++t){let e=null;const i=o[t];if("Circle"===i.feature.getGeometry().getType()){let t=i.feature.getGeometry();const s=_n();s&&(t=t.clone().transform(s,n)),e=Pi(r,t)}else{const[t,s]=i.segment;s&&($y[0]=xn(t,n),$y[1]=xn(s,n),e=Ii(r,$y))}if(e){const t=Ni(r,e);t<c&&(l=yn(e,n),c=t)}}const t=d();if(t)return t}return null}updateFeature_(t){this.removeFeature(t,!1),this.addFeature(t,!1)}segmentCircleGeometry_(t,e){const i=this.getMap().getView().getProjection();let n=e;const r=_n();r&&(n=n.clone().transform(r,i));const s=Mr(n);r&&s.transform(i,r);const o=s.getCoordinates()[0];for(let e=0,i=o.length-1;e<i;++e)t.push(o.slice(e,e+2))}segmentGeometryCollectionGeometry_(t,e){const i=e.getGeometriesArray();for(let e=0;e<i.length;++e){const n=this.GEOMETRY_SEGMENTERS_[i[e].getType()];n&&n(t,i[e])}}segmentLineStringGeometry_(t,e){const i=e.getCoordinates();for(let e=0,n=i.length-1;e<n;++e)t.push(i.slice(e,e+2))}segmentMultiLineStringGeometry_(t,e){const i=e.getCoordinates();for(let e=0,n=i.length;e<n;++e){const n=i[e];for(let e=0,i=n.length-1;e<i;++e)t.push(n.slice(e,e+2))}}segmentMultiPointGeometry_(t,e){e.getCoordinates().forEach((e=>{t.push([e])}))}segmentMultiPolygonGeometry_(t,e){const i=e.getCoordinates();for(let e=0,n=i.length;e<n;++e){const n=i[e];for(let e=0,i=n.length;e<i;++e){const i=n[e];for(let e=0,n=i.length-1;e<n;++e)t.push(i.slice(e,e+2))}}}segmentPointGeometry_(t,e){t.push([e.getCoordinates()])}segmentPolygonGeometry_(t,e){const i=e.getCoordinates();for(let e=0,n=i.length;e<n;++e){const n=i[e];for(let e=0,i=n.length-1;e<i;++e)t.push(n.slice(e,e+2))}}};const Qy="translatestart",tx="translating",ex="translateend";class ix extends r{constructor(t,e,i,n,r){super(t),this.features=e,this.coordinate=i,this.startCoordinate=n,this.mapBrowserEvent=r}}var nx=class extends Sa{constructor(t){let e;if(super(t=t||{}),this.on,this.once,this.un,this.lastCoordinate_=null,this.startCoordinate_=null,this.features_=void 0!==t.features?t.features:null,t.layers&&!this.features_)if("function"==typeof t.layers)e=t.layers;else{const i=t.layers;e=function(t){return i.includes(t)}}else e=p;this.layerFilter_=e,this.filter_=t.filter&&!this.features_?t.filter:p,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.condition_=t.condition?t.condition:ba,this.lastFeature_=null,this.addChangeListener(pa,this.handleActiveChanged_)}handleDownEvent(t){if(!t.originalEvent||!this.condition_(t))return!1;if(this.lastFeature_=this.featuresAtPixel_(t.pixel,t.map),!this.lastCoordinate_&&this.lastFeature_){this.startCoordinate_=t.coordinate,this.lastCoordinate_=t.coordinate,this.handleMoveEvent(t);const e=this.features_||new $([this.lastFeature_]);return this.dispatchEvent(new ix(Qy,e,t.coordinate,this.startCoordinate_,t)),!0}return!1}handleUpEvent(t){if(this.lastCoordinate_){this.lastCoordinate_=null,this.handleMoveEvent(t);const e=this.features_||new $([this.lastFeature_]);return this.dispatchEvent(new ix(ex,e,t.coordinate,this.startCoordinate_,t)),this.startCoordinate_=null,!0}return!1}handleDragEvent(t){if(this.lastCoordinate_){const e=t.coordinate,i=t.map.getView().getProjection(),n=xn(e,i),r=xn(this.lastCoordinate_,i),s=n[0]-r[0],o=n[1]-r[1],a=this.features_||new $([this.lastFeature_]),l=_n();a.forEach((function(t){const e=t.getGeometry();l?(e.transform(l,i),e.translate(s,o),e.transform(i,l)):e.translate(s,o),t.setGeometry(e)})),this.lastCoordinate_=e,this.dispatchEvent(new ix(tx,a,e,this.startCoordinate_,t))}}handleMoveEvent(t){const e=t.map.getViewport();this.featuresAtPixel_(t.pixel,t.map)?(e.classList.remove(this.lastCoordinate_?"ol-grab":"ol-grabbing"),e.classList.add(this.lastCoordinate_?"ol-grabbing":"ol-grab")):e.classList.remove("ol-grab","ol-grabbing")}featuresAtPixel_(t,e){return e.forEachFeatureAtPixel(t,((t,e)=>{if(t instanceof Nt&&this.filter_(t,e)&&(!this.features_||this.features_.getArray().includes(t)))return t}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_})}getHitTolerance(){return this.hitTolerance_}setHitTolerance(t){this.hitTolerance_=t}setMap(t){const e=this.getMap();super.setMap(t),this.updateState_(e)}handleActiveChanged_(){this.updateState_(null)}updateState_(t){let e=this.getMap();const i=this.getActive();if((!e||!i)&&(e=e||t,e)){e.getViewport().classList.remove("ol-grab","ol-grabbing")}}};function rx(t,e,i,n,r,s){void 0!==r?s=void 0!==s?s:0:(r=[],s=0);let o=e;for(;o<i;){const e=t[o++];r[s++]=t[o++],r[s++]=e;for(let e=2;e<n;++e)r[s++]=t[o++]}return r.length=s,r}function sx(t){if("string"==typeof t){const e=JSON.parse(t);return e||null}return null!==t?t:null}var ox=class extends __{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(sx(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(sx(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return z()}readFeaturesFromObject(t,e){return z()}readGeometry(t,e){return this.readGeometryFromObject(sx(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return z()}readProjection(t){return this.readProjectionFromObject(sx(t))}readProjectionFromObject(t){return z()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return z()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return z()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return z()}};const ax={Point:function(t){let e;e=void 0!==t.m&&void 0!==t.z?new lr([t.x,t.y,t.z,t.m],"XYZM"):void 0!==t.z?new lr([t.x,t.y,t.z],"XYZ"):void 0!==t.m?new lr([t.x,t.y,t.m],"XYM"):new lr([t.x,t.y]);return e},LineString:function(t){const e=cx(t);return new Vm(t.paths[0],e)},Polygon:function(t){const e=cx(t);return new Ir(t.rings,e)},MultiPoint:function(t){const e=cx(t);return new Km(t.points,e)},MultiLineString:function(t){const e=cx(t);return new Zm(t.paths,e)},MultiPolygon:function(t){const e=cx(t);return new $m(t.rings,e)}},lx={Point:function(t,e){const i=t.getCoordinates();let n;const r=t.getLayout();"XYZ"===r?n={x:i[0],y:i[1],z:i[2]}:"XYM"===r?n={x:i[0],y:i[1],m:i[2]}:"XYZM"===r?n={x:i[0],y:i[1],z:i[2],m:i[3]}:"XY"===r?n={x:i[0],y:i[1]}:Mt(!1,34);return n},LineString:function(t,e){const i=ux(t);return{hasZ:i.hasZ,hasM:i.hasM,paths:[t.getCoordinates()]}},Polygon:function(t,e){const i=ux(t);return{hasZ:i.hasZ,hasM:i.hasM,rings:t.getCoordinates(!1)}},MultiPoint:function(t,e){const i=ux(t);return{hasZ:i.hasZ,hasM:i.hasM,points:t.getCoordinates()}},MultiLineString:function(t,e){const i=ux(t);return{hasZ:i.hasZ,hasM:i.hasM,paths:t.getCoordinates()}},MultiPolygon:function(t,e){const i=ux(t),n=t.getCoordinates(!1),r=[];for(let t=0;t<n.length;t++)for(let e=n[t].length-1;e>=0;e--)r.push(n[t][e]);return{hasZ:i.hasZ,hasM:i.hasM,rings:r}}};function hx(t,e){if(!t)return null;let i;if("number"==typeof t.x&&"number"==typeof t.y)i="Point";else if(t.points)i="MultiPoint";else if(t.paths){i=1===t.paths.length?"LineString":"MultiLineString"}else if(t.rings){const e=t,n=cx(e),r=function(t,e){const i=[],n=[],r=[];let s,o;for(s=0,o=t.length;s<o;++s){i.length=0,Xn(i,0,t[s],e.length);wr(i,0,i.length,e.length)?n.push([t[s]]):r.push(t[s])}for(;r.length;){const t=r.shift();let e=!1;for(s=n.length-1;s>=0;s--){const i=n[s][0];if(re(new or(i).getExtent(),new or(t).getExtent())){n[s].push(t),e=!0;break}}e||n.push([t.reverse()])}return n}(e.rings,n);1===r.length?(i="Polygon",t=Object.assign({},t,{rings:r[0]})):(i="MultiPolygon",t=Object.assign({},t,{rings:r}))}return y_((0,ax[i])(t),!1,e)}function cx(t){let e="XY";return!0===t.hasZ&&!0===t.hasM?e="XYZM":!0===t.hasZ?e="XYZ":!0===t.hasM&&(e="XYM"),e}function ux(t){const e=t.getLayout();return{hasZ:"XYZ"===e||"XYZM"===e,hasM:"XYM"===e||"XYZM"===e}}function dx(t,e){return(0,lx[t.getType()])(y_(t,!0,e),e)}var gx=class extends ox{constructor(t){t=t||{},super(),this.geometryName_=t.geometryName}readFeatureFromObject(t,e,i){const n=t,r=hx(n.geometry,e),s=new Nt;if(this.geometryName_&&s.setGeometryName(this.geometryName_),s.setGeometry(r),n.attributes){s.setProperties(n.attributes,!0);const t=n.attributes[i];void 0!==t&&s.setId(t)}return s}readFeaturesFromObject(t,e){if(e=e||{},t.features){const i=[],n=t.features;for(let r=0,s=n.length;r<s;++r)i.push(this.readFeatureFromObject(n[r],e,t.objectIdFieldName));return i}return[this.readFeatureFromObject(t,e)]}readGeometryFromObject(t,e){return hx(t,e)}readProjectionFromObject(t){if(t.spatialReference&&void 0!==t.spatialReference.wkid){return nn("EPSG:"+t.spatialReference.wkid)}return null}writeGeometryObject(t,e){return dx(t,this.adaptOptions(e))}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={};if(!t.hasProperties())return i.attributes={},i;const n=t.getProperties(),r=t.getGeometry();if(r){i.geometry=dx(r,e);const s=e&&(e.dataProjection||e.featureProjection);s&&(i.geometry.spatialReference={wkid:Number(nn(s).getCode().split(":").pop())}),delete n[t.getGeometryName()]}return S(n)?i.attributes={}:i.attributes=n,i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let n=0,r=t.length;n<r;++n)i.push(this.writeFeatureObject(t[n],e));return{features:i}}};var fx=class extends __{constructor(){super(),this.xmlSerializer_=Md()}getType(){return"xml"}readFeature(t,e){if(!t)return null;if("string"==typeof t){const i=fd(t);return this.readFeatureFromDocument(i,e)}return dd(t)?this.readFeatureFromDocument(t,e):this.readFeatureFromNode(t,e)}readFeatureFromDocument(t,e){const i=this.readFeaturesFromDocument(t,e);return i.length>0?i[0]:null}readFeatureFromNode(t,e){return null}readFeatures(t,e){if(!t)return[];if("string"==typeof t){const i=fd(t);return this.readFeaturesFromDocument(i,e)}return dd(t)?this.readFeaturesFromDocument(t,e):this.readFeaturesFromNode(t,e)}readFeaturesFromDocument(t,e){const i=[];for(let n=t.firstChild;n;n=n.nextSibling)n.nodeType==Node.ELEMENT_NODE&&d(i,this.readFeaturesFromNode(n,e));return i}readFeaturesFromNode(t,e){return z()}readGeometry(t,e){if(!t)return null;if("string"==typeof t){const i=fd(t);return this.readGeometryFromDocument(i,e)}return dd(t)?this.readGeometryFromDocument(t,e):this.readGeometryFromNode(t,e)}readGeometryFromDocument(t,e){return null}readGeometryFromNode(t,e){return null}readProjection(t){if(!t)return null;if("string"==typeof t){const e=fd(t);return this.readProjectionFromDocument(e)}return dd(t)?this.readProjectionFromDocument(t):this.readProjectionFromNode(t)}readProjectionFromDocument(t){return this.dataProjection}readProjectionFromNode(t){return this.dataProjection}writeFeature(t,e){const i=this.writeFeatureNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeFeatureNode(t,e){return null}writeFeatures(t,e){const i=this.writeFeaturesNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeFeaturesNode(t,e){return null}writeGeometry(t,e){const i=this.writeGeometryNode(t,e);return this.xmlSerializer_.serializeToString(i)}writeGeometryNode(t,e){return null}};const px="http://www.opengis.net/gml",mx=/^\s*$/;class _x extends fx{constructor(t){super(),t=t||{},this.featureType=t.featureType,this.featureNS=t.featureNS,this.srsName=t.srsName,this.schemaLocation="",this.FEATURE_COLLECTION_PARSERS={},this.FEATURE_COLLECTION_PARSERS[this.namespace]={featureMember:md(this.readFeaturesInternal),featureMembers:_d(this.readFeaturesInternal)},this.supportedMediaTypes=["application/gml+xml"]}readFeaturesInternal(t,e){const i=t.localName;let n=null;if("FeatureCollection"==i)n=bd([],this.FEATURE_COLLECTION_PARSERS,t,e,this);else if("featureMembers"==i||"featureMember"==i||"member"==i){const r=e[0];let s=r.featureType,o=r.featureNS;const a="p",l="p0";if(!s&&t.childNodes){s=[],o={};for(let e=0,i=t.childNodes.length;e<i;++e){const i=t.childNodes[e];if(1===i.nodeType){const t=i.nodeName.split(":").pop();if(!s.includes(t)){let e="",n=0;const r=i.namespaceURI;for(const t in o){if(o[t]===r){e=t;break}++n}e||(e=a+n,o[e]=r),s.push(e+":"+t)}}}"featureMember"!=i&&(r.featureType=s,r.featureNS=o)}if("string"==typeof o){const t=o;o={},o[l]=t}const h={},c=Array.isArray(s)?s:[s];for(const t in o){const e={};for(let n=0,r=c.length;n<r;++n){(c[n].includes(":")?c[n].split(":")[0]:l)===t&&(e[c[n].split(":").pop()]="featureMembers"==i?md(this.readFeatureElement,this):_d(this.readFeatureElement,this))}h[o[t]]=e}n=bd("featureMember"==i||"member"==i?void 0:[],h,t,e)}return null===n&&(n=[]),n}readGeometryOrExtent(t,e){const i=e[0];return i.srsName=t.firstElementChild.getAttribute("srsName"),i.srsDimension=t.firstElementChild.getAttribute("srsDimension"),bd(null,this.GEOMETRY_PARSERS,t,e,this)}readExtentElement(t,e){const i=e[0],n=this.readGeometryOrExtent(t,e);return n?x_(n,i):void 0}readGeometryElement(t,e){const i=e[0],n=this.readGeometryOrExtent(t,e);return n?y_(n,!1,i):void 0}readFeatureElementInternal(t,e,i){let n;const r={};for(let s=t.firstElementChild;s;s=s.nextElementSibling){let t;const o=s.localName;0===s.childNodes.length||1===s.childNodes.length&&(3===s.firstChild.nodeType||4===s.firstChild.nodeType)?(t=cd(s,!1),mx.test(t)&&(t=void 0)):(i&&(t="boundedBy"===o?this.readExtentElement(s,e):this.readGeometryElement(s,e)),t?"boundedBy"!==o&&(n=o):t=this.readFeatureElementInternal(s,e,!1));const a=s.attributes.length;if(a>0&&!(t instanceof Ln)){t={_content_:t};for(let e=0;e<a;e++){t[s.attributes[e].name]=s.attributes[e].value}}r[o]?(r[o]instanceof Array||(r[o]=[r[o]]),r[o].push(t)):r[o]=t}if(!i)return r;const s=new Nt(r);n&&s.setGeometryName(n);const o=t.getAttribute("fid")||gd(t,this.namespace,"id");return o&&s.setId(o),s}readFeatureElement(t,e){return this.readFeatureElementInternal(t,e,!0)}readPoint(t,e){const i=this.readFlatCoordinatesFromNode(t,e);if(i)return new lr(i,"XYZ")}readMultiPoint(t,e){const i=bd([],this.MULTIPOINT_PARSERS,t,e,this);if(i)return new Km(i)}readMultiLineString(t,e){const i=bd([],this.MULTILINESTRING_PARSERS,t,e,this);if(i)return new Zm(i)}readMultiPolygon(t,e){const i=bd([],this.MULTIPOLYGON_PARSERS,t,e,this);if(i)return new $m(i)}pointMemberParser(t,e){Rd(this.POINTMEMBER_PARSERS,t,e,this)}lineStringMemberParser(t,e){Rd(this.LINESTRINGMEMBER_PARSERS,t,e,this)}polygonMemberParser(t,e){Rd(this.POLYGONMEMBER_PARSERS,t,e,this)}readLineString(t,e){const i=this.readFlatCoordinatesFromNode(t,e);if(i){return new Vm(i,"XYZ")}}readFlatLinearRing(t,e){const i=bd(null,this.GEOMETRY_FLAT_COORDINATES_PARSERS,t,e,this);if(i)return i}readLinearRing(t,e){const i=this.readFlatCoordinatesFromNode(t,e);if(i)return new or(i,"XYZ")}readPolygon(t,e){const i=bd([null],this.FLAT_LINEAR_RINGS_PARSERS,t,e,this);if(i&&i[0]){const t=i[0],e=[t.length];let n,r;for(n=1,r=i.length;n<r;++n)d(t,i[n]),e.push(t.length);return new Ir(t,"XYZ",e)}}readFlatCoordinatesFromNode(t,e){return bd(null,this.GEOMETRY_FLAT_COORDINATES_PARSERS,t,e,this)}readGeometryFromNode(t,e){const i=this.readGeometryElement(t,[this.getReadOptions(t,e||{})]);return i||null}readFeaturesFromNode(t,e){const i={featureType:this.featureType,featureNS:this.featureNS};i&&Object.assign(i,this.getReadOptions(t,e));return this.readFeaturesInternal(t,[i])||[]}readProjectionFromNode(t){return nn(this.srsName?this.srsName:t.firstElementChild.getAttribute("srsName"))}}_x.prototype.namespace=px,_x.prototype.FLAT_LINEAR_RINGS_PARSERS={"http://www.opengis.net/gml":{}},_x.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS={"http://www.opengis.net/gml":{}},_x.prototype.GEOMETRY_PARSERS={"http://www.opengis.net/gml":{}},_x.prototype.MULTIPOINT_PARSERS={"http://www.opengis.net/gml":{pointMember:md(_x.prototype.pointMemberParser),pointMembers:md(_x.prototype.pointMemberParser)}},_x.prototype.MULTILINESTRING_PARSERS={"http://www.opengis.net/gml":{lineStringMember:md(_x.prototype.lineStringMemberParser),lineStringMembers:md(_x.prototype.lineStringMemberParser)}},_x.prototype.MULTIPOLYGON_PARSERS={"http://www.opengis.net/gml":{polygonMember:md(_x.prototype.polygonMemberParser),polygonMembers:md(_x.prototype.polygonMemberParser)}},_x.prototype.POINTMEMBER_PARSERS={"http://www.opengis.net/gml":{Point:md(_x.prototype.readFlatCoordinatesFromNode)}},_x.prototype.LINESTRINGMEMBER_PARSERS={"http://www.opengis.net/gml":{LineString:md(_x.prototype.readLineString)}},_x.prototype.POLYGONMEMBER_PARSERS={"http://www.opengis.net/gml":{Polygon:md(_x.prototype.readPolygon)}},_x.prototype.RING_PARSERS={"http://www.opengis.net/gml":{LinearRing:_d(_x.prototype.readFlatLinearRing)}};var yx=_x;function xx(t){return vx(cd(t,!1))}function vx(t){const e=/^\s*(true|1)|(false|0)\s*$/.exec(t);if(e)return void 0!==e[1]||!1}function Sx(t){const e=cd(t,!1),i=Date.parse(e);return isNaN(i)?void 0:i/1e3}function wx(t){return Ex(cd(t,!1))}function Ex(t){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(t);if(e)return parseFloat(e[1])}function Tx(t){return Cx(cd(t,!1))}function Cx(t){const e=/^\s*(\d+)\s*$/.exec(t);if(e)return parseInt(e[1],10)}function Rx(t){return cd(t,!1).trim()}function bx(t,e){Mx(t,e?"1":"0")}function Px(t,e){t.appendChild(Ad().createCDATASection(e))}function Ix(t,e){const i=new Date(1e3*e),n=i.getUTCFullYear()+"-"+Ci(i.getUTCMonth()+1,2)+"-"+Ci(i.getUTCDate(),2)+"T"+Ci(i.getUTCHours(),2)+":"+Ci(i.getUTCMinutes(),2)+":"+Ci(i.getUTCSeconds(),2)+"Z";t.appendChild(Ad().createTextNode(n))}function Fx(t,e){const i=e.toPrecision();t.appendChild(Ad().createTextNode(i))}function Lx(t,e){const i=e.toString();t.appendChild(Ad().createTextNode(i))}function Mx(t,e){t.appendChild(Ad().createTextNode(e))}const Ax=px+" http://schemas.opengis.net/gml/2.1.2/feature.xsd",Ox={MultiLineString:"lineStringMember",MultiCurve:"curveMember",MultiPolygon:"polygonMember",MultiSurface:"surfaceMember"};class Nx extends yx{constructor(t){super(t=t||{}),this.FEATURE_COLLECTION_PARSERS[px].featureMember=md(this.readFeaturesInternal),this.schemaLocation=t.schemaLocation?t.schemaLocation:Ax}readFlatCoordinates(t,e){const i=cd(t,!1).replace(/^\s*|\s*$/g,""),n=e[0].srsName;let r="enu";if(n){const t=nn(n);t&&(r=t.getAxisOrientation())}const s=i.trim().split(/\s+/),o=[];for(let t=0,e=s.length;t<e;t++){const e=s[t].split(/,+/),i=parseFloat(e[0]),n=parseFloat(e[1]),a=3===e.length?parseFloat(e[2]):0;"en"===r.substr(0,2)?o.push(i,n,a):o.push(n,i,a)}return o}readBox(t,e){const i=bd([null],this.BOX_PARSERS_,t,e,this);return le(i[1][0],i[1][1],i[1][3],i[1][4])}innerBoundaryIsParser(t,e){const i=bd(void 0,this.RING_PARSERS,t,e,this);if(i){e[e.length-1].push(i)}}outerBoundaryIsParser(t,e){const i=bd(void 0,this.RING_PARSERS,t,e,this);if(i){e[e.length-1][0]=i}}GEOMETRY_NODE_FACTORY_(t,e,i){const n=e[e.length-1],r=n.multiSurface,s=n.surface,o=n.multiCurve;return Array.isArray(t)?i="Envelope":"MultiPolygon"===(i=t.getType())&&!0===r?i="MultiSurface":"Polygon"===i&&!0===s?i="Surface":"MultiLineString"===i&&!0===o&&(i="MultiCurve"),hd("http://www.opengis.net/gml",i)}writeFeatureElement(t,e,i){const n=e.getId();n&&t.setAttribute("fid",n);const r=i[i.length-1],s=r.featureNS,o=e.getGeometryName();r.serializers||(r.serializers={},r.serializers[s]={});const a=[],l=[];if(e.hasProperties()){const t=e.getProperties();for(const e in t){const i=t[e];null!==i&&(a.push(e),l.push(i),e==o||"function"==typeof i.getSimplifiedGeometry?e in r.serializers[s]||(r.serializers[s][e]=vd(this.writeGeometryElement,this)):e in r.serializers[s]||(r.serializers[s][e]=vd(Mx)))}}const h=Object.assign({},r);h.node=t,Id(h,r.serializers,wd(void 0,s),l,i,a)}writeCurveOrLineString(t,e,i){const n=i[i.length-1].srsName;if("LineStringSegment"!==t.nodeName&&n&&t.setAttribute("srsName",n),"LineString"===t.nodeName||"LineStringSegment"===t.nodeName){const n=this.createCoordinatesNode_(t.namespaceURI);t.appendChild(n),this.writeCoordinates_(n,e,i)}else if("Curve"===t.nodeName){const n=hd(t.namespaceURI,"segments");t.appendChild(n),this.writeCurveSegments_(n,e,i)}}writeLineStringOrCurveMember(t,e,i){const n=this.GEOMETRY_NODE_FACTORY_(e,i);n&&(t.appendChild(n),this.writeCurveOrLineString(n,e,i))}writeMultiCurveOrLineString(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName,o=n.curve;s&&t.setAttribute("srsName",s);const a=e.getLineStrings();Id({node:t,hasZ:r,srsName:s,curve:o},this.LINESTRINGORCURVEMEMBER_SERIALIZERS,this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_,a,i,void 0,this)}writeGeometryElement(t,e,i){const n=i[i.length-1],r=Object.assign({},n);let s;r.node=t,s=Array.isArray(e)?x_(e,n):y_(e,!0,n),Id(r,this.GEOMETRY_SERIALIZERS,this.GEOMETRY_NODE_FACTORY_,[s],i,void 0,this)}createCoordinatesNode_(t){const e=hd(t,"coordinates");return e.setAttribute("decimal","."),e.setAttribute("cs",","),e.setAttribute("ts"," "),e}writeCoordinates_(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName,o=e.getCoordinates(),a=o.length,l=new Array(a);for(let t=0;t<a;++t){const e=o[t];l[t]=this.getCoords_(e,s,r)}Mx(t,l.join(" "))}writeCurveSegments_(t,e,i){const n=hd(t.namespaceURI,"LineStringSegment");t.appendChild(n),this.writeCurveOrLineString(n,e,i)}writeSurfaceOrPolygon(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName;if("PolygonPatch"!==t.nodeName&&s&&t.setAttribute("srsName",s),"Polygon"===t.nodeName||"PolygonPatch"===t.nodeName){const n=e.getLinearRings();Id({node:t,hasZ:r,srsName:s},this.RING_SERIALIZERS,this.RING_NODE_FACTORY_,n,i,void 0,this)}else if("Surface"===t.nodeName){const n=hd(t.namespaceURI,"patches");t.appendChild(n),this.writeSurfacePatches_(n,e,i)}}RING_NODE_FACTORY_(t,e,i){const n=e[e.length-1],r=n.node,s=n.exteriorWritten;return void 0===s&&(n.exteriorWritten=!0),hd(r.namespaceURI,void 0!==s?"innerBoundaryIs":"outerBoundaryIs")}writeSurfacePatches_(t,e,i){const n=hd(t.namespaceURI,"PolygonPatch");t.appendChild(n),this.writeSurfaceOrPolygon(n,e,i)}writeRing(t,e,i){const n=hd(t.namespaceURI,"LinearRing");t.appendChild(n),this.writeLinearRing(n,e,i)}getCoords_(t,e,i){let n="enu";e&&(n=nn(e).getAxisOrientation());let r="en"===n.substr(0,2)?t[0]+","+t[1]:t[1]+","+t[0];if(i){r+=","+(t[2]||0)}return r}writePoint(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName;s&&t.setAttribute("srsName",s);const o=this.createCoordinatesNode_(t.namespaceURI);t.appendChild(o);const a=e.getCoordinates();Mx(o,this.getCoords_(a,s,r))}writeMultiPoint(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName;s&&t.setAttribute("srsName",s);const o=e.getPoints();Id({node:t,hasZ:r,srsName:s},this.POINTMEMBER_SERIALIZERS,wd("pointMember"),o,i,void 0,this)}writePointMember(t,e,i){const n=hd(t.namespaceURI,"Point");t.appendChild(n),this.writePoint(n,e,i)}writeLinearRing(t,e,i){const n=i[i.length-1].srsName;n&&t.setAttribute("srsName",n);const r=this.createCoordinatesNode_(t.namespaceURI);t.appendChild(r),this.writeCoordinates_(r,e,i)}writeMultiSurfaceOrPolygon(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName,o=n.surface;s&&t.setAttribute("srsName",s);const a=e.getPolygons();Id({node:t,hasZ:r,srsName:s,surface:o},this.SURFACEORPOLYGONMEMBER_SERIALIZERS,this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_,a,i,void 0,this)}writeSurfaceOrPolygonMember(t,e,i){const n=this.GEOMETRY_NODE_FACTORY_(e,i);n&&(t.appendChild(n),this.writeSurfaceOrPolygon(n,e,i))}writeEnvelope(t,e,i){const n=i[i.length-1].srsName;n&&t.setAttribute("srsName",n);const r=[e[0]+" "+e[1],e[2]+" "+e[3]];Id({node:t},this.ENVELOPE_SERIALIZERS,Ed,r,i,["lowerCorner","upperCorner"],this)}MULTIGEOMETRY_MEMBER_NODE_FACTORY_(t,e,i){const n=e[e.length-1].node;return hd("http://www.opengis.net/gml",Ox[n.nodeName])}}Nx.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS={"http://www.opengis.net/gml":{coordinates:_d(Nx.prototype.readFlatCoordinates)}},Nx.prototype.FLAT_LINEAR_RINGS_PARSERS={"http://www.opengis.net/gml":{innerBoundaryIs:Nx.prototype.innerBoundaryIsParser,outerBoundaryIs:Nx.prototype.outerBoundaryIsParser}},Nx.prototype.BOX_PARSERS_={"http://www.opengis.net/gml":{coordinates:md(Nx.prototype.readFlatCoordinates)}},Nx.prototype.GEOMETRY_PARSERS={"http://www.opengis.net/gml":{Point:_d(yx.prototype.readPoint),MultiPoint:_d(yx.prototype.readMultiPoint),LineString:_d(yx.prototype.readLineString),MultiLineString:_d(yx.prototype.readMultiLineString),LinearRing:_d(yx.prototype.readLinearRing),Polygon:_d(yx.prototype.readPolygon),MultiPolygon:_d(yx.prototype.readMultiPolygon),Box:_d(Nx.prototype.readBox)}},Nx.prototype.GEOMETRY_SERIALIZERS={"http://www.opengis.net/gml":{Curve:vd(Nx.prototype.writeCurveOrLineString),MultiCurve:vd(Nx.prototype.writeMultiCurveOrLineString),Point:vd(Nx.prototype.writePoint),MultiPoint:vd(Nx.prototype.writeMultiPoint),LineString:vd(Nx.prototype.writeCurveOrLineString),MultiLineString:vd(Nx.prototype.writeMultiCurveOrLineString),LinearRing:vd(Nx.prototype.writeLinearRing),Polygon:vd(Nx.prototype.writeSurfaceOrPolygon),MultiPolygon:vd(Nx.prototype.writeMultiSurfaceOrPolygon),Surface:vd(Nx.prototype.writeSurfaceOrPolygon),MultiSurface:vd(Nx.prototype.writeMultiSurfaceOrPolygon),Envelope:vd(Nx.prototype.writeEnvelope)}},Nx.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS={"http://www.opengis.net/gml":{lineStringMember:vd(Nx.prototype.writeLineStringOrCurveMember),curveMember:vd(Nx.prototype.writeLineStringOrCurveMember)}},Nx.prototype.RING_SERIALIZERS={"http://www.opengis.net/gml":{outerBoundaryIs:vd(Nx.prototype.writeRing),innerBoundaryIs:vd(Nx.prototype.writeRing)}},Nx.prototype.POINTMEMBER_SERIALIZERS={"http://www.opengis.net/gml":{pointMember:vd(Nx.prototype.writePointMember)}},Nx.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS={"http://www.opengis.net/gml":{surfaceMember:vd(Nx.prototype.writeSurfaceOrPolygonMember),polygonMember:vd(Nx.prototype.writeSurfaceOrPolygonMember)}},Nx.prototype.ENVELOPE_SERIALIZERS={"http://www.opengis.net/gml":{lowerCorner:vd(Mx),upperCorner:vd(Mx)}};var Dx=Nx;const kx=px+" http://schemas.opengis.net/gml/3.1.1/profiles/gmlsfProfile/1.0.0/gmlsf.xsd",Gx={MultiLineString:"lineStringMember",MultiCurve:"curveMember",MultiPolygon:"polygonMember",MultiSurface:"surfaceMember"};class jx extends yx{constructor(t){super(t=t||{}),this.surface_=void 0!==t.surface&&t.surface,this.curve_=void 0!==t.curve&&t.curve,this.multiCurve_=void 0===t.multiCurve||t.multiCurve,this.multiSurface_=void 0===t.multiSurface||t.multiSurface,this.schemaLocation=t.schemaLocation?t.schemaLocation:kx,this.hasZ=void 0!==t.hasZ&&t.hasZ}readMultiCurve(t,e){const i=bd([],this.MULTICURVE_PARSERS,t,e,this);if(i){return new Zm(i)}}readFlatCurveRing(t,e){const i=bd([],this.MULTICURVE_PARSERS,t,e,this),n=[];for(let t=0,e=i.length;t<e;++t)d(n,i[t].getFlatCoordinates());return n}readMultiSurface(t,e){const i=bd([],this.MULTISURFACE_PARSERS,t,e,this);if(i)return new $m(i)}curveMemberParser(t,e){Rd(this.CURVEMEMBER_PARSERS,t,e,this)}surfaceMemberParser(t,e){Rd(this.SURFACEMEMBER_PARSERS,t,e,this)}readPatch(t,e){return bd([null],this.PATCHES_PARSERS,t,e,this)}readSegment(t,e){return bd([],this.SEGMENTS_PARSERS,t,e,this)}readPolygonPatch(t,e){return bd([null],this.FLAT_LINEAR_RINGS_PARSERS,t,e,this)}readLineStringSegment(t,e){return bd([null],this.GEOMETRY_FLAT_COORDINATES_PARSERS,t,e,this)}interiorParser(t,e){const i=bd(void 0,this.RING_PARSERS,t,e,this);if(i){e[e.length-1].push(i)}}exteriorParser(t,e){const i=bd(void 0,this.RING_PARSERS,t,e,this);if(i){e[e.length-1][0]=i}}readSurface(t,e){const i=bd([null],this.SURFACE_PARSERS,t,e,this);if(i&&i[0]){const t=i[0],e=[t.length];let n,r;for(n=1,r=i.length;n<r;++n)d(t,i[n]),e.push(t.length);return new Ir(t,"XYZ",e)}}readCurve(t,e){const i=bd([null],this.CURVE_PARSERS,t,e,this);if(i){return new Vm(i,"XYZ")}}readEnvelope(t,e){const i=bd([null],this.ENVELOPE_PARSERS,t,e,this);return le(i[1][0],i[1][1],i[2][0],i[2][1])}readFlatPos(t,e){let i=cd(t,!1);const n=/^\s*([+\-]?\d*\.?\d+(?:[eE][+\-]?\d+)?)\s*/,r=[];let s;for(;s=n.exec(i);)r.push(parseFloat(s[1])),i=i.substr(s[0].length);if(""!==i)return;const o=e[0].srsName;let a="enu";if(o){a=nn(o).getAxisOrientation()}if("neu"===a){let t,e;for(t=0,e=r.length;t<e;t+=3){const e=r[t],i=r[t+1];r[t]=i,r[t+1]=e}}const l=r.length;return 2==l&&r.push(0),0!==l?r:void 0}readFlatPosList(t,e){const i=cd(t,!1).replace(/^\s*|\s*$/g,""),n=e[0],r=n.srsName,s=n.srsDimension;let o="enu";if(r){o=nn(r).getAxisOrientation()}const a=i.split(/\s+/);let l,h,c,u=2;t.getAttribute("srsDimension")?u=Cx(t.getAttribute("srsDimension")):t.getAttribute("dimension")?u=Cx(t.getAttribute("dimension")):t.parentNode.getAttribute("srsDimension")?u=Cx(t.parentNode.getAttribute("srsDimension")):s&&(u=Cx(s));const d=[];for(let t=0,e=a.length;t<e;t+=u)l=parseFloat(a[t]),h=parseFloat(a[t+1]),c=3===u?parseFloat(a[t+2]):0,"en"===o.substr(0,2)?d.push(l,h,c):d.push(h,l,c);return d}writePos_(t,e,i){const n=i[i.length-1],r=n.hasZ,s=r?"3":"2";t.setAttribute("srsDimension",s);const o=n.srsName;let a="enu";o&&(a=nn(o).getAxisOrientation());const l=e.getCoordinates();let h;if(h="en"===a.substr(0,2)?l[0]+" "+l[1]:l[1]+" "+l[0],r){h+=" "+(l[2]||0)}Mx(t,h)}getCoords_(t,e,i){let n="enu";e&&(n=nn(e).getAxisOrientation());let r="en"===n.substr(0,2)?t[0]+" "+t[1]:t[1]+" "+t[0];if(i){r+=" "+(t[2]||0)}return r}writePosList_(t,e,i){const n=i[i.length-1],r=n.hasZ,s=r?"3":"2";t.setAttribute("srsDimension",s);const o=n.srsName,a=e.getCoordinates(),l=a.length,h=new Array(l);let c;for(let t=0;t<l;++t)c=a[t],h[t]=this.getCoords_(c,o,r);Mx(t,h.join(" "))}writePoint(t,e,i){const n=i[i.length-1].srsName;n&&t.setAttribute("srsName",n);const r=hd(t.namespaceURI,"pos");t.appendChild(r),this.writePos_(r,e,i)}writeEnvelope(t,e,i){const n=i[i.length-1].srsName;n&&t.setAttribute("srsName",n);const r=[e[0]+" "+e[1],e[2]+" "+e[3]];Id({node:t},this.ENVELOPE_SERIALIZERS,Ed,r,i,["lowerCorner","upperCorner"],this)}writeLinearRing(t,e,i){const n=i[i.length-1].srsName;n&&t.setAttribute("srsName",n);const r=hd(t.namespaceURI,"posList");t.appendChild(r),this.writePosList_(r,e,i)}RING_NODE_FACTORY_(t,e,i){const n=e[e.length-1],r=n.node,s=n.exteriorWritten;return void 0===s&&(n.exteriorWritten=!0),hd(r.namespaceURI,void 0!==s?"interior":"exterior")}writeSurfaceOrPolygon(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName;if("PolygonPatch"!==t.nodeName&&s&&t.setAttribute("srsName",s),"Polygon"===t.nodeName||"PolygonPatch"===t.nodeName){const n=e.getLinearRings();Id({node:t,hasZ:r,srsName:s},this.RING_SERIALIZERS,this.RING_NODE_FACTORY_,n,i,void 0,this)}else if("Surface"===t.nodeName){const n=hd(t.namespaceURI,"patches");t.appendChild(n),this.writeSurfacePatches_(n,e,i)}}writeCurveOrLineString(t,e,i){const n=i[i.length-1].srsName;if("LineStringSegment"!==t.nodeName&&n&&t.setAttribute("srsName",n),"LineString"===t.nodeName||"LineStringSegment"===t.nodeName){const n=hd(t.namespaceURI,"posList");t.appendChild(n),this.writePosList_(n,e,i)}else if("Curve"===t.nodeName){const n=hd(t.namespaceURI,"segments");t.appendChild(n),this.writeCurveSegments_(n,e,i)}}writeMultiSurfaceOrPolygon(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName,o=n.surface;s&&t.setAttribute("srsName",s);const a=e.getPolygons();Id({node:t,hasZ:r,srsName:s,surface:o},this.SURFACEORPOLYGONMEMBER_SERIALIZERS,this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_,a,i,void 0,this)}writeMultiPoint(t,e,i){const n=i[i.length-1],r=n.srsName,s=n.hasZ;r&&t.setAttribute("srsName",r);const o=e.getPoints();Id({node:t,hasZ:s,srsName:r},this.POINTMEMBER_SERIALIZERS,wd("pointMember"),o,i,void 0,this)}writeMultiCurveOrLineString(t,e,i){const n=i[i.length-1],r=n.hasZ,s=n.srsName,o=n.curve;s&&t.setAttribute("srsName",s);const a=e.getLineStrings();Id({node:t,hasZ:r,srsName:s,curve:o},this.LINESTRINGORCURVEMEMBER_SERIALIZERS,this.MULTIGEOMETRY_MEMBER_NODE_FACTORY_,a,i,void 0,this)}writeRing(t,e,i){const n=hd(t.namespaceURI,"LinearRing");t.appendChild(n),this.writeLinearRing(n,e,i)}writeSurfaceOrPolygonMember(t,e,i){const n=this.GEOMETRY_NODE_FACTORY_(e,i);n&&(t.appendChild(n),this.writeSurfaceOrPolygon(n,e,i))}writePointMember(t,e,i){const n=hd(t.namespaceURI,"Point");t.appendChild(n),this.writePoint(n,e,i)}writeLineStringOrCurveMember(t,e,i){const n=this.GEOMETRY_NODE_FACTORY_(e,i);n&&(t.appendChild(n),this.writeCurveOrLineString(n,e,i))}writeSurfacePatches_(t,e,i){const n=hd(t.namespaceURI,"PolygonPatch");t.appendChild(n),this.writeSurfaceOrPolygon(n,e,i)}writeCurveSegments_(t,e,i){const n=hd(t.namespaceURI,"LineStringSegment");t.appendChild(n),this.writeCurveOrLineString(n,e,i)}writeGeometryElement(t,e,i){const n=i[i.length-1],r=Object.assign({},n);let s;r.node=t,s=Array.isArray(e)?x_(e,n):y_(e,!0,n),Id(r,this.GEOMETRY_SERIALIZERS,this.GEOMETRY_NODE_FACTORY_,[s],i,void 0,this)}writeFeatureElement(t,e,i){const n=e.getId();n&&t.setAttribute("fid",n);const r=i[i.length-1],s=r.featureNS,o=e.getGeometryName();r.serializers||(r.serializers={},r.serializers[s]={});const a=[],l=[];if(e.hasProperties()){const t=e.getProperties();for(const e in t){const i=t[e];null!==i&&(a.push(e),l.push(i),e==o||"function"==typeof i.getSimplifiedGeometry?e in r.serializers[s]||(r.serializers[s][e]=vd(this.writeGeometryElement,this)):e in r.serializers[s]||(r.serializers[s][e]=vd(Mx)))}}const h=Object.assign({},r);h.node=t,Id(h,r.serializers,wd(void 0,s),l,i,a)}writeFeatureMembers_(t,e,i){const n=i[i.length-1],r=n.featureType,s=n.featureNS,o={};o[s]={},o[s][r]=vd(this.writeFeatureElement,this);const a=Object.assign({},n);a.node=t,Id(a,o,wd(r,s),e,i)}MULTIGEOMETRY_MEMBER_NODE_FACTORY_(t,e,i){const n=e[e.length-1].node;return hd(this.namespace,Gx[n.nodeName])}GEOMETRY_NODE_FACTORY_(t,e,i){const n=e[e.length-1],r=n.multiSurface,s=n.surface,o=n.curve,a=n.multiCurve;return Array.isArray(t)?i="Envelope":"MultiPolygon"===(i=t.getType())&&!0===r?i="MultiSurface":"Polygon"===i&&!0===s?i="Surface":"LineString"===i&&!0===o?i="Curve":"MultiLineString"===i&&!0===a&&(i="MultiCurve"),hd(this.namespace,i)}writeGeometryNode(t,e){e=this.adaptOptions(e);const i=hd(this.namespace,"geom"),n={node:i,hasZ:this.hasZ,srsName:this.srsName,curve:this.curve_,surface:this.surface_,multiSurface:this.multiSurface_,multiCurve:this.multiCurve_};return e&&Object.assign(n,e),this.writeGeometryElement(i,t,[n]),i}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=hd(this.namespace,"featureMembers");i.setAttributeNS(ld,"xsi:schemaLocation",this.schemaLocation);const n={srsName:this.srsName,hasZ:this.hasZ,curve:this.curve_,surface:this.surface_,multiSurface:this.multiSurface_,multiCurve:this.multiCurve_,featureNS:this.featureNS,featureType:this.featureType};return e&&Object.assign(n,e),this.writeFeatureMembers_(i,t,[n]),i}}jx.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS={"http://www.opengis.net/gml":{pos:_d(jx.prototype.readFlatPos),posList:_d(jx.prototype.readFlatPosList),coordinates:_d(Dx.prototype.readFlatCoordinates)}},jx.prototype.FLAT_LINEAR_RINGS_PARSERS={"http://www.opengis.net/gml":{interior:jx.prototype.interiorParser,exterior:jx.prototype.exteriorParser}},jx.prototype.GEOMETRY_PARSERS={"http://www.opengis.net/gml":{Point:_d(yx.prototype.readPoint),MultiPoint:_d(yx.prototype.readMultiPoint),LineString:_d(yx.prototype.readLineString),MultiLineString:_d(yx.prototype.readMultiLineString),LinearRing:_d(yx.prototype.readLinearRing),Polygon:_d(yx.prototype.readPolygon),MultiPolygon:_d(yx.prototype.readMultiPolygon),Surface:_d(jx.prototype.readSurface),MultiSurface:_d(jx.prototype.readMultiSurface),Curve:_d(jx.prototype.readCurve),MultiCurve:_d(jx.prototype.readMultiCurve),Envelope:_d(jx.prototype.readEnvelope)}},jx.prototype.MULTICURVE_PARSERS={"http://www.opengis.net/gml":{curveMember:md(jx.prototype.curveMemberParser),curveMembers:md(jx.prototype.curveMemberParser)}},jx.prototype.MULTISURFACE_PARSERS={"http://www.opengis.net/gml":{surfaceMember:md(jx.prototype.surfaceMemberParser),surfaceMembers:md(jx.prototype.surfaceMemberParser)}},jx.prototype.CURVEMEMBER_PARSERS={"http://www.opengis.net/gml":{LineString:md(yx.prototype.readLineString),Curve:md(jx.prototype.readCurve)}},jx.prototype.SURFACEMEMBER_PARSERS={"http://www.opengis.net/gml":{Polygon:md(yx.prototype.readPolygon),Surface:md(jx.prototype.readSurface)}},jx.prototype.SURFACE_PARSERS={"http://www.opengis.net/gml":{patches:_d(jx.prototype.readPatch)}},jx.prototype.CURVE_PARSERS={"http://www.opengis.net/gml":{segments:_d(jx.prototype.readSegment)}},jx.prototype.ENVELOPE_PARSERS={"http://www.opengis.net/gml":{lowerCorner:md(jx.prototype.readFlatPosList),upperCorner:md(jx.prototype.readFlatPosList)}},jx.prototype.PATCHES_PARSERS={"http://www.opengis.net/gml":{PolygonPatch:_d(jx.prototype.readPolygonPatch)}},jx.prototype.SEGMENTS_PARSERS={"http://www.opengis.net/gml":{LineStringSegment:pd(jx.prototype.readLineStringSegment)}},yx.prototype.RING_PARSERS={"http://www.opengis.net/gml":{LinearRing:_d(yx.prototype.readFlatLinearRing),Ring:_d(jx.prototype.readFlatCurveRing)}},jx.prototype.writeFeatures,jx.prototype.RING_SERIALIZERS={"http://www.opengis.net/gml":{exterior:vd(jx.prototype.writeRing),interior:vd(jx.prototype.writeRing)}},jx.prototype.ENVELOPE_SERIALIZERS={"http://www.opengis.net/gml":{lowerCorner:vd(Mx),upperCorner:vd(Mx)}},jx.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS={"http://www.opengis.net/gml":{surfaceMember:vd(jx.prototype.writeSurfaceOrPolygonMember),polygonMember:vd(jx.prototype.writeSurfaceOrPolygonMember)}},jx.prototype.POINTMEMBER_SERIALIZERS={"http://www.opengis.net/gml":{pointMember:vd(jx.prototype.writePointMember)}},jx.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS={"http://www.opengis.net/gml":{lineStringMember:vd(jx.prototype.writeLineStringOrCurveMember),curveMember:vd(jx.prototype.writeLineStringOrCurveMember)}},jx.prototype.GEOMETRY_SERIALIZERS={"http://www.opengis.net/gml":{Curve:vd(jx.prototype.writeCurveOrLineString),MultiCurve:vd(jx.prototype.writeMultiCurveOrLineString),Point:vd(jx.prototype.writePoint),MultiPoint:vd(jx.prototype.writeMultiPoint),LineString:vd(jx.prototype.writeCurveOrLineString),MultiLineString:vd(jx.prototype.writeMultiCurveOrLineString),LinearRing:vd(jx.prototype.writeLinearRing),Polygon:vd(jx.prototype.writeSurfaceOrPolygon),MultiPolygon:vd(jx.prototype.writeMultiSurfaceOrPolygon),Surface:vd(jx.prototype.writeSurfaceOrPolygon),MultiSurface:vd(jx.prototype.writeMultiSurfaceOrPolygon),Envelope:vd(jx.prototype.writeEnvelope)}};var Bx=jx;const Ux=Bx;Ux.prototype.writeFeatures,Ux.prototype.writeFeaturesNode;var zx=Ux;class Xx extends Bx{constructor(t){super(t=t||{}),this.schemaLocation=t.schemaLocation?t.schemaLocation:this.namespace+" http://schemas.opengis.net/gml/3.2.1/gml.xsd"}writeGeometryElement(t,e,i){const n=i[i.length-1];i[i.length-1]=Object.assign({multiCurve:!0,multiSurface:!0},n),super.writeGeometryElement(t,e,i)}}Xx.prototype.namespace="http://www.opengis.net/gml/3.2",Xx.prototype.GEOMETRY_FLAT_COORDINATES_PARSERS={"http://www.opengis.net/gml/3.2":{pos:_d(Bx.prototype.readFlatPos),posList:_d(Bx.prototype.readFlatPosList),coordinates:_d(Dx.prototype.readFlatCoordinates)}},Xx.prototype.FLAT_LINEAR_RINGS_PARSERS={"http://www.opengis.net/gml/3.2":{interior:Bx.prototype.interiorParser,exterior:Bx.prototype.exteriorParser}},Xx.prototype.GEOMETRY_PARSERS={"http://www.opengis.net/gml/3.2":{Point:_d(yx.prototype.readPoint),MultiPoint:_d(yx.prototype.readMultiPoint),LineString:_d(yx.prototype.readLineString),MultiLineString:_d(yx.prototype.readMultiLineString),LinearRing:_d(yx.prototype.readLinearRing),Polygon:_d(yx.prototype.readPolygon),MultiPolygon:_d(yx.prototype.readMultiPolygon),Surface:_d(Xx.prototype.readSurface),MultiSurface:_d(Bx.prototype.readMultiSurface),Curve:_d(Xx.prototype.readCurve),MultiCurve:_d(Bx.prototype.readMultiCurve),Envelope:_d(Xx.prototype.readEnvelope)}},Xx.prototype.MULTICURVE_PARSERS={"http://www.opengis.net/gml/3.2":{curveMember:md(Bx.prototype.curveMemberParser),curveMembers:md(Bx.prototype.curveMemberParser)}},Xx.prototype.MULTISURFACE_PARSERS={"http://www.opengis.net/gml/3.2":{surfaceMember:md(Bx.prototype.surfaceMemberParser),surfaceMembers:md(Bx.prototype.surfaceMemberParser)}},Xx.prototype.CURVEMEMBER_PARSERS={"http://www.opengis.net/gml/3.2":{LineString:md(yx.prototype.readLineString),Curve:md(Bx.prototype.readCurve)}},Xx.prototype.SURFACEMEMBER_PARSERS={"http://www.opengis.net/gml/3.2":{Polygon:md(yx.prototype.readPolygon),Surface:md(Bx.prototype.readSurface)}},Xx.prototype.SURFACE_PARSERS={"http://www.opengis.net/gml/3.2":{patches:_d(Bx.prototype.readPatch)}},Xx.prototype.CURVE_PARSERS={"http://www.opengis.net/gml/3.2":{segments:_d(Bx.prototype.readSegment)}},Xx.prototype.ENVELOPE_PARSERS={"http://www.opengis.net/gml/3.2":{lowerCorner:md(Bx.prototype.readFlatPosList),upperCorner:md(Bx.prototype.readFlatPosList)}},Xx.prototype.PATCHES_PARSERS={"http://www.opengis.net/gml/3.2":{PolygonPatch:_d(Bx.prototype.readPolygonPatch)}},Xx.prototype.SEGMENTS_PARSERS={"http://www.opengis.net/gml/3.2":{LineStringSegment:pd(Bx.prototype.readLineStringSegment)}},Xx.prototype.MULTIPOINT_PARSERS={"http://www.opengis.net/gml/3.2":{pointMember:md(yx.prototype.pointMemberParser),pointMembers:md(yx.prototype.pointMemberParser)}},Xx.prototype.MULTILINESTRING_PARSERS={"http://www.opengis.net/gml/3.2":{lineStringMember:md(yx.prototype.lineStringMemberParser),lineStringMembers:md(yx.prototype.lineStringMemberParser)}},Xx.prototype.MULTIPOLYGON_PARSERS={"http://www.opengis.net/gml/3.2":{polygonMember:md(yx.prototype.polygonMemberParser),polygonMembers:md(yx.prototype.polygonMemberParser)}},Xx.prototype.POINTMEMBER_PARSERS={"http://www.opengis.net/gml/3.2":{Point:md(yx.prototype.readFlatCoordinatesFromNode)}},Xx.prototype.LINESTRINGMEMBER_PARSERS={"http://www.opengis.net/gml/3.2":{LineString:md(yx.prototype.readLineString)}},Xx.prototype.POLYGONMEMBER_PARSERS={"http://www.opengis.net/gml/3.2":{Polygon:md(yx.prototype.readPolygon)}},Xx.prototype.RING_PARSERS={"http://www.opengis.net/gml/3.2":{LinearRing:_d(yx.prototype.readFlatLinearRing),Ring:_d(Xx.prototype.readFlatCurveRing)}},Xx.prototype.RING_SERIALIZERS={"http://www.opengis.net/gml/3.2":{exterior:vd(Bx.prototype.writeRing),interior:vd(Bx.prototype.writeRing)}},Xx.prototype.ENVELOPE_SERIALIZERS={"http://www.opengis.net/gml/3.2":{lowerCorner:vd(Mx),upperCorner:vd(Mx)}},Xx.prototype.SURFACEORPOLYGONMEMBER_SERIALIZERS={"http://www.opengis.net/gml/3.2":{surfaceMember:vd(Bx.prototype.writeSurfaceOrPolygonMember),polygonMember:vd(Bx.prototype.writeSurfaceOrPolygonMember)}},Xx.prototype.POINTMEMBER_SERIALIZERS={"http://www.opengis.net/gml/3.2":{pointMember:vd(Bx.prototype.writePointMember)}},Xx.prototype.LINESTRINGORCURVEMEMBER_SERIALIZERS={"http://www.opengis.net/gml/3.2":{lineStringMember:vd(Bx.prototype.writeLineStringOrCurveMember),curveMember:vd(Bx.prototype.writeLineStringOrCurveMember)}},Xx.prototype.GEOMETRY_SERIALIZERS={"http://www.opengis.net/gml/3.2":{Curve:vd(Bx.prototype.writeCurveOrLineString),MultiCurve:vd(Bx.prototype.writeMultiCurveOrLineString),Point:vd(Xx.prototype.writePoint),MultiPoint:vd(Bx.prototype.writeMultiPoint),LineString:vd(Bx.prototype.writeCurveOrLineString),MultiLineString:vd(Bx.prototype.writeMultiCurveOrLineString),LinearRing:vd(Bx.prototype.writeLinearRing),Polygon:vd(Bx.prototype.writeSurfaceOrPolygon),MultiPolygon:vd(Bx.prototype.writeMultiSurfaceOrPolygon),Surface:vd(Bx.prototype.writeSurfaceOrPolygon),MultiSurface:vd(Bx.prototype.writeMultiSurfaceOrPolygon),Envelope:vd(Bx.prototype.writeEnvelope)}};var Vx=Xx;const Wx=[null,"http://www.topografix.com/GPX/1/0","http://www.topografix.com/GPX/1/1"],Zx={rte:xv,trk:vv,wpt:Sv},Yx=Cd(Wx,{rte:md(xv),trk:md(vv),wpt:md(Sv)}),Kx=Cd(Wx,{text:xd(Rx,"linkText"),type:xd(Rx,"linkType")}),Hx=Cd(Wx,{rte:vd((function(t,e,i){const n=i[0],r=e.getProperties(),s={node:t};s.properties=r;const o=e.getGeometry();if("LineString"==o.getType()){const t=y_(o,!0,n);s.geometryLayout=t.getLayout(),r.rtept=t.getCoordinates()}const a=i[i.length-1].node,l=rv[a.namespaceURI],h=Td(r,l);Id(s,sv,Ed,h,i,l)})),trk:vd((function(t,e,i){const n=i[0],r=e.getProperties(),s={node:t};s.properties=r;const o=e.getGeometry();if("MultiLineString"==o.getType()){const t=y_(o,!0,n);r.trkseg=t.getLineStrings()}const a=i[i.length-1].node,l=av[a.namespaceURI],h=Td(r,l);Id(s,lv,Ed,h,i,l)})),wpt:vd((function(t,e,i){const n=i[0],r=i[i.length-1];r.properties=e.getProperties();const s=e.getGeometry();if("Point"==s.getType()){const e=y_(s,!0,n);r.geometryLayout=e.getLayout(),Ev(t,e.getCoordinates(),i)}}))});const qx=Cd(Wx,{name:xd(Rx),cmt:xd(Rx),desc:xd(Rx),src:xd(Rx),link:_v,number:xd(Tx),extensions:yv,type:xd(Rx),rtept:function(t,e){const i=bd({},$x,t,e);if(i){const n=e[e.length-1];pv(n.flatCoordinates,n.layoutOptions,t,i)}}}),$x=Cd(Wx,{ele:xd(wx),time:xd(Sx)}),Jx=Cd(Wx,{name:xd(Rx),cmt:xd(Rx),desc:xd(Rx),src:xd(Rx),link:_v,number:xd(Tx),type:xd(Rx),extensions:yv,trkseg:function(t,e){const i=e[e.length-1];Rd(Qx,t,e);const n=i.flatCoordinates;i.ends.push(n.length)}}),Qx=Cd(Wx,{trkpt:function(t,e){const i=bd({},tv,t,e);if(i){const n=e[e.length-1];pv(n.flatCoordinates,n.layoutOptions,t,i)}}}),tv=Cd(Wx,{ele:xd(wx),time:xd(Sx)}),ev=Cd(Wx,{ele:xd(wx),time:xd(Sx),magvar:xd(wx),geoidheight:xd(wx),name:xd(Rx),cmt:xd(Rx),desc:xd(Rx),src:xd(Rx),link:_v,sym:xd(Rx),type:xd(Rx),fix:xd(Rx),sat:xd(Tx),hdop:xd(wx),vdop:xd(wx),pdop:xd(wx),ageofdgpsdata:xd(wx),dgpsid:xd(Tx),extensions:yv}),iv=["text","type"],nv=Cd(Wx,{text:vd(Mx),type:vd(Mx)}),rv=Cd(Wx,["name","cmt","desc","src","link","number","type","rtept"]),sv=Cd(Wx,{name:vd(Mx),cmt:vd(Mx),desc:vd(Mx),src:vd(Mx),link:vd(wv),number:vd(Lx),type:vd(Mx),rtept:Sd(vd(Ev))}),ov=Cd(Wx,["ele","time"]),av=Cd(Wx,["name","cmt","desc","src","link","number","type","trkseg"]),lv=Cd(Wx,{name:vd(Mx),cmt:vd(Mx),desc:vd(Mx),src:vd(Mx),link:vd(wv),number:vd(Lx),type:vd(Mx),trkseg:Sd(vd((function(t,e,i){const n={node:t};n.geometryLayout=e.getLayout(),n.properties={},Id(n,cv,hv,e.getCoordinates(),i)})))}),hv=wd("trkpt"),cv=Cd(Wx,{trkpt:vd(Ev)}),uv=Cd(Wx,["ele","time","magvar","geoidheight","name","cmt","desc","src","link","sym","type","fix","sat","hdop","vdop","pdop","ageofdgpsdata","dgpsid"]),dv=Cd(Wx,{ele:vd(Fx),time:vd(Ix),magvar:vd(Fx),geoidheight:vd(Fx),name:vd(Mx),cmt:vd(Mx),desc:vd(Mx),src:vd(Mx),link:vd(wv),sym:vd(Mx),type:vd(Mx),fix:vd(Mx),sat:vd(Lx),hdop:vd(Fx),vdop:vd(Fx),pdop:vd(Fx),ageofdgpsdata:vd(Fx),dgpsid:vd(Lx)}),gv={Point:"wpt",LineString:"rte",MultiLineString:"trk"};function fv(t,e,i){const n=t.getGeometry();if(n){const t=gv[n.getType()];if(t){return hd(e[e.length-1].node.namespaceURI,t)}}}function pv(t,e,i,n){return t.push(parseFloat(i.getAttribute("lon")),parseFloat(i.getAttribute("lat"))),"ele"in n?(t.push(n.ele),delete n.ele,e.hasZ=!0):t.push(0),"time"in n?(t.push(n.time),delete n.time,e.hasM=!0):t.push(0),t}function mv(t,e,i){let n="XY",r=2;if(t.hasZ&&t.hasM?(n="XYZM",r=4):t.hasZ?(n="XYZ",r=3):t.hasM&&(n="XYM",r=3),4!==r){for(let i=0,n=e.length/4;i<n;i++)e[i*r]=e[4*i],e[i*r+1]=e[4*i+1],t.hasZ&&(e[i*r+2]=e[4*i+2]),t.hasM&&(e[i*r+2]=e[4*i+3]);if(e.length=e.length/4*r,i)for(let t=0,e=i.length;t<e;t++)i[t]=i[t]/4*r}return n}function _v(t,e){const i=e[e.length-1],n=t.getAttribute("href");null!==n&&(i.link=n),Rd(Kx,t,e)}function yv(t,e){e[e.length-1].extensionsNode_=t}function xv(t,e){const i=e[0],n=bd({flatCoordinates:[],layoutOptions:{}},qx,t,e);if(!n)return;const r=n.flatCoordinates;delete n.flatCoordinates;const s=n.layoutOptions;delete n.layoutOptions;const o=mv(s,r),a=new Vm(r,o);y_(a,!1,i);const l=new Nt(a);return l.setProperties(n,!0),l}function vv(t,e){const i=e[0],n=bd({flatCoordinates:[],ends:[],layoutOptions:{}},Jx,t,e);if(!n)return;const r=n.flatCoordinates;delete n.flatCoordinates;const s=n.ends;delete n.ends;const o=n.layoutOptions;delete n.layoutOptions;const a=mv(o,r,s),l=new Zm(r,a,s);y_(l,!1,i);const h=new Nt(l);return h.setProperties(n,!0),h}function Sv(t,e){const i=e[0],n=bd({},ev,t,e);if(!n)return;const r={},s=pv([],r,t,n),o=mv(r,s),a=new lr(s,o);y_(a,!1,i);const l=new Nt(a);return l.setProperties(n,!0),l}function wv(t,e,i){t.setAttribute("href",e);const n=i[i.length-1].properties,r=[n.linkText,n.linkType];Id({node:t},nv,Ed,r,i,iv)}function Ev(t,e,i){const n=i[i.length-1],r=n.node.namespaceURI,s=n.properties;t.setAttributeNS(null,"lat",String(e[1])),t.setAttributeNS(null,"lon",String(e[0]));switch(n.geometryLayout){case"XYZM":0!==e[3]&&(s.time=e[3]);case"XYZ":0!==e[2]&&(s.ele=e[2]);break;case"XYM":0!==e[2]&&(s.time=e[2])}const o="rtept"==t.nodeName?ov[r]:uv[r],a=Td(s,o);Id({node:t,properties:s},dv,Ed,a,i,o)}var Tv=class extends fx{constructor(t){super(),t=t||{},this.dataProjection=nn("EPSG:4326"),this.readExtensions_=t.readExtensions}handleReadExtensions_(t){t||(t=[]);for(let e=0,i=t.length;e<i;++e){const i=t[e];if(this.readExtensions_){const t=i.get("extensionsNode_")||null;this.readExtensions_(i,t)}i.set("extensionsNode_",void 0)}}readFeatureFromNode(t,e){if(!Wx.includes(t.namespaceURI))return null;const i=Zx[t.localName];if(!i)return null;const n=i(t,[this.getReadOptions(t,e)]);return n?(this.handleReadExtensions_([n]),n):null}readFeaturesFromNode(t,e){if(!Wx.includes(t.namespaceURI))return[];if("gpx"==t.localName){const i=bd([],Yx,t,[this.getReadOptions(t,e)]);return i?(this.handleReadExtensions_(i),i):[]}return[]}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=hd("http://www.topografix.com/GPX/1/1","gpx");return i.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xsi",ld),i.setAttributeNS(ld,"xsi:schemaLocation","http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"),i.setAttribute("version","1.1"),i.setAttribute("creator","OpenLayers"),Id({node:i},Hx,fv,t,[e]),i}};function Cv(t,e){if(!t)return null;let i;switch(t.type){case"Point":i=function(t){return new lr(t.coordinates)}(t);break;case"LineString":i=function(t){return new Vm(t.coordinates)}(t);break;case"Polygon":i=function(t){return new Ir(t.coordinates)}(t);break;case"MultiPoint":i=function(t){return new Km(t.coordinates)}(t);break;case"MultiLineString":i=function(t){return new Zm(t.coordinates)}(t);break;case"MultiPolygon":i=function(t){return new $m(t.coordinates)}(t);break;case"GeometryCollection":i=function(t,e){const i=t.geometries.map((function(t){return Cv(t,e)}));return new jm(i)}(t);break;default:throw new Error("Unsupported GeoJSON type: "+t.type)}return y_(i,!1,e)}function Rv(t,e){const i=(t=y_(t,!0,e)).getType();let n;switch(i){case"Point":n=function(t,e){return{type:"Point",coordinates:t.getCoordinates()}}(t);break;case"LineString":n=function(t,e){return{type:"LineString",coordinates:t.getCoordinates()}}(t);break;case"Polygon":n=function(t,e){let i;e&&(i=e.rightHanded);return{type:"Polygon",coordinates:t.getCoordinates(i)}}(t,e);break;case"MultiPoint":n=function(t,e){return{type:"MultiPoint",coordinates:t.getCoordinates()}}(t);break;case"MultiLineString":n=function(t,e){return{type:"MultiLineString",coordinates:t.getCoordinates()}}(t);break;case"MultiPolygon":n=function(t,e){let i;e&&(i=e.rightHanded);return{type:"MultiPolygon",coordinates:t.getCoordinates(i)}}(t,e);break;case"GeometryCollection":n=function(t,e){e=Object.assign({},e),delete e.featureProjection;const i=t.getGeometriesArray().map((function(t){return Rv(t,e)}));return{type:"GeometryCollection",geometries:i}}(t,e);break;case"Circle":n={type:"GeometryCollection",geometries:[]};break;default:throw new Error("Unsupported geometry type: "+i)}return n}var bv=class extends ox{constructor(t){t=t||{},super(),this.dataProjection=nn(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=nn(t.featureProjection)),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;i="Feature"===t.type?t:{type:"Feature",geometry:t,properties:null};const n=Cv(i.geometry,e),r=new Nt;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&"geometry_name"in i!==void 0&&r.setGeometryName(i.geometry_name),r.setGeometry(n),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){let i=null;if("FeatureCollection"===t.type){i=[];const n=t.features;for(let t=0,r=n.length;t<r;++t)i.push(this.readFeatureFromObject(n[t],e))}else i=[this.readFeatureFromObject(t,e)];return i}readGeometryFromObject(t,e){return Cv(t,e)}readProjectionFromObject(t){const e=t.crs;let i;return e?"name"==e.type?i=nn(e.properties.name):"EPSG"===e.type?i=nn("EPSG:"+e.properties.code):Mt(!1,36):i=this.dataProjection,i}writeFeatureObject(t,e){e=this.adaptOptions(e);const i={type:"Feature",geometry:null,properties:null},n=t.getId();if(void 0!==n&&(i.id=n),!t.hasProperties())return i;const r=t.getProperties(),s=t.getGeometry();return s&&(i.geometry=Rv(s,e),delete r[t.getGeometryName()]),S(r)||(i.properties=r),i}writeFeaturesObject(t,e){e=this.adaptOptions(e);const i=[];for(let n=0,r=t.length;n<r;++n)i.push(this.writeFeatureObject(t[n],e));return{type:"FeatureCollection",features:i}}writeGeometryObject(t,e){return Rv(t,this.adaptOptions(e))}};function Pv(t){return"string"==typeof t?t:""}var Iv=class extends __{constructor(){super()}getType(){return"text"}readFeature(t,e){return this.readFeatureFromText(Pv(t),this.adaptOptions(e))}readFeatureFromText(t,e){return z()}readFeatures(t,e){return this.readFeaturesFromText(Pv(t),this.adaptOptions(e))}readFeaturesFromText(t,e){return z()}readGeometry(t,e){return this.readGeometryFromText(Pv(t),this.adaptOptions(e))}readGeometryFromText(t,e){return z()}readProjection(t){return this.readProjectionFromText(Pv(t))}readProjectionFromText(t){return this.dataProjection}writeFeature(t,e){return this.writeFeatureText(t,this.adaptOptions(e))}writeFeatureText(t,e){return z()}writeFeatures(t,e){return this.writeFeaturesText(t,this.adaptOptions(e))}writeFeaturesText(t,e){return z()}writeGeometry(t,e){return this.writeGeometryText(t,this.adaptOptions(e))}writeGeometryText(t,e){return z()}};const Fv=/^B(\d{2})(\d{2})(\d{2})(\d{2})(\d{5})([NS])(\d{3})(\d{5})([EW])([AV])(\d{5})(\d{5})/,Lv=/^H.([A-Z]{3}).*?:(.*)/,Mv=/^HFDTE(\d{2})(\d{2})(\d{2})/,Av=/\r\n|\r|\n/;var Ov=class extends Iv{constructor(t){super(),t=t||{},this.dataProjection=nn("EPSG:4326"),this.altitudeMode_=t.altitudeMode?t.altitudeMode:"none"}readFeatureFromText(t,e){const i=this.altitudeMode_,n=t.split(Av),r={},s=[];let o,a,l=2e3,h=0,c=1,u=-1;for(o=0,a=n.length;o<a;++o){const t=n[o];let e;if("B"==t.charAt(0)){if(e=Fv.exec(t),e){const t=parseInt(e[1],10),n=parseInt(e[2],10),r=parseInt(e[3],10);let o=parseInt(e[4],10)+parseInt(e[5],10)/6e4;"S"==e[6]&&(o=-o);let a=parseInt(e[7],10)+parseInt(e[8],10)/6e4;if("W"==e[9]&&(a=-a),s.push(a,o),"none"!=i){let t;t="gps"==i?parseInt(e[11],10):"barometric"==i?parseInt(e[12],10):0,s.push(t)}let d=Date.UTC(l,h,c,t,n,r);d<u&&(d=Date.UTC(l,h,c+1,t,n,r)),s.push(d/1e3),u=d}}else"H"==t.charAt(0)&&(e=Mv.exec(t),e?(c=parseInt(e[1],10),h=parseInt(e[2],10)-1,l=2e3+parseInt(e[3],10)):(e=Lv.exec(t),e&&(r[e[1]]=e[2].trim())))}if(0===s.length)return null;const d=new Vm(s,"none"==i?"XYM":"XYZM"),g=new Nt(y_(d,!1,e));return g.setProperties(r,!0),g}readFeaturesFromText(t,e){const i=this.readFeatureFromText(t,e);return i?[i]:[]}};const Nv=["http://www.google.com/kml/ext/2.2"],Dv=[null,"http://earth.google.com/kml/2.0","http://earth.google.com/kml/2.1","http://earth.google.com/kml/2.2","http://www.opengis.net/kml/2.2"],kv={fraction:"fraction",pixels:"pixels",insetPixels:"pixels"},Gv=Cd(Dv,{ExtendedData:US,Region:zS,MultiGeometry:xd(MS,"geometry"),LineString:xd(IS,"geometry"),LinearRing:xd(FS,"geometry"),Point:xd(AS,"geometry"),Polygon:xd(NS,"geometry"),Style:xd(kS),StyleMap:function(t,e){const i=pS.call(this,t,e);if(!i)return;const n=e[e.length-1];Array.isArray(i)?n.Style=i:"string"==typeof i?n.styleUrl=i:Mt(!1,38)},address:xd(Rx),description:xd(Rx),name:xd(Rx),open:xd(xx),phoneNumber:xd(Rx),styleUrl:xd(dS),visibility:xd(xx)},Cd(Nv,{MultiTrack:xd((function(t,e){const i=bd([],wS,t,e);if(!i)return;return new Zm(i)}),"geometry"),Track:xd(TS,"geometry")})),jv=Cd(Dv,{ExtendedData:US,Region:zS,Link:function(t,e){Rd(Bv,t,e)},address:xd(Rx),description:xd(Rx),name:xd(Rx),open:xd(xx),phoneNumber:xd(Rx),visibility:xd(xx)}),Bv=Cd(Dv,{href:xd(uS)}),Uv=Cd(Dv,{Altitude:xd(wx),Longitude:xd(wx),Latitude:xd(wx),Tilt:xd(wx),AltitudeMode:xd(Rx),Heading:xd(wx),Roll:xd(wx)}),zv=Cd(Dv,{LatLonAltBox:function(t,e){const i=bd({},WS,t,e);if(!i)return;const n=e[e.length-1],r=[parseFloat(i.west),parseFloat(i.south),parseFloat(i.east),parseFloat(i.north)];n.extent=r,n.altitudeMode=i.altitudeMode,n.minAltitude=parseFloat(i.minAltitude),n.maxAltitude=parseFloat(i.maxAltitude)},Lod:function(t,e){const i=bd({},ZS,t,e);if(!i)return;const n=e[e.length-1];n.minLodPixels=parseFloat(i.minLodPixels),n.maxLodPixels=parseFloat(i.maxLodPixels),n.minFadeExtent=parseFloat(i.minFadeExtent),n.maxFadeExtent=parseFloat(i.maxFadeExtent)}}),Xv=Cd(Dv,["Document","Placemark"]),Vv=Cd(Dv,{Document:vd((function(t,e,i){const n={node:t};Id(n,$S,JS,e,i,void 0,this)})),Placemark:vd(ww)});let Wv,Zv,Yv,Kv,Hv,qv,$v=null;let Jv,Qv=null;let tS,eS=null;let iS=null;let nS=null;let rS,sS=null;function oS(t){return 32/Math.min(t[0],t[1])}function aS(t){return t}function lS(t,e,i){return Array.isArray(t)?t:"string"==typeof t?lS(i[t],e,i):e}function hS(t){const e=cd(t,!1),i=/^\s*#?\s*([0-9A-Fa-f]{8})\s*$/.exec(e);if(i){const t=i[1];return[parseInt(t.substr(6,2),16),parseInt(t.substr(4,2),16),parseInt(t.substr(2,2),16),parseInt(t.substr(0,2),16)/255]}}function cS(t){let e=cd(t,!1);const i=[];e=e.replace(/\s*,\s*/g,",");const n=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?),([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|,|$)(?:([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)(?:\s+|$))?\s*/i;let r;for(;r=n.exec(e);){const t=parseFloat(r[1]),n=parseFloat(r[2]),s=r[3]?parseFloat(r[3]):0;i.push(t,n,s),e=e.substr(r[0].length)}if(""===e)return i}function uS(t){const e=cd(t,!1).trim();let i=t.baseURI;if(i&&"about:blank"!=i||(i=window.location.href),i){return new URL(e,i).href}return e}function dS(t){const e=cd(t,!1).trim().replace(/^(?!.*#)/,"#");let i=t.baseURI;if(i&&"about:blank"!=i||(i=window.location.href),i){return new URL(e,i).href}return e}function gS(t){return wx(t)}const fS=Cd(Dv,{Pair:function(t,e){const i=bd({},XS,t,e,this);if(!i)return;const n=i.key;if(n&&"normal"==n){const t=i.styleUrl;t&&(e[e.length-1]=t);const n=i.Style;n&&(e[e.length-1]=n)}}});function pS(t,e){return bd(void 0,fS,t,e,this)}const mS=Cd(Dv,{Icon:xd((function(t,e){const i=bd({},CS,t,e);if(i)return i;return null})),color:xd(hS),heading:xd(wx),hotSpot:xd((function(t){const e=t.getAttribute("xunits"),i=t.getAttribute("yunits");let n;return n="insetPixels"!==e?"insetPixels"!==i?"bottom-left":"top-left":"insetPixels"!==i?"bottom-right":"top-right",{x:parseFloat(t.getAttribute("x")),xunits:kv[e],y:parseFloat(t.getAttribute("y")),yunits:kv[i],origin:n}})),scale:xd(gS)});const _S=Cd(Dv,{color:xd(hS),scale:xd(gS)});const yS=Cd(Dv,{color:xd(hS),width:xd(wx)});const xS=Cd(Dv,{color:xd(hS),fill:xd(xx),outline:xd(xx)});const vS=Cd(Dv,{coordinates:_d(cS)});function SS(t,e){return bd(null,vS,t,e)}const wS=Cd(Nv,{Track:md(TS)});const ES=Cd(Dv,{when:function(t,e){const i=e[e.length-1].whens,n=cd(t,!1),r=Date.parse(n);i.push(isNaN(r)?0:r)}},Cd(Nv,{coord:function(t,e){const i=e[e.length-1].coordinates,n=cd(t,!1),r=/^\s*([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s+([+\-]?\d+(?:\.\d*)?(?:e[+\-]?\d*)?)\s*$/i.exec(n);if(r){const t=parseFloat(r[1]),e=parseFloat(r[2]),n=parseFloat(r[3]);i.push([t,e,n])}else i.push([])}}));function TS(t,e){const i=bd({coordinates:[],whens:[]},ES,t,e);if(!i)return;const n=[],r=i.coordinates,s=i.whens;for(let t=0,e=Math.min(r.length,s.length);t<e;++t)3==r[t].length&&n.push(r[t][0],r[t][1],r[t][2],s[t]);return new Vm(n,"XYZM")}const CS=Cd(Dv,{href:xd(uS)},Cd(Nv,{x:xd(wx),y:xd(wx),w:xd(wx),h:xd(wx)}));const RS=Cd(Dv,{coordinates:_d(cS)});function bS(t,e){return bd(null,RS,t,e)}const PS=Cd(Dv,{extrude:xd(xx),tessellate:xd(xx),altitudeMode:xd(Rx)});function IS(t,e){const i=bd({},PS,t,e),n=bS(t,e);if(n){const t=new Vm(n,"XYZ");return t.setProperties(i,!0),t}}function FS(t,e){const i=bd({},PS,t,e),n=bS(t,e);if(n){const t=new Ir(n,"XYZ",[n.length]);return t.setProperties(i,!0),t}}const LS=Cd(Dv,{LineString:md(IS),LinearRing:md(FS),MultiGeometry:md(MS),Point:md(AS),Polygon:md(NS)});function MS(t,e){const i=bd([],LS,t,e);if(!i)return null;if(0===i.length)return new jm(i);let n,r=!0;const s=i[0].getType();let o;for(let t=1,e=i.length;t<e;++t)if(o=i[t],o.getType()!=s){r=!1;break}if(r){let t,e;if("Point"==s){const r=i[0];t=r.getLayout(),e=r.getFlatCoordinates();for(let t=1,n=i.length;t<n;++t)o=i[t],d(e,o.getFlatCoordinates());n=new Km(e,t),GS(n,i)}else"LineString"==s?(n=new Zm(i),GS(n,i)):"Polygon"==s?(n=new $m(i),GS(n,i)):"GeometryCollection"==s?n=new jm(i):Mt(!1,37)}else n=new jm(i);return n}function AS(t,e){const i=bd({},PS,t,e),n=bS(t,e);if(n){const t=new lr(n,"XYZ");return t.setProperties(i,!0),t}}const OS=Cd(Dv,{innerBoundaryIs:function(t,e){const i=bd([],YS,t,e);if(i.length>0){e[e.length-1].push(...i)}},outerBoundaryIs:function(t,e){const i=bd(void 0,KS,t,e);if(i){e[e.length-1][0]=i}}});function NS(t,e){const i=bd({},PS,t,e),n=bd([null],OS,t,e);if(n&&n[0]){const t=n[0],e=[t.length];for(let i=1,r=n.length;i<r;++i)d(t,n[i]),e.push(t.length);const r=new Ir(t,"XYZ",e);return r.setProperties(i,!0),r}}const DS=Cd(Dv,{IconStyle:function(t,e){const i=bd({},mS,t,e);if(!i)return;const n=e[e.length-1],r="Icon"in i?i.Icon:{},s=!("Icon"in i)||Object.keys(r).length>0;let o;const a=r.href;let l,h,c;a?o=a:s&&(o=qv);let u="bottom-left";const d=i.hotSpot;let g;d?(l=[d.x,d.y],h=d.xunits,c=d.yunits,u=d.origin):/^https?:\/\/maps\.(?:google|gstatic)\.com\//.test(o)&&(o.includes("pushpin")?(l=Zv,h=Yv,c=Kv):o.includes("arrow-reverse")?(l=[54,42],h=Yv,c=Kv):o.includes("paddle")&&(l=[32,1],h=Yv,c=Kv));const f=r.x,p=r.y;let m;void 0!==f&&void 0!==p&&(g=[f,p]);const _=r.w,y=r.h;let x;void 0!==_&&void 0!==y&&(m=[_,y]);const v=i.heading;void 0!==v&&(x=yi(v));const S=i.scale,w=i.color;if(s){o==qv&&(m=Hv);const t=new of({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:g,offsetOrigin:"bottom-left",rotation:x,scale:S,size:m,src:this.iconUrlFunction_(o),color:w}),e=t.getScaleArray()[0],i=t.getSize();if(null===i){const i=t.getImageState();if(i===Kr||i===Hr){const n=function(){const i=t.getImageState();if(i!==Kr&&i!==Hr){const i=t.getSize();if(i&&2==i.length){const n=oS(i);t.setScale(e*n)}t.unlistenImageChange(n)}};t.listenImageChange(n),i===Kr&&t.load()}}else if(2==i.length){const n=oS(i);t.setScale(e*n)}n.imageStyle=t}else n.imageStyle=Jv},LabelStyle:function(t,e){const i=bd({},_S,t,e);if(!i)return;const n=e[e.length-1],r=new _f({fill:new Jg({color:"color"in i?i.color:Wv}),scale:i.scale});n.textStyle=r},LineStyle:function(t,e){const i=bd({},yS,t,e);if(!i)return;const n=e[e.length-1],r=new lf({color:"color"in i?i.color:Wv,width:"width"in i?i.width:1});n.strokeStyle=r},PolyStyle:function(t,e){const i=bd({},xS,t,e);if(!i)return;const n=e[e.length-1],r=new Jg({color:"color"in i?i.color:Wv});n.fillStyle=r;const s=i.fill;void 0!==s&&(n.fill=s);const o=i.outline;void 0!==o&&(n.outline=o)}});function kS(t,e){const i=bd({},DS,t,e,this);if(!i)return null;let n="fillStyle"in i?i.fillStyle:$v;const r=i.fill;let s;void 0===r||r||(n=null),"imageStyle"in i?i.imageStyle!=Jv&&(s=i.imageStyle):s=Qv;const o="textStyle"in i?i.textStyle:iS,a="strokeStyle"in i?i.strokeStyle:eS,l=i.outline;return void 0===l||l?[new pf({fill:n,image:s,stroke:a,text:o,zIndex:void 0})]:[new pf({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new jm(e.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Polygon"!==e&&"MultiPolygon"!==e})))}if("Polygon"!==i&&"MultiPolygon"!==i)return e},fill:n,image:s,stroke:a,text:o,zIndex:void 0}),new pf({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new jm(e.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Polygon"===e||"MultiPolygon"===e})))}if("Polygon"===i||"MultiPolygon"===i)return e},fill:n,stroke:null,zIndex:void 0})]}function GS(t,e){const i=e.length,n=new Array(e.length),r=new Array(e.length),s=new Array(e.length);let o,a,l;o=!1,a=!1,l=!1;for(let t=0;t<i;++t){const i=e[t];n[t]=i.get("extrude"),r[t]=i.get("tessellate"),s[t]=i.get("altitudeMode"),o=o||void 0!==n[t],a=a||void 0!==r[t],l=l||s[t]}o&&t.set("extrude",n),a&&t.set("tessellate",r),l&&t.set("altitudeMode",s)}const jS=Cd(Dv,{displayName:xd(Rx),value:xd(Rx)});const BS=Cd(Dv,{Data:function(t,e){const i=t.getAttribute("name");Rd(jS,t,e);const n=e[e.length-1];i&&n.displayName?n[i]={value:n.value,displayName:n.displayName,toString:function(){return n.value}}:null!==i?n[i]=n.value:null!==n.displayName&&(n[n.displayName]=n.value),delete n.value},SchemaData:function(t,e){Rd(VS,t,e)}});function US(t,e){Rd(BS,t,e)}function zS(t,e){Rd(zv,t,e)}const XS=Cd(Dv,{Style:xd(kS),key:xd(Rx),styleUrl:xd(dS)});const VS=Cd(Dv,{SimpleData:function(t,e){const i=t.getAttribute("name");if(null!==i){const n=Rx(t);e[e.length-1][i]=n}}});const WS=Cd(Dv,{altitudeMode:xd(Rx),minAltitude:xd(wx),maxAltitude:xd(wx),north:xd(wx),south:xd(wx),east:xd(wx),west:xd(wx)});const ZS=Cd(Dv,{minLodPixels:xd(wx),maxLodPixels:xd(wx),minFadeExtent:xd(wx),maxFadeExtent:xd(wx)});const YS=Cd(Dv,{LinearRing:md(SS)});const KS=Cd(Dv,{LinearRing:_d(SS)});function HS(t,e){const i=hs(e),n=[255*(4==i.length?i[3]:1),i[2],i[1],i[0]];for(let t=0;t<4;++t){const e=Math.floor(n[t]).toString(16);n[t]=1==e.length?"0"+e:e}Mx(t,n.join(""))}const qS=Cd(Dv,{Data:vd((function(t,e,i){t.setAttribute("name",e.name);const n={node:t},r=e.value;"object"==typeof r?(null!==r&&r.displayName&&Id(n,qS,Ed,[r.displayName],i,["displayName"]),null!==r&&r.value&&Id(n,qS,Ed,[r.value],i,["value"])):Id(n,qS,Ed,[r],i,["value"])})),value:vd((function(t,e){Mx(t,e)})),displayName:vd((function(t,e){Px(t,e)}))});const $S=Cd(Dv,{Placemark:vd(ww)}),JS=function(t,e,i){return hd(e[e.length-1].node.namespaceURI,"Placemark")};const QS=wd("Data");const tw=Cd(Dv,["href"],Cd(Nv,["x","y","w","h"])),ew=Cd(Dv,{href:vd(Mx)},Cd(Nv,{x:vd(Fx),y:vd(Fx),w:vd(Fx),h:vd(Fx)})),iw=function(t,e,i){return hd(Nv[0],"gx:"+i)};const nw=Cd(Dv,["scale","heading","Icon","color","hotSpot"]),rw=Cd(Dv,{Icon:vd((function(t,e,i){const n={node:t},r=i[i.length-1].node;let s=tw[r.namespaceURI],o=Td(e,s);Id(n,ew,Ed,o,i,s),s=tw[Nv[0]],o=Td(e,s),Id(n,ew,iw,o,i,s)})),color:vd(HS),heading:vd(Fx),hotSpot:vd((function(t,e){t.setAttribute("x",String(e.x)),t.setAttribute("y",String(e.y)),t.setAttribute("xunits",e.xunits),t.setAttribute("yunits",e.yunits)})),scale:vd(Mw)});const sw=Cd(Dv,["color","scale"]),ow=Cd(Dv,{color:vd(HS),scale:vd(Mw)});const aw=Cd(Dv,["color","width"]),lw=Cd(Dv,{color:vd(HS),width:vd(Fx)});const hw={Point:"Point",LineString:"LineString",LinearRing:"LinearRing",Polygon:"Polygon",MultiPoint:"MultiGeometry",MultiLineString:"MultiGeometry",MultiPolygon:"MultiGeometry",GeometryCollection:"MultiGeometry"},cw=function(t,e,i){if(t){return hd(e[e.length-1].node.namespaceURI,hw[t.getType()])}},uw=wd("Point"),dw=wd("LineString"),gw=wd("LinearRing"),fw=wd("Polygon"),pw=Cd(Dv,{LineString:vd(Cw),Point:vd(Cw),Polygon:vd(Fw),GeometryCollection:vd(mw)});function mw(t,e,i){const n={node:t},r=e.getType();let s,o=[];"GeometryCollection"===r?(e.getGeometriesArrayRecursive().forEach((function(t){const e=t.getType();"MultiPoint"===e?o=o.concat(t.getPoints()):"MultiLineString"===e?o=o.concat(t.getLineStrings()):"MultiPolygon"===e?o=o.concat(t.getPolygons()):"Point"===e||"LineString"===e||"Polygon"===e?o.push(t):Mt(!1,39)})),s=cw):"MultiPoint"===r?(o=e.getPoints(),s=uw):"MultiLineString"===r?(o=e.getLineStrings(),s=dw):"MultiPolygon"===r?(o=e.getPolygons(),s=fw):Mt(!1,39),Id(n,pw,s,o,i)}const _w=Cd(Dv,{LinearRing:vd(Cw)});function yw(t,e,i){Id({node:t},_w,gw,[e],i)}const xw=Cd(Dv,{ExtendedData:vd((function(t,e,i){const n={node:t},r=e.names,s=e.values,o=r.length;for(let t=0;t<o;t++)Id(n,qS,QS,[{name:r[t],value:s[t]}],i)})),MultiGeometry:vd(mw),LineString:vd(Cw),LinearRing:vd(Cw),Point:vd(Cw),Polygon:vd(Fw),Style:vd((function(t,e,i){const n={node:t},r={};if(e.pointStyles.length){const t=e.pointStyles[0].getText();t&&(r.LabelStyle=t);const i=e.pointStyles[0].getImage();i&&"function"==typeof i.getSrc&&(r.IconStyle=i)}if(e.lineStyles.length){const t=e.lineStyles[0].getStroke();t&&(r.LineStyle=t)}if(e.polyStyles.length){const t=e.polyStyles[0].getStroke();t&&!r.LineStyle&&(r.LineStyle=t),r.PolyStyle=e.polyStyles[0]}const s=i[i.length-1].node,o=Aw[s.namespaceURI],a=Td(r,o);Id(n,Ow,Ed,a,i,o)})),address:vd(Mx),description:vd(Mx),name:vd(Mx),open:vd(bx),phoneNumber:vd(Mx),styleUrl:vd(Mx),visibility:vd(bx)}),vw=Cd(Dv,["name","open","visibility","address","phoneNumber","description","styleUrl","Style"]),Sw=wd("ExtendedData");function ww(t,e,i){const n={node:t};e.getId()&&t.setAttribute("id",e.getId());const r=e.getProperties(),s={address:1,description:1,name:1,open:1,phoneNumber:1,styleUrl:1,visibility:1};s[e.getGeometryName()]=1;const o=Object.keys(r||{}).sort().filter((function(t){return!s[t]})),a=e.getStyleFunction();if(a){const t=a(e,0);if(t){const i=Array.isArray(t)?t:[t];let n=i;if(e.getGeometry()&&(n=i.filter((function(t){const i=t.getGeometryFunction()(e);if(i){const t=i.getType();return"GeometryCollection"===t?i.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Point"===e||"MultiPoint"===e})).length:"Point"===t||"MultiPoint"===t}}))),this.writeStyles_){let t=i,s=i;e.getGeometry()&&(t=i.filter((function(t){const i=t.getGeometryFunction()(e);if(i){const t=i.getType();return"GeometryCollection"===t?i.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"LineString"===e||"MultiLineString"===e})).length:"LineString"===t||"MultiLineString"===t}})),s=i.filter((function(t){const i=t.getGeometryFunction()(e);if(i){const t=i.getType();return"GeometryCollection"===t?i.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Polygon"===e||"MultiPolygon"===e})).length:"Polygon"===t||"MultiPolygon"===t}}))),r.Style={pointStyles:n,lineStyles:t,polyStyles:s}}if(n.length&&void 0===r.name){const t=n[0].getText();t&&(r.name=t.getText())}}}const l=i[i.length-1].node,h=vw[l.namespaceURI],c=Td(r,h);if(Id(n,xw,Ed,c,i,h),o.length>0){const t=Td(r,o);Id(n,xw,Sw,[{names:o,values:t}],i)}const u=i[0];let d=e.getGeometry();d&&(d=y_(d,!0,u)),Id(n,xw,cw,[d],i)}const Ew=Cd(Dv,["extrude","tessellate","altitudeMode","coordinates"]),Tw=Cd(Dv,{extrude:vd(bx),tessellate:vd(bx),altitudeMode:vd(Mx),coordinates:vd((function(t,e,i){const n=i[i.length-1],r=n.layout,s=n.stride;let o;"XY"==r||"XYM"==r?o=2:"XYZ"==r||"XYZM"==r?o=3:Mt(!1,34);const a=e.length;let l="";if(a>0){l+=e[0];for(let t=1;t<o;++t)l+=","+e[t];for(let t=s;t<a;t+=s){l+=" "+e[t];for(let i=1;i<o;++i)l+=","+e[t+i]}}Mx(t,l)}))});function Cw(t,e,i){const n=e.getFlatCoordinates(),r={node:t};r.layout=e.getLayout(),r.stride=e.getStride();const s=e.getProperties();s.coordinates=n;const o=i[i.length-1].node,a=Ew[o.namespaceURI],l=Td(s,a);Id(r,Tw,Ed,l,i,a)}const Rw=Cd(Dv,["color","fill","outline"]),bw=Cd(Dv,{outerBoundaryIs:vd(yw),innerBoundaryIs:vd(yw)}),Pw=wd("innerBoundaryIs"),Iw=wd("outerBoundaryIs");function Fw(t,e,i){const n=e.getLinearRings(),r=n.shift(),s={node:t};Id(s,bw,Pw,n,i),Id(s,bw,Iw,[r],i)}const Lw=Cd(Dv,{color:vd(HS),fill:vd(bx),outline:vd(bx)});function Mw(t,e){Fx(t,Math.round(1e6*e)/1e6)}const Aw=Cd(Dv,["IconStyle","LabelStyle","LineStyle","PolyStyle"]),Ow=Cd(Dv,{IconStyle:vd((function(t,e,i){const n={node:t},r={},s=e.getSrc(),o=e.getSize(),a=e.getImageSize(),l={href:s};if(o){l.w=o[0],l.h=o[1];const t=e.getAnchor(),i=e.getOrigin();if(i&&a&&0!==i[0]&&i[1]!==o[1]&&(l.x=i[0],l.y=a[1]-(i[1]+o[1])),t&&(t[0]!==o[0]/2||t[1]!==o[1]/2)){const e={x:t[0],xunits:"pixels",y:o[1]-t[1],yunits:"pixels"};r.hotSpot=e}}r.Icon=l;let h=e.getScaleArray()[0],c=o;if(null===c&&(c=Hv),2==c.length){h/=oS(c)}1!==h&&(r.scale=h);const u=e.getRotation();0!==u&&(r.heading=u);const d=e.getColor();d&&(r.color=d);const g=i[i.length-1].node,f=nw[g.namespaceURI],p=Td(r,f);Id(n,rw,Ed,p,i,f)})),LabelStyle:vd((function(t,e,i){const n={node:t},r={},s=e.getFill();s&&(r.color=s.getColor());const o=e.getScale();o&&1!==o&&(r.scale=o);const a=i[i.length-1].node,l=sw[a.namespaceURI],h=Td(r,l);Id(n,ow,Ed,h,i,l)})),LineStyle:vd((function(t,e,i){const n={node:t},r={color:e.getColor(),width:Number(e.getWidth())||1},s=i[i.length-1].node,o=aw[s.namespaceURI],a=Td(r,o);Id(n,lw,Ed,a,i,o)})),PolyStyle:vd((function(t,e,i){const n={node:t},r=e.getFill(),s=e.getStroke(),o={color:r?r.getColor():void 0,fill:!!r&&void 0,outline:!!s&&void 0},a=i[i.length-1].node,l=Rw[a.namespaceURI],h=Td(o,l);Id(n,Lw,Ed,h,i,l)}))});var Nw=class extends fx{constructor(t){super(),t=t||{},sS||(Wv=[255,255,255,1],$v=new Jg({color:Wv}),Zv=[20,2],Yv="pixels",Kv="pixels",Hv=[64,64],qv="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",Qv=new of({anchor:Zv,anchorOrigin:"bottom-left",anchorXUnits:Yv,anchorYUnits:Kv,crossOrigin:"anonymous",rotation:0,scale:oS(Hv),size:Hv,src:qv}),Jv="NO_IMAGE",eS=new lf({color:Wv,width:1}),tS=new lf({color:[51,51,51,1],width:2}),iS=new _f({font:"bold 16px Helvetica",fill:$v,stroke:tS,scale:.8}),nS=new pf({fill:$v,image:Qv,text:iS,stroke:eS,zIndex:0}),sS=[nS]),this.dataProjection=nn("EPSG:4326"),this.defaultStyle_=t.defaultStyle?t.defaultStyle:sS,this.extractStyles_=void 0===t.extractStyles||t.extractStyles,this.writeStyles_=void 0===t.writeStyles||t.writeStyles,this.sharedStyles_={},this.showPointNames_=void 0===t.showPointNames||t.showPointNames,this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:"anonymous",this.iconUrlFunction_=t.iconUrlFunction?t.iconUrlFunction:aS,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(t,e){const i=bd([],Cd(Dv,{Document:pd(this.readDocumentOrFolder_,this),Folder:pd(this.readDocumentOrFolder_,this),Placemark:md(this.readPlacemark_,this),Style:this.readSharedStyle_.bind(this),StyleMap:this.readSharedStyleMap_.bind(this)}),t,e,this);if(i)return i}readPlacemark_(t,e){const i=bd({geometry:null},Gv,t,e,this);if(!i)return;const n=new Nt,r=t.getAttribute("id");null!==r&&n.setId(r);const s=e[0],o=i.geometry;if(o&&y_(o,!1,s),n.setGeometry(o),delete i.geometry,this.extractStyles_){const t=function(t,e,i,n,r){return function(s,o){let a=r,l="",h=[];if(a){const t=s.getGeometry();if(t)if(t instanceof jm)h=t.getGeometriesArrayRecursive().filter((function(t){const e=t.getType();return"Point"===e||"MultiPoint"===e})),a=h.length>0;else{const e=t.getType();a="Point"===e||"MultiPoint"===e}}a&&(l=s.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(rS||(rS=document.createElement("textarea")),rS.innerHTML=l,l=rS.value));let c=i;if(t?c=t:e&&(c=lS(e,i,n)),a){const t=function(t,e){const i=[0,0];let n="start";const r=t.getImage();if(r){const t=r.getSize();if(t&&2==t.length){const e=r.getScaleArray(),s=r.getAnchor();i[0]=e[0]*(t[0]-s[0]),i[1]=e[1]*(t[1]/2-s[1]),n="left"}}let s=t.getText();s?(s=s.clone(),s.setFont(s.getFont()||iS.getFont()),s.setScale(s.getScale()||iS.getScale()),s.setFill(s.getFill()||iS.getFill()),s.setStroke(s.getStroke()||tS)):s=iS.clone();s.setText(e),s.setOffsetX(i[0]),s.setOffsetY(i[1]),s.setTextAlign(n);const o=new pf({image:r,text:s});return o}(c[0],l);if(h.length>0){t.setGeometry(new jm(h));return[t,new pf({geometry:c[0].getGeometry(),image:null,fill:c[0].getFill(),stroke:c[0].getStroke(),text:null})].concat(c.slice(1))}return t}return c}}(i.Style,i.styleUrl,this.defaultStyle_,this.sharedStyles_,this.showPointNames_);n.setStyle(t)}return delete i.Style,n.setProperties(i,!0),n}readSharedStyle_(t,e){const i=t.getAttribute("id");if(null!==i){const n=kS.call(this,t,e);if(n){let e,r=t.baseURI;if(r&&"about:blank"!=r||(r=window.location.href),r){e=new URL("#"+i,r).href}else e="#"+i;this.sharedStyles_[e]=n}}}readSharedStyleMap_(t,e){const i=t.getAttribute("id");if(null===i)return;const n=pS.call(this,t,e);if(!n)return;let r,s=t.baseURI;if(s&&"about:blank"!=s||(s=window.location.href),s){r=new URL("#"+i,s).href}else r="#"+i;this.sharedStyles_[r]=n}readFeatureFromNode(t,e){if(!Dv.includes(t.namespaceURI))return null;const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i||null}readFeaturesFromNode(t,e){if(!Dv.includes(t.namespaceURI))return[];let i;const n=t.localName;if("Document"==n||"Folder"==n)return i=this.readDocumentOrFolder_(t,[this.getReadOptions(t,e)]),i||[];if("Placemark"==n){const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i?[i]:[]}if("kml"==n){i=[];for(let n=t.firstElementChild;n;n=n.nextElementSibling){const t=this.readFeaturesFromNode(n,e);t&&d(i,t)}return i}return[]}readName(t){if(t){if("string"==typeof t){const e=fd(t);return this.readNameFromDocument(e)}return dd(t)?this.readNameFromDocument(t):this.readNameFromNode(t)}}readNameFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE){const t=this.readNameFromNode(e);if(t)return t}}readNameFromNode(t){for(let e=t.firstElementChild;e;e=e.nextElementSibling)if(Dv.includes(e.namespaceURI)&&"name"==e.localName)return Rx(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(Dv.includes(e.namespaceURI)&&("Document"==t||"Folder"==t||"Placemark"==t||"kml"==t)){const t=this.readNameFromNode(e);if(t)return t}}}readNetworkLinks(t){const e=[];if("string"==typeof t){const i=fd(t);d(e,this.readNetworkLinksFromDocument(i))}else dd(t)?d(e,this.readNetworkLinksFromDocument(t)):d(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&d(e,this.readNetworkLinksFromNode(i));return e}readNetworkLinksFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Dv.includes(i.namespaceURI)&&"NetworkLink"==i.localName){const t=bd({},jv,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Dv.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||d(e,this.readNetworkLinksFromNode(i))}return e}readRegion(t){const e=[];if("string"==typeof t){const i=fd(t);d(e,this.readRegionFromDocument(i))}else dd(t)?d(e,this.readRegionFromDocument(t)):d(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&d(e,this.readRegionFromNode(i));return e}readRegionFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Dv.includes(i.namespaceURI)&&"Region"==i.localName){const t=bd({},zv,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Dv.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||d(e,this.readRegionFromNode(i))}return e}readCamera(t){const e=[];if("string"==typeof t){const i=fd(t);d(e,this.readCameraFromDocument(i))}else dd(t)?d(e,this.readCameraFromDocument(t)):d(e,this.readCameraFromNode(t));return e}readCameraFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&d(e,this.readCameraFromNode(i));return e}readCameraFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Dv.includes(i.namespaceURI)&&"Camera"===i.localName){const t=bd({},Uv,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Dv.includes(i.namespaceURI)||"Document"!==t&&"Folder"!==t&&"Placemark"!==t&&"kml"!==t||d(e,this.readCameraFromNode(i))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=hd(Dv[4],"kml"),n="http://www.w3.org/2000/xmlns/";i.setAttributeNS(n,"xmlns:gx",Nv[0]),i.setAttributeNS(n,"xmlns:xsi",ld),i.setAttributeNS(ld,"xsi:schemaLocation","http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd");const r={node:i},s={};t.length>1?s.Document=t:1==t.length&&(s.Placemark=t[0]);const o=Xv[i.namespaceURI],a=Td(s,o);return Id(r,Vv,Ed,a,[e],o,this),i}};const Dw=[null],kw=Cd(Dw,{nd:function(t,e){const i=e[e.length-1];i.ndrefs.push(t.getAttribute("ref")),t.hasAttribute("lon")&&t.hasAttribute("lat")&&(i.flatCoordinates.push(parseFloat(t.getAttribute("lon"))),i.flatCoordinates.push(parseFloat(t.getAttribute("lat"))))},tag:Bw}),Gw=Cd(Dw,{node:function(t,e){const i=e[0],n=e[e.length-1],r=t.getAttribute("id"),s=[parseFloat(t.getAttribute("lon")),parseFloat(t.getAttribute("lat"))];n.nodes[r]=s;const o=bd({tags:{}},jw,t,e);if(!S(o.tags)){const t=new lr(s);y_(t,!1,i);const e=new Nt(t);void 0!==r&&e.setId(r),e.setProperties(o.tags,!0),n.features.push(e)}},way:function(t,e){const i=bd({id:t.getAttribute("id"),ndrefs:[],flatCoordinates:[],tags:{}},kw,t,e);e[e.length-1].ways.push(i)}});const jw=Cd(Dw,{tag:Bw});function Bw(t,e){e[e.length-1].tags[t.getAttribute("k")]=t.getAttribute("v")}var Uw=class extends fx{constructor(){super(),this.dataProjection=nn("EPSG:4326")}readFeaturesFromNode(t,e){if(e=this.getReadOptions(t,e),"osm"==t.localName){const i=bd({nodes:{},ways:[],features:[]},Gw,t,[e]);for(let t=0;t<i.ways.length;t++){const n=i.ways[t],r=n.flatCoordinates;if(!r.length)for(let t=0,e=n.ndrefs.length;t<e;t++){d(r,i.nodes[n.ndrefs[t]])}let s;s=n.ndrefs[0]==n.ndrefs[n.ndrefs.length-1]?new Ir(r,"XY",[r.length]):new Vm(r,"XY"),y_(s,!1,e);const o=new Nt(s);void 0!==n.id&&o.setId(n.id),o.setProperties(n.tags,!0),i.features.push(o)}if(i.features)return i.features}return[]}};var zw=class{read(t){if(!t)return null;if("string"==typeof t){const e=fd(t);return this.readFromDocument(e)}return dd(t)?this.readFromDocument(t):this.readFromNode(t)}readFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE)return this.readFromNode(e);return null}readFromNode(t){}};const Xw="http://www.w3.org/1999/xlink";function Vw(t){return t.getAttributeNS(Xw,"href")}const Ww=[null,"http://www.opengis.net/ows/1.1"],Zw=Cd(Ww,{ServiceIdentification:xd((function(t,e){return bd({},rE,t,e)})),ServiceProvider:xd((function(t,e){return bd({},sE,t,e)})),OperationsMetadata:xd((function(t,e){return bd({},tE,t,e)}))});const Yw=Cd(Ww,{DeliveryPoint:xd(Rx),City:xd(Rx),AdministrativeArea:xd(Rx),PostalCode:xd(Rx),Country:xd(Rx),ElectronicMailAddress:xd(Rx)}),Kw=Cd(Ww,{Value:yd((function(t,e){return Rx(t)}))}),Hw=Cd(Ww,{AllowedValues:xd((function(t,e){return bd({},Kw,t,e)}))}),qw=Cd(Ww,{Phone:xd((function(t,e){return bd({},eE,t,e)})),Address:xd((function(t,e){return bd({},Yw,t,e)}))}),$w=Cd(Ww,{HTTP:xd((function(t,e){return bd({},Jw,t,e)}))}),Jw=Cd(Ww,{Get:yd((function(t,e){const i=Vw(t);if(!i)return;return bd({href:i},iE,t,e)})),Post:void 0}),Qw=Cd(Ww,{DCP:xd((function(t,e){return bd({},$w,t,e)}))}),tE=Cd(Ww,{Operation:function(t,e){const i=t.getAttribute("name"),n=bd({},Qw,t,e);if(!n)return;e[e.length-1][i]=n}}),eE=Cd(Ww,{Voice:xd(Rx),Facsimile:xd(Rx)}),iE=Cd(Ww,{Constraint:yd((function(t,e){const i=t.getAttribute("name");if(!i)return;return bd({name:i},Hw,t,e)}))}),nE=Cd(Ww,{IndividualName:xd(Rx),PositionName:xd(Rx),ContactInfo:xd((function(t,e){return bd({},qw,t,e)}))}),rE=Cd(Ww,{Abstract:xd(Rx),AccessConstraints:xd(Rx),Fees:xd(Rx),Title:xd(Rx),ServiceTypeVersion:xd(Rx),ServiceType:xd(Rx)}),sE=Cd(Ww,{ProviderName:xd(Rx),ProviderSite:xd(Vw),ServiceContact:xd((function(t,e){return bd({},nE,t,e)}))});var oE=class extends zw{constructor(){super()}readFromNode(t){const e=bd({},Zw,t,[]);return e||null}};function aE(t,e,i){let n;i=i||1e5;const r=new Array(e);for(n=0;n<e;++n)r[n]=0;for(let i=0,s=t.length;i<s;)for(n=0;n<e;++n,++i){const e=t[i],s=e-r[n];r[n]=e,t[i]=s}return hE(t,i)}function lE(t,e,i){let n;i=i||1e5;const r=new Array(e);for(n=0;n<e;++n)r[n]=0;const s=cE(t,i);for(let t=0,i=s.length;t<i;)for(n=0;n<e;++n,++t)r[n]+=s[t],s[t]=r[n];return s}function hE(t,e){e=e||1e5;for(let i=0,n=t.length;i<n;++i)t[i]=Math.round(t[i]*e);return uE(t)}function cE(t,e){e=e||1e5;const i=dE(t);for(let t=0,n=i.length;t<n;++t)i[t]/=e;return i}function uE(t){for(let e=0,i=t.length;e<i;++e){const i=t[e];t[e]=i<0?~(i<<1):i<<1}return gE(t)}function dE(t){const e=fE(t);for(let t=0,i=e.length;t<i;++t){const i=e[t];e[t]=1&i?~(i>>1):i>>1}return e}function gE(t){let e="";for(let i=0,n=t.length;i<n;++i)e+=pE(t[i]);return e}function fE(t){const e=[];let i=0,n=0;for(let r=0,s=t.length;r<s;++r){const s=t.charCodeAt(r)-63;i|=(31&s)<<n,s<32?(e.push(i),i=0,n=0):n+=5}return e}function pE(t){let e,i="";for(;t>=32;)e=63+(32|31&t),i+=String.fromCharCode(e),t>>=5;return e=t+63,i+=String.fromCharCode(e),i}var mE=class extends Iv{constructor(t){super(),t=t||{},this.dataProjection=nn("EPSG:4326"),this.factor_=t.factor?t.factor:1e5,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY"}readFeatureFromText(t,e){const i=this.readGeometryFromText(t,e);return new Nt(i)}readFeaturesFromText(t,e){return[this.readFeatureFromText(t,e)]}readGeometryFromText(t,e){const i=Mn(this.geometryLayout_),n=lE(t,i,this.factor_);rx(n,0,n.length,i,n);const r=Qn(n,0,n.length,i);return y_(new Vm(r,this.geometryLayout_),!1,this.adaptOptions(e))}writeFeatureText(t,e){const i=t.getGeometry();return i?this.writeGeometryText(i,e):(Mt(!1,40),"")}writeFeaturesText(t,e){return this.writeFeatureText(t[0],e)}writeGeometryText(t,e){const i=(t=y_(t,!0,this.adaptOptions(e))).getFlatCoordinates(),n=t.getStride();return rx(i,0,i.length,n,i),aE(i,n,this.factor_)}};const _E={Point:function(t,e,i){const n=t.coordinates;e&&i&&wE(n,e,i);return new lr(n)},LineString:function(t,e){const i=yE(t.arcs,e);return new Vm(i)},Polygon:function(t,e){const i=[];for(let n=0,r=t.arcs.length;n<r;++n)i[n]=yE(t.arcs[n],e);return new Ir(i)},MultiPoint:function(t,e,i){const n=t.coordinates;if(e&&i)for(let t=0,r=n.length;t<r;++t)wE(n[t],e,i);return new Km(n)},MultiLineString:function(t,e){const i=[];for(let n=0,r=t.arcs.length;n<r;++n)i[n]=yE(t.arcs[n],e);return new Zm(i)},MultiPolygon:function(t,e){const i=[];for(let n=0,r=t.arcs.length;n<r;++n){const r=t.arcs[n],s=[];for(let t=0,i=r.length;t<i;++t)s[t]=yE(r[t],e);i[n]=s}return new $m(i)}};function yE(t,e){const i=[];let n;for(let r=0,s=t.length;r<s;++r)if(n=t[r],r>0&&i.pop(),n>=0){const t=e[n];for(let e=0,n=t.length;e<n;++e)i.push(t[e].slice(0))}else{const t=e[~n];for(let e=t.length-1;e>=0;--e)i.push(t[e].slice(0))}return i}function xE(t,e,i,n,r,s,o){const a=t.geometries,l=[];for(let t=0,h=a.length;t<h;++t)l[t]=vE(a[t],e,i,n,r,s,o);return l}function vE(t,e,i,n,r,s,o){let a=null;const l=t.type;if(l){const r=_E[l];a="Point"===l||"MultiPoint"===l?r(t,i,n):r(t,e),a=y_(a,!1,o)}const h=new Nt({geometry:a});void 0!==t.id&&h.setId(t.id);let c=t.properties;return r&&(c||(c={}),c[r]=s),c&&h.setProperties(c,!0),h}function SE(t,e,i){let n=0,r=0;for(let s=0,o=t.length;s<o;++s){const o=t[s];n+=o[0],r+=o[1],o[0]=n,o[1]=r,wE(o,e,i)}}function wE(t,e,i){t[0]=t[0]*e[0]+i[0],t[1]=t[1]*e[1]+i[1]}var EE=class extends ox{constructor(t){super(),t=t||{},this.layerName_=t.layerName,this.layers_=t.layers?t.layers:null,this.dataProjection=nn(t.dataProjection?t.dataProjection:"EPSG:4326")}readFeaturesFromObject(t,e){if("Topology"==t.type){const i=t;let n,r=null,s=null;i.transform&&(n=i.transform,r=n.scale,s=n.translate);const o=i.arcs;n&&function(t,e,i){for(let n=0,r=t.length;n<r;++n)SE(t[n],e,i)}(o,r,s);const a=[],l=i.objects,h=this.layerName_;let c;for(const t in l)this.layers_&&!this.layers_.includes(t)||("GeometryCollection"===l[t].type?(c=l[t],a.push.apply(a,xE(c,o,r,s,h,t,e))):(c=l[t],a.push(vE(c,o,r,s,h,t,e))));return a}return[]}readProjectionFromObject(t){return this.dataProjection}};var TE=class{constructor(t){this.tagName_=t}getTagName(){return this.tagName_}};var CE=class extends TE{constructor(t,e){super(t),this.conditions=e,Mt(this.conditions.length>=2,57)}};var RE=class extends CE{constructor(t){super("And",Array.prototype.slice.call(arguments))}};var bE=class extends TE{constructor(t,e,i){if(super("BBOX"),this.geometryName=t,this.extent=e,4!==e.length)throw new Error("Expected an extent with four values ([minX, minY, maxX, maxY])");this.srsName=i}};var PE=class extends TE{constructor(t,e,i,n){super(t),this.geometryName=e||"the_geom",this.geometry=i,this.srsName=n}};var IE=class extends PE{constructor(t,e,i){super("Contains",t,e,i)}};var FE=class extends PE{constructor(t,e,i,n,r){super("DWithin",t,e,r),this.distance=i,this.unit=n}};var LE=class extends PE{constructor(t,e,i){super("Disjoint",t,e,i)}};var ME=class extends TE{constructor(t,e){super(t),this.propertyName=e}};var AE=class extends ME{constructor(t,e,i){super("During",t),this.begin=e,this.end=i}};var OE=class extends ME{constructor(t,e,i,n){super(t,e),this.expression=i,this.matchCase=n}};var NE=class extends OE{constructor(t,e,i){super("PropertyIsEqualTo",t,e,i)}};var DE=class extends OE{constructor(t,e){super("PropertyIsGreaterThan",t,e)}};var kE=class extends OE{constructor(t,e){super("PropertyIsGreaterThanOrEqualTo",t,e)}};var GE=class extends PE{constructor(t,e,i){super("Intersects",t,e,i)}};var jE=class extends ME{constructor(t,e,i){super("PropertyIsBetween",t),this.lowerBoundary=e,this.upperBoundary=i}};var BE=class extends ME{constructor(t,e,i,n,r,s){super("PropertyIsLike",t),this.pattern=e,this.wildCard=void 0!==i?i:"*",this.singleChar=void 0!==n?n:".",this.escapeChar=void 0!==r?r:"!",this.matchCase=s}};var UE=class extends ME{constructor(t){super("PropertyIsNull",t)}};var zE=class extends OE{constructor(t,e){super("PropertyIsLessThan",t,e)}};var XE=class extends OE{constructor(t,e){super("PropertyIsLessThanOrEqualTo",t,e)}};var VE=class extends TE{constructor(t){super("Not"),this.condition=t}};var WE=class extends OE{constructor(t,e,i){super("PropertyIsNotEqualTo",t,e,i)}};var ZE=class extends CE{constructor(t){super("Or",Array.prototype.slice.call(arguments))}};var YE=class extends TE{constructor(t){super("ResourceId"),this.rid=t}};var KE=class extends PE{constructor(t,e,i){super("Within",t,e,i)}};function HE(t){const e=[null].concat(Array.prototype.slice.call(arguments));return new(Function.prototype.bind.apply(RE,e))}function qE(t,e,i){return new bE(t,e,i)}const $E={"http://www.opengis.net/gml":{boundedBy:xd(yx.prototype.readExtentElement,"bounds")},"http://www.opengis.net/wfs/2.0":{member:md(yx.prototype.readFeaturesInternal)}},JE={"http://www.opengis.net/wfs":{totalInserted:xd(Tx),totalUpdated:xd(Tx),totalDeleted:xd(Tx)},"http://www.opengis.net/wfs/2.0":{totalInserted:xd(Tx),totalUpdated:xd(Tx),totalDeleted:xd(Tx)}},QE={"http://www.opengis.net/wfs":{TransactionSummary:xd(cT,"transactionSummary"),InsertResults:xd(fT,"insertIds")},"http://www.opengis.net/wfs/2.0":{TransactionSummary:xd(cT,"transactionSummary"),InsertResults:xd(fT,"insertIds")}},tT={"http://www.opengis.net/wfs":{PropertyName:vd(Mx)},"http://www.opengis.net/wfs/2.0":{PropertyName:vd(Mx)}},eT={"http://www.opengis.net/wfs":{Insert:vd(pT),Update:vd(xT),Delete:vd(yT),Property:vd(vT),Native:vd(ST)},"http://www.opengis.net/wfs/2.0":{Insert:vd(pT),Update:vd(xT),Delete:vd(yT),Property:vd(vT),Native:vd(ST)}},iT="feature",nT="http://www.w3.org/2000/xmlns/",rT={"2.0.0":"http://www.opengis.net/ogc/1.1","1.1.0":"http://www.opengis.net/ogc","1.0.0":"http://www.opengis.net/ogc"},sT={"2.0.0":"http://www.opengis.net/wfs/2.0","1.1.0":"http://www.opengis.net/wfs","1.0.0":"http://www.opengis.net/wfs"},oT={"2.0.0":"http://www.opengis.net/fes/2.0","1.1.0":"http://www.opengis.net/fes","1.0.0":"http://www.opengis.net/fes"},aT={"2.0.0":"http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd","1.1.0":"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd","1.0.0":"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/wfs.xsd"},lT={"2.0.0":Vx,"1.1.0":Bx,"1.0.0":Dx};function hT(t,e,i,n){Id(n,eT,wd(t),e,i)}function cT(t,e){return bd({},JE,t,e)}const uT={"http://www.opengis.net/ogc":{FeatureId:md((function(t,e){return t.getAttribute("fid")}))},"http://www.opengis.net/ogc/1.1":{FeatureId:md((function(t,e){return t.getAttribute("fid")}))}};function dT(t,e){Rd(uT,t,e)}const gT={"http://www.opengis.net/wfs":{Feature:dT},"http://www.opengis.net/wfs/2.0":{Feature:dT}};function fT(t,e){return bd([],gT,t,e)}function pT(t,e,i){const n=i[i.length-1],r=n.featureType,s=n.featureNS,o=n.gmlVersion,a=hd(s,r);t.appendChild(a),2===o?Dx.prototype.writeFeatureElement(a,e,i):3===o?Bx.prototype.writeFeatureElement(a,e,i):Vx.prototype.writeFeatureElement(a,e,i)}function mT(t,e,i){const n=i[i.length-1].version,r=rT[n],s=hd(r,"Filter"),o=hd(r,"FeatureId");s.appendChild(o),o.setAttribute("fid",e),t.appendChild(s)}function _T(t,e){const i=(t=t||iT)+":";return e.startsWith(i)?e:i+e}function yT(t,e,i){const n=i[i.length-1];Mt(void 0!==e.getId(),26);const r=n.featureType,s=n.featurePrefix,o=n.featureNS,a=_T(s,r);t.setAttribute("typeName",a),t.setAttributeNS(nT,"xmlns:"+s,o);const l=e.getId();void 0!==l&&mT(t,l,i)}function xT(t,e,i){const n=i[i.length-1];Mt(void 0!==e.getId(),27);const r=n.version,s=n.featureType,o=n.featurePrefix,a=n.featureNS,l=_T(o,s),h=e.getGeometryName();t.setAttribute("typeName",l),t.setAttributeNS(nT,"xmlns:"+o,a);const c=e.getId();if(void 0!==c){const s=e.getKeys(),o=[];for(let t=0,i=s.length;t<i;t++){const i=e.get(s[t]);if(void 0!==i){let e=s[t];i&&"function"==typeof i.getSimplifiedGeometry&&(e=h),o.push({name:e,value:i})}}Id({version:r,gmlVersion:n.gmlVersion,node:t,hasZ:n.hasZ,srsName:n.srsName},eT,wd("Property"),o,i),mT(t,c,i)}}function vT(t,e,i){const n=i[i.length-1],r=n.version,s=sT[r],o=hd(s,"Name"),a=n.gmlVersion;if(t.appendChild(o),Mx(o,e.name),void 0!==e.value&&null!==e.value){const n=hd(s,"Value");t.appendChild(n),e.value&&"function"==typeof e.value.getSimplifiedGeometry?2===a?Dx.prototype.writeGeometryElement(n,e.value,i):3===a?Bx.prototype.writeGeometryElement(n,e.value,i):Vx.prototype.writeGeometryElement(n,e.value,i):Mx(n,e.value)}}function ST(t,e,i){e.vendorId&&t.setAttribute("vendorId",e.vendorId),void 0!==e.safeToIgnore&&t.setAttribute("safeToIgnore",String(e.safeToIgnore)),void 0!==e.value&&Mx(t,e.value)}const wT={"http://www.opengis.net/wfs":{Query:vd(ET)},"http://www.opengis.net/wfs/2.0":{Query:vd(ET)},"http://www.opengis.net/ogc":{During:vd(PT),And:vd(IT),Or:vd(IT),Not:vd(FT),BBOX:vd(CT),Contains:vd(RT),Intersects:vd(RT),Within:vd(RT),DWithin:vd(bT),PropertyIsEqualTo:vd(LT),PropertyIsNotEqualTo:vd(LT),PropertyIsLessThan:vd(LT),PropertyIsLessThanOrEqualTo:vd(LT),PropertyIsGreaterThan:vd(LT),PropertyIsGreaterThanOrEqualTo:vd(LT),PropertyIsNull:vd(MT),PropertyIsBetween:vd(AT),PropertyIsLike:vd(OT)},"http://www.opengis.net/fes/2.0":{During:vd(PT),And:vd(IT),Or:vd(IT),Not:vd(FT),BBOX:vd(CT),Contains:vd(RT),Disjoint:vd(RT),Intersects:vd(RT),ResourceId:vd((function(t,e,i){t.setAttribute("rid",e.rid)})),Within:vd(RT),DWithin:vd(bT),PropertyIsEqualTo:vd(LT),PropertyIsNotEqualTo:vd(LT),PropertyIsLessThan:vd(LT),PropertyIsLessThanOrEqualTo:vd(LT),PropertyIsGreaterThan:vd(LT),PropertyIsGreaterThanOrEqualTo:vd(LT),PropertyIsNull:vd(MT),PropertyIsBetween:vd(AT),PropertyIsLike:vd(OT)}};function ET(t,e,i){const n=i[i.length-1],r=n.version,s=n.featurePrefix,o=n.featureNS,a=n.propertyNames,l=n.srsName;let h,c;h=s?_T(s,e):e,c="2.0.0"===r?"typeNames":"typeName",t.setAttribute(c,h),l&&t.setAttribute("srsName",l),o&&t.setAttributeNS(nT,"xmlns:"+s,o);const u=Object.assign({},n);u.node=t,Id(u,tT,wd("PropertyName"),a,i);const d=n.filter;if(d){const e=hd(BT(r),"Filter");t.appendChild(e),TT(e,d,i)}}function TT(t,e,i){const n=i[i.length-1],r={node:t};Object.assign(r,{context:n}),Id(r,wT,wd(e.getTagName()),[e],i)}function CT(t,e,i){const n=i[i.length-1],r=n.context.version;n.srsName=e.srsName;const s=lT[r];kT(r,t,e.geometryName),s.prototype.writeGeometryElement(t,e.extent,i)}function RT(t,e,i){const n=i[i.length-1],r=n.context.version;n.srsName=e.srsName;const s=lT[r];kT(r,t,e.geometryName),s.prototype.writeGeometryElement(t,e.geometry,i)}function bT(t,e,i){const n=i[i.length-1].context.version;RT(t,e,i);const r=hd(BT(n),"Distance");Mx(r,e.distance.toString()),"2.0.0"===n?r.setAttribute("uom",e.unit):r.setAttribute("units",e.unit),t.appendChild(r)}function PT(t,e,i){const n=i[i.length-1].context.version;NT(oT[n],"ValueReference",t,e.propertyName);const r=hd(px,"TimePeriod");t.appendChild(r);const s=hd(px,"begin");r.appendChild(s),GT(s,e.begin);const o=hd(px,"end");r.appendChild(o),GT(o,e.end)}function IT(t,e,i){const n=i[i.length-1].context,r={node:t};Object.assign(r,{context:n});const s=e.conditions;for(let t=0,e=s.length;t<e;++t){const e=s[t];Id(r,wT,wd(e.getTagName()),[e],i)}}function FT(t,e,i){const n=i[i.length-1].context,r={node:t};Object.assign(r,{context:n});const s=e.condition;Id(r,wT,wd(s.getTagName()),[s],i)}function LT(t,e,i){const n=i[i.length-1].context.version;void 0!==e.matchCase&&t.setAttribute("matchCase",e.matchCase.toString()),kT(n,t,e.propertyName),DT(n,t,""+e.expression)}function MT(t,e,i){kT(i[i.length-1].context.version,t,e.propertyName)}function AT(t,e,i){const n=i[i.length-1].context.version,r=BT(n);kT(n,t,e.propertyName);const s=hd(r,"LowerBoundary");t.appendChild(s),DT(n,s,""+e.lowerBoundary);const o=hd(r,"UpperBoundary");t.appendChild(o),DT(n,o,""+e.upperBoundary)}function OT(t,e,i){const n=i[i.length-1].context.version;t.setAttribute("wildCard",e.wildCard),t.setAttribute("singleChar",e.singleChar),t.setAttribute("escapeChar",e.escapeChar),void 0!==e.matchCase&&t.setAttribute("matchCase",e.matchCase.toString()),kT(n,t,e.propertyName),DT(n,t,""+e.pattern)}function NT(t,e,i,n){const r=hd(t,e);Mx(r,n),i.appendChild(r)}function DT(t,e,i){NT(BT(t),"Literal",e,i)}function kT(t,e,i){"2.0.0"===t?NT(oT[t],"ValueReference",e,i):NT(rT[t],"PropertyName",e,i)}function GT(t,e){const i=hd(px,"TimeInstant");t.appendChild(i);const n=hd(px,"timePosition");i.appendChild(n),Mx(n,e)}function jT(t,e,i){const n=i[i.length-1],r=Object.assign({},n);r.node=t,Id(r,wT,wd("Query"),e,i)}function BT(t){let e;return e="2.0.0"===t?oT[t]:rT[t],e}var UT=class extends fx{constructor(t){super(),t=t||{},this.version_=t.version?t.version:"1.1.0",this.featureType_=t.featureType,this.featureNS_=t.featureNS,this.gmlFormat_=t.gmlFormat?t.gmlFormat:new lT[this.version_],this.schemaLocation_=t.schemaLocation?t.schemaLocation:aT[this.version_]}getFeatureType(){return this.featureType_}setFeatureType(t){this.featureType_=t}readFeaturesFromNode(t,e){const i={node:t};Object.assign(i,{featureType:this.featureType_,featureNS:this.featureNS_}),Object.assign(i,this.getReadOptions(t,e||{}));const n=[i];let r;r="2.0.0"===this.version_?$E:this.gmlFormat_.FEATURE_COLLECTION_PARSERS;let s=bd([],r,t,n,this.gmlFormat_);return s||(s=[]),s}readTransactionResponse(t){if(t){if("string"==typeof t){const e=fd(t);return this.readTransactionResponseFromDocument(e)}return dd(t)?this.readTransactionResponseFromDocument(t):this.readTransactionResponseFromNode(t)}}readFeatureCollectionMetadata(t){if(t){if("string"==typeof t){const e=fd(t);return this.readFeatureCollectionMetadataFromDocument(e)}return dd(t)?this.readFeatureCollectionMetadataFromDocument(t):this.readFeatureCollectionMetadataFromNode(t)}}readFeatureCollectionMetadataFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE)return this.readFeatureCollectionMetadataFromNode(e)}readFeatureCollectionMetadataFromNode(t){const e={},i=Cx(t.getAttribute("numberOfFeatures"));return e.numberOfFeatures=i,bd(e,$E,t,[],this.gmlFormat_)}readTransactionResponseFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE)return this.readTransactionResponseFromNode(e)}readTransactionResponseFromNode(t){return bd({},QE,t,[])}writeGetFeature(t){const e=hd(sT[this.version_],"GetFeature");e.setAttribute("service","WFS"),e.setAttribute("version",this.version_),t.handle&&e.setAttribute("handle",t.handle),t.outputFormat&&e.setAttribute("outputFormat",t.outputFormat),void 0!==t.maxFeatures&&e.setAttribute("maxFeatures",String(t.maxFeatures)),t.resultType&&e.setAttribute("resultType",t.resultType),void 0!==t.startIndex&&e.setAttribute("startIndex",String(t.startIndex)),void 0!==t.count&&e.setAttribute("count",String(t.count)),void 0!==t.viewParams&&e.setAttribute("viewParams",t.viewParams),e.setAttributeNS(ld,"xsi:schemaLocation",this.schemaLocation_);const i={node:e};if(Object.assign(i,{version:this.version_,srsName:t.srsName,featureNS:t.featureNS?t.featureNS:this.featureNS_,featurePrefix:t.featurePrefix,propertyNames:t.propertyNames?t.propertyNames:[]}),Mt(Array.isArray(t.featureTypes),11),"string"==typeof t.featureTypes[0]){let n=t.filter;t.bbox&&(Mt(t.geometryName,12),n=this.combineBboxAndFilter(t.geometryName,t.bbox,t.srsName,n)),Object.assign(i,{geometryName:t.geometryName,filter:n}),jT(e,t.featureTypes,[i])}else t.featureTypes.forEach((n=>{const r=this.combineBboxAndFilter(n.geometryName,n.bbox,t.srsName,t.filter);Object.assign(i,{geometryName:n.geometryName,filter:r}),jT(e,[n.name],[i])}));return e}combineBboxAndFilter(t,e,i,n){const r=qE(t,e,i);return n?HE(n,r):r}writeTransaction(t,e,i,n){const r=[],s=n.version?n.version:this.version_,o=hd(sT[s],"Transaction");let a;o.setAttribute("service","WFS"),o.setAttribute("version",s),n&&(a=n.gmlOptions?n.gmlOptions:{},n.handle&&o.setAttribute("handle",n.handle)),o.setAttributeNS(ld,"xsi:schemaLocation",aT[s]);const l=function(t,e,i,n){const r=n.featurePrefix?n.featurePrefix:iT;let s;"1.0.0"===i?s=2:"1.1.0"===i?s=3:"2.0.0"===i&&(s=3.2);const o=Object.assign({node:t},{version:i,featureNS:n.featureNS,featureType:n.featureType,featurePrefix:r,gmlVersion:s,hasZ:n.hasZ,srsName:n.srsName},e);return o}(o,a,s,n);return t&&hT("Insert",t,r,l),e&&hT("Update",e,r,l),i&&hT("Delete",i,r,l),n.nativeElements&&hT("Native",n.nativeElements,r,l),o}readProjectionFromDocument(t){for(let e=t.firstChild;e;e=e.nextSibling)if(e.nodeType==Node.ELEMENT_NODE)return this.readProjectionFromNode(e);return null}readProjectionFromNode(t){if(t.firstElementChild&&t.firstElementChild.firstElementChild)for(let e=(t=t.firstElementChild.firstElementChild).firstElementChild;e;e=e.nextElementSibling)if(0!==e.childNodes.length&&(1!==e.childNodes.length||3!==e.firstChild.nodeType)){const t=[{}];return this.gmlFormat_.readGeometryElement(e,t),nn(t.pop().srsName)}return null}};const zT=1,XT=2,VT=3,WT=4,ZT=5,YT=6,KT=7,HT=15,qT=16,$T=17;class JT{constructor(t){this.view_=t,this.pos_=0,this.initialized_=!1,this.isLittleEndian_=!1,this.hasZ_=!1,this.hasM_=!1,this.srid_=null,this.layout_="XY"}readUint8(){return this.view_.getUint8(this.pos_++)}readUint32(t){return this.view_.getUint32((this.pos_+=4)-4,void 0!==t?t:this.isLittleEndian_)}readDouble(t){return this.view_.getFloat64((this.pos_+=8)-8,void 0!==t?t:this.isLittleEndian_)}readPoint(){const t=[];return t.push(this.readDouble()),t.push(this.readDouble()),this.hasZ_&&t.push(this.readDouble()),this.hasM_&&t.push(this.readDouble()),t}readLineString(){const t=this.readUint32(),e=[];for(let i=0;i<t;i++)e.push(this.readPoint());return e}readPolygon(){const t=this.readUint32(),e=[];for(let i=0;i<t;i++)e.push(this.readLineString());return e}readWkbHeader(t){const e=this.readUint8()>0,i=this.readUint32(e),n=Math.floor((268435455&i)/1e3),r=Boolean(2147483648&i)||1===n||3===n,s=Boolean(1073741824&i)||2===n||3===n,o=Boolean(536870912&i),a=(268435455&i)%1e3,l=["XY",r?"Z":"",s?"M":""].join(""),h=o?this.readUint32(e):null;if(void 0!==t&&t!==a)throw new Error("Unexpected WKB geometry type "+a);if(this.initialized_){if(this.isLittleEndian_!==e)throw new Error("Inconsistent endian");if(this.layout_!==l)throw new Error("Inconsistent geometry layout");if(h&&this.srid_!==h)throw new Error("Inconsistent coordinate system (SRID)")}else this.isLittleEndian_=e,this.hasZ_=r,this.hasM_=s,this.layout_=l,this.srid_=h,this.initialized_=!0;return a}readWkbPayload(t){switch(t){case zT:return this.readPoint();case XT:return this.readLineString();case VT:case $T:return this.readPolygon();case WT:return this.readMultiPoint();case ZT:return this.readMultiLineString();case YT:case HT:case qT:return this.readMultiPolygon();case KT:return this.readGeometryCollection();default:throw new Error("Unsupported WKB geometry type "+t+" is found")}}readWkbBlock(t){return this.readWkbPayload(this.readWkbHeader(t))}readWkbCollection(t,e){const i=this.readUint32(),n=[];for(let r=0;r<i;r++){const i=t.call(this,e);i&&n.push(i)}return n}readMultiPoint(){return this.readWkbCollection(this.readWkbBlock,zT)}readMultiLineString(){return this.readWkbCollection(this.readWkbBlock,XT)}readMultiPolygon(){return this.readWkbCollection(this.readWkbBlock,VT)}readGeometryCollection(){return this.readWkbCollection(this.readGeometry)}readGeometry(){const t=this.readWkbHeader(),e=this.readWkbPayload(t);switch(t){case zT:return new lr(e,this.layout_);case XT:return new Vm(e,this.layout_);case VT:case $T:return new Ir(e,this.layout_);case WT:return new Km(e,this.layout_);case ZT:return new Zm(e,this.layout_);case YT:case HT:case qT:return new $m(e,this.layout_);case KT:return new jm(e);default:return null}}getSrid(){return this.srid_}}class QT{constructor(t){t=t||{},this.layout_=t.layout,this.isLittleEndian_=!1!==t.littleEndian,this.isEWKB_=!1!==t.ewkb,this.writeQueue_=[],this.nodata_=Object.assign({X:0,Y:0,Z:0,M:0},t.nodata)}writeUint8(t){this.writeQueue_.push([1,t])}writeUint32(t){this.writeQueue_.push([4,t])}writeDouble(t){this.writeQueue_.push([8,t])}writePoint(t,e){const i=Object.assign.apply(null,e.split("").map(((e,i)=>({[e]:t[i]}))));for(const t of this.layout_)this.writeDouble(t in i?i[t]:this.nodata_[t])}writeLineString(t,e){this.writeUint32(t.length);for(let i=0;i<t.length;i++)this.writePoint(t[i],e)}writePolygon(t,e){this.writeUint32(t.length);for(let i=0;i<t.length;i++)this.writeLineString(t[i],e)}writeWkbHeader(t,e){t%=1e3,this.layout_.includes("Z")&&(t+=this.isEWKB_?2147483648:1e3),this.layout_.includes("M")&&(t+=this.isEWKB_?1073741824:2e3),this.isEWKB_&&Number.isInteger(e)&&(t|=536870912),this.writeUint8(this.isLittleEndian_?1:0),this.writeUint32(t),this.isEWKB_&&Number.isInteger(e)&&this.writeUint32(e)}writeMultiPoint(t,e){this.writeUint32(t.length);for(let i=0;i<t.length;i++)this.writeWkbHeader(1),this.writePoint(t[i],e)}writeMultiLineString(t,e){this.writeUint32(t.length);for(let i=0;i<t.length;i++)this.writeWkbHeader(2),this.writeLineString(t[i],e)}writeMultiPolygon(t,e){this.writeUint32(t.length);for(let i=0;i<t.length;i++)this.writeWkbHeader(3),this.writePolygon(t[i],e)}writeGeometryCollection(t){this.writeUint32(t.length);for(let e=0;e<t.length;e++)this.writeGeometry(t[e])}findMinimumLayout(t,e="XYZM"){if(t instanceof On)return(i=t.getLayout())===(n=e)?i:"XYZM"===i?n:"XYZM"===n?i:"XY";var i,n;if(t instanceof jm){const i=t.getGeometriesArray();for(let t=0;t<i.length&&"XY"!==e;t++)e=this.findMinimumLayout(i[t],e)}return e}writeGeometry(t,e){const i={Point:zT,LineString:XT,Polygon:VT,MultiPoint:WT,MultiLineString:ZT,MultiPolygon:YT,GeometryCollection:KT},n=t.getType(),r=i[n];if(!r)throw new Error("GeometryType "+n+" is not supported");if(this.layout_||(this.layout_=this.findMinimumLayout(t)),this.writeWkbHeader(r,e),t instanceof On){({Point:this.writePoint,LineString:this.writeLineString,Polygon:this.writePolygon,MultiPoint:this.writeMultiPoint,MultiLineString:this.writeMultiLineString,MultiPolygon:this.writeMultiPolygon})[n].call(this,t.getCoordinates(),t.getLayout())}else t instanceof jm&&this.writeGeometryCollection(t.getGeometriesArray())}getBuffer(){const t=this.writeQueue_.reduce(((t,e)=>t+e[0]),0),e=new ArrayBuffer(t),i=new DataView(e);let n=0;return this.writeQueue_.forEach((t=>{switch(t[0]){case 1:i.setUint8(n,t[1]);break;case 4:i.setUint32(n,t[1],this.isLittleEndian_);break;case 8:i.setFloat64(n,t[1],this.isLittleEndian_)}n+=t[0]})),e}}function tC(t){return"string"==typeof t?function(t){const e=new Uint8Array(t.length/2);for(let i=0;i<t.length/2;i++)e[i]=parseInt(t.substr(2*i,2),16);return new DataView(e.buffer)}(t):ArrayBuffer.isView(t)?t instanceof DataView?t:new DataView(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer?new DataView(t):null}var eC=class extends __{constructor(t){super(),t=t||{},this.splitCollection=Boolean(t.splitCollection),this.viewCache_=null,this.hex_=!1!==t.hex,this.littleEndian_=!1!==t.littleEndian,this.ewkb_=!1!==t.ewkb,this.layout_=t.geometryLayout,this.nodataZ_=t.nodataZ||0,this.nodataM_=t.nodataM||0,this.srid_=t.srid}getType(){return this.hex_?"text":"arraybuffer"}readFeature(t,e){return new Nt({geometry:this.readGeometry(t,e)})}readFeatures(t,e){let i=[];const n=this.readGeometry(t,e);return i=this.splitCollection&&n instanceof jm?n.getGeometriesArray():[n],i.map((t=>new Nt({geometry:t})))}readGeometry(t,e){const i=tC(t);if(!i)return null;const n=new JT(i).readGeometry();return this.viewCache_=i,e=this.getReadOptions(t,e),this.viewCache_=null,y_(n,!1,e)}readProjection(t){const e=this.viewCache_||tC(t);if(!e)return;const i=new JT(e);return i.readWkbHeader(),i.getSrid()&&nn("EPSG:"+i.getSrid())||void 0}writeFeature(t,e){return this.writeGeometry(t.getGeometry(),e)}writeFeatures(t,e){return this.writeGeometry(new jm(t.map((t=>t.getGeometry()))),e)}writeGeometry(t,e){e=this.adaptOptions(e);const i=new QT({layout:this.layout_,littleEndian:this.littleEndian_,ewkb:this.ewkb_,nodata:{Z:this.nodataZ_,M:this.nodataM_}});let n=Number.isInteger(this.srid_)?Number(this.srid_):null;if(!1!==this.srid_&&!Number.isInteger(this.srid_)){const t=e.dataProjection&&nn(e.dataProjection);if(t){const e=t.getCode();e.startsWith("EPSG:")&&(n=Number(e.substring(5)))}}i.writeGeometry(y_(t,!0,e),n);const r=i.getBuffer();return this.hex_?function(t){const e=new Uint8Array(t);return Array.from(e.values()).map((t=>(t<16?"0":"")+Number(t).toString(16).toUpperCase())).join("")}(r):r}};const iC={POINT:lr,LINESTRING:Vm,POLYGON:Ir,MULTIPOINT:Km,MULTILINESTRING:Zm,MULTIPOLYGON:$m},nC="EMPTY",rC="Z",sC="M",oC=0,aC=1,lC=2,hC=3,cC=4,uC=5,dC=6,gC={Point:"POINT",LineString:"LINESTRING",Polygon:"POLYGON",MultiPoint:"MULTIPOINT",MultiLineString:"MULTILINESTRING",MultiPolygon:"MULTIPOLYGON",GeometryCollection:"GEOMETRYCOLLECTION",Circle:"CIRCLE"};class fC{constructor(t){this.wkt=t,this.index_=-1}isAlpha_(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isNumeric_(t,e){return e=void 0!==e&&e,t>="0"&&t<="9"||"."==t&&!e}isWhiteSpace_(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const t=this.nextChar_(),e=this.index_;let i,n=t;if("("==t)i=lC;else if(","==t)i=uC;else if(")"==t)i=hC;else if(this.isNumeric_(t)||"-"==t)i=cC,n=this.readNumber_();else if(this.isAlpha_(t))i=aC,n=this.readText_();else{if(this.isWhiteSpace_(t))return this.nextToken();if(""!==t)throw new Error("Unexpected character: "+t);i=dC}return{position:e,value:n,type:i}}readNumber_(){let t;const e=this.index_;let i=!1,n=!1;do{"."==t?i=!0:"e"!=t&&"E"!=t||(n=!0),t=this.nextChar_()}while(this.isNumeric_(t,i)||!n&&("e"==t||"E"==t)||n&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}readText_(){let t;const e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}class pC{constructor(t){this.lexer_=t,this.token_={position:0,type:oC},this.layout_="XY"}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(t){return this.token_.type==t}match(t){const e=this.isTokenType(t);return e&&this.consume_(),e}parse(){return this.consume_(),this.parseGeometry_()}parseGeometryLayout_(){let t="XY";const e=this.token_;if(this.isTokenType(aC)){const i=e.value;i===rC?t="XYZ":i===sC?t="XYM":"ZM"===i&&(t="XYZM"),"XY"!==t&&this.consume_()}return t}parseGeometryCollectionText_(){if(this.match(lC)){const t=[];do{t.push(this.parseGeometry_())}while(this.match(uC));if(this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(lC)){const t=this.parsePoint_();if(this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(lC)){const t=this.parsePointList_();if(this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(lC)){const t=this.parseLineStringTextList_();if(this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(lC)){let t;if(t=this.token_.type==lC?this.parsePointTextList_():this.parsePointList_(),this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(lC)){const t=this.parseLineStringTextList_();if(this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(lC)){const t=this.parsePolygonTextList_();if(this.match(hC))return t}throw new Error(this.formatErrorMessage_())}parsePoint_(){const t=[],e=this.layout_.length;for(let i=0;i<e;++i){const e=this.token_;if(!this.match(cC))break;t.push(e.value)}if(t.length==e)return t;throw new Error(this.formatErrorMessage_())}parsePointList_(){const t=[this.parsePoint_()];for(;this.match(uC);)t.push(this.parsePoint_());return t}parsePointTextList_(){const t=[this.parsePointText_()];for(;this.match(uC);)t.push(this.parsePointText_());return t}parseLineStringTextList_(){const t=[this.parseLineStringText_()];for(;this.match(uC);)t.push(this.parseLineStringText_());return t}parsePolygonTextList_(){const t=[this.parsePolygonText_()];for(;this.match(uC);)t.push(this.parsePolygonText_());return t}isEmptyGeometry_(){const t=this.isTokenType(aC)&&this.token_.value==nC;return t&&this.consume_(),t}formatErrorMessage_(){return"Unexpected `"+this.token_.value+"` at position "+this.token_.position+" in `"+this.lexer_.wkt+"`"}parseGeometry_(){const t=this.token_;if(this.match(aC)){const e=t.value;this.layout_=this.parseGeometryLayout_();const i=this.isEmptyGeometry_();if("GEOMETRYCOLLECTION"==e){if(i)return new jm([]);const t=this.parseGeometryCollectionText_();return new jm(t)}const n=iC[e];if(!n)throw new Error("Invalid geometry type: "+e);let r;if(i)r="POINT"==e?[NaN,NaN]:[];else switch(e){case"POINT":r=this.parsePointText_();break;case"LINESTRING":r=this.parseLineStringText_();break;case"POLYGON":r=this.parsePolygonText_();break;case"MULTIPOINT":r=this.parseMultiPointText_();break;case"MULTILINESTRING":r=this.parseMultiLineStringText_();break;case"MULTIPOLYGON":r=this.parseMultiPolygonText_()}return new n(r,this.layout_)}throw new Error(this.formatErrorMessage_())}}function mC(t){const e=t.getCoordinates();return 0===e.length?"":e.join(" ")}function _C(t){const e=t.getCoordinates(),i=[];for(let t=0,n=e.length;t<n;++t)i.push(e[t].join(" "));return i.join(",")}function yC(t){const e=[],i=t.getLinearRings();for(let t=0,n=i.length;t<n;++t)e.push("("+_C(i[t])+")");return e.join(",")}const xC={Point:mC,LineString:_C,Polygon:yC,MultiPoint:function(t){const e=[],i=t.getPoints();for(let t=0,n=i.length;t<n;++t)e.push("("+mC(i[t])+")");return e.join(",")},MultiLineString:function(t){const e=[],i=t.getLineStrings();for(let t=0,n=i.length;t<n;++t)e.push("("+_C(i[t])+")");return e.join(",")},MultiPolygon:function(t){const e=[],i=t.getPolygons();for(let t=0,n=i.length;t<n;++t)e.push("("+yC(i[t])+")");return e.join(",")},GeometryCollection:function(t){const e=[],i=t.getGeometries();for(let t=0,n=i.length;t<n;++t)e.push(vC(i[t]));return e.join(",")}};function vC(t){const e=t.getType(),i=(0,xC[e])(t);let n=gC[e];if("function"==typeof t.getFlatCoordinates){const e=function(t){const e=t.getLayout();let i="";return"XYZ"!==e&&"XYZM"!==e||(i+=rC),"XYM"!==e&&"XYZM"!==e||(i+=sC),i}(t);e.length>0&&(n+=" "+e)}return 0===i.length?n+" "+nC:n+"("+i+")"}var SC=class extends Iv{constructor(t){super(),t=t||{},this.splitCollection_=void 0!==t.splitCollection&&t.splitCollection}parse_(t){const e=new fC(t);return new pC(e).parse()}readFeatureFromText(t,e){const i=this.readGeometryFromText(t,e),n=new Nt;return n.setGeometry(i),n}readFeaturesFromText(t,e){let i=[];const n=this.readGeometryFromText(t,e);i=this.splitCollection_&&"GeometryCollection"==n.getType()?n.getGeometriesArray():[n];const r=[];for(let t=0,e=i.length;t<e;++t){const e=new Nt;e.setGeometry(i[t]),r.push(e)}return r}readGeometryFromText(t,e){return y_(this.parse_(t),!1,e)}writeFeatureText(t,e){const i=t.getGeometry();return i?this.writeGeometryText(i,e):""}writeFeaturesText(t,e){if(1==t.length)return this.writeFeatureText(t[0],e);const i=[];for(let e=0,n=t.length;e<n;++e)i.push(t[e].getGeometry());const n=new jm(i);return this.writeGeometryText(n,e)}writeGeometryText(t,e){return vC(y_(t,!0,e))}};const wC=[null,"http://www.opengis.net/wms"],EC=Cd(wC,{Service:xd((function(t,e){return bd({},CC,t,e)})),Capability:xd((function(t,e){return bd({},TC,t,e)}))}),TC=Cd(wC,{Request:xd((function(t,e){return bd({},AC,t,e)})),Exception:xd((function(t,e){return bd([],IC,t,e)})),Layer:xd((function(t,e){const i=bd({},FC,t,e);if(void 0===i.Layer)return Object.assign(i,BC(t,e));return i}))});const CC=Cd(wC,{Name:xd(Rx),Title:xd(Rx),Abstract:xd(Rx),KeywordList:xd(VC),OnlineResource:xd(Vw),ContactInformation:xd((function(t,e){return bd({},RC,t,e)})),Fees:xd(Rx),AccessConstraints:xd(Rx),LayerLimit:xd(Tx),MaxWidth:xd(Tx),MaxHeight:xd(Tx)}),RC=Cd(wC,{ContactPersonPrimary:xd((function(t,e){return bd({},bC,t,e)})),ContactPosition:xd(Rx),ContactAddress:xd((function(t,e){return bd({},PC,t,e)})),ContactVoiceTelephone:xd(Rx),ContactFacsimileTelephone:xd(Rx),ContactElectronicMailAddress:xd(Rx)}),bC=Cd(wC,{ContactPerson:xd(Rx),ContactOrganization:xd(Rx)}),PC=Cd(wC,{AddressType:xd(Rx),Address:xd(Rx),City:xd(Rx),StateOrProvince:xd(Rx),PostCode:xd(Rx),Country:xd(Rx)}),IC=Cd(wC,{Format:md(Rx)}),FC=Cd(wC,{Name:xd(Rx),Title:xd(Rx),Abstract:xd(Rx),KeywordList:xd(VC),CRS:yd(Rx),EX_GeographicBoundingBox:xd((function(t,e){const i=bd({},MC,t,e);if(!i)return;const n=i.westBoundLongitude,r=i.southBoundLatitude,s=i.eastBoundLongitude,o=i.northBoundLatitude;if(void 0===n||void 0===r||void 0===s||void 0===o)return;return[n,r,s,o]})),BoundingBox:yd((function(t,e){const i=[Ex(t.getAttribute("minx")),Ex(t.getAttribute("miny")),Ex(t.getAttribute("maxx")),Ex(t.getAttribute("maxy"))],n=[Ex(t.getAttribute("resx")),Ex(t.getAttribute("resy"))];return{crs:t.getAttribute("CRS"),extent:i,res:n}})),Dimension:yd((function(t,e){return{name:t.getAttribute("name"),units:t.getAttribute("units"),unitSymbol:t.getAttribute("unitSymbol"),default:t.getAttribute("default"),multipleValues:vx(t.getAttribute("multipleValues")),nearestValue:vx(t.getAttribute("nearestValue")),current:vx(t.getAttribute("current")),values:Rx(t)}})),Attribution:xd((function(t,e){return bd({},LC,t,e)})),AuthorityURL:yd((function(t,e){const i=UC(t,e);if(i)return i.name=t.getAttribute("name"),i;return})),Identifier:yd(Rx),MetadataURL:yd((function(t,e){const i=UC(t,e);if(i)return i.type=t.getAttribute("type"),i;return})),DataURL:yd(UC),FeatureListURL:yd(UC),Style:yd((function(t,e){return bd({},kC,t,e)})),MinScaleDenominator:xd(wx),MaxScaleDenominator:xd(wx),Layer:yd(BC)}),LC=Cd(wC,{Title:xd(Rx),OnlineResource:xd(Vw),LogoURL:xd(XC)}),MC=Cd(wC,{westBoundLongitude:xd(wx),eastBoundLongitude:xd(wx),southBoundLatitude:xd(wx),northBoundLatitude:xd(wx)}),AC=Cd(wC,{GetCapabilities:xd(zC),GetMap:xd(zC),GetFeatureInfo:xd(zC)}),OC=Cd(wC,{Format:yd(Rx),DCPType:yd((function(t,e){return bd({},NC,t,e)}))}),NC=Cd(wC,{HTTP:xd((function(t,e){return bd({},DC,t,e)}))}),DC=Cd(wC,{Get:xd(UC),Post:xd(UC)}),kC=Cd(wC,{Name:xd(Rx),Title:xd(Rx),Abstract:xd(Rx),LegendURL:yd(XC),StyleSheetURL:xd(UC),StyleURL:xd(UC)}),GC=Cd(wC,{Format:xd(Rx),OnlineResource:xd(Vw)}),jC=Cd(wC,{Keyword:md(Rx)});function BC(t,e){const i=e[e.length-1],n=bd({},FC,t,e);if(!n)return;let r=vx(t.getAttribute("queryable"));void 0===r&&(r=i.queryable),n.queryable=void 0!==r&&r;let s=Cx(t.getAttribute("cascaded"));void 0===s&&(s=i.cascaded),n.cascaded=s;let o=vx(t.getAttribute("opaque"));void 0===o&&(o=i.opaque),n.opaque=void 0!==o&&o;let a=vx(t.getAttribute("noSubsets"));void 0===a&&(a=i.noSubsets),n.noSubsets=void 0!==a&&a;let l=Ex(t.getAttribute("fixedWidth"));l||(l=i.fixedWidth),n.fixedWidth=l;let h=Ex(t.getAttribute("fixedHeight"));h||(h=i.fixedHeight),n.fixedHeight=h;["Style","CRS","AuthorityURL"].forEach((function(t){if(t in i){const e=n[t]||[];n[t]=e.concat(i[t])}}));return["EX_GeographicBoundingBox","BoundingBox","Dimension","Attribution","MinScaleDenominator","MaxScaleDenominator"].forEach((function(t){if(!(t in n)){const e=i[t];n[t]=e}})),n}function UC(t,e){return bd({},GC,t,e)}function zC(t,e){return bd({},OC,t,e)}function XC(t,e){const i=UC(t,e);if(i){const e=[Cx(t.getAttribute("width")),Cx(t.getAttribute("height"))];return i.size=e,i}}function VC(t,e){return bd([],jC,t,e)}var WC=class extends zw{constructor(){super(),this.version=void 0}readFromNode(t){this.version=t.getAttribute("version").trim();const e=bd({version:this.version},EC,t,[]);return e||null}};var ZC=class extends fx{constructor(t){super(),t=t||{},this.featureNS_="http://mapserver.gis.umn.edu/mapserver",this.gmlFormat_=new Dx,this.layers_=t.layers?t.layers:null}getLayers(){return this.layers_}setLayers(t){this.layers_=t}readFeatures_(t,e){t.setAttribute("namespaceURI",this.featureNS_);const i=t.localName;let n=[];if(0===t.childNodes.length)return n;if("msGMLOutput"==i)for(let i=0,r=t.childNodes.length;i<r;i++){const r=t.childNodes[i];if(r.nodeType!==Node.ELEMENT_NODE)continue;const s=r,o=e[0],a="_layer",l=s.localName.replace(a,"");if(this.layers_&&!this.layers_.includes(l))continue;const h=l+"_feature";o.featureType=h,o.featureNS=this.featureNS_;const c={};c[h]=md(this.gmlFormat_.readFeatureElement,this.gmlFormat_);const u=Cd([o.featureNS,null],c);s.setAttribute("namespaceURI",this.featureNS_);const g=bd([],u,s,e,this.gmlFormat_);g&&d(n,g)}if("FeatureCollection"==i){const e=bd([],this.gmlFormat_.FEATURE_COLLECTION_PARSERS,t,[{}],this.gmlFormat_);e&&(n=e)}return n}readFeaturesFromNode(t,e){const i={};return e&&Object.assign(i,this.getReadOptions(t,e)),this.readFeatures_(t,[i])}};const YC=[null,"http://www.opengis.net/wmts/1.0"],KC=[null,"http://www.opengis.net/ows/1.1"],HC=Cd(YC,{Contents:xd((function(t,e){return bd({},qC,t,e)}))});const qC=Cd(YC,{Layer:yd((function(t,e){return bd({},$C,t,e)})),TileMatrixSet:yd((function(t,e){return bd({},rR,t,e)}))}),$C=Cd(YC,{Style:yd((function(t,e){const i=bd({},JC,t,e);if(!i)return;const n="true"===t.getAttribute("isDefault");return i.isDefault=n,i})),Format:yd(Rx),TileMatrixSetLink:yd((function(t,e){return bd({},QC,t,e)})),Dimension:yd((function(t,e){return bd({},iR,t,e)})),ResourceURL:yd((function(t,e){const i=t.getAttribute("format"),n=t.getAttribute("template"),r=t.getAttribute("resourceType"),s={};i&&(s.format=i);n&&(s.template=n);r&&(s.resourceType=r);return s}))},Cd(KC,{Title:xd(Rx),Abstract:xd(Rx),WGS84BoundingBox:xd(oR),Identifier:xd(Rx)})),JC=Cd(YC,{LegendURL:yd((function(t,e){const i={};return i.format=t.getAttribute("format"),i.href=Vw(t),i}))},Cd(KC,{Title:xd(Rx),Identifier:xd(Rx)})),QC=Cd(YC,{TileMatrixSet:xd(Rx),TileMatrixSetLimits:xd((function(t,e){return bd([],tR,t,e)}))}),tR=Cd(YC,{TileMatrixLimits:md((function(t,e){return bd({},eR,t,e)}))}),eR=Cd(YC,{TileMatrix:xd(Rx),MinTileRow:xd(Tx),MaxTileRow:xd(Tx),MinTileCol:xd(Tx),MaxTileCol:xd(Tx)}),iR=Cd(YC,{Default:xd(Rx),Value:yd(Rx)},Cd(KC,{Identifier:xd(Rx)})),nR=Cd(KC,{LowerCorner:md(aR),UpperCorner:md(aR)}),rR=Cd(YC,{WellKnownScaleSet:xd(Rx),TileMatrix:yd((function(t,e){return bd({},sR,t,e)}))},Cd(KC,{SupportedCRS:xd(Rx),Identifier:xd(Rx),BoundingBox:xd(oR)})),sR=Cd(YC,{TopLeftCorner:xd(aR),ScaleDenominator:xd(wx),TileWidth:xd(Tx),TileHeight:xd(Tx),MatrixWidth:xd(Tx),MatrixHeight:xd(Tx)},Cd(KC,{Identifier:xd(Rx)}));function oR(t,e){const i=bd([],nR,t,e);if(2==i.length)return Qt(i)}function aR(t,e){const i=Rx(t).split(/\s+/);if(!i||2!=i.length)return;const n=+i[0],r=+i[1];return isNaN(n)||isNaN(r)?void 0:[n,r]}var lR=class extends zw{constructor(){super(),this.owsParser_=new oE}readFromNode(t){let e=t.getAttribute("version");e&&(e=e.trim());let i=this.owsParser_.readFromNode(t);return i?(i.version=e,i=bd(i,HC,t,[]),i||null):null}};const hR=["fullscreenchange","webkitfullscreenchange","MSFullscreenChange"],cR="enterfullscreen",uR="leavefullscreen";function dR(t){const e=t.body;return!!(e.webkitRequestFullscreen||e.requestFullscreen&&t.fullscreenEnabled)}function gR(t){return!(!t.webkitIsFullScreen&&!t.fullscreenElement)}function fR(t){t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen()}var pR=class extends ca{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target}),this.on,this.once,this.un,this.keys_=void 0!==t.keys&&t.keys,this.source_=t.source,this.isInFullscreen_=!1,this.boundHandleMapTargetChange_=this.handleMapTargetChange_.bind(this),this.cssClassName_=void 0!==t.className?t.className:"ol-full-screen",this.documentListeners_=[],this.activeClassName_=void 0!==t.activeClassName?t.activeClassName.split(" "):[this.cssClassName_+"-true"],this.inactiveClassName_=void 0!==t.inactiveClassName?t.inactiveClassName.split(" "):[this.cssClassName_+"-false"];const e=void 0!==t.label?t.label:"⤢";this.labelNode_="string"==typeof e?document.createTextNode(e):e;const i=void 0!==t.labelActive?t.labelActive:"×";this.labelActiveNode_="string"==typeof i?document.createTextNode(i):i;const n=t.tipLabel?t.tipLabel:"Toggle full-screen";this.button_=document.createElement("button"),this.button_.title=n,this.button_.setAttribute("type","button"),this.button_.appendChild(this.labelNode_),this.button_.addEventListener(R,this.handleClick_.bind(this),!1),this.setClassName_(this.button_,this.isInFullscreen_),this.element.className=`${this.cssClassName_} ${ho} ${uo}`,this.element.appendChild(this.button_)}handleClick_(t){t.preventDefault(),this.handleFullScreen_()}handleFullScreen_(){const t=this.getMap();if(!t)return;const e=t.getOwnerDocument();if(dR(e))if(gR(e))!function(t){t.exitFullscreen?t.exitFullscreen():t.webkitExitFullscreen&&t.webkitExitFullscreen()}(e);else{let i;i=this.source_?"string"==typeof this.source_?e.getElementById(this.source_):this.source_:t.getTargetElement(),this.keys_?function(t){t.webkitRequestFullscreen?t.webkitRequestFullscreen():fR(t)}(i):fR(i)}}handleFullScreenChange_(){const t=this.getMap();if(!t)return;const e=this.isInFullscreen_;this.isInFullscreen_=gR(t.getOwnerDocument()),e!==this.isInFullscreen_&&(this.setClassName_(this.button_,this.isInFullscreen_),this.isInFullscreen_?(wt(this.labelActiveNode_,this.labelNode_),this.dispatchEvent(cR)):(wt(this.labelNode_,this.labelActiveNode_),this.dispatchEvent(uR)),t.updateSize())}setClassName_(t,e){e?(t.classList.remove(...this.inactiveClassName_),t.classList.add(...this.activeClassName_)):(t.classList.remove(...this.activeClassName_),t.classList.add(...this.inactiveClassName_))}setMap(t){const e=this.getMap();e&&e.removeChangeListener(ra,this.boundHandleMapTargetChange_),super.setMap(t),this.handleMapTargetChange_(),t&&t.addChangeListener(ra,this.boundHandleMapTargetChange_)}handleMapTargetChange_(){const t=this.documentListeners_;for(let e=0,i=t.length;e<i;++e)G(t[e]);t.length=0;const e=this.getMap();if(e){const i=e.getOwnerDocument();dR(i)?this.element.classList.remove(co):this.element.classList.add(co);for(let e=0,n=hR.length;e<n;++e)t.push(D(i,hR[e],this.handleFullScreenChange_,this));this.handleFullScreenChange_()}}};const mR="projection",_R="coordinateFormat";var yR=class extends ca{constructor(t){t=t||{};const e=document.createElement("div");e.className=void 0!==t.className?t.className:"ol-mouse-position",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un,this.addChangeListener(mR,this.handleProjectionChanged_),t.coordinateFormat&&this.setCoordinateFormat(t.coordinateFormat),t.projection&&this.setProjection(t.projection),this.renderOnMouseOut_=void 0!==t.placeholder,this.placeholder_=this.renderOnMouseOut_?t.placeholder:"&#160;",this.renderedHTML_=e.innerHTML,this.mapProjection_=null,this.transform_=null,this.wrapX_=!1!==t.wrapX}handleProjectionChanged_(){this.transform_=null}getCoordinateFormat(){return this.get(_R)}getProjection(){return this.get(mR)}handleMouseMove(t){const e=this.getMap();this.updateHTML_(e.getEventPixel(t))}handleMouseOut(t){this.updateHTML_(null)}setMap(t){if(super.setMap(t),t){const e=t.getViewport();this.listenerKeys.push(D(e,Zo,this.handleMouseMove,this)),this.renderOnMouseOut_&&this.listenerKeys.push(D(e,Ho,this.handleMouseOut,this)),this.updateHTML_(null)}}setCoordinateFormat(t){this.set(_R,t)}setProjection(t){this.set(mR,nn(t))}updateHTML_(t){let e=this.placeholder_;if(t&&this.mapProjection_){if(!this.transform_){const t=this.getProjection();this.transform_=t?un(this.mapProjection_,t):Qi}const i=this.getMap().getCoordinateFromPixelInternal(t);if(i){const t=_n();if(t&&(this.transform_=un(this.mapProjection_,t)),this.transform_(i,i),this.wrapX_){ji(i,t||this.getProjection()||this.mapProjection_)}const n=this.getCoordinateFormat();e=n?n(i):i.toString()}}this.renderedHTML_&&e===this.renderedHTML_||(this.element.innerHTML=e,this.renderedHTML_=e)}render(t){const e=t.frameState;e?this.mapProjection_!=e.viewState.projection&&(this.mapProjection_=e.viewState.projection,this.transform_=null):this.mapProjection_=null}};const xR=.75,vR=.1;var SR=class extends ca{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.boundHandleRotationChanged_=this.handleRotationChanged_.bind(this),this.collapsed_=void 0===t.collapsed||t.collapsed,this.collapsible_=void 0===t.collapsible||t.collapsible,this.collapsible_||(this.collapsed_=!1),this.rotateWithView_=void 0!==t.rotateWithView&&t.rotateWithView,this.viewExtent_=void 0;const e=void 0!==t.className?t.className:"ol-overviewmap",i=void 0!==t.tipLabel?t.tipLabel:"Overview map",n=void 0!==t.collapseLabel?t.collapseLabel:"";"string"==typeof n?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=n):this.collapseLabel_=n;const r=void 0!==t.label?t.label:"";"string"==typeof r?(this.label_=document.createElement("span"),this.label_.textContent=r):this.label_=r;const s=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_,o=document.createElement("button");o.setAttribute("type","button"),o.title=i,o.appendChild(s),o.addEventListener(R,this.handleClick_.bind(this),!1),this.ovmapDiv_=document.createElement("div"),this.ovmapDiv_.className="ol-overviewmap-map",this.view_=t.view;const a=new hl({view:t.view,controls:new $,interactions:new $});this.ovmap_=a,t.layers&&t.layers.forEach((function(t){a.addLayer(t)}));const l=document.createElement("div");l.className="ol-overviewmap-box",l.style.boxSizing="border-box",this.boxOverlay_=new pl({position:[0,0],positioning:"center-center",element:l}),this.ovmap_.addOverlay(this.boxOverlay_);const h=e+" "+ho+" "+uo+(this.collapsed_&&this.collapsible_?" "+go:"")+(this.collapsible_?"":" ol-uncollapsible"),c=this.element;c.className=h,c.appendChild(this.ovmapDiv_),c.appendChild(o);const u=this,d=this.boxOverlay_,g=this.boxOverlay_.getElement(),f=function(t){const e={clientX:(i=t).clientX,clientY:i.clientY};var i;const n=a.getEventCoordinateInternal(e);d.setPosition(n)},p=function(t){const e=a.getEventCoordinateInternal(t);u.getMap().getView().setCenterInternal(e),window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",p)};g.addEventListener("mousedown",(function(){window.addEventListener("mousemove",f),window.addEventListener("mouseup",p)}))}setMap(t){const e=this.getMap();if(t!==e){if(e){const t=e.getView();t&&this.unbindView_(t),this.ovmap_.setTarget(null)}if(super.setMap(t),t){this.ovmap_.setTarget(this.ovmapDiv_),this.listenerKeys.push(D(t,s,this.handleMapPropertyChange_,this));const e=t.getView();e&&(this.bindView_(e),e.isDef()&&(this.ovmap_.updateSize(),this.resetExtent_())),this.ovmap_.isRendered()||this.updateBoxAfterOvmapIsRendered_()}}}handleMapPropertyChange_(t){if(t.key===sa){const e=t.oldValue;e&&this.unbindView_(e);const i=this.getMap().getView();this.bindView_(i)}else this.ovmap_.isRendered()||t.key!==ra&&t.key!==na||this.ovmap_.updateSize()}bindView_(t){if(!this.view_){const e=new eo({projection:t.getProjection()});this.ovmap_.setView(e)}t.addChangeListener(Ns.ROTATION,this.boundHandleRotationChanged_),this.handleRotationChanged_()}unbindView_(t){t.removeChangeListener(Ns.ROTATION,this.boundHandleRotationChanged_)}handleRotationChanged_(){this.rotateWithView_&&this.ovmap_.getView().setRotation(this.getMap().getView().getRotation())}validateExtent_(){const t=this.getMap(),e=this.ovmap_;if(!t.isRendered()||!e.isRendered())return;const i=t.getSize(),n=t.getView().calculateExtentInternal(i);if(this.viewExtent_&&de(n,this.viewExtent_))return;this.viewExtent_=n;const r=e.getSize(),s=e.getView().calculateExtentInternal(r),o=e.getPixelFromCoordinateInternal(Fe(n)),a=e.getPixelFromCoordinateInternal(Ee(n)),l=Math.abs(o[0]-a[0]),h=Math.abs(o[1]-a[1]),c=r[0],u=r[1];l<c*vR||h<u*vR||l>c*xR||h>u*xR?this.resetExtent_():re(s,n)||this.recenter_()}resetExtent_(){const t=this.getMap(),e=this.ovmap_,i=t.getSize(),n=t.getView().calculateExtentInternal(i),r=e.getView(),s=Math.log(7.5)/Math.LN2;De(n,1/(Math.pow(2,s/2)*vR)),r.fitInternal(Lr(n))}recenter_(){const t=this.getMap(),e=this.ovmap_,i=t.getView();e.getView().setCenterInternal(i.getCenterInternal())}updateBox_(){const t=this.getMap(),e=this.ovmap_;if(!t.isRendered()||!e.isRendered())return;const i=t.getSize(),n=t.getView(),r=e.getView(),s=this.rotateWithView_?0:-n.getRotation(),o=this.boxOverlay_,a=this.boxOverlay_.getElement(),l=n.getCenterInternal(),h=n.getResolution(),c=r.getResolution(),u=i[0]*h/c,d=i[1]*h/c;if(o.setPosition(l),a){a.style.width=u+"px",a.style.height=d+"px";const t="rotate("+s+"rad)";a.style.transform=t}}updateBoxAfterOvmapIsRendered_(){this.ovmapPostrenderKey_||(this.ovmapPostrenderKey_=k(this.ovmap_,$o,(function(t){delete this.ovmapPostrenderKey_,this.updateBox_()}),this))}handleClick_(t){t.preventDefault(),this.handleToggle_()}handleToggle_(){this.element.classList.toggle(go),this.collapsed_?wt(this.collapseLabel_,this.label_):wt(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_;const t=this.ovmap_;if(!this.collapsed_){if(t.isRendered())return this.viewExtent_=void 0,void t.render();t.updateSize(),this.resetExtent_(),this.updateBoxAfterOvmapIsRendered_()}}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),!t&&this.collapsed_&&this.handleToggle_())}setCollapsed(t){this.collapsible_&&this.collapsed_!==t&&this.handleToggle_()}getCollapsed(){return this.collapsed_}getRotateWithView(){return this.rotateWithView_}setRotateWithView(t){this.rotateWithView_!==t&&(this.rotateWithView_=t,0!==this.getMap().getView().getRotation()&&(this.rotateWithView_?this.handleRotationChanged_():this.ovmap_.getView().setRotation(0),this.viewExtent_=void 0,this.validateExtent_(),this.updateBox_()))}getOverviewMap(){return this.ovmap_}render(t){this.validateExtent_(),this.updateBox_()}};const wR="units",ER=[1,2,5],TR=25.4/.28;var CR=class extends ca{constructor(t){t=t||{};const e=document.createElement("div");e.style.pointerEvents="none",super({element:e,render:t.render,target:t.target}),this.on,this.once,this.un;const i=void 0!==t.className?t.className:t.bar?"ol-scale-bar":"ol-scale-line";this.innerElement_=document.createElement("div"),this.innerElement_.className=i+"-inner",this.element.className=i+" "+ho,this.element.appendChild(this.innerElement_),this.viewState_=null,this.minWidth_=void 0!==t.minWidth?t.minWidth:64,this.maxWidth_=t.maxWidth,this.renderedVisible_=!1,this.renderedWidth_=void 0,this.renderedHTML_="",this.addChangeListener(wR,this.handleUnitsChanged_),this.setUnits(t.units||"metric"),this.scaleBar_=t.bar||!1,this.scaleBarSteps_=t.steps||4,this.scaleBarText_=t.text||!1,this.dpi_=t.dpi||void 0}getUnits(){return this.get(wR)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(wR,t)}setDpi(t){this.dpi_=t}updateElement_(){const t=this.viewState_;if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=t.center,i=t.projection,n=this.getUnits(),r="degrees"==n?"degrees":"m";let s=rn(i,t.resolution,e,r);const o=this.minWidth_*(this.dpi_||TR)/TR,a=void 0!==this.maxWidth_?this.maxWidth_*(this.dpi_||TR)/TR:void 0;let l=o*s,h="";if("degrees"==n){const t=Xe.degrees;l*=t,l<t/60?(h="″",s*=3600):l<t?(h="",s*=60):h="°"}else"imperial"==n?l<.9144?(h="in",s/=.0254):l<1609.344?(h="ft",s/=.3048):(h="mi",s/=1609.344):"nautical"==n?(s/=1852,h="NM"):"metric"==n?l<.001?(h="μm",s*=1e6):l<1?(h="mm",s*=1e3):l<1e3?h="m":(h="km",s/=1e3):"us"==n?l<.9144?(h="in",s*=39.37):l<1609.344?(h="ft",s/=.30480061):(h="mi",s/=1609.3472):Mt(!1,33);let c,u,d,g,f,p,m=3*Math.floor(Math.log(o*s)/Math.log(10));for(;;){d=Math.floor(m/3);const t=Math.pow(10,d);if(c=ER[(m%3+3)%3]*t,u=Math.round(c/s),isNaN(u))return this.element.style.display="none",void(this.renderedVisible_=!1);if(void 0!==a&&u>=a){c=g,u=f,d=p;break}if(u>=o)break;g=c,f=u,p=d,++m}const _=this.scaleBar_?this.createScaleBar(u,c,h):c.toFixed(d<0?-d:0)+" "+h;this.renderedHTML_!=_&&(this.innerElement_.innerHTML=_,this.renderedHTML_=_),this.renderedWidth_!=u&&(this.innerElement_.style.width=u+"px",this.renderedWidth_=u),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(t,e,i){const n=this.getScaleForResolution(),r=n<1?Math.round(1/n).toLocaleString()+" : 1":"1 : "+Math.round(n).toLocaleString(),s=this.scaleBarSteps_,o=t/s,a=[this.createMarker("absolute")];for(let n=0;n<s;++n){const r=n%2==0?"ol-scale-singlebar-odd":"ol-scale-singlebar-even";a.push(`<div><div class="ol-scale-singlebar ${r}" style="width: ${o}px;"></div>`+this.createMarker("relative")+(n%2==0||2===s?this.createStepText(n,t,!1,e,i):"")+"</div>")}a.push(this.createStepText(s,t,!0,e,i));return(this.scaleBarText_?`<div class="ol-scale-text" style="width: ${t}px;">`+r+"</div>":"")+a.join("")}createMarker(t){return`<div class="ol-scale-step-marker" style="position: ${t}; top: ${"absolute"===t?3:-10}px;"></div>`}createStepText(t,e,i,n,r){const s=(0===t?0:Math.round(n/this.scaleBarSteps_*t*100)/100)+(0===t?"":" "+r);return`<div class="ol-scale-step-text" style="margin-left: ${0===t?-3:e/this.scaleBarSteps_*-1}px;text-align: ${0===t?"left":"center"};min-width: ${0===t?0:e/this.scaleBarSteps_*2}px;left: ${i?e+"px":"unset"};">`+s+"</div>"}getScaleForResolution(){return rn(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m")*(1e3/25.4)*(this.dpi_||TR)}render(t){const e=t.frameState;this.viewState_=e?e.viewState:null,this.updateElement_()}};const RR=0,bR=1;var PR=class extends ca{constructor(t){super({target:(t=t||{}).target,element:document.createElement("div"),render:t.render}),this.dragListenerKeys_=[],this.currentResolution_=void 0,this.direction_=RR,this.dragging_,this.heightLimit_=0,this.widthLimit_=0,this.startX_,this.startY_,this.thumbSize_=null,this.sliderInitialized_=!1,this.duration_=void 0!==t.duration?t.duration:200;const e=void 0!==t.className?t.className:"ol-zoomslider",i=document.createElement("button");i.setAttribute("type","button"),i.className=e+"-thumb "+ho;const r=this.element;r.className=e+" "+ho+" "+uo,r.appendChild(i),r.addEventListener(Yo,this.handleDraggerStart_.bind(this),!1),r.addEventListener(Zo,this.handleDraggerDrag_.bind(this),!1),r.addEventListener(Ko,this.handleDraggerEnd_.bind(this),!1),r.addEventListener(R,this.handleContainerClick_.bind(this),!1),i.addEventListener(R,n,!1)}setMap(t){super.setMap(t),t&&t.render()}initSlider_(){const t=this.element;let e=t.offsetWidth,i=t.offsetHeight;if(0===e&&0===i)return this.sliderInitialized_=!1;const n=getComputedStyle(t);e-=parseFloat(n.paddingRight)+parseFloat(n.paddingLeft),i-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom);const r=t.firstElementChild,s=getComputedStyle(r),o=r.offsetWidth+parseFloat(s.marginRight)+parseFloat(s.marginLeft),a=r.offsetHeight+parseFloat(s.marginTop)+parseFloat(s.marginBottom);return this.thumbSize_=[o,a],e>i?(this.direction_=bR,this.widthLimit_=e-o):(this.direction_=RR,this.heightLimit_=i-a),this.sliderInitialized_=!0}handleContainerClick_(t){const e=this.getMap().getView(),i=this.getRelativePosition_(t.offsetX-this.thumbSize_[0]/2,t.offsetY-this.thumbSize_[1]/2),n=this.getResolutionForPosition_(i),r=e.getConstrainedZoom(e.getZoomForResolution(n));e.animateInternal({zoom:r,duration:this.duration_,easing:rt})}handleDraggerStart_(t){if(!this.dragging_&&t.target===this.element.firstElementChild){const e=this.element.firstElementChild;if(this.getMap().getView().beginInteraction(),this.startX_=t.clientX-parseFloat(e.style.left),this.startY_=t.clientY-parseFloat(e.style.top),this.dragging_=!0,0===this.dragListenerKeys_.length){const t=this.handleDraggerDrag_,e=this.handleDraggerEnd_,i=this.getMap().getOwnerDocument();this.dragListenerKeys_.push(D(i,Zo,t,this),D(i,Ko,e,this))}}}handleDraggerDrag_(t){if(this.dragging_){const e=t.clientX-this.startX_,i=t.clientY-this.startY_,n=this.getRelativePosition_(e,i);this.currentResolution_=this.getResolutionForPosition_(n),this.getMap().getView().setResolution(this.currentResolution_)}}handleDraggerEnd_(t){if(this.dragging_){this.getMap().getView().endInteraction(),this.dragging_=!1,this.startX_=void 0,this.startY_=void 0,this.dragListenerKeys_.forEach(G),this.dragListenerKeys_.length=0}}setThumbPosition_(t){const e=this.getPositionForResolution_(t),i=this.element.firstElementChild;this.direction_==bR?i.style.left=this.widthLimit_*e+"px":i.style.top=this.heightLimit_*e+"px"}getRelativePosition_(t,e){let i;return i=this.direction_===bR?t/this.widthLimit_:e/this.heightLimit_,gi(i,0,1)}getResolutionForPosition_(t){return this.getMap().getView().getResolutionForValueFunction()(1-t)}getPositionForResolution_(t){return gi(1-this.getMap().getView().getValueForResolutionFunction()(t),0,1)}render(t){if(!t.frameState)return;if(!this.sliderInitialized_&&!this.initSlider_())return;const e=t.frameState.viewState.resolution;this.currentResolution_=e,this.setThumbPosition_(e)}};var IR=class extends ca{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target}),this.extent=t.extent?t.extent:null;const e=void 0!==t.className?t.className:"ol-zoom-extent",i=void 0!==t.label?t.label:"E",n=void 0!==t.tipLabel?t.tipLabel:"Fit to extent",r=document.createElement("button");r.setAttribute("type","button"),r.title=n,r.appendChild("string"==typeof i?document.createTextNode(i):i),r.addEventListener(R,this.handleClick_.bind(this),!1);const s=e+" "+ho+" "+uo,o=this.element;o.className=s,o.appendChild(r)}handleClick_(t){t.preventDefault(),this.handleZoomToExtent()}handleZoomToExtent(){const t=this.getMap().getView(),e=this.extent?this.extent:t.getProjection().getExtent();t.fitInternal(Lr(e))}},FR={};return FR.AssertionError=i,FR.Collection=$,FR.Collection.CollectionEvent=q,FR.DataTile=Lt,FR.DataTile.asArrayLike=bt,FR.DataTile.asImageLike=Rt,FR.DataTile.toArray=It,FR.Disposable=o,FR.Feature=Nt,FR.Feature.createStyleFunction=Ot,FR.Geolocation=Zr,FR.Geolocation.GeolocationError=Wr,FR.Image=ts,FR.Image.listenImage=Qr,FR.ImageBase=Yr,FR.ImageCanvas=es,FR.ImageTile=is,FR.Kinetic=ns,FR.Map=hl,FR.MapBrowserEvent=Vo,FR.MapBrowserEventHandler=qo,FR.MapEvent=Xo,FR.Object=Z,FR.Object.ObjectEvent=W,FR.Observable=U,FR.Observable.unByKey=B,FR.Overlay=pl,FR.Tile=at,FR.TileCache=Tl,FR.TileQueue=la,FR.TileQueue.getTilePriority=ha,FR.TileRange=bl,FR.TileRange.createOrUpdate=Rl,FR.VectorRenderTile=Il,FR.VectorTile=Fl,FR.View=eo,FR.View.createCenterConstraint=qs,FR.View.createResolutionConstraint=$s,FR.View.createRotationConstraint=Js,FR.View.isNoopAnimation=Qs,FR.array={},FR.array.ascending=l,FR.array.binarySearch=a,FR.array.descending=h,FR.array.equals=g,FR.array.extend=d,FR.array.isSorted=f,FR.array.linearFindNearest=c,FR.array.remove=function(t,e){const i=t.indexOf(e),n=i>-1;return n&&t.splice(i,1),n},FR.array.reverseSubArray=u,FR.array.stableSort=function(t,e){const i=t.length,n=Array(t.length);let r;for(r=0;r<i;r++)n[r]={index:r,value:t[r]};for(n.sort((function(t,i){return e(t.value,i.value)||t.index-i.index})),r=0;r<t.length;r++)t[r]=n[r].value},FR.asserts={},FR.asserts.assert=Mt,FR.centerconstraint={},FR.centerconstraint.createExtent=Gs,FR.centerconstraint.none=js,FR.color={},FR.color.asArray=hs,FR.color.asString=os,FR.color.fromString=ls,FR.color.isStringColor=ds,FR.color.normalize=cs,FR.color.toString=us,FR.colorlike={},FR.colorlike.asColorLike=Ll,FR.console={},FR.console.error=Hi,FR.console.log=function(...t){Yi>Zi.info||console.log(...t)},FR.console.setLevel=function(t){Yi=Zi[t]},FR.console.warn=Ki,FR.control={},FR.control.Attribution=ua,FR.control.Control=ca,FR.control.FullScreen=pR,FR.control.MousePosition=yR,FR.control.OverviewMap=SR,FR.control.Rotate=da,FR.control.ScaleLine=CR,FR.control.Zoom=ga,FR.control.ZoomSlider=PR,FR.control.ZoomToExtent=IR,FR.control.defaults={},FR.control.defaults.defaults=fa,FR.coordinate={},FR.coordinate.add=bi,FR.coordinate.closestOnCircle=Pi,FR.coordinate.closestOnSegment=Ii,FR.coordinate.createStringXY=function(t){return function(e){return Gi(e,t)}},FR.coordinate.degreesToStringHDMS=Fi,FR.coordinate.distance=Di,FR.coordinate.equals=Mi,FR.coordinate.format=Li,FR.coordinate.getWorldsAway=Bi,FR.coordinate.rotate=Ai,FR.coordinate.scale=Oi,FR.coordinate.squaredDistance=Ni,FR.coordinate.squaredDistanceToSegment=ki,FR.coordinate.toStringHDMS=function(t,e){return t?Fi("NS",t[1],e)+" "+Fi("EW",t[0],e):""},FR.coordinate.toStringXY=Gi,FR.coordinate.wrapX=ji,FR.css={},FR.css.CLASS_COLLAPSED=go,FR.css.CLASS_CONTROL=uo,FR.css.CLASS_HIDDEN=ao,FR.css.CLASS_SELECTABLE=lo,FR.css.CLASS_UNSELECTABLE=ho,FR.css.CLASS_UNSUPPORTED=co,FR.css.getFontParameters=mo,FR.dom={},FR.dom.createCanvasContext2D=yt,FR.dom.outerHeight=St,FR.dom.outerWidth=vt,FR.dom.releaseCanvas=xt,FR.dom.removeChildren=Tt,FR.dom.removeNode=Et,FR.dom.replaceChildren=Ct,FR.dom.replaceNode=wt,FR.easing={},FR.easing.easeIn=nt,FR.easing.easeOut=rt,FR.easing.inAndOut=st,FR.easing.linear=ot,FR.easing.upAndDown=function(t){return t<.5?st(2*t):1-st(2*(t-.5))},FR.events={},FR.events.Event=r,FR.events.Event.preventDefault=function(t){t.preventDefault()},FR.events.Event.stopPropagation=n,FR.events.SnapEvent={},FR.events.SnapEvent.SnapEvent=Hy,FR.events.Target=w,FR.events.condition={},FR.events.condition.all=wa,FR.events.condition.altKeyOnly=Ea,FR.events.condition.altShiftKeysOnly=Ta,FR.events.condition.always=ba,FR.events.condition.click=function(t){return t.type==Wo.CLICK},FR.events.condition.doubleClick=function(t){return t.type==Wo.DBLCLICK},FR.events.condition.focus=Ca,FR.events.condition.focusWithTabindex=Ra,FR.events.condition.mouseActionButton=Pa,FR.events.condition.mouseOnly=Na,FR.events.condition.never=Ia,FR.events.condition.noModifierKeys=La,FR.events.condition.penOnly=function(t){const e=t.originalEvent;return Mt(void 0!==e,56),"pen"===e.pointerType},FR.events.condition.platformModifierKey=Ma,FR.events.condition.platformModifierKeyOnly=function(t){const e=t.originalEvent;return!e.altKey&&(gt?e.metaKey:e.ctrlKey)&&!e.shiftKey},FR.events.condition.pointerMove=function(t){return"pointermove"==t.type},FR.events.condition.primaryAction=Da,FR.events.condition.shiftKeyOnly=Aa,FR.events.condition.singleClick=Fa,FR.events.condition.targetNotEditable=Oa,FR.events.condition.touchOnly=function(t){const e=t.originalEvent;return Mt(void 0!==e,56),"touch"===e.pointerType},FR.events.listen=D,FR.events.listenOnce=k,FR.events.unlistenByKey=G,FR.extent={},FR.extent.applyTransform=Ge,FR.extent.approximatelyEquals=ge,FR.extent.boundingExtent=Qt,FR.extent.buffer=te,FR.extent.clone=ee,FR.extent.closestSquaredDistanceXY=ie,FR.extent.containsCoordinate=ne,FR.extent.containsExtent=re,FR.extent.containsXY=se,FR.extent.coordinateRelationship=oe,FR.extent.createEmpty=ae,FR.extent.createOrUpdate=le,FR.extent.createOrUpdateEmpty=he,FR.extent.createOrUpdateFromCoordinate=ce,FR.extent.createOrUpdateFromCoordinates=function(t,e){return me(he(e),t)},FR.extent.createOrUpdateFromFlatCoordinates=ue,FR.extent.createOrUpdateFromRings=function(t,e){return ye(he(e),t)},FR.extent.equals=de,FR.extent.extend=fe,FR.extent.extendCoordinate=pe,FR.extent.extendCoordinates=me,FR.extent.extendFlatCoordinates=_e,FR.extent.extendRings=ye,FR.extent.extendXY=xe,FR.extent.forEachCorner=ve,FR.extent.getArea=Se,FR.extent.getBottomLeft=we,FR.extent.getBottomRight=Ee,FR.extent.getCenter=Te,FR.extent.getCorner=Ce,FR.extent.getEnlargedArea=function(t,e){const i=Math.min(t[0],e[0]),n=Math.min(t[1],e[1]);return(Math.max(t[2],e[2])-i)*(Math.max(t[3],e[3])-n)},FR.extent.getForViewAndSize=Re,FR.extent.getHeight=Pe,FR.extent.getIntersection=Ie,FR.extent.getIntersectionArea=function(t,e){return Se(Ie(t,e))},FR.extent.getMargin=function(t){return Me(t)+Pe(t)},FR.extent.getRotatedViewport=be,FR.extent.getSize=function(t){return[t[2]-t[0],t[3]-t[1]]},FR.extent.getTopLeft=Fe,FR.extent.getTopRight=Le,FR.extent.getWidth=Me,FR.extent.intersects=Ae,FR.extent.intersectsSegment=ke,FR.extent.isEmpty=Oe,FR.extent.returnOrUpdate=Ne,FR.extent.scaleFromCenter=De,FR.extent.wrapAndSliceX=Be,FR.extent.wrapX=je,FR.featureloader={},FR.featureloader.loadFeaturesXhr=Ol,FR.featureloader.setWithCredentials=function(t){Al=t},FR.featureloader.xhr=Nl,FR.format={},FR.format.EsriJSON=gx,FR.format.Feature=__,FR.format.Feature.transformExtentWithOptions=x_,FR.format.Feature.transformGeometryWithOptions=y_,FR.format.GML=zx,FR.format.GML2=Dx,FR.format.GML3=Bx,FR.format.GML32=Vx,FR.format.GMLBase=yx,FR.format.GMLBase.GMLNS=px,FR.format.GPX=Tv,FR.format.GeoJSON=bv,FR.format.IGC=Ov,FR.format.IIIFInfo=Gc,FR.format.JSONFeature=ox,FR.format.KML=Nw,FR.format.KML.getDefaultFillStyle=function(){return $v},FR.format.KML.getDefaultImageStyle=function(){return Qv},FR.format.KML.getDefaultStrokeStyle=function(){return eS},FR.format.KML.getDefaultStyle=function(){return nS},FR.format.KML.getDefaultStyleArray=function(){return sS},FR.format.KML.getDefaultTextStyle=function(){return iS},FR.format.KML.readFlatCoordinates=cS,FR.format.MVT=Y_,FR.format.OSMXML=Uw,FR.format.OWS=oE,FR.format.Polyline=mE,FR.format.Polyline.decodeDeltas=lE,FR.format.Polyline.decodeFloats=cE,FR.format.Polyline.decodeSignedIntegers=dE,FR.format.Polyline.decodeUnsignedIntegers=fE,FR.format.Polyline.encodeDeltas=aE,FR.format.Polyline.encodeFloats=hE,FR.format.Polyline.encodeSignedIntegers=uE,FR.format.Polyline.encodeUnsignedInteger=pE,FR.format.Polyline.encodeUnsignedIntegers=gE,FR.format.TextFeature=Iv,FR.format.TopoJSON=EE,FR.format.WFS=UT,FR.format.WFS.writeFilter=function(t,e){const i=hd(BT(e=e||"1.1.0"),"Filter"),n={node:i};return Object.assign(n,{version:e,filter:t}),TT(i,t,[n]),i},FR.format.WKB=eC,FR.format.WKT=SC,FR.format.WMSCapabilities=WC,FR.format.WMSGetFeatureInfo=ZC,FR.format.WMTSCapabilities=lR,FR.format.XML=zw,FR.format.XMLFeature=fx,FR.format.filter={},FR.format.filter.And=RE,FR.format.filter.Bbox=bE,FR.format.filter.Comparison=ME,FR.format.filter.ComparisonBinary=OE,FR.format.filter.Contains=IE,FR.format.filter.DWithin=FE,FR.format.filter.Disjoint=LE,FR.format.filter.During=AE,FR.format.filter.EqualTo=NE,FR.format.filter.Filter=TE,FR.format.filter.GreaterThan=DE,FR.format.filter.GreaterThanOrEqualTo=kE,FR.format.filter.Intersects=GE,FR.format.filter.IsBetween=jE,FR.format.filter.IsLike=BE,FR.format.filter.IsNull=UE,FR.format.filter.LessThan=zE,FR.format.filter.LessThanOrEqualTo=XE,FR.format.filter.LogicalNary=CE,FR.format.filter.Not=VE,FR.format.filter.NotEqualTo=WE,FR.format.filter.Or=ZE,FR.format.filter.ResourceId=YE,FR.format.filter.Spatial=PE,FR.format.filter.Within=KE,FR.format.filter.and=HE,FR.format.filter.bbox=qE,FR.format.filter.between=function(t,e,i){return new jE(t,e,i)},FR.format.filter.contains=function(t,e,i){return new IE(t,e,i)},FR.format.filter.disjoint=function(t,e,i){return new LE(t,e,i)},FR.format.filter.during=function(t,e,i){return new AE(t,e,i)},FR.format.filter.dwithin=function(t,e,i,n,r){return new FE(t,e,i,n,r)},FR.format.filter.equalTo=function(t,e,i){return new NE(t,e,i)},FR.format.filter.greaterThan=function(t,e){return new DE(t,e)},FR.format.filter.greaterThanOrEqualTo=function(t,e){return new kE(t,e)},FR.format.filter.intersects=function(t,e,i){return new GE(t,e,i)},FR.format.filter.isNull=function(t){return new UE(t)},FR.format.filter.lessThan=function(t,e){return new zE(t,e)},FR.format.filter.lessThanOrEqualTo=function(t,e){return new XE(t,e)},FR.format.filter.like=function(t,e,i,n,r,s){return new BE(t,e,i,n,r,s)},FR.format.filter.not=function(t){return new VE(t)},FR.format.filter.notEqualTo=function(t,e,i){return new WE(t,e,i)},FR.format.filter.or=function(t){const e=[null].concat(Array.prototype.slice.call(arguments));return new(Function.prototype.bind.apply(ZE,e))},FR.format.filter.resourceId=function(t){return new YE(t)},FR.format.filter.within=function(t,e,i){return new KE(t,e,i)},FR.format.xlink={},FR.format.xlink.readHref=Vw,FR.format.xsd={},FR.format.xsd.readBoolean=xx,FR.format.xsd.readBooleanString=vx,FR.format.xsd.readDateTime=Sx,FR.format.xsd.readDecimal=wx,FR.format.xsd.readDecimalString=Ex,FR.format.xsd.readNonNegativeIntegerString=Cx,FR.format.xsd.readPositiveInteger=Tx,FR.format.xsd.readString=Rx,FR.format.xsd.writeBooleanTextNode=bx,FR.format.xsd.writeCDATASection=Px,FR.format.xsd.writeDateTimeTextNode=Ix,FR.format.xsd.writeDecimalTextNode=Fx,FR.format.xsd.writeNonNegativeIntegerTextNode=Lx,FR.format.xsd.writeStringTextNode=Mx,FR.functions={},FR.functions.FALSE=m,FR.functions.TRUE=p,FR.functions.VOID=_,FR.functions.memoizeOne=y,FR.functions.toPromise=x,FR.geom={},FR.geom.Circle=Dm,FR.geom.Geometry=Ln,FR.geom.GeometryCollection=jm,FR.geom.LineString=Vm,FR.geom.LinearRing=or,FR.geom.MultiLineString=Zm,FR.geom.MultiPoint=Km,FR.geom.MultiPolygon=$m,FR.geom.Point=lr,FR.geom.Polygon=Ir,FR.geom.Polygon.circular=Fr,FR.geom.Polygon.fromCircle=Mr,FR.geom.Polygon.fromExtent=Lr,FR.geom.Polygon.makeRegular=Ar,FR.geom.SimpleGeometry=On,FR.geom.SimpleGeometry.getStrideForLayout=Mn,FR.geom.SimpleGeometry.transformGeom2D=An,FR.geom.flat={},FR.geom.flat.area={},FR.geom.flat.area.linearRing=ir,FR.geom.flat.area.linearRings=nr,FR.geom.flat.area.linearRingss=rr,FR.geom.flat.center={},FR.geom.flat.center.linearRingss=Hm,FR.geom.flat.closest={},FR.geom.flat.closest.arrayMaxSquaredDelta=kn,FR.geom.flat.closest.assignClosestArrayPoint=Bn,FR.geom.flat.closest.assignClosestMultiArrayPoint=Un,FR.geom.flat.closest.assignClosestPoint=jn,FR.geom.flat.closest.maxSquaredDelta=Dn,FR.geom.flat.closest.multiArrayMaxSquaredDelta=Gn,FR.geom.flat.contains={},FR.geom.flat.contains.linearRingContainsExtent=hr,FR.geom.flat.contains.linearRingContainsXY=cr,FR.geom.flat.contains.linearRingsContainsXY=ur,FR.geom.flat.contains.linearRingssContainsXY=dr,FR.geom.flat.deflate={},FR.geom.flat.deflate.deflateCoordinate=zn,FR.geom.flat.deflate.deflateCoordinates=Xn,FR.geom.flat.deflate.deflateCoordinatesArray=Vn,FR.geom.flat.deflate.deflateMultiCoordinatesArray=Wn,FR.geom.flat.flip={},FR.geom.flat.flip.flipXY=rx,FR.geom.flat.geodesic={},FR.geom.flat.geodesic.greatCircleArc=function(t,e,i,n,r,s){const o=nn("EPSG:4326"),a=Math.cos(yi(e)),l=Math.sin(yi(e)),h=Math.cos(yi(n)),c=Math.sin(yi(n)),u=Math.cos(yi(i-t)),d=Math.sin(yi(i-t)),g=l*c+a*h*u;return o_((function(e){if(1<=g)return[i,n];const r=e*Math.acos(g),s=Math.cos(r),o=Math.sin(r),f=d*h,p=a*c-l*h*u,m=Math.atan2(f,p),_=Math.asin(l*s+a*o*Math.cos(m));return[_i(yi(t)+Math.atan2(Math.sin(m)*o*a,s-l*Math.sin(_))),_i(_)]}),dn(o,r),s)},FR.geom.flat.geodesic.meridian=a_,FR.geom.flat.geodesic.parallel=l_,FR.geom.flat.inflate={},FR.geom.flat.inflate.inflateCoordinates=Qn,FR.geom.flat.inflate.inflateCoordinatesArray=tr,FR.geom.flat.inflate.inflateMultiCoordinatesArray=er,FR.geom.flat.interiorpoint={},FR.geom.flat.interiorpoint.getInteriorPointOfArray=gr,FR.geom.flat.interiorpoint.getInteriorPointsOfMultiArray=fr,FR.geom.flat.interpolate={},FR.geom.flat.interpolate.interpolatePoint=Bm,FR.geom.flat.interpolate.lineStringCoordinateAtM=Um,FR.geom.flat.interpolate.lineStringsCoordinateAtM=zm,FR.geom.flat.intersectsextent={},FR.geom.flat.intersectsextent.intersectsLineString=mr,FR.geom.flat.intersectsextent.intersectsLineStringArray=_r,FR.geom.flat.intersectsextent.intersectsLinearRing=yr,FR.geom.flat.intersectsextent.intersectsLinearRingArray=xr,FR.geom.flat.intersectsextent.intersectsLinearRingMultiArray=vr,FR.geom.flat.length={},FR.geom.flat.length.lineStringLength=dm,FR.geom.flat.length.linearRingLength=function(t,e,i,n){let r=dm(t,e,i,n);const s=t[i-n]-t[e],o=t[i-n+1]-t[e+1];return r+=Math.sqrt(s*s+o*o),r},FR.geom.flat.orient={},FR.geom.flat.orient.inflateEnds=br,FR.geom.flat.orient.linearRingIsClockwise=wr,FR.geom.flat.orient.linearRingsAreOriented=Er,FR.geom.flat.orient.linearRingssAreOriented=Tr,FR.geom.flat.orient.orientLinearRings=Cr,FR.geom.flat.orient.orientLinearRingsArray=Rr,FR.geom.flat.reverse={},FR.geom.flat.reverse.coordinates=Sr,FR.geom.flat.segments={},FR.geom.flat.segments.forEach=pr,FR.geom.flat.simplify={},FR.geom.flat.simplify.douglasPeucker=Zn,FR.geom.flat.simplify.douglasPeuckerArray=Yn,FR.geom.flat.simplify.douglasPeuckerMultiArray=function(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;l<h;++l){const h=i[l],c=[];o=Yn(t,e,h,n,r,s,o,c),a.push(c),e=h[h.length-1]}return o},FR.geom.flat.simplify.quantize=qn,FR.geom.flat.simplify.quantizeArray=$n,FR.geom.flat.simplify.quantizeMultiArray=Jn,FR.geom.flat.simplify.radialDistance=Kn,FR.geom.flat.simplify.simplifyLineString=function(t,e,i,n,r,s,o){return o=void 0!==o?o:[],s||(i=Kn(t,e,i,n,r,o,0),t=o,e=0,n=2),o.length=Zn(t,e,i,n,r,o,0),o},FR.geom.flat.simplify.snap=Hn,FR.geom.flat.straightchunk={},FR.geom.flat.straightchunk.matchingChunk=om,FR.geom.flat.textpath={},FR.geom.flat.textpath.drawTextOnPath=um,FR.geom.flat.topology={},FR.geom.flat.topology.lineStringIsClosed=function(t,e,i,n){const r=i-n;return t[e]===t[r]&&t[e+1]===t[r+1]&&(i-e)/n>3&&!!ir(t,e,i,n)},FR.geom.flat.transform={},FR.geom.flat.transform.rotate=bn,FR.geom.flat.transform.scale=Pn,FR.geom.flat.transform.transform2D=Rn,FR.geom.flat.transform.translate=In,FR.has={},FR.has.DEVICE_PIXEL_RATIO=ft,FR.has.FIREFOX=ht,FR.has.IMAGE_DECODE=mt,FR.has.MAC=gt,FR.has.PASSIVE_EVENT_LISTENERS=_t,FR.has.SAFARI=ct,FR.has.SAFARI_BUG_237906=ut,FR.has.WEBKIT=dt,FR.has.WORKER_OFFSCREEN_CANVAS=pt,FR.interaction={},FR.interaction.DblClickDragZoom=iy,FR.interaction.DoubleClickZoom=xa,FR.interaction.DragAndDrop=sy,FR.interaction.DragAndDrop.DragAndDropEvent=ry,FR.interaction.DragBox=Wa,FR.interaction.DragBox.DragBoxEvent=Va,FR.interaction.DragPan=ka,FR.interaction.DragRotate=Ga,FR.interaction.DragRotateAndZoom=oy,FR.interaction.DragZoom=Za,FR.interaction.Draw=Sy,FR.interaction.Draw.DrawEvent=cy,FR.interaction.Draw.createBox=function(){return function(t,e,i){const n=Qt([t[0],t[t.length-1]].map((function(t){return xn(t,i)}))),r=[[we(n),Ee(n),Le(n),Fe(n),we(n)]];e?e.setCoordinates(r):e=new Ir(r);const s=_n();return s&&e.transform(i,s),e}},FR.interaction.Draw.createRegularPolygon=function(t,e){return function(i,n,r){const s=xn(i[0],r),o=xn(i[i.length-1],r),a=Math.sqrt(Ni(s,o));n=n||Mr(new Dm(s),t);let l=e;if(!e&&0!==e){const t=o[0]-s[0],e=o[1]-s[1];l=Math.atan2(e,t)}Ar(n,s,a,l);const h=_n();return h&&n.transform(r,h),n}},FR.interaction.Extent=Py,FR.interaction.Extent.ExtentEvent=Ey,FR.interaction.Interaction=ya,FR.interaction.Interaction.pan=ma,FR.interaction.Interaction.zoomByDelta=_a,FR.interaction.KeyboardPan=$a,FR.interaction.KeyboardZoom=Ja,FR.interaction.Link=My,FR.interaction.Modify=zy,FR.interaction.Modify.ModifyEvent=ky,FR.interaction.MouseWheelZoom=Qa,FR.interaction.PinchRotate=tl,FR.interaction.PinchZoom=el,FR.interaction.Pointer=Sa,FR.interaction.Pointer.centroid=va,FR.interaction.Select=Yy,FR.interaction.Select.SelectEvent=Vy,FR.interaction.Snap=Jy,FR.interaction.Translate=nx,FR.interaction.Translate.TranslateEvent=ix,FR.interaction.defaults={},FR.interaction.defaults.defaults=il,FR.layer={},FR.layer.Base=bs,FR.layer.BaseImage=fu,FR.layer.BaseTile=Eu,FR.layer.BaseVector=Df,FR.layer.Graticule=u_,FR.layer.Group=zo,FR.layer.Group.GroupEvent=jo,FR.layer.Heatmap=m_,FR.layer.Image=vu,FR.layer.Layer=no,FR.layer.Layer.inView=io,FR.layer.MapboxVector=q_,FR.layer.Tile=Cu,FR.layer.Vector=s_,FR.layer.VectorImage=$_,FR.layer.VectorTile=K_,FR.layer.WebGLPoints=J_,FR.layer.WebGLTile=ey,FR.loadingstrategy={},FR.loadingstrategy.all=Dl,FR.loadingstrategy.bbox=function(t,e){return[t]},FR.loadingstrategy.tile=function(t){return function(e,i,n){const r=t.getZForResolution(En(i,n)),s=t.getTileRangeForExtentAndZ(Sn(e,n),r),o=[],a=[r,0,0];for(a[1]=s.minX;a[1]<=s.maxX;++a[1])for(a[2]=s.minY;a[2]<=s.maxY;++a[2])o.push(vn(t.getTileCoordExtent(a),n));return o}},FR.math={},FR.math.ceil=Ti,FR.math.clamp=gi,FR.math.floor=Ei,FR.math.lerp=vi,FR.math.modulo=xi,FR.math.round=wi,FR.math.solveLinearSystem=mi,FR.math.squaredDistance=pi,FR.math.squaredSegmentDistance=fi,FR.math.toDegrees=_i,FR.math.toFixed=Si,FR.math.toRadians=yi,FR.net={},FR.net.ClientError=jl,FR.net.ResponseError=Gl,FR.net.getJSON=Bl,FR.net.jsonp=kl,FR.net.overrideXHR=function(t){"undefined"!=typeof XMLHttpRequest&&(Ml=XMLHttpRequest),global.XMLHttpRequest=t},FR.net.resolveUrl=Ul,FR.net.restoreXHR=function(){global.XMLHttpRequest=Ml},FR.obj={},FR.obj.clear=v,FR.obj.isEmpty=S,FR.proj={},FR.proj.Projection=Ve,FR.proj.Units={},FR.proj.Units.METERS_PER_UNIT=Xe,FR.proj.Units.fromCode=ze,FR.proj.addCommon=Cn,FR.proj.addCoordinateTransforms=hn,FR.proj.addEquivalentProjections=sn,FR.proj.addEquivalentTransforms=on,FR.proj.addProjection=tn,FR.proj.addProjections=en,FR.proj.clearAllProjections=function(){oi(),ci()},FR.proj.clearUserProjection=function(){pn=null},FR.proj.cloneTransform=Ji,FR.proj.createProjection=an,FR.proj.createSafeCoordinateTransform=Tn,FR.proj.createTransformFromCoordinateTransform=ln,FR.proj.disableCoordinateWarning=$i,FR.proj.epsg3857={},FR.proj.epsg3857.EXTENT=Ye,FR.proj.epsg3857.HALF_SIZE=Ze,FR.proj.epsg3857.MAX_SAFE_Y=He,FR.proj.epsg3857.PROJECTIONS=$e,FR.proj.epsg3857.RADIUS=We,FR.proj.epsg3857.WORLD_EXTENT=Ke,FR.proj.epsg3857.fromEPSG4326=Je,FR.proj.epsg3857.toEPSG4326=Qe,FR.proj.epsg4326={},FR.proj.epsg4326.EXTENT=ei,FR.proj.epsg4326.METERS_PER_UNIT=ii,FR.proj.epsg4326.PROJECTIONS=ri,FR.proj.epsg4326.RADIUS=ti,FR.proj.equivalent=cn,FR.proj.fromLonLat=function(t,e){return $i(),gn(t,"EPSG:4326",void 0!==e?e:"EPSG:3857")},FR.proj.fromUserCoordinate=xn,FR.proj.fromUserExtent=Sn,FR.proj.fromUserResolution=En,FR.proj.get=nn,FR.proj.getPointResolution=rn,FR.proj.getTransform=dn,FR.proj.getTransformFromProjections=un,FR.proj.getUserProjection=_n,FR.proj.identityTransform=Qi,FR.proj.proj4={},FR.proj.proj4.epsgLookupMapTiler=function(t){return async function(e){const i=await fetch(`https://api.maptiler.com/coordinates/search/code:${e}.json?transformations=true&exports=true&key=${t}`);if(!i.ok)throw new Error(`Unexpected response from maptiler.com: ${i.status}`);return i.json().then((t=>{const i=t.results;if(i?.length>0){const t=i.filter((t=>"EPSG"===t.id?.authority&&t.id?.code===e))[0];if(t){const e=t.transformations;if(e?.length>0){const i=t.default_transformation;if(e.filter((t=>t.id?.authority===i?.authority&&t.id?.code===i?.code&&0===t.grids?.length)).length>0)return t.exports?.proj4;const n=e.filter((t=>0===t.grids?.length&&"EPSG"===t.target_crs?.authority&&4326===t.target_crs?.code&&!1===t.deprecated&&!0===t.usable)).sort(((t,e)=>t.accuracy-e.accuracy))[0]?.exports?.proj4;if(n)return n}return t.exports?.proj4}}}))}},FR.proj.proj4.fromEPSGCode=async function(t){"string"==typeof t&&(t=parseInt(t.split(":").pop(),10));const e=i_;if(!e)throw new Error("Proj4 must be registered first with register(proj4)");const i="EPSG:"+t;return e.defs(i)||(e.defs(i,await r_(t)),n_(e)),nn(i)},FR.proj.proj4.getEPSGLookup=function(){return r_},FR.proj.proj4.isRegistered=function(){return!!i_},FR.proj.proj4.register=n_,FR.proj.proj4.setEPSGLookup=function(t){r_=t},FR.proj.proj4.unregister=function(){i_=null},FR.proj.projections={},FR.proj.projections.add=li,FR.proj.projections.clear=oi,FR.proj.projections.get=ai,FR.proj.setUserProjection=mn,FR.proj.toLonLat=function(t,e){const i=gn(t,void 0!==e?e:"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=xi(n+180,360)-180),i},FR.proj.toUserCoordinate=yn,FR.proj.toUserExtent=vn,FR.proj.toUserResolution=wn,FR.proj.transform=gn,FR.proj.transformExtent=fn,FR.proj.transformWithProjections=function(t,e,i){return un(e,i)(t)},FR.proj.transforms={},FR.proj.transforms.add=ui,FR.proj.transforms.clear=ci,FR.proj.transforms.get=di,FR.proj.transforms.remove=function(t,e){const i=t.getCode(),n=e.getCode(),r=hi[i][n];return delete hi[i][n],S(hi[i])&&delete hi[i],r},FR.proj.useGeographic=function(){mn("EPSG:4326")},FR.render={},FR.render.Box=ja,FR.render.Event=oo,FR.render.Feature=e_,FR.render.Feature.toFeature=function(t,e){const i=t.getId(),n=t_(t),r=t.getProperties(),s=new Nt;return void 0!==e&&s.setGeometryName(e),s.setGeometry(n),void 0!==i&&s.setId(i),s.setProperties(r,!0),s},FR.render.Feature.toGeometry=t_,FR.render.VectorContext=zl,FR.render.canvas={},FR.render.canvas.Builder=em,FR.render.canvas.BuilderGroup=cm,FR.render.canvas.Executor=wm,FR.render.canvas.ExecutorGroup=Rm,FR.render.canvas.ExecutorGroup.getPixelIndexArray=Cm,FR.render.canvas.ImageBuilder=im,FR.render.canvas.Immediate=Xl,FR.render.canvas.Instruction={},FR.render.canvas.Instruction.beginPathInstruction=Qp,FR.render.canvas.Instruction.closePathInstruction=tm,FR.render.canvas.Instruction.fillInstruction=$p,FR.render.canvas.Instruction.strokeInstruction=Jp,FR.render.canvas.LineStringBuilder=nm,FR.render.canvas.PolygonBuilder=rm,FR.render.canvas.TextBuilder=lm,FR.render.canvas.TextBuilder.TEXT_ALIGN=am,FR.render.canvas.checkedFonts=bo,FR.render.canvas.defaultFillStyle=yo,FR.render.canvas.defaultFont=_o,FR.render.canvas.defaultLineCap=xo,FR.render.canvas.defaultLineDash=vo,FR.render.canvas.defaultLineDashOffset=0,FR.render.canvas.defaultLineJoin=So,FR.render.canvas.defaultLineWidth=1,FR.render.canvas.defaultMiterLimit=wo,FR.render.canvas.defaultPadding=Ro,FR.render.canvas.defaultStrokeStyle=Eo,FR.render.canvas.defaultTextAlign=To,FR.render.canvas.defaultTextBaseline=Co,FR.render.canvas.drawImageOrLabel=ko,FR.render.canvas.getTextDimensions=Do,FR.render.canvas.hitdetect={},FR.render.canvas.hitdetect.HIT_DETECT_RESOLUTION=bm,FR.render.canvas.hitdetect.createHitDetectionImageData=Pm,FR.render.canvas.hitdetect.hitDetect=Im,FR.render.canvas.measureAndCacheTextWidth=No,FR.render.canvas.measureTextHeight=Mo,FR.render.canvas.measureTextWidth=Oo,FR.render.canvas.registerFont=Lo,FR.render.canvas.rotateAtOffset=function(t,e,i,n){0!==e&&(t.translate(i,n),t.rotate(e),t.translate(-i,-n))},FR.render.canvas.textHeights=Fo,FR.render.getRenderPixel=function(t,e){return zt(t.inversePixelTransform,e.slice(0))},FR.render.getVectorContext=$l,FR.render.toContext=function(t,e){const i=t.canvas,n=(e=e||{}).pixelRatio||ft,r=e.size;r&&(i.width=r[0]*n,i.height=r[1]*n,i.style.width=r[0]+"px",i.style.height=r[1]+"px");const s=[0,0,i.width,i.height],o=Vt([1,0,0,1,0,0],n,n);return new Xl(t,n,s,o,0)},FR.render.webgl={},FR.render.webgl.MixedGeometryBatch=bf,FR.render.webgl.VectorStyleRenderer=Op,FR.render.webgl.renderinstructions={},FR.render.webgl.renderinstructions.generateLineStringRenderInstructions=Cp,FR.render.webgl.renderinstructions.generatePointRenderInstructions=Tp,FR.render.webgl.renderinstructions.generatePolygonRenderInstructions=Rp,FR.render.webgl.renderinstructions.getCustomAttributesSize=Ep,FR.render.webgl.utils={},FR.render.webgl.utils.colorDecodeId=xp,FR.render.webgl.utils.colorEncodeId=yp,FR.render.webgl.utils.getBlankImageData=function(){const t=document.createElement("canvas").getContext("2d").createImageData(1,1);return t.data[0]=255,t.data[1]=255,t.data[2]=255,t.data[3]=255,t},FR.render.webgl.utils.writeLineSegmentToBuffers=function(t,e,i,n,r,s,o,a,l,h){const c=5+a.length,u=s.length/c,d=[t[e+0],t[e+1]],g=[t[i],t[i+1]],f=zt(h,[...d]),p=zt(h,[...g]);function m(t,e,i){const n=1e4;return Math.round(1500*e)+Math.round(1500*i)*n+t*n*n}function _(t,e,i){const n=Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])),r=[(e[0]-t[0])/n,(e[1]-t[1])/n],s=[-r[1],r[0]],o=Math.sqrt((i[0]-t[0])*(i[0]-t[0])+(i[1]-t[1])*(i[1]-t[1])),a=[(i[0]-t[0])/o,(i[1]-t[1])/o],l=0===n||0===o?0:Math.acos(gi(a[0]*r[0]+a[1]*r[1],-1,1));return a[0]*s[0]+a[1]*s[1]>0?l:2*Math.PI-l}const y=null!==r;let x=0,v=0;if(null!==n){x=_(f,p,zt(h,[...[t[n],t[n+1]]]))}if(y){v=_(p,f,zt(h,[...[t[r],t[r+1]]]))}s.push(d[0],d[1],g[0],g[1],m(0,x,v)),s.push(...a),s.push(d[0],d[1],g[0],g[1],m(1,x,v)),s.push(...a),s.push(d[0],d[1],g[0],g[1],m(2,x,v)),s.push(...a),s.push(d[0],d[1],g[0],g[1],m(3,x,v)),s.push(...a),o.push(u,u+1,u+2,u+1,u+3,u+2)},FR.render.webgl.utils.writePointFeatureToBuffers=function(t,e,i,n,r,s){const o=3+r,a=t[e+0],l=t[e+1],h=pp;h.length=r;for(let i=0;i<h.length;i++)h[i]=t[e+2+i];let c=s?s.vertexPosition:0,u=s?s.indexPosition:0;const d=c/o;return _p(i,c,a,l,0),h.length&&i.set(h,c+3),c+=o,_p(i,c,a,l,1),h.length&&i.set(h,c+3),c+=o,_p(i,c,a,l,2),h.length&&i.set(h,c+3),c+=o,_p(i,c,a,l,3),h.length&&i.set(h,c+3),c+=o,n[u++]=d,n[u++]=d+1,n[u++]=d+3,n[u++]=d+1,n[u++]=d+2,n[u++]=d+3,mp.vertexPosition=c,mp.indexPosition=u,mp},FR.render.webgl.utils.writePolygonTrianglesToBuffers=function(t,e,i,n,r){const s=2+r;let o=e;const a=t.slice(o,o+r);o+=r;const l=t[o++];let h=0;const c=new Array(l-1);for(let e=0;e<l;e++)h+=t[o++],e<l-1&&(c[e]=h);const u=t.slice(o,o+2*h),d=fp(u,c,2);for(let t=0;t<d.length;t++)n.push(d[t]+i.length/s);for(let t=0;t<u.length;t+=2)i.push(u[t],u[t+1],...a);return o+2*h},FR.renderer={},FR.renderer.Composite=Go,FR.renderer.Layer=pu,FR.renderer.Map=so,FR.renderer.canvas={},FR.renderer.canvas.ImageLayer=xu,FR.renderer.canvas.Layer=yu,FR.renderer.canvas.Layer.canvasPool=mu,FR.renderer.canvas.TileLayer=Tu,FR.renderer.canvas.VectorImageLayer=Lm,FR.renderer.canvas.VectorLayer=Fm,FR.renderer.canvas.VectorTileLayer=Om,FR.renderer.vector={},FR.renderer.vector.defaultOrder=Zl,FR.renderer.vector.getSquaredTolerance=Yl,FR.renderer.vector.getTolerance=Kl,FR.renderer.vector.renderFeature=Hl,FR.renderer.webgl={},FR.renderer.webgl.Layer=sg,FR.renderer.webgl.PointsLayer=Sp,FR.renderer.webgl.TileLayer=_g,FR.renderer.webgl.TileLayer.Attributes=pg,FR.renderer.webgl.TileLayer.Uniforms=fg,FR.renderer.webgl.TileLayerBase=gg,FR.renderer.webgl.TileLayerBase.Uniforms=og,FR.renderer.webgl.TileLayerBase.getCacheKey=dg,FR.renderer.webgl.TileLayerBase.newTileRepresentationLookup=lg,FR.renderer.webgl.VectorLayer=Dp,FR.renderer.webgl.VectorLayer.Uniforms=Np,FR.renderer.webgl.VectorTileLayer=kp,FR.reproj={},FR.reproj.DataTile=dc,FR.reproj.Image=Uc,FR.reproj.Tile=ah,FR.reproj.Triangulation=oh,FR.reproj.calculateSourceExtentResolution=nh,FR.reproj.calculateSourceResolution=ih,FR.reproj.canvasPool=Ql,FR.reproj.common={},FR.reproj.common.ERROR_THRESHOLD=sh,FR.reproj.render=rh,FR.resolutionconstraint={},FR.resolutionconstraint.createMinMaxResolution=Vs,FR.resolutionconstraint.createSnapToPower=Xs,FR.resolutionconstraint.createSnapToResolutions=zs,FR.rotationconstraint={},FR.rotationconstraint.createSnapToN=Ys,FR.rotationconstraint.createSnapToZero=Ks,FR.rotationconstraint.disable=Ws,FR.rotationconstraint.none=Zs,FR.size={},FR.size.buffer=nl,FR.size.hasArea=rl,FR.size.scale=sl,FR.size.toSize=ol,FR.source={},FR.source.BingMaps=Oh,FR.source.BingMaps.quadKey=Ah,FR.source.CartoDB=Dh,FR.source.Cluster=uc,FR.source.DataTile=gc,FR.source.GeoTIFF=bc,FR.source.IIIF=Bc,FR.source.Image=Yc,FR.source.Image.ImageSourceEvent=Wc,FR.source.Image.defaultImageLoadFunction=Zc,FR.source.ImageArcGISRest=Hc,FR.source.ImageCanvas=qc,FR.source.ImageMapGuide=$c,FR.source.ImageStatic=Jc,FR.source.ImageWMS=eu,FR.source.OGCMapTile=lu,FR.source.OGCVectorTile=uu,FR.source.OSM=gu,FR.source.OSM.ATTRIBUTION=du,FR.source.Raster=ju,FR.source.Raster.Processor=Lu,FR.source.Raster.RasterSourceEvent=Ou,FR.source.Raster.newImageData=Pu,FR.source.Source=dh,FR.source.Stamen=Xu,FR.source.Tile=Eh,FR.source.Tile.TileSourceEvent=wh,FR.source.TileArcGISRest=Vu,FR.source.TileDebug=Wu,FR.source.TileImage=Mh,FR.source.TileJSON=Zu,FR.source.TileWMS=Yu,FR.source.UTFGrid=Hu,FR.source.UTFGrid.CustomTile=Ku,FR.source.UrlTile=Fh,FR.source.Vector=cc,FR.source.Vector.VectorSourceEvent=hc,FR.source.VectorTile=hu,FR.source.VectorTile.defaultLoadFunction=cu,FR.source.WMTS=Qu,FR.source.WMTS.optionsFromCapabilities=function(t,e){const i=t.Contents.Layer.find((function(t){return t.Identifier==e.layer}));if(!i)return null;const n=t.Contents.TileMatrixSet;let r;r=i.TileMatrixSetLink.length>1?"projection"in e?i.TileMatrixSetLink.findIndex((function(t){const i=n.find((function(e){return e.Identifier==t.TileMatrixSet})).SupportedCRS,r=nn(i),s=nn(e.projection);return r&&s?cn(r,s):i==e.projection})):i.TileMatrixSetLink.findIndex((function(t){return t.TileMatrixSet==e.matrixSet})):0,r<0&&(r=0);const s=i.TileMatrixSetLink[r].TileMatrixSet,o=i.TileMatrixSetLink[r].TileMatrixSetLimits;let a=i.Format[0];"format"in e&&(a=e.format),r=i.Style.findIndex((function(t){return"style"in e?t.Title==e.style:t.isDefault})),r<0&&(r=0);const l=i.Style[r].Identifier,h={};"Dimension"in i&&i.Dimension.forEach((function(t,e,i){const n=t.Identifier;let r=t.Default;void 0===r&&(r=t.Value[0]),h[n]=r}));const c=t.Contents.TileMatrixSet.find((function(t){return t.Identifier==s}));let u;const d=c.SupportedCRS;if(d&&(u=nn(d)),"projection"in e){const t=nn(e.projection);t&&(u&&!cn(t,u)||(u=t))}let g=!1;const f="ne"==u.getAxisOrientation().substr(0,2);let p=c.TileMatrix[0],m={MinTileCol:0,MinTileRow:0,MaxTileCol:p.MatrixWidth-1,MaxTileRow:p.MatrixHeight-1};if(o){m=o[o.length-1];const t=c.TileMatrix.find((t=>t.Identifier===m.TileMatrix||c.Identifier+":"+t.Identifier===m.TileMatrix));t&&(p=t)}const _=28e-5*p.ScaleDenominator/u.getMetersPerUnit(),y=f?[p.TopLeftCorner[1],p.TopLeftCorner[0]]:p.TopLeftCorner,x=p.TileWidth*_,v=p.TileHeight*_;let S=c.BoundingBox;S&&f&&(S=[S[1],S[0],S[3],S[2]]);let w=[y[0]+x*m.MinTileCol,y[1]-v*(1+m.MaxTileRow),y[0]+x*(1+m.MaxTileCol),y[1]-v*m.MinTileRow];if(void 0!==S&&!re(S,w)){const t=i.WGS84BoundingBox,e=nn("EPSG:4326").getExtent();if(w=S,t)g=t[0]===e[0]&&t[2]===e[2];else{const t=fn(S,c.SupportedCRS,"EPSG:4326");g=t[0]-1e-10<=e[0]&&t[2]+1e-10>=e[2]}}const E=Ju(c,w,o),T=[];let C=e.requestEncoding;if(C=void 0!==C?C:"","OperationsMetadata"in t&&"GetTile"in t.OperationsMetadata){const e=t.OperationsMetadata.GetTile.DCP.HTTP.Get;for(let t=0,i=e.length;t<i;++t)if(e[t].Constraint){const i=e[t].Constraint.find((function(t){return"GetEncoding"==t.name})).AllowedValues.Value;if(""===C&&(C=i[0]),"KVP"!==C)break;i.includes("KVP")&&T.push(e[t].href)}else e[t].href&&(C="KVP",T.push(e[t].href))}return 0===T.length&&(C="REST",i.ResourceURL.forEach((function(t){"tile"===t.resourceType&&(a=t.format,T.push(t.template))}))),{urls:T,layer:e.layer,matrixSet:s,format:a,projection:u,requestEncoding:C,tileGrid:E,style:l,dimensions:h,wrapX:g,crossOrigin:e.crossOrigin}},FR.source.XYZ=Nh,FR.source.Zoomify=Ic,FR.source.Zoomify.CustomTile=Pc,FR.source.common={},FR.source.common.DEFAULT_WMS_VERSION="1.3.0",FR.source.ogcTileUtil={},FR.source.ogcTileUtil.getMapTileUrlTemplate=ru,FR.source.ogcTileUtil.getTileSetInfo=au,FR.source.ogcTileUtil.getVectorTileUrlTemplate=su,FR.source.sourcesFromTileGrid=function(t,e){const i=new ml(32),n=t.getExtent();return function(r,s){i.expireCache(),n&&(r=Ie(n,r));const o=t.getZForResolution(s),a=[];return t.forEachTileCoord(r,o,(t=>{const n=t.toString();if(!i.containsKey(n)){const r=e(t);i.set(n,r)}a.push(i.get(n))})),a}},FR.source.wms={},FR.source.wms.DEFAULT_VERSION=Qc,FR.sphere={},FR.sphere.DEFAULT_RADIUS=Ui,FR.sphere.getArea=function t(e,i){const n=(i=i||{}).radius||Ui,r=i.projection||"EPSG:3857",s=e.getType();"GeometryCollection"!==s&&(e=e.clone().transform(r,"EPSG:4326"));let o,a,l,h,c,u,d=0;switch(s){case"Point":case"MultiPoint":case"LineString":case"MultiLineString":case"LinearRing":break;case"Polygon":for(o=e.getCoordinates(),d=Math.abs(Vi(o[0],n)),l=1,h=o.length;l<h;++l)d-=Math.abs(Vi(o[l],n));break;case"MultiPolygon":for(o=e.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],d+=Math.abs(Vi(a[0],n)),c=1,u=a.length;c<u;++c)d-=Math.abs(Vi(a[c],n));break;case"GeometryCollection":{const n=e.getGeometries();for(l=0,h=n.length;l<h;++l)d+=t(n[l],i);break}default:throw new Error("Unsupported geometry type: "+s)}return d},FR.sphere.getDistance=zi,FR.sphere.getLength=function t(e,i){const n=(i=i||{}).radius||Ui,r=i.projection||"EPSG:3857",s=e.getType();"GeometryCollection"!==s&&(e=e.clone().transform(r,"EPSG:4326"));let o,a,l,h,c,u,d=0;switch(s){case"Point":case"MultiPoint":break;case"LineString":case"LinearRing":o=e.getCoordinates(),d=Xi(o,n);break;case"MultiLineString":case"Polygon":for(o=e.getCoordinates(),l=0,h=o.length;l<h;++l)d+=Xi(o[l],n);break;case"MultiPolygon":for(o=e.getCoordinates(),l=0,h=o.length;l<h;++l)for(a=o[l],c=0,u=a.length;c<u;++c)d+=Xi(a[c],n);break;case"GeometryCollection":{const n=e.getGeometries();for(l=0,h=n.length;l<h;++l)d+=t(n[l],i);break}default:throw new Error("Unsupported geometry type: "+s)}return d},FR.sphere.offset=Wi,FR.string={},FR.string.compareVersions=Ri,FR.string.padNumber=Ci,FR.structs={},FR.structs.LRUCache=ml,FR.structs.LinkedList=Of,FR.structs.PriorityQueue=aa,FR.structs.PriorityQueue.DROP=oa,FR.structs.RBush=ec,FR.style={},FR.style.Circle=qg,FR.style.Fill=Jg,FR.style.Icon=of,FR.style.IconImage=nf,FR.style.IconImage.get=ef,FR.style.IconImageCache=ps,FR.style.IconImageCache.shared=ms,FR.style.Image=Zg,FR.style.RegularShape=Kg,FR.style.Stroke=lf,FR.style.Style=pf,FR.style.Style.createDefaultStyle=df,FR.style.Style.createEditingStyle=gf,FR.style.Style.toFunction=cf,FR.style.Text=_f,FR.style.expressions={},FR.style.expressions.Operators=xg,FR.style.expressions.PALETTE_TEXTURE_ARRAY=Ug,FR.style.expressions.arrayToGlsl=Tg,FR.style.expressions.colorToGlsl=Cg,FR.style.expressions.expressionToGlsl=Pg,FR.style.expressions.getStringNumberEquivalent=Rg,FR.style.expressions.getValueType=vg,FR.style.expressions.isTypeUnique=Sg,FR.style.expressions.numberToGlsl=Eg,FR.style.expressions.stringToGlsl=bg,FR.style.expressions.uniformNameForVariable=Bg,FR.style.flat={},FR.style.flat.createDefaultStyle=Ef,FR.style.flat.toStyle=yf,FR.tilecoord={},FR.tilecoord.createOrUpdate=_l,FR.tilecoord.fromKey=Sl,FR.tilecoord.getCacheKeyForTileKey=vl,FR.tilecoord.getKey=xl,FR.tilecoord.getKeyZXY=yl,FR.tilecoord.hash=wl,FR.tilecoord.withinExtentAndZ=El,FR.tilegrid={},FR.tilegrid.TileGrid=fh,FR.tilegrid.WMTS=$u,FR.tilegrid.WMTS.createFromCapabilitiesMatrixSet=Ju,FR.tilegrid.common={},FR.tilegrid.common.DEFAULT_MAX_ZOOM=Ds,FR.tilegrid.common.DEFAULT_TILE_SIZE=ks,FR.tilegrid.createForExtent=_h,FR.tilegrid.createForProjection=vh,FR.tilegrid.createXYZ=yh,FR.tilegrid.extentFromProjection=Sh,FR.tilegrid.getForProjection=ph,FR.tilegrid.wrapX=mh,FR.tileurlfunction={},FR.tileurlfunction.createFromTemplate=Th,FR.tileurlfunction.createFromTemplates=Ch,FR.tileurlfunction.createFromTileUrlFunctions=Rh,FR.tileurlfunction.expandUrl=Ph,FR.tileurlfunction.nullTileUrlFunction=bh,FR.transform={},FR.transform.apply=zt,FR.transform.compose=Yt,FR.transform.composeCssTransform=function(t,e,i,n,r,s,o){return $t(Yt([1,0,0,1,0,0],t,e,i,n,r,s,o))},FR.transform.create=kt,FR.transform.determinant=Ht,FR.transform.invert=function(t){return Kt(t,t)},FR.transform.makeInverse=Kt,FR.transform.makeScale=Wt,FR.transform.multiply=jt,FR.transform.reset=Gt,FR.transform.rotate=Xt,FR.transform.scale=Vt,FR.transform.set=Bt,FR.transform.setFromArray=Ut,FR.transform.toString=$t,FR.transform.translate=Zt,FR.uri={},FR.uri.appendParams=Kc,FR.util={},FR.util.VERSION="7.5.1",FR.util.abstract=z,FR.util.getUid=V,FR.vec={},FR.vec.mat4={},FR.vec.mat4.create=Ud,FR.vec.mat4.fromTransform=zd,FR.webgl={},FR.webgl.ARRAY_BUFFER=td,FR.webgl.BaseTileRepresentation=Od,FR.webgl.Buffer=kd,FR.webgl.Buffer.getArrayClassForType=Dd,FR.webgl.DYNAMIC_DRAW=nd,FR.webgl.ELEMENT_ARRAY_BUFFER=ed,FR.webgl.FLOAT=rd,FR.webgl.Helper=qd,FR.webgl.Helper.computeAttributesStride=Kd,FR.webgl.PaletteTexture=$d,FR.webgl.PostProcessingPass=Bd,FR.webgl.RenderTarget=Qd,FR.webgl.STATIC_DRAW=id,FR.webgl.STREAM_DRAW=35040,FR.webgl.ShaderBuilder={},FR.webgl.ShaderBuilder.ShaderBuilder=Rf,FR.webgl.TileGeometry=Pf,FR.webgl.TileTexture=ng,FR.webgl.UNSIGNED_BYTE=5121,FR.webgl.UNSIGNED_INT=5125,FR.webgl.UNSIGNED_SHORT=5123,FR.webgl.getContext=od,FR.webgl.getSupportedExtensions=function(){if(!ad){const t=od(document.createElement("canvas"));t&&(ad=t.getSupportedExtensions())}return ad},FR.webgl.styleparser={},FR.webgl.styleparser.getSymbolOpacityGlslFunction=If,FR.webgl.styleparser.packColor=Ff,FR.webgl.styleparser.parseLiteralStyle=Af,FR.xml={},FR.xml.OBJECT_PROPERTY_NODE_FACTORY=Ed,FR.xml.XML_SCHEMA_INSTANCE_URI=ld,FR.xml.createElementNS=hd,FR.xml.getAllTextContent=cd,FR.xml.getAllTextContent_=ud,FR.xml.getAttributeNS=gd,FR.xml.getDocument=Ad,FR.xml.getXMLSerializer=Md,FR.xml.isDocument=dd,FR.xml.makeArrayExtender=pd,FR.xml.makeArrayPusher=md,FR.xml.makeArraySerializer=Sd,FR.xml.makeChildAppender=vd,FR.xml.makeObjectPropertyPusher=yd,FR.xml.makeObjectPropertySetter=xd,FR.xml.makeReplacer=_d,FR.xml.makeSequence=Td,FR.xml.makeSimpleNodeFactory=wd,FR.xml.makeStructureNS=Cd,FR.xml.parse=fd,FR.xml.parseNode=Rd,FR.xml.pushParseAndPop=bd,FR.xml.pushSerializeAndPop=Id,FR.xml.registerDocument=function(t){Ld=t},FR.xml.registerXMLSerializer=function(t){Fd=t},FR.xml.serialize=Pd,FR}();
//# sourceMappingURL=ol.js.map