diff --git a/sec-beidou/src/main/resources/static/css/ol.css b/sec-beidou/src/main/resources/static/css/ol.css new file mode 100644 index 00000000..5128b54c --- /dev/null +++ b/sec-beidou/src/main/resources/static/css/ol.css @@ -0,0 +1,354 @@ +:root, +:host { + --ol-background-color: white; + --ol-accent-background-color: #F5F5F5; + --ol-subtle-background-color: rgba(128, 128, 128, 0.25); + --ol-partial-background-color: rgba(255, 255, 255, 0.75); + --ol-foreground-color: #333333; + --ol-subtle-foreground-color: #666666; + --ol-brand-color: #00AAFF; +} + +.ol-box { + box-sizing: border-box; + border-radius: 2px; + border: 1.5px solid var(--ol-background-color); + background-color: var(--ol-partial-background-color); +} + +.ol-mouse-position { + top: 8px; + right: 8px; + position: absolute; +} + +.ol-scale-line { + background: var(--ol-partial-background-color); + border-radius: 4px; + bottom: 8px; + left: 8px; + padding: 2px; + position: absolute; +} + +.ol-scale-line-inner { + border: 1px solid var(--ol-subtle-foreground-color); + border-top: none; + color: var(--ol-foreground-color); + font-size: 10px; + text-align: center; + margin: 1px; + will-change: contents, width; + transition: all 0.25s; +} + +.ol-scale-bar { + position: absolute; + bottom: 8px; + left: 8px; +} + +.ol-scale-bar-inner { + display: flex; +} + +.ol-scale-step-marker { + width: 1px; + height: 15px; + background-color: var(--ol-foreground-color); + float: right; + z-index: 10; +} + +.ol-scale-step-text { + position: absolute; + bottom: -5px; + font-size: 10px; + z-index: 11; + color: var(--ol-foreground-color); + text-shadow: -1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color); +} + +.ol-scale-text { + position: absolute; + font-size: 12px; + text-align: center; + bottom: 25px; + color: var(--ol-foreground-color); + text-shadow: -1.5px 0 var(--ol-partial-background-color), 0 1.5px var(--ol-partial-background-color), 1.5px 0 var(--ol-partial-background-color), 0 -1.5px var(--ol-partial-background-color); +} + +.ol-scale-singlebar { + position: relative; + height: 10px; + z-index: 9; + box-sizing: border-box; + border: 1px solid var(--ol-foreground-color); +} + +.ol-scale-singlebar-even { + background-color: var(--ol-subtle-foreground-color); +} + +.ol-scale-singlebar-odd { + background-color: var(--ol-background-color); +} + +.ol-unsupported { + display: none; +} + +.ol-viewport, +.ol-unselectable { + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-tap-highlight-color: transparent; +} + +.ol-viewport canvas { + all: unset; + overflow: hidden; +} + +.ol-viewport { + touch-action: pan-x pan-y; +} + +.ol-selectable { + -webkit-touch-callout: default; + -webkit-user-select: text; + -moz-user-select: text; + user-select: text; +} + +.ol-grabbing { + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + cursor: grabbing; +} + +.ol-grab { + cursor: move; + cursor: -webkit-grab; + cursor: -moz-grab; + cursor: grab; +} + +.ol-control { + position: absolute; + background-color: var(--ol-subtle-background-color); + border-radius: 4px; +} + +.ol-zoom { + top: .5em; + left: .5em; +} + +.ol-rotate { + top: .5em; + right: .5em; + transition: opacity .25s linear, visibility 0s linear; +} + +.ol-rotate.ol-hidden { + opacity: 0; + visibility: hidden; + transition: opacity .25s linear, visibility 0s linear .25s; +} + +.ol-zoom-extent { + top: 4.643em; + left: .5em; +} + +.ol-full-screen { + right: .5em; + top: .5em; +} + +.ol-control button { + display: block; + margin: 1px; + padding: 0; + color: var(--ol-subtle-foreground-color); + font-weight: bold; + text-decoration: none; + font-size: inherit; + text-align: center; + height: 1.375em; + width: 1.375em; + line-height: .4em; + background-color: var(--ol-background-color); + border: none; + border-radius: 2px; +} + +.ol-control button::-moz-focus-inner { + border: none; + padding: 0; +} + +.ol-zoom-extent button { + line-height: 1.4em; +} + +.ol-compass { + display: block; + font-weight: normal; + will-change: transform; +} + +.ol-touch .ol-control button { + font-size: 1.5em; +} + +.ol-touch .ol-zoom-extent { + top: 5.5em; +} + +.ol-control button:hover, +.ol-control button:focus { + text-decoration: none; + outline: 1px solid var(--ol-subtle-foreground-color); + color: var(--ol-foreground-color); +} + +.ol-zoom .ol-zoom-in { + border-radius: 2px 2px 0 0; +} + +.ol-zoom .ol-zoom-out { + border-radius: 0 0 2px 2px; +} + +.ol-attribution { + text-align: right; + bottom: .5em; + right: .5em; + max-width: calc(100% - 1.3em); + display: flex; + flex-flow: row-reverse; + align-items: center; +} + +.ol-attribution a { + color: var(--ol-subtle-foreground-color); + text-decoration: none; +} + +.ol-attribution ul { + margin: 0; + padding: 1px .5em; + color: var(--ol-foreground-color); + text-shadow: 0 0 2px var(--ol-background-color); + font-size: 12px; +} + +.ol-attribution li { + display: inline; + list-style: none; +} + +.ol-attribution li:not(:last-child):after { + content: " "; +} + +.ol-attribution img { + max-height: 2em; + max-width: inherit; + vertical-align: middle; +} + +.ol-attribution button { + flex-shrink: 0; +} + +.ol-attribution.ol-collapsed ul { + display: none; +} + +.ol-attribution:not(.ol-collapsed) { + background: var(--ol-partial-background-color); +} + +.ol-attribution.ol-uncollapsible { + bottom: 0; + right: 0; + border-radius: 4px 0 0; +} + +.ol-attribution.ol-uncollapsible img { + margin-top: -.2em; + max-height: 1.6em; +} + +.ol-attribution.ol-uncollapsible button { + display: none; +} + +.ol-zoomslider { + top: 4.5em; + left: .5em; + height: 200px; +} + +.ol-zoomslider button { + position: relative; + height: 10px; +} + +.ol-touch .ol-zoomslider { + top: 5.5em; +} + +.ol-overviewmap { + left: 0.5em; + bottom: 0.5em; +} + +.ol-overviewmap.ol-uncollapsible { + bottom: 0; + left: 0; + border-radius: 0 4px 0 0; +} + +.ol-overviewmap .ol-overviewmap-map, +.ol-overviewmap button { + display: block; +} + +.ol-overviewmap .ol-overviewmap-map { + border: 1px solid var(--ol-subtle-foreground-color); + height: 150px; + width: 150px; +} + +.ol-overviewmap:not(.ol-collapsed) button { + bottom: 0; + left: 0; + position: absolute; +} + +.ol-overviewmap.ol-collapsed .ol-overviewmap-map, +.ol-overviewmap.ol-uncollapsible button { + display: none; +} + +.ol-overviewmap:not(.ol-collapsed) { + background: var(--ol-subtle-background-color); +} + +.ol-overviewmap-box { + border: 1.5px dotted var(--ol-subtle-foreground-color); +} + +.ol-overviewmap .ol-overviewmap-box:hover { + cursor: move; +} + +.ol-overviewmap .ol-viewport:hover { + cursor: pointer; +} diff --git a/sec-beidou/src/main/resources/static/js/ol.js b/sec-beidou/src/main/resources/static/js/ol.js new file mode 100644 index 00000000..b3a2237d --- /dev/null +++ b/sec-beidou/src/main/resources/static/js/ol.js @@ -0,0 +1,2 @@ +var ol=function(){"use strict";var t="add",e="remove",i="propertychange",n="change",r="error",s="contextmenu",o="click",a="dblclick",l="dragenter",h="dragover",c="drop",u="keydown",d="keypress",g="load",f="touchmove",p="wheel";class _{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function m(t,e,i){let n,r;i=i||y;let s=0,o=t.length,a=!1;for(;s>1),r=+i(t[n],e),r<0?s=n+1:(o=n,a=!r);return a?s:~s}function y(t,e){return t>e?1:te?-1:0}function v(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;r0?r-1:r}return n-1}if(i>0){for(let i=1;i0||i&&0===s)}))}function C(){return!0}function R(){return!1}function b(){}function P(t){let e,i,n;return function(){const r=Array.prototype.slice.call(arguments);return i&&this===n&&w(r,i)||(n=this,i=r,e=t.apply(this,arguments)),e}}function I(t){return function(){let e;try{e=t()}catch(t){return Promise.reject(t)}return e instanceof Promise?e:Promise.resolve(e)}()}function F(t){for(const e in t)delete t[e]}function M(t){let e;for(e in t)return!1;return!e}class L{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}function A(t){t.stopPropagation()}class O extends _{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 r=e?new L(t):t;r.target||(r.target=this.eventTarget_||this);const s=this.dispatching_||(this.dispatching_={}),o=this.pendingRemovals_||(this.pendingRemovals_={});let a;i in s||(s[i]=0,o[i]=0),++s[i];for(let t=0,e=n.length;t0)}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const n=i.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=b,++this.pendingRemovals_[t]):(i.splice(n,1),0===i.length&&delete this.listeners_[t]))}}function D(t,e,i,n,r){if(r){const r=i;i=function(s){return t.removeEventListener(e,i),r.call(n??this,s)}}else n&&n!==t&&(i=i.bind(n));const s={target:t,type:e,listener:i};return t.addEventListener(e,i),s}function N(t,e,i,n){return D(t,e,i,n,!0)}function k(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),F(t))}class G extends O{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(n)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r0;)this.pop()}extend(t){for(let e=0,i=t.length;ethis.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(i),this.array_.splice(e,0,i),this.updateLength_(),this.dispatchEvent(new W(t,i,e))}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=this.getLength())return;const i=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new W(e,i,t)),i}setAt(i,n){if(i>=this.getLength())return void this.insertAt(i,n);if(i<0)throw new Error("Index out of bounds: "+i);this.unique_&&this.assertUnique_(n,i);const r=this.array_[i];this.array_[i]=n,this.dispatchEvent(new W(e,r,i)),this.dispatchEvent(new W(t,n,i))}updateLength_(){this.set($,this.array_.length)}assertUnique_(t,e){for(let i=0,n=this.array_.length;it)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){j()}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:Q(n/this.transition_)}inTransition(t){return!!this.transition_&&-1!==this.transitionStarts_[t]}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}const rt="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"",st=rt.includes("safari")&&!rt.includes("chrom"),ot=st&&(rt.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(rt)),at=rt.includes("webkit")&&!rt.includes("edge"),lt=rt.includes("macintosh"),ht="undefined"!=typeof devicePixelRatio?devicePixelRatio:1,ct="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope,ut="undefined"!=typeof Image&&Image.prototype.decode,dt="function"==typeof createImageBitmap,gt=function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return t}();function ft(t,e,i,n){let r;return r=i&&i.length?i.shift():ct?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",n)}let pt;function _t(){return pt||(pt=ft(1,1)),pt}function mt(t){const e=t.canvas;e.width=1,e.height=1,t.clearRect(0,0,1,1)}function yt(t){let e=t.offsetWidth;const i=getComputedStyle(t);return e+=parseInt(i.marginLeft,10)+parseInt(i.marginRight,10),e}function xt(t){let e=t.offsetHeight;const i=getComputedStyle(t);return e+=parseInt(i.marginTop,10)+parseInt(i.marginBottom,10),e}function vt(t,e){const i=e.parentNode;i&&i.replaceChild(t,e)}function St(t){for(;t.lastChild;)t.lastChild.remove()}function Et(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 wt(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}function Tt(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t instanceof DataView?t:null}const Ct=new Error("disposed");let Rt=null;function bt(t){Rt||(Rt=ft(t.width,t.height,void 0,{willReadFrequently:!0}));const e=Rt.canvas,i=t.width;e.width!==i&&(e.width=i);const n=t.height;return e.height!==n&&(e.height=n),Rt.clearRect(0,0,i,n),Rt.drawImage(t,0,0),Rt.getImageData(0,0,i,n).data}const Pt=[256,256];class It extends nt{constructor(t){const e=Y;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,this.controller_=t.controller||null}getSize(){if(this.size_)return this.size_;const t=wt(this.data_);return t?[t.width,t.height]:Pt}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==Y&&this.state!==q)return;this.state=H,this.changed();const t=this;this.loader_().then((function(e){t.data_=e,t.state=K,t.changed()})).catch((function(e){t.error_=e,t.state=q,t.changed()}))}disposeInternal(){this.controller_&&(this.controller_.abort(Ct),this.controller_=null),super.disposeInternal()}}function Ft(t,e){if(!t)throw new Error(e)}class Mt extends V{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 Mt(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_&&(k(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=D(t,n,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?Lt(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 Lt(t){if("function"==typeof t)return t;let e;if(Array.isArray(t))e=t;else{Ft("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`");e=[t]}return function(){return e}}var At=0,Ot=1,Dt=2,Nt=4,kt=8,Gt=16;function Ut(t){const e=Zt();for(let i=0,n=t.length;ir&&(l|=Nt),as&&(l|=Dt),l===At&&(l=Ot),l}function Zt(){return[1/0,1/0,-1/0,-1/0]}function Yt(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 Ht(t){return Yt(1/0,1/0,-1/0,-1/0,t)}function Kt(t,e){const i=t[0],n=t[1];return Yt(i,n,i,n,e)}function qt(t,e,i,n,r){return ne(Ht(r),t,e,i,n)}function Jt(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function Qt(t,e,i){return Math.abs(t[0]-e[0])t[2]&&(t[2]=e[2]),e[1]t[3]&&(t[3]=e[3]),t}function ee(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function ie(t,e){for(let i=0,n=e.length;ie[0]?n[0]=t[0]:n[0]=e[0],t[1]>e[1]?n[1]=t[1]:n[1]=e[1],t[2]=e[0]&&t[1]<=e[3]&&t[3]>=e[1]}function ve(t){return t[2]=o&&p<=l),n||!(s&Nt)||r&Nt||(_=g-(d-l)*f,n=_>=a&&_<=h),n||!(s&kt)||r&kt||(p=d-(g-a)/f,n=p>=o&&p<=l),n||!(s&Gt)||r&Gt||(_=g-(d-o)*f,n=_>=a&&_<=h)}return n}function Te(t,e,i,n){if(ve(t))return Ht(i);let r=[];if(n>1){const e=t[2]-t[0],i=t[3]-t[1];for(let s=0;s=i[2])){const e=ye(i),r=Math.floor((n[0]-i[0])/e)*e;t[0]-=r,t[2]-=r}return t}function Re(t,e,i){if(e.canWrapX()){const n=e.getExtent();if(!isFinite(t[0])||!isFinite(t[2]))return[[n[0],t[1],n[2],t[3]]];Ce(t,e);const r=ye(n);if(ye(t)>r&&!i)return[[n[0],t[1],n[2],t[3]]];if(t[0]n[2])return[[t[0],t[1],n[2],t[3]],[n[0],t[1],t[2]-r,t[3]]]}return[t]}function be(t,e,i){return Math.min(Math.max(t,e),i)}function Pe(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 Ie(t,e,i,n)}function Ie(t,e,i,n){const r=i-t,s=n-e;return r*r+s*s}function Fe(t){const e=t.length;for(let i=0;ir&&(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=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 Me(t){return 180*t/Math.PI}function Le(t){return t*Math.PI/180}function Ae(t,e){const i=t%e;return i*e<0?i+e:i}function Oe(t,e,i){return t+i*(e-t)}function De(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}function Ne(t,e){return Math.round(De(t,e))}function ke(t,e){return Math.floor(De(t,e))}function Ge(t,e){return Math.ceil(De(t,e))}function Ue(t,e,i){if(t>=e&&t$e.warn||console.warn(...t)}function Ye(...t){We>$e.error||console.error(...t)}function He(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 Ke(t,e){const i=(""+t).split("."),n=(""+e).split(".");for(let t=0;tr)return 1;if(r>e)return-1}return 0}function qe(t,e){return t[0]+=+e[0],t[1]+=+e[1],t}function Je(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 Qe(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 ti(t,e,i){const n=Ae(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=De(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+=" "+He(a,2)+"′"),0!==l&&(h+=" "+He(l,2,s)+"″"),0!==n&&(h+=" "+t.charAt(n<0?1:0)),h}function ei(t,e,i){return t?e.replace("{x}",t[0].toFixed(i)).replace("{y}",t[1].toFixed(i)):""}function ii(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 ni(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 ri(t,e){return t[0]*=e,t[1]*=e,t}function si(t,e){const i=t[0]-e[0],n=t[1]-e[1];return i*i+n*n}function oi(t,e){return Math.sqrt(si(t,e))}function ai(t,e){return si(t,Qe(t,e))}function li(t,e){return ei(t,"{x}, {y}",e)}function hi(t,e){if(e.canWrapX()){const i=ye(e.getExtent()),n=ci(t,e,i);n&&(t[0]-=n*i)}return t}function ci(t,e,i){const n=e.getExtent();let r=0;return e.canWrapX()&&(t[0]n[2])&&(i=i||ye(n),r=Math.floor((t[0]-n[0])/i)),r}const ui={9001:"m",9002:"ft",9003:"us-ft",9101:"radians",9102:"degrees"};function di(t){return ui[t]}const gi={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class fi{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_||gi[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 pi=6378137,_i=Math.PI*pi,mi=[-_i,-_i,_i,_i],yi=[-180,-85,180,85],xi=pi*Math.log(Math.tan(Math.PI/2));class vi extends fi{constructor(t){super({code:t,units:"m",extent:mi,global:!0,worldExtent:yi,getPointResolution:function(t,e){return t/Math.cosh(e[1]/pi)}})}}const Si=[new vi("EPSG:3857"),new vi("EPSG:102100"),new vi("EPSG:102113"),new vi("EPSG:900913"),new vi("http://www.opengis.net/def/crs/EPSG/0/3857"),new vi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ei(t,e,i,n){const r=t.length;i=i>1?i:2,n=n??i,void 0===e&&(e=i>2?t.slice():new Array(r));for(let i=0;ixi?n=xi:n<-xi&&(n=-xi),e[i+1]=n}return e}function wi(t,e,i,n){const r=t.length;i=i>1?i:2,n=n??i,void 0===e&&(e=i>2?t.slice():new Array(r));for(let i=0;i84&&(e=84);const n=Le(e),r=Math.sin(n),s=Math.cos(n),o=r/s,a=o*o,l=a*a,h=Le(t),c=Le(sn(i.number)),u=en/Math.sqrt(1-Gi*r**2),d=Bi*s**2,g=s*Ue(h-c,-Math.PI,Math.PI),f=g*g,p=f*g,_=p*g,m=_*g,y=m*g,x=en*(Yi*n-.002514607064228144*Math.sin(2*n)+Hi*Math.sin(4*n)-Ki*Math.sin(6*n)),v=ki*u*(g+p/6*(1-a+d)+m/120*(5-18*a+l+72*d-58*Bi))+5e5;let S=ki*(x+u*o*(f/2+_/24*(5-a+9*d+4*d**2)+y/720*(61-58*a+l+600*d-330*Bi)));return i.north||(S+=1e7),[v,S]}function sn(t){return 6*(t-1)-180+3}const on=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function an(t){let e=0;for(const i of on){const n=t.match(i);if(n){e=parseInt(n[1]);break}}if(!e)return null;let i=0,n=!1;return e>32700&&e<32761?i=e-32700:e>32600&&e<32661&&(n=!0,i=e-32600),i?{number:i,north:n}:null}function ln(t,e){return function(i,n,r,s){const o=i.length;r=r>1?r:2,s=s??r,n||(n=r>2?i.slice():new Array(o));for(let r=0;r=a?e[o+t]:s[t]}return i}}function Cn(t,e,i,n){const r=xn(t),s=xn(e);Di(r,s,Tn(i)),Di(s,r,Tn(n))}function Rn(t,e){const i=Mn(t,void 0!==e?e:"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=Ae(n+180,360)-180),i}function bn(t,e){if(t===e)return!0;const i=t.getUnits()===e.getUnits();if(t.getCode()===e.getCode())return i;return Pn(t,e)===pn&&i}function Pn(t,e){const i=t.getCode(),n=e.getCode();let r=Ni(i,n);if(r)return r;let s=null,o=null;for(const i of un)s||(s=i(t)),o||(o=i(e));if(!s&&!o)return null;const a="EPSG:4326";if(o)if(s)r=In(s.inverse,o.forward);else{const t=Ni(i,a);t&&(r=In(t,o.forward))}else{const t=Ni(a,n);t&&(r=In(s.inverse,t))}return r&&(mn(t),mn(e),Di(t,e,r)),r}function In(t,e){return function(i,n,r,s){return n=t(i,n,r,s),e(n,n,r,s)}}function Fn(t,e){return Pn(xn(t),xn(e))}function Mn(t,e,i){const n=Fn(e,i);if(!n){const t=xn(e).getCode(),n=xn(i).getCode();throw new Error(`No transform available between ${t} and ${n}`)}return n(t,void 0,t.length)}function Ln(t,e,i,n){return Te(t,Fn(e,i),void 0,n)}let An=null;function On(t){An=xn(t)}function Dn(){return An}function Nn(t,e){return An?Mn(t,e,An):t}function kn(t,e){return An?Mn(t,An,e):(gn&&!ii(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(gn=!1,Ze("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t)}function Gn(t,e){return An?Ln(t,e,An):t}function Un(t,e){return An?Ln(t,An,e):t}function jn(t,e){if(!An)return t;const i=xn(e).getMetersPerUnit(),n=An.getMetersPerUnit();return i&&n?t*i/n:t}function Bn(t,e){if(!An)return t;const i=xn(e).getMetersPerUnit(),n=An.getMetersPerUnit();return i&&n?t*n/i:t}function zn(t,e,i){return function(n){let r,s;if(t.canWrapX()){const e=t.getExtent(),o=ye(e);s=ci(n=n.slice(0),t,o),s&&(n[0]=n[0]-s*o),n[0]=be(n[0],e[0],e[2]),n[1]=be(n[1],e[1],e[3]),r=i(n)}else r=i(n);return s&&e.canWrapX()&&(r[0]+=s*ye(e.getExtent())),r}}function Xn(){Sn(Si),Sn(Pi),En(Pi,Si,Ei,wi)}Xn();const Vn=new Array(6);function $n(){return[1,0,0,1,0,0]}function Wn(t){return Yn(t,1,0,0,1,0,0)}function Zn(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 Yn(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 Hn(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 Kn(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 qn(t,e){const i=Math.cos(e),n=Math.sin(e);return Zn(t,Yn(Vn,i,n,-n,i,0,0))}function Jn(t,e,i){return Zn(t,Yn(Vn,e,0,0,i,0,0))}function Qn(t,e,i){return Zn(t,Yn(Vn,1,0,0,1,e,i))}function tr(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 er(t,e){const i=ir(e);Ft(0!==i,"Transformation matrix cannot be inverted");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 ir(t){return t[0]*t[3]-t[1]*t[2]}const nr=[1e5,1e5,1e5,1e5,2,2];function rr(t){return"matrix("+t.join(", ")+")"}function sr(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function or(t,e){const i=sr(t),n=sr(e);for(let t=0;t<6;++t)if(0!==Math.round((i[t]-n[t])*nr[t]))return!1;return!0}function ar(t,e,i,n,r,s,o){s=s||[],o=o||2;let a=0;for(let l=e;l{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 j()}closestPointXY(t,e,i,n){return j()}containsXY(t,e){return 0===this.closestPointXY(t,e,dr,Number.MIN_VALUE)}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 j()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&Ht(t),this.extentRevision_=this.getRevision()}return Se(this.extent_,t)}rotate(t,e){j()}scale(t,e,i){j()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return j()}getType(){return j()}applyTransform(t){j()}intersectsExtent(t){return j()}translate(t,e){j()}transform(t,e){const i=xn(t),n="tile-pixels"==i.getUnits()?function(t,n,r){const s=i.getExtent(),o=i.getWorldExtent(),a=fe(o)/fe(s);tr(ur,o[0],o[3],a,-a,0,0,0);const l=ar(t,0,t.length,r,ur,n),h=Fn(i,e);return h?h(l,l,r):l}:Fn(i,e);return this.applyTransform(n),this}}class fr extends gr{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return qt(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return j()}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().length1)u=i;else{if(d>0){for(let r=0;rr&&(r=a),s=i,o=n}return r}function wr(t,e,i,n,r){for(let s=0,o=i.length;s0;){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;eo&&(c=e,o=i)}o>r&&(l[(c-e)/n]=1,s+nr&&(s[o++]=h,s[o++]=c,a=h,l=c);return h==a&&c==l||(s[o++]=h,s[o++]=c),o}function Gr(t,e){return e*Math.round(t/e)}function Ur(t,e,i,n,r,s,o){if(e==i)return o;let a,l,h=Gr(t[e],r),c=Gr(t[e+1],r);e+=n,s[o++]=h,s[o++]=c;do{if(a=Gr(t[e],r),l=Gr(t[e+1],r),(e+=n)==i)return s[o++]=a,s[o++]=l,o}while(a==h&&l==c);for(;e0&&f>d)&&(g<0&&p0&&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 jr(t,e,i,n,r,s,o,a){for(let l=0,h=i.length;ls&&(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 Wr(t,e,i,n,r,s){if(0===i.length)return!1;if(!$r(t,e,i[0],n,r,s))return!1;for(let e=1,o=i.length;em&&(h=(c+u)/2,Wr(t,e,i,n,h,f)&&(_=h,m=r)),c=u}return isNaN(_)&&(_=r[s]),o?(o.push(_,f,m),o):[_,f,m]}function Hr(t,e,i,n,r){let s=[];for(let o=0,a=i.length;o=r[0]&&s[2]<=r[2]||s[1]>=r[1]&&s[3]<=r[3]||Kr(t,e,i,n,(function(t,e){return we(r,t,e)})))}function Qr(t,e,i,n,r){for(let s=0,o=i.length;s0}function ss(t,e,i,n,r){r=void 0!==r&&r;for(let s=0,o=i.length;sthis.loader(this.getExtent(),e,this.getPixelRatio()))).then((t=>{"image"in t&&(this.image_=t.image),"extent"in t&&(this.extent=t.extent),"resolution"in t&&(this.resolution=t.resolution),"pixelRatio"in t&&(this.pixelRatio_=t.pixelRatio),(t instanceof HTMLImageElement||dt&&t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement)&&(this.image_=t),this.state=Is})).catch((t=>{this.state=Fs,console.error(t)})).finally((()=>this.changed()))}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}}function As(t,e,i){const n=t;let s=!0,o=!1,a=!1;const l=[N(n,g,(function(){a=!0,o||e()}))];return n.src&&ut?(o=!0,n.decode().then((function(){s&&e()})).catch((function(t){s&&(a?e():i())}))):l.push(N(n,r,i)),function(){s=!1,l.forEach(k)}}function Os(t,e){return new Promise(((i,n)=>{function r(){o(),i(t)}function s(){o(),n(new Error("Image load error"))}function o(){t.removeEventListener("load",r),t.removeEventListener("error",s)}t.addEventListener("load",r),t.addEventListener("error",s),e&&(t.src=e)}))}function Ds(t,e){return e&&(t.src=e),t.src&&ut?new Promise(((e,i)=>t.decode().then((()=>e(t))).catch((n=>t.complete&&t.width?e(t):i(n))))):Os(t)}function Ns(t,e){return e&&(t.src=e),t.src&&ut&&dt?t.decode().then((()=>createImageBitmap(t))).catch((e=>{if(t.complete&&t.width)return t;throw e})):Ds(t)}class ks extends Ls{constructor(t,e,i,n,r){super(t,e,i,void 0!==r?bs:Is),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=Fs):this.state=Is,this.changed()}load(){this.state==bs&&(this.state=Ps,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}class Gs extends nt{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=K,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=q,this.unlistenImage_(),this.image_=function(){const t=ft(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=K:this.state=J,this.unlistenImage_(),this.changed()}load(){this.state==q&&(this.state=Y,this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==Y&&(this.state=H,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=As(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}disposeInternal(){this.unlistenImage_(),this.image_=null,super.disposeInternal()}}class Us{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]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_}}class js extends L{constructor(t,e,i){super(t),this.map=e,this.frameState=void 0!==i?i:null}}class Bs extends js{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()}}var zs={SINGLECLICK:"singleclick",CLICK:o,DBLCLICK:a,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Xs="pointermove",Vs="pointerdown",$s="pointerup",Ws="pointerout";class Zs extends O{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,Vs,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=D(i,Xs,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(f,this.boundHandleTouchMove_,!!gt&&{passive:!1})}emulateClick_(t){let e=new Bs(zs.CLICK,this.map_,t);this.dispatchEvent(e),void 0!==this.clickTimeoutId_?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Bs(zs.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout((()=>{this.clickTimeoutId_=void 0;const e=new Bs(zs.SINGLECLICK,this.map_,t);this.dispatchEvent(e)}),250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==zs.POINTERUP||e.type==zs.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!=zs.POINTERDOWN&&e.type!=zs.POINTERMOVE||(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Bs(zs.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(k),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 Bs(zs.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,zs.POINTERMOVE,this.handlePointerMove_,this),D(t,zs.POINTERUP,this.handlePointerUp_,this),D(this.element_,zs.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(D(this.element_.getRootNode(),zs.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Bs(zs.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 Bs(zs.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_&&(k(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(f,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(k(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(k),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}var Ys="postrender",Hs="movestart",Ks="moveend",qs="loadstart",Js="loadend",Qs="layergroup",to="size",eo="target",io="view";const no=1/0;class ro{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,F(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){Ft(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=no&&(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>1;){const r=this.getLeftChildIndex_(t),s=this.getRightChildIndex_(t),o=st;){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;ot.apply(null,e)),(t=>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(n,this.boundHandleTileChange_)}return e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===K||i===q||i===J){i!==q&&e.removeEventListener(n,this.boundHandleTileChange_);const t=e.getKey();t in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[t],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_0;){const t=this.dequeue()[0],e=t.getKey();t.getState()!==Y||e in this.tilesLoadingKeys_||(this.tilesLoadingKeys_[e]=!0,++this.tilesLoading_,++i,t.load())}}}function oo(t,e,i,n,r){if(!t||!(i in t.wantedTiles))return no;if(!t.wantedTiles[i][e.getKey()])return no;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 ao=0,lo=1,ho={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function co(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 _=be(n[0],d,g),m=be(n[1],f,p);if(o&&i&&r){const t=30*r;_+=-t*Math.log(1+Math.max(0,d-n[0])/t)+t*Math.log(1+Math.max(0,n[0]-g)/t),m+=-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 uo(t){return t}function go(t,e,i,n){const r=ye(e)/i[0],s=fe(e)/i[1];return n?Math.min(t,Math.max(r,s)):Math.min(t,Math.min(r,s))}function fo(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),be(n,i/2,2*e)}function po(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],c=i?go(l,i,o,n):l;if(a)return e?fo(r,c,h):be(r,h,c);const u=Math.min(c,r),d=Math.floor(v(t,u,s));return t[d]>c&&d1&&"function"==typeof arguments[i-1]&&(e=arguments[i-1],--i);let n=0;for(;n0}getInteracting(){return this.hints_[lo]>0}cancelAnimations(){let t;this.setHint(ao,-this.hints_[ao]);for(let e=0,i=this.animations_.length;e=0;--i){const n=this.animations_[i];let r=!0;for(let i=0,s=n.length;i0?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?Ae(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(ao,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=n[0].callback;t&&To(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]],ni(i,t-this.getRotation()),qe(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?Nn(t,this.getProjection()):t}getCenterInternal(){return this.get(ho.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 Gn(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();Ft(e,"The view center is not defined");const i=this.getResolution();Ft(void 0!==i,"The view resolution is not defined");const n=this.getRotation();return Ft(void 0!==n,"The view rotation is not defined"),de(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(ho.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Un(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=ye(t)/e[0],n=fe(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(ho.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=Io(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=v(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_?.length){if(1===this.resolutions_.length)return this.resolutions_[0];const e=be(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,be(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(Ft(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){Ft(!ve(t),"Cannot fit empty extent provided as `geometry`");i=ds(Un(t,this.getProjection()))}else if("Circle"===t.getType()){const e=Un(t.getExtent(),this.getProjection());i=ds(e),i.rotate(this.getRotation(),ce(e))}else{const e=Dn();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;te.getAttributions(t))));if(void 0!==this.attributions_&&(Array.isArray(this.attributions_)?this.attributions_.forEach((t=>i.add(t))):i.add(this.attributions_)),!this.overrideCollapsible_){const t=!e.some((t=>!1===t.getSource()?.getAttributionsCollapsible()));this.setCollapsible(t)}return Array.from(i)}async updateElement_(t){if(!t)return void(this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1));const e=await Promise.all(this.collectSourceAttributions_(t).map((t=>I((()=>t))))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!w(e,this.renderedAttributions_)){St(this.ulElement_);for(let t=0,i=e.length;t0&&e%(2*Math.PI)!=0?t.animate({rotation:0,duration:this.duration_,easing:tt}):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(Fo);t||0!==i?t&&0!==i&&this.element.classList.remove(Fo):this.element.classList.add(Fo)}this.label_.style.transform=t}this.rotation_=i}}class zo extends Uo{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:"+",a=void 0!==t.zoomOutLabel?t.zoomOutLabel:"–",l=void 0!==t.zoomInTipLabel?t.zoomInTipLabel:"Zoom in",h=void 0!==t.zoomOutTipLabel?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=n,c.setAttribute("type","button"),c.title=l,c.appendChild("string"==typeof s?document.createTextNode(s):s),c.addEventListener(o,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild("string"==typeof a?document.createTextNode(a):a),u.addEventListener(o,this.handleClick_.bind(this,-i),!1);const d=e+" "+Lo+" "+Oo,g=this.element;g.className=d,g.appendChild(c),g.appendChild(u),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:tt})):e.setZoom(n)}}}function Xo(t){t=t||{};const e=new Z;(void 0===t.zoom||t.zoom)&&e.push(new zo(t.zoomOptions));(void 0===t.rotate||t.rotate)&&e.push(new Bo(t.rotateOptions));return(void 0===t.attribution||t.attribution)&&e.push(new jo(t.attributionOptions)),e}var Vo="active";class $o extends V{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(Vo)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Vo,t)}setMap(t){this.map_=t}}function Wo(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:it,center:t.getConstrainedCenter(r)})}}function Zo(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:tt})}class Yo extends $o{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==zs.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,s=i.shiftKey?-this.delta_:this.delta_;Zo(n.getView(),s,r,this.duration_),i.preventDefault(),e=!0}return!e}}function Ho(t){const e=arguments;return function(t){let i=!0;for(let n=0,r=e.length;n0}}else if(t.type==zs.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==zs.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 ua(t){const e=t.length;let i=0,n=0;for(let r=0;r0&&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}}class ga extends ca{constructor(t){t=t||{},super({stopDown:R}),this.condition_=t.condition?t.condition:qo,this.lastAngle_=void 0,this.duration_=void 0!==t.duration?t.duration:250}handleDragEvent(t){if(!la(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===yo)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(!la(t))return!0;return t.map.getView().endInteraction(this.duration_),!1}handleDownEvent(t){if(!la(t))return!1;if(ea(t)&&this.condition_(t)){return t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0}return!1}}class fa extends _{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(){if(!this.map_)return;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 cs([i])}getGeometry(){return this.geometry_}}const pa="boxstart",_a="boxdrag",ma="boxend",ya="boxcancel";class xa extends L{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class va extends ca{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new fa(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??ea,this.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.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new xa(_a,t.coordinate,t)))}handleUpEvent(t){if(!this.startPixel_)return!1;const e=this.boxEndCondition_(t,this.startPixel_,t.pixel);return e&&this.onBoxEnd(t),this.dispatchEvent(new xa(e?ma:ya,t.coordinate,t)),this.box_.setMap(null),this.startPixel_=null,!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 xa(pa,t.coordinate,t)),!0)}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new xa(ya,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new xa(ya,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class Sa extends va{constructor(t){super({condition:(t=t||{}).condition?t.condition:oa,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:tt})}}var Ea="ArrowLeft",wa="ArrowUp",Ta="ArrowRight",Ca="ArrowDown";class Ra extends $o{constructor(t){super(),t=t||{},this.defaultCondition_=function(t){return ra(t)&&aa(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==u){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==Ca||n==Ea||n==Ta||n==wa)){const r=t.map.getView(),s=r.getResolution()*this.pixelDelta_;let o=0,a=0;n==Ca?a=-s:n==Ea?o=-s:n==Ta?o=s:a=s;const l=[o,a];ni(l,r.getRotation()),Wo(r,l,this.duration_),i.preventDefault(),e=!0}}return!e}}class ba extends $o{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(t){return!sa(t)&&aa(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==u||t.type==d){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&("+"===n||"-"===n)){const r=t.map,s="+"===n?this.delta_:-this.delta_;Zo(r.getView(),s,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}class Pa extends $o{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:ta;this.condition_=t.onFocusOnly?Ho(Qo,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_?t.getCoordinateFromPixel(this.lastAnchor_):null)}handleEvent(t){if(!this.condition_(t))return!0;if(t.type!==p)return!0;const e=t.map,i=t.originalEvent;let n;if(i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel),t.type==p&&(n=i.deltaY,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_?e.getCoordinateFromPixel(this.lastAnchor_):null),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=-be(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Zo(e,i,this.lastAnchor_?t.getCoordinateFromPixel(this.lastAnchor_):null,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)}}class Ia extends ca{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=R),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!==yo&&(this.anchor_=s.getCoordinateFromPixelInternal(s.getEventPixel(ua(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}}class Fa extends ca{constructor(t){const e=t=t||{};e.stopDown||(e.stopDown=R),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(ua(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 Ma(t){t=t||{};const e=new Z,i=new Us(-.005,.05,100);(void 0===t.altShiftDragRotate||t.altShiftDragRotate)&&e.push(new ga);(void 0===t.doubleClickZoom||t.doubleClickZoom)&&e.push(new Yo({delta:t.zoomDelta,duration:t.zoomDuration}));(void 0===t.dragPan||t.dragPan)&&e.push(new da({onFocusOnly:t.onFocusOnly,kinetic:i}));(void 0===t.pinchRotate||t.pinchRotate)&&e.push(new Ia);(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new Fa({duration:t.zoomDuration}));(void 0===t.keyboard||t.keyboard)&&(e.push(new Ra),e.push(new ba({delta:t.zoomDelta,duration:t.zoomDuration})));(void 0===t.mouseWheelZoom||t.mouseWheelZoom)&&e.push(new Pa({onFocusOnly:t.onFocusOnly,duration:t.zoomDuration}));return(void 0===t.shiftDragZoom||t.shiftDragZoom)&&e.push(new Sa({duration:t.zoomDuration})),e}var La="opacity",Aa="visible",Oa="extent",Da="zIndex",Na="maxResolution",ka="minResolution",Ga="maxZoom",Ua="minZoom",ja="source",Ba="map";class za extends V{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[La]=void 0!==t.opacity?t.opacity:1,Ft("number"==typeof e[La],"Layer opacity must be a number"),e[Aa]=void 0===t.visible||t.visible,e[Da]=t.zIndex,e[Na]=void 0!==t.maxResolution?t.maxResolution:1/0,e[ka]=void 0!==t.minResolution?t.minResolution:0,e[Ua]=void 0!==t.minZoom?t.minZoom:-1/0,e[Ga]=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=be(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 j()}getLayerStatesArray(t){return j()}getExtent(){return this.get(Oa)}getMaxResolution(){return this.get(Na)}getMinResolution(){return this.get(ka)}getMinZoom(){return this.get(Ua)}getMaxZoom(){return this.get(Ga)}getOpacity(){return this.get(La)}getSourceState(){return j()}getVisible(){return this.get(Aa)}getZIndex(){return this.get(Da)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(Oa,t)}setMaxResolution(t){this.set(Na,t)}setMinResolution(t){this.set(ka,t)}setMaxZoom(t){this.set(Ga,t)}setMinZoom(t){this.set(Ua,t)}setOpacity(t){Ft("number"==typeof t,"Layer opacity must be a number"),this.set(La,t)}setVisible(t){this.set(Aa,t)}setZIndex(t){this.set(Da,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}class Xa extends L{constructor(t,e){super(t),this.layer=e}}const Va="layers";class $a extends za{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(Va,this.handleLayersChanged_),i?Array.isArray(i)?i=new Z(i.slice(),{unique:!0}):Ft("function"==typeof i.getArray,"Expected `layers` to be an array or a `Collection`"):i=new Z(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(k),this.layersListenerKeys_.length=0;const i=this.getLayers();this.layersListenerKeys_.push(D(i,t,this.handleLayersAdd_,this),D(i,e,this.handleLayersRemove_,this));for(const t in this.listenerKeys_)this.listenerKeys_[t].forEach(k);F(this.listenerKeys_);const n=i.getArray();for(let t=0,e=n.length;t{this.dispatchEvent("sourceready")}),0)),this.clearRenderer()),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;if(!t&&i&&(t=i.getView()),e=t instanceof wo?{viewState:t.getState(),extent:t.calculateExtent()}:t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray()),e.layerStatesArray){if(n=e.layerStatesArray.find((t=>t.layer===this)),!n)return!1}else n=this.getLayerState();const r=this.getExtent();return Ja(n,e.viewState)&&(!r||xe(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];let i=e(t instanceof wo?t.getViewStateAndExtent():t);return Array.isArray(i)||(i=[i]),i}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(Ba,t)}getMapInternal(){return this.get(Ba)}setMap(t){this.mapPrecomposeKey_&&(k(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(k(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=D(t,Ya,this.handlePrecompose_,this),this.mapRenderKey_=D(this,n,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);Ft(!e.some((t=>t.layer===i.layer)),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),e.push(i)}setSource(t){this.set(ja,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Ja(t,e){if(!t.visible)return!1;const i=e.resolution;if(i=t.maxResolution)return!1;const n=e.zoom;return n>t.minZoom&&n<=t.maxZoom}function Qa(t,e,i=0,n=t.length-1,r=el){for(;n>i;){if(n-i>600){const 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);Qa(t,e,Math.max(i,Math.floor(e-o*l/s+h)),Math.min(n,Math.floor(e+(s-o)*l/s+h)),r)}const s=t[e];let o=i,a=n;for(tl(t,i,e),r(t[n],s)>0&&tl(t,i,n);o0;)a--}0===r(t[i],s)?tl(t,i,a):(a++,tl(t,a,n)),a<=e&&(i=a+1),e<=a&&(n=a-1)}}function tl(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function el(t,e){return te?1:0}let il=class{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(!gl(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let s=0;s=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=fl(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,rl(i,this.toBBox),rl(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=fl([t,e]),this.data.height=t.height+1,this.data.leaf=!1,rl(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=sl(t,0,o,this.toBBox),a=sl(t,o,i,this.toBBox),l=ul(e,a),h=hl(e)+hl(a);l=e;n--){const e=t.children[n];ol(o,t.leaf?r(e):e),a+=cl(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)ol(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():rl(t[i],this.toBBox)}};function nl(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n=t.minX&&e.maxY>=t.minY}function fl(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function pl(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;Qa(t,o,e,i,r),s.push(e,o,o,i)}}const _l=[NaN,NaN,NaN,0];let ml;const yl=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,xl=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,vl=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Sl=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function El(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function wl(t){throw new Error('failed to parse "'+t+'" as color')}function Tl(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(xl)||t.match(yl)||t.match(vl);if(e){const t=e[4],i=100/255;return[be(El(e[1],i)+.5|0,0,255),be(El(e[2],i)+.5|0,0,255),be(El(e[3],i)+.5|0,0,255),void 0!==t?be(El(t,100),0,1):1]}wl(t)}if(t.startsWith("#")){if(Sl.test(t)){const e=t.substring(1),i=e.length<=4?1:2,n=[0,0,0,255];for(let t=0,r=e.length;t.0031308?269.025*Math.pow(t,1/2.4)-14.025:3294.6*t}function Fl(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Ml(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function Ll(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Al(t){const e=Ml(t[0]),i=Ml(t[1]),n=Ml(t[2]),r=Ll(.222488403*e+.716873169*i+.06060791*n),s=500*(Ll(.452247074*e+.399439023*i+.148375274*n)-r),o=200*(r-Ll(.016863605*e+.117638439*i+.865350722*n)),a=Math.atan2(o,s)*(180/Math.PI);return[116*r-16,Math.sqrt(s*s+o*o),a<0?a+360:a,t[3]]}function Ol(t){const e=(t[0]+16)/116,i=t[1],n=t[2]*Math.PI/180,r=Fl(e),s=Fl(e+i/500*Math.cos(n)),o=Fl(e-i/200*Math.sin(n)),a=Il(3.021973625*s-1.617392459*r-.404875592*o),l=Il(-.943766287*s+1.916279586*r+.027607165*o),h=Il(.069407491*s-.22898585*r+1.159737864*o);return[be(a+.5|0,0,255),be(l+.5|0,0,255),be(h+.5|0,0,255),t[3]]}function Dl(t){if("none"===t)return _l;if(Rl.hasOwnProperty(t))return Rl[t];if(bl>=1024){let t=0;for(const e in Rl)3&t++||(delete Rl[e],--bl)}const e=Tl(t);4!==e.length&&wl(t);for(const i of e)isNaN(i)&&wl(t);return Rl[t]=e,++bl,e}function Nl(t){return Array.isArray(t)?t:Dl(t)}function kl(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(1e3*t[3])/1e3)+")"}function Gl(t){return t[0]>0&&t[1]>0}function Ul(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 jl(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}let Bl=0;const zl=1<",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},sh={[rh.Get]:gh(hh(1,1/0),oh),[rh.Var]:gh(hh(1,1),(function(t,e,i){const n=t[1];if("string"!=typeof n)throw new Error("expected a string argument for var operation");return i.variables.add(n),[new th(Vl,n)]})),[rh.Has]:gh(hh(1,1/0),oh),[rh.Id]:gh((function(t,e,i){i.featureId=!0}),lh),[rh.Concat]:gh(hh(2,1/0),uh(Vl)),[rh.GeometryType]:gh((function(t,e,i){i.geometryType=!0}),lh),[rh.LineMetric]:gh(lh),[rh.Resolution]:gh(ah,lh),[rh.Zoom]:gh(ah,lh),[rh.Time]:gh(ah,lh),[rh.Any]:gh(hh(2,1/0),uh(zl)),[rh.All]:gh(hh(2,1/0),uh(zl)),[rh.Not]:gh(hh(1,1),uh(zl)),[rh.Equal]:gh(hh(2,2),uh(Yl)),[rh.NotEqual]:gh(hh(2,2),uh(Yl)),[rh.GreaterThan]:gh(hh(2,2),uh(Xl)),[rh.GreaterThanOrEqualTo]:gh(hh(2,2),uh(Xl)),[rh.LessThan]:gh(hh(2,2),uh(Xl)),[rh.LessThanOrEqualTo]:gh(hh(2,2),uh(Xl)),[rh.Multiply]:gh(hh(2,1/0),ch),[rh.Coalesce]:gh(hh(2,1/0),ch),[rh.Divide]:gh(hh(2,2),uh(Xl)),[rh.Add]:gh(hh(2,1/0),uh(Xl)),[rh.Subtract]:gh(hh(2,2),uh(Xl)),[rh.Clamp]:gh(hh(3,3),uh(Xl)),[rh.Mod]:gh(hh(2,2),uh(Xl)),[rh.Pow]:gh(hh(2,2),uh(Xl)),[rh.Abs]:gh(hh(1,1),uh(Xl)),[rh.Floor]:gh(hh(1,1),uh(Xl)),[rh.Ceil]:gh(hh(1,1),uh(Xl)),[rh.Round]:gh(hh(1,1),uh(Xl)),[rh.Sin]:gh(hh(1,1),uh(Xl)),[rh.Cos]:gh(hh(1,1),uh(Xl)),[rh.Atan]:gh(hh(1,2),uh(Xl)),[rh.Sqrt]:gh(hh(1,1),uh(Xl)),[rh.Match]:gh(hh(4,1/0),dh,(function(t,e,i){const n=t.length-1,r=Vl|Xl|zl,s=nh(t[1],r,i),o=nh(t[t.length-1],e,i),a=new Array(n-2);for(let e=0;ee){throw new Error(`expected ${e===1/0?`${t} or more`:`${t} to ${e}`} arguments for ${s}, got ${o}`)}}}function ch(t,e,i){const n=t.length-1,r=new Array(n);for(let s=0;s{for(let e=0;e{for(let r=0;r{const n=t.args;let r=e.properties[i];for(let t=1,e=n.length;tt.variables[i];case rh.Has:return e=>{const n=t.args;if(!(i in e.properties))return!1;let r=e.properties[i];for(let t=1,e=n.length;tt.featureId;case rh.GeometryType:return t=>t.geometryType;case rh.Concat:{const e=t.args.map((t=>mh(t)));return t=>"".concat(...e.map((e=>e(t).toString())))}case rh.Resolution:return t=>t.resolution;case rh.Any:case rh.All:case rh.Between:case rh.In:case rh.Not:return function(t){const e=t.operator,i=t.args.length,n=new Array(i);for(let e=0;e{for(let e=0;e{for(let e=0;e{const e=n[0](t),i=n[1](t),r=n[2](t);return e>=i&&e<=r};case rh.In:return t=>{const e=n[0](t);for(let r=1;r!n[0](t);default:throw new Error(`Unsupported logical operator ${e}`)}}(t);case rh.Equal:case rh.NotEqual:case rh.LessThan:case rh.LessThanOrEqualTo:case rh.GreaterThan:case rh.GreaterThanOrEqualTo:return function(t){const e=t.operator,i=mh(t.args[0]),n=mh(t.args[1]);switch(e){case rh.Equal:return t=>i(t)===n(t);case rh.NotEqual:return t=>i(t)!==n(t);case rh.LessThan:return t=>i(t)i(t)<=n(t);case rh.GreaterThan:return t=>i(t)>n(t);case rh.GreaterThanOrEqualTo:return t=>i(t)>=n(t);default:throw new Error(`Unsupported comparison operator ${e}`)}}(t);case rh.Multiply:case rh.Divide:case rh.Add:case rh.Subtract:case rh.Clamp:case rh.Mod:case rh.Pow:case rh.Abs:case rh.Floor:case rh.Ceil:case rh.Round:case rh.Sin:case rh.Cos:case rh.Atan:case rh.Sqrt:return function(t){const e=t.operator,i=t.args.length,n=new Array(i);for(let e=0;e{let e=1;for(let r=0;rn[0](t)/n[1](t);case rh.Add:return t=>{let e=0;for(let r=0;rn[0](t)-n[1](t);case rh.Clamp:return t=>{const e=n[0](t),i=n[1](t);if(er?r:e};case rh.Mod:return t=>n[0](t)%n[1](t);case rh.Pow:return t=>Math.pow(n[0](t),n[1](t));case rh.Abs:return t=>Math.abs(n[0](t));case rh.Floor:return t=>Math.floor(n[0](t));case rh.Ceil:return t=>Math.ceil(n[0](t));case rh.Round:return t=>Math.round(n[0](t));case rh.Sin:return t=>Math.sin(n[0](t));case rh.Cos:return t=>Math.cos(n[0](t));case rh.Atan:return 2===i?t=>Math.atan2(n[0](t),n[1](t)):t=>Math.atan(n[0](t));case rh.Sqrt:return t=>Math.sqrt(n[0](t));default:throw new Error(`Unsupported numeric operator ${e}`)}}(t);case rh.Case:return function(t){const e=t.args.length,i=new Array(e);for(let n=0;n{for(let n=0;n{const n=i[0](t);for(let r=1;r{const n=i[0](t),r=i[1](t);let s,o;for(let a=2;a=r)return 2===a?l:h?xh(n,r,s,o,e,l):yh(n,r,s,o,e,l);s=e,o=l}return o}}(t);case rh.ToString:return function(t){const e=t.operator,i=t.args.length,n=new Array(i);for(let e=0;e{const i=n[0](e);return t.args[0].type===$l?kl(i):i.toString()};throw new Error(`Unsupported convert operator ${e}`)}(t);default:throw new Error(`Unsupported operator ${i}`)}}function yh(t,e,i,n,r,s){const o=r-i;if(0===o)return n;const a=e-i;return n+(1===t?a/o:(Math.pow(t,a)-1)/(Math.pow(t,o)-1))*(s-n)}function xh(t,e,i,n,r,s){if(0===r-i)return n;const o=Al(n),a=Al(s);let l=a[2]-o[2];l>180?l-=360:l<-180&&(l+=360);return Ol([yh(t,e,i,o[0],r,a[0]),yh(t,e,i,o[1],r,a[1]),o[2]+yh(t,e,i,0,r,l),yh(t,e,i,n[3],r,s[3])])}class vh{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},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];3&t++||i.hasListener()||(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const n=Sh(t,e,i);return n in this.cache_?this.cache_[n]:null}getPattern(t,e,i){const n=Sh(t,e,i);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,i,n,r){const s=Sh(t,e,i),o=s in this.cache_;this.cache_[s]=n,r&&(n.getImageState()===bs&&n.load(),n.getImageState()===Ps?n.ready().then((()=>{this.patternCache_[s]=_t().createPattern(n.getImage(1),"repeat")})):this.patternCache_[s]=_t().createPattern(n.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function Sh(t,e,i){return e+":"+t+":"+(i?Nl(i):"null")}const Eh=new vh;let wh=null;class Th extends O{constructor(t,e,i,n,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=void 0===n?bs:n,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,null!==this.crossOrigin_&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(void 0===this.tainted_&&this.imageState_===Is){wh||(wh=ft(1,1,void 0,{willReadFrequently:!0})),wh.drawImage(this.image_,0,0);try{wh.getImageData(0,0,1,1),this.tainted_=!1}catch{wh=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(n)}handleImageError_(){this.imageState_=Fs,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Is,this.size_=[this.image_.width,this.image_.height],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=ft(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_===bs){this.image_||this.initializeImage_(),this.imageState_=Ps;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Ds(this.image_,this.src_).then((t=>{this.image_=t,this.handleImageLoad_()})).catch(this.handleImageError_.bind(this))}}replaceColor_(t){if(!this.color_||this.canvas_[t]||this.imageState_!==Is)return;const e=this.image_,i=ft(Math.ceil(e.width*t),Math.ceil(e.height*t)),n=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Cl(this.color_),i.fillRect(0,0,n.width/t,n.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise((t=>{if(this.imageState_===Is||this.imageState_===Fs)t();else{const e=()=>{this.imageState_!==Is&&this.imageState_!==Fs||(this.removeEventListener(n,e),t())};this.addEventListener(n,e)}}))),this.ready_}}function Ch(t,e,i,n,r,s){let o=void 0===e?void 0:Eh.get(e,i,r);return o||(o=new Th(t,t&&"src"in t?t.src||void 0:e,i,n,r),Eh.set(e,i,r,o,s)),s&&o&&!Eh.getPattern(e,i,r)&&Eh.set(e,i,r,o,s),o}function Rh(t){return t?Array.isArray(t)?kl(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return Eh.getPattern(t.src,"anonymous",t.color);const e=t.src+":"+t.offset,i=Eh.getPattern(e,void 0,t.color);if(i)return i;const n=Eh.get(t.src,"anonymous",null);if(n.getImageState()!==Is)return null;const r=ft(t.size[0],t.size[1]);return r.drawImage(n.getImage(1),t.offset[0],t.offset[1],t.size[0],t.size[1],0,0,t.size[0],t.size[1]),Ch(r.canvas,e,void 0,Is,t.color,!0),Eh.getPattern(e,void 0,t.color)}(t):t:null}const bh="10px sans-serif",Ph="#000",Ih="round",Fh=[],Mh="round",Lh=10,Ah="#000",Oh="center",Dh="middle",Nh=[0,0,0,0],kh=new V;let Gh,Uh=null;const jh={},Bh=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;hMath.max(e,Vh(t,i))),0);return i[e]=n,n}function Wh(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,l=0;continue}const d=e[h+1]||t.font,g=Vh(d,u);i.push(g),o+=g;const f=zh(d);n.push(f),l=Math.max(l,f)}return{width:s,height:a,widths:i,heights:n,lineWidths:r}}function Zh(t,e,i,n,r,s,o,a,l,h,c){t.save(),1!==i&&(void 0===t.globalAlpha?t.globalAlpha=t=>t.globalAlpha*=i:t.globalAlpha*=i),e&&t.transform.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;tthis.imageState_=Is)),this.render()}clone(){const t=this.getScale(),e=new Hh({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_,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.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let n=Eh.get(i,null,null)?.getImage(1);if(!n){const e=this.renderOptions_,r=Math.ceil(e.size*t),s=ft(r,r);this.draw_(e,s,t),n=s.canvas,Eh.set(i,null,null,new Th(n,void 0,null,Is,null))}return n}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}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{this.patternImage_=null})),e.getImageState()===bs&&e.load(),e.getImageState()===Ps&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?z(t):"object"==typeof t&&"src"in t?t.src+":"+t.offset:Nl(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function Jh(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 Qh extends Yh{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;let o,a=t.src;if(Ft(!(void 0!==a&&s),"`image` and `src` cannot be provided at the same time"),void 0!==a&&0!==a.length||!s||(a=s.src||z(s)),Ft(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),Ft(!((void 0!==t.width||void 0!==t.height)&&void 0!==t.scale),"`width` or `height` cannot be provided together with `scale`"),void 0!==t.src?o=bs:void 0!==s&&(o="complete"in s?s.complete?s.src?Is:bs:Ps:Is),this.color_=void 0!==t.color?Nl(t.color):null,this.iconImage_=Ch(s,a,this.crossOrigin_,o,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,this.initialOptions_,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.width&&n.height)e=n.width,i=n.height;else if(n instanceof HTMLImageElement){this.initialOptions_=t;const e=()=>{if(this.unlistenImageChange(e),!this.initialOptions_)return;const i=this.iconImage_.getSize();this.setScale(Jh(i[0],i[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(Jh(e,i,t.width,t.height))}}clone(){let t,e,i;return this.initialOptions_?(e=this.initialOptions_.width,i=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new Qh({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_,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()==Is?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:this.iconImage_.getImageState()==Is?this.iconImage_.getSize()[1]*t[1]:void 0}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(n,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(n,t)}ready(){return this.iconImage_.ready()}}class tc{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 tc({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}}class ec{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=oc,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 ec({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,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_=oc,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function ic(t){let e;if("function"==typeof t)e=t;else{let i;if(Array.isArray(t))i=t;else{Ft("function"==typeof t.getZIndex,"Expected an `Style` or an array of `Style`");i=[t]}e=function(){return i}}return e}let nc=null;function rc(t,e){if(!nc){const t=new qh({color:"rgba(255,255,255,0.4)"}),e=new tc({color:"#3399CC",width:1.25});nc=[new ec({image:new Kh({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return nc}function sc(){const t={},e=[255,255,255,1],i=[0,153,255,1];return t.Polygon=[new ec({fill:new qh({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new ec({stroke:new tc({color:e,width:5})}),new ec({stroke:new tc({color:i,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new ec({image:new Kh({radius:6,fill:new qh({color:i}),stroke:new tc({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function oc(t){return t.getGeometry()}class ac{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=jl(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 qh({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,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new ac({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),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,declutterMode:this.getDeclutterMode()})}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_}getKeepUpright(){return this.keepUpright_}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_}getDeclutterMode(){return this.declutterMode_}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}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=jl(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}}function lc(t){return!0}function hc(t){const e=ih(),i=uc(t,e),n={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""};return function(t,r){if(n.properties=t.getPropertiesInternal(),n.resolution=r,e.featureId){const e=t.getId();n.featureId=void 0!==e?e:null}return e.geometryType&&(n.geometryType=fh(t.getGeometry())),i(n)}}function cc(t){const e=ih(),i=t.length,n=new Array(i);for(let r=0;rnull;n=yc(t,e+"fill-color",i)}if(!n)return null;const r=new qh;return function(t){const e=n(t);return e===_l?null:(r.setColor(e),r)}}function fc(t,e,i){const n=pc(t,e+"stroke-width",i),r=yc(t,e+"stroke-color",i);if(!n&&!r)return null;const s=_c(t,e+"stroke-line-cap",i),o=_c(t,e+"stroke-line-join",i),a=xc(t,e+"stroke-line-dash",i),l=pc(t,e+"stroke-line-dash-offset",i),h=pc(t,e+"stroke-miter-limit",i),c=new tc;return function(t){if(r){const e=r(t);if(e===_l)return null;c.setColor(e)}if(n&&c.setWidth(n(t)),s){const e=s(t);if("butt"!==e&&"round"!==e&&"square"!==e)throw new Error("Expected butt, round, or square line cap");c.setLineCap(e)}if(o){const e=o(t);if("bevel"!==e&&"round"!==e&&"miter"!==e)throw new Error("Expected bevel, round, or miter line join");c.setLineJoin(e)}return a&&c.setLineDash(a(t)),l&&c.setLineDashOffset(l(t)),h&&c.setMiterLimit(h(t)),c}}function pc(t,e,i){if(!(e in t))return;const n=_h(t[e],Xl,i);return function(t){return Ic(n(t),e)}}function _c(t,e,i){if(!(e in t))return null;const n=_h(t[e],Vl,i);return function(t){return Pc(n(t),e)}}function mc(t,e,i){if(!(e in t))return null;const n=_h(t[e],zl,i);return function(t){const i=n(t);if("boolean"!=typeof i)throw new Error(`Expected a boolean for ${e}`);return i}}function yc(t,e,i){if(!(e in t))return null;const n=_h(t[e],$l,i);return function(t){return Fc(n(t),e)}}function xc(t,e,i){if(!(e in t))return null;const n=_h(t[e],Wl,i);return function(t){return bc(n(t),e)}}function vc(t,e,i){if(!(e in t))return null;const n=_h(t[e],Wl,i);return function(t){const i=bc(n(t),e);if(2!==i.length)throw new Error(`Expected two numbers for ${e}`);return i}}function Sc(t,e,i){if(!(e in t))return null;const n=_h(t[e],Wl,i);return function(t){return Mc(n(t),e)}}function Ec(t,e,i){if(!(e in t))return null;const n=_h(t[e],Wl|Xl,i);return function(t){return function(t,e){if("number"==typeof t)return t;return Mc(t,e)}(n(t),e)}}function wc(t,e){const i=t[e];if(void 0!==i){if("number"!=typeof i)throw new Error(`Expected a number for ${e}`);return i}}function Tc(t,e){const i=t[e];if(void 0!==i){if("bottom-left"!==i&&"bottom-right"!==i&&"top-left"!==i&&"top-right"!==i)throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return i}}function Cc(t,e){const i=t[e];if(void 0!==i){if("pixels"!==i&&"fraction"!==i)throw new Error(`Expected pixels or fraction for ${e}`);return i}}function Rc(t,e){const i=t[e];if(void 0!==i){if("string"!=typeof i)throw new Error(`Expected a string for ${e}`);if("declutter"!==i&&"obstacle"!==i&&"none"!==i)throw new Error(`Expected declutter, obstacle, or none for ${e}`);return i}}function bc(t,e){if(!Array.isArray(t))throw new Error(`Expected an array for ${e}`);const i=t.length;for(let n=0;n4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return i}function Mc(t,e){const i=bc(t,e);if(2!==i.length)throw new Error(`Expected an array of two numbers for ${e}`);return i}const Lc="renderOrder";class Ac extends qa{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_=t.declutter?String(t.declutter):void 0,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(Lc)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,e){const i=this.getDeclutter();i in t.declutter==!1&&(t.declutter[i]=new il(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Lc,t)}setStyle(t){this.style_=void 0===t?rc:t;const e=function(t){if(void 0===t)return rc;if(!t)return null;if("function"==typeof t)return t;if(t instanceof ec)return t;if(!Array.isArray(t))return cc([t]);if(0===t.length)return[];const e=t.length,i=t[0];if(i instanceof ec){const i=new Array(e);for(let n=0;n=0;--r){const s=f[r],u=s.layer;if(u.hasRenderer()&&Ja(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);m[0]=a[0]+g[n][0],m[1]=a[1]+g[n][1],l=r.forEachFeatureAtCoordinate(m,e,i,h,_)}if(l)return l}}if(0===_.length)return;const y=1/_.length;return _.forEach(((t,e)=>t.distanceSq+=e*y)),_.sort(((t,e)=>t.distanceSq-e.distanceSq)),_.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,C,this,r,s)}getMap(){return this.map_}renderFrame(t){j()}scheduleExpireIconCache(t){Eh.canExpireCache()&&t.postRenderFunctions.push(Nc)}}function Nc(t,e){Eh.expire()}class kc extends Dc{constructor(t){super(t),this.fontChangeListenerKey_=D(kh,i,t.redrawText,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=Lo+" ol-layers";const n=t.getViewport();n.insertBefore(this.element_,n.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new Oc(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){k(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t)return void(this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1));this.calculateMatrices2D(t),this.dispatchRenderEvent(Ya,t);const e=t.layerStatesArray.sort(((t,e)=>t.zIndex-e.zIndex));e.some((t=>t.layer instanceof Ac&&t.layer.getDeclutter()))&&(t.declutter={});const i=t.viewState;this.children_.length=0;const n=[];let r=null;for(let s=0,o=e.length;s=0;--i){const n=e[i],r=n.layer;r.getDeclutter()&&r.renderDeclutter(t,n)}e.forEach((e=>e.layer.renderDeferred(t)))}}}function Gc(t){t instanceof qa?t.setMapInternal(null):t instanceof $a&&t.getLayers().forEach(Gc)}function Uc(t,e){if(t instanceof qa)t.setMapInternal(e);else if(t instanceof $a){const i=t.getLayers().getArray();for(let t=0,n=i.length;tthis.updateSize())),this.controls=n.controls||Xo(),this.interactions=n.interactions||Ma({onFocusOnly:!0}),this.overlays_=n.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new so(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Qs,this.handleLayerGroupChanged_),this.addChangeListener(io,this.handleViewChanged_),this.addChangeListener(to,this.handleSizeChanged_),this.addChangeListener(eo,this.handleTargetChanged_),this.setProperties(n.values);const r=this;!i.view||i.view instanceof wo||i.view.then((function(t){r.setView(new wo(t))})),this.controls.addEventListener(t,(t=>{t.element.setMap(this)})),this.controls.addEventListener(e,(t=>{t.element.setMap(null)})),this.interactions.addEventListener(t,(t=>{t.element.setMap(this)})),this.interactions.addEventListener(e,(t=>{t.element.setMap(null)})),this.overlays_.addEventListener(t,(t=>{this.addOverlayInternal_(t.element)})),this.overlays_.addEventListener(e,(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){Uc(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:C,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 $a?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:C,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(eo)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Nn(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?Kn(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(Qs)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Z)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=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[ao]||e[lo]){const e=Date.now()-t.time>8;i=e?0:8,n=e?0:2}}e.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()}),0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Xa("removelayer",e)),this.set(Qs,t)}setSize(t){this.set(to,t)}setTarget(t){this.set(eo,t)}setView(t){if(!t||t instanceof wo)return void this.set(io,t);this.set(io,new wo);const e=this;t.then((function(t){e.setView(new wo(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=[Math.max(0,n),Math.max(0,r)],!Gl(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Ze("No map visible because the map container's width or height are 0."))}const i=this.getSize();!e||i&&w(e,i)||(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};const Bc="element",zc="map",Xc="offset",Vc="position",$c="positioning";class Wc extends V{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 "+Mo,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(Bc,this.handleElementChanged),this.addChangeListener(zc,this.handleMapChanged),this.addChangeListener(Xc,this.handleOffsetChanged),this.addChangeListener(Vc,this.handlePositionChanged),this.addChangeListener($c,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(Bc)}getId(){return this.id}getMap(){return this.get(zc)||null}getOffset(){return this.get(Xc)}getPosition(){return this.get(Vc)}getPositioning(){return this.get($c)}handleElementChanged(){St(this.element);const t=this.getElement();t&&this.element.appendChild(t)}handleMapChanged(){this.mapPostrenderListenerKey&&(this.element?.remove(),k(this.mapPostrenderListenerKey),this.mapPostrenderListenerKey=null);const t=this.getMap();if(t){this.mapPostrenderListenerKey=D(t,Ys,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(Bc,t)}setMap(t){this.set(zc,t)}setOffset(t){this.set(Xc,t)}setPosition(t){this.set(Vc,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(Vc))return;const i=this.getRect(e.getTargetElement(),e.getSize()),n=this.getElement(),r=this.getRect(n,[yt(n),xt(n)]),s=void 0===(t=t||{}).margin?20:t.margin;if(!Vt(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($c,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}}class Zc{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.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.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 Yc(t,e,i,n,r){return void 0!==r?(r.minX=t,r.maxX=e,r.minY=i,r.maxY=n,r):new Zc(t,e,i,n)}const Hc=[];class Kc extends nt{constructor(t,e,i,n,r){super(t,e,{transition:0}),this.context_=null,this.executorGroups={},this.loadingSourceTiles=0,this.hitDetectionImageData={},this.replayState_={},this.sourceTiles=[],this.errorTileKeys={},this.wantedResolution,this.getSourceTiles=n.bind(void 0,this),this.removeSourceTiles_=r,this.wrappedTileCoord=i}getContext(){return this.context_||(this.context_=ft(1,1,Hc)),this.context_}hasContext(){return!!this.context_}getImage(){return this.hasContext()?this.getContext().canvas:null}getReplayState(t){const e=z(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(){this.context_&&(mt(this.context_),Hc.push(this.context_.canvas),this.context_=null),this.removeSourceTiles_(this),this.sourceTiles.length=0,super.release()}}let qc,Jc=class extends nt{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}getTileUrl(){return this.url_}getFormat(){return this.format_}getFeatures(){return this.features_}load(){this.state==Y&&(this.setState(H),this.tileLoadFunction_(this,this.url_),this.loader_&&this.loader_(this.extent,this.resolution,this.projection))}onLoad(t,e){this.setFeatures(t)}onError(){this.setState(q)}setFeatures(t){this.features_=t,this.setState(K)}setLoader(t){this.loader_=t}},Qc=!1;function tu(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=Qc,a.onload=function(t){if(!a.status||a.status>=200&&a.status<300){const t=e.getType();try{let n;"text"==t||"json"==t?n=a.responseText:"xml"==t?n=a.responseXML||a.responseText:"arraybuffer"==t&&(n=a.response),n?s(e.readFeatures(n,{extent:i,featureProjection:r}),e.readProjection(n)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function eu(t,e){return function(i,n,r,s,o){tu(t,e,i,n,r,((t,e)=>{this.addFeatures(t),void 0!==s&&s(t)}),(()=>{this.changed(),void 0!==o&&o()}))}}function iu(t,e){return[[-1/0,-1/0,1/0,1/0]]}function nu(t,e,i,n){const r=document.createElement("script"),s="olc_"+z(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 ru extends Error{constructor(t){super("Unexpected response status: "+t.status),this.name="ResponseError",this.response=t}}class su extends Error{constructor(t){super("Failed to issue request"),this.name="ClientError",this.client=t}}function ou(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 ru(n))})),n.addEventListener("error",(function(t){i(new su(t.target))})),n.open("GET",t),n.setRequestHeader("Accept","application/json"),n.send()}))}function au(t,e){return e.includes("://")?e:new URL(e,t).href}class lu{drawCustom(t,e,i,n,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}class hu extends lu{constructor(t,e,i,n,r,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?De(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=ar(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;tt*this.pixelRatio_)),lineDashOffset:(r||0)*this.pixelRatio_,lineJoin:void 0!==s?s:Mh,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:Lh,strokeStyle:Rh(t||Ah)}}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:Rh(t||Ph)}}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:Ih,lineDash:n||Fh,lineDashOffset:r||0,lineJoin:void 0!==s?s:Mh,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:Lh,strokeStyle:Rh(t||Ah)}}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:bh,textAlign:void 0!==c?c:Oh,textBaseline:void 0!==u?u:Dh},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 cu={Point:function(t,e,i,n,r,s){const o=i.getImage(),a=i.getText(),l=a&&a.getText(),h=s&&o&&l?{}:void 0;if(o){if(o.getImageState()!=Is)return;const s=t.getBuilder(i.getZIndex(),"Image");s.setImageStyle(o,h),s.drawPoint(e,n,r)}if(l){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(a,h),s.drawText(e,n,r)}},LineString:function(t,e,i,n,r){const s=i.getStroke();if(s){const o=t.getBuilder(i.getZIndex(),"LineString");o.setFillStrokeStyle(null,s),o.drawLineString(e,n,r)}const o=i.getText();if(o&&o.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,n,r)}},Polygon:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(s||o){const a=t.getBuilder(i.getZIndex(),"Polygon");a.setFillStrokeStyle(s,o),a.drawPolygon(e,n,r)}const a=i.getText();if(a&&a.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n,r)}},MultiPoint:function(t,e,i,n,r,s){const o=i.getImage(),a=o&&0!==o.getOpacity(),l=i.getText(),h=l&&l.getText(),c=s&&a&&h?{}:void 0;if(a){if(o.getImageState()!=Is)return;const s=t.getBuilder(i.getZIndex(),"Image");s.setImageStyle(o,c),s.drawMultiPoint(e,n,r)}if(h){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(l,c),s.drawText(e,n,r)}},MultiLineString:function(t,e,i,n,r){const s=i.getStroke();if(s){const o=t.getBuilder(i.getZIndex(),"LineString");o.setFillStrokeStyle(null,s),o.drawMultiLineString(e,n,r)}const o=i.getText();if(o&&o.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(o),s.drawText(e,n,r)}},MultiPolygon:function(t,e,i,n,r){const s=i.getFill(),o=i.getStroke();if(o||s){const a=t.getBuilder(i.getZIndex(),"Polygon");a.setFillStrokeStyle(s,o),a.drawMultiPolygon(e,n,r)}const a=i.getText();if(a&&a.getText()){const s=t.getBuilder(i.getZIndex(),"Text");s.setTextStyle(a),s.drawText(e,n,r)}},GeometryCollection:function(t,e,i,n,r,s){const o=e.getGeometriesArray();let a,l;for(a=0,l=o.length;a0;return u&&Promise.all(l).then((()=>r(null))),function(t,e,i,n,r,s,o){const a=i.getGeometryFunction()(e);if(!a)return;const l=a.simplifyTransformed(n,r),h=i.getRenderer();if(h)pu(t,l,i,e,o);else{(0,cu[l.getType()])(t,l,i,e,o,s)}}(t,e,i,n,s,o,a),u}function pu(t,e,i,n,r){if("GeometryCollection"==e.getType()){const s=e.getGeometries();for(let e=0,o=s.length;e2||Math.abs(t[4*e+3]-191.25)>2}function Su(t,e,i,n){const r=Mn(i,e,t);let s=vn(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||Xt(l,r)){const e=vn(t,s,r)/s;isFinite(e)&&e>0&&(s/=e)}return s}function Eu(t,e,i,n){const r=ce(i);let s=Su(t,e,r,n);return(!isFinite(s)||s<=0)&&oe(i,(function(i){return s=Su(t,e,i,n),isFinite(s)&&s>0})),s}function wu(t,e,i,n,r,s,o,a,l,h,c,u,d,g){const f=ft(Math.round(i*t),Math.round(i*e),yu);if(u||(f.imageSmoothingEnabled=!1),0===l.length)return f.canvas;function p(t){return Math.round(t*i)/i}f.scale(i,i),f.globalCompositeOperation="lighter";const _=[1/0,1/0,-1/0,-1/0];let m;l.forEach((function(t,e,i){te(_,t.extent)}));const y=i/n,x=(u?1:1+Math.pow(2,-24))/y;if(!d||1!==l.length||0!==h){if(m=ft(Math.round(ye(_)*y),Math.round(fe(_)*y),yu),u||(m.imageSmoothingEnabled=!1),r&&g){const t=(r[0]-_[0])*y,e=-(r[3]-_[3])*y,i=ye(r)*y,n=fe(r)*y;m.rect(t,e,i,n),m.clip()}l.forEach((function(t,e,i){if(t.image.width>0&&t.image.height>0){if(t.clipExtent){m.save();const e=(t.clipExtent[0]-_[0])*y,i=-(t.clipExtent[3]-_[3])*y,n=ye(t.clipExtent)*y,r=fe(t.clipExtent)*y;m.rect(u?e:Math.round(e),u?i:Math.round(i),u?n:Math.round(e+n)-Math.round(e),u?r:Math.round(i+r)-Math.round(i)),m.clip()}const e=(t.extent[0]-_[0])*y,i=-(t.extent[3]-_[3])*y,n=ye(t.extent)*y,r=fe(t.extent)*y;m.drawImage(t.image,h,h,t.image.width-2*h,t.image.height-2*h,u?e:Math.round(e),u?i:Math.round(i),u?n:Math.round(e+n)-Math.round(e),u?r:Math.round(i+r)-Math.round(i)),t.clipExtent&&m.restore()}}))}const v=_e(o);return a.getTriangles().forEach((function(t,e,i){const n=t.source,r=t.target;let o=n[0][0],a=n[0][1],h=n[1][0],c=n[1][1],d=n[2][0],g=n[2][1];const y=p((r[0][0]-v[0])/s),S=p(-(r[0][1]-v[1])/s),E=p((r[1][0]-v[0])/s),w=p(-(r[1][1]-v[1])/s),T=p((r[2][0]-v[0])/s),C=p(-(r[2][1]-v[1])/s),R=o,b=a;o=0,a=0,h-=R,c-=b,d-=R,g-=b;const P=Fe([[h,c,0,0,E-y],[d,g,0,0,T-y],[0,0,h,c,w-S],[0,0,d,g,C-S]]);if(!P)return;if(f.save(),f.beginPath(),function(){if(void 0===mu){const t=ft(6,6,yu);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",xu(t,4,5,4,0),xu(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;mu=vu(e,0)||vu(e,4)||vu(e,8),mt(t),yu.push(t.canvas)}return mu}()||!u){f.moveTo(E,w);const t=4,e=y-E,i=S-w;for(let n=0;n0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}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 Ft(void 0!==i,"Tried to get a value for a key that does not exist in the cache"),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 Ft(void 0!==e,"Tried to get a value for a key that does not exist in the cache"),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){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){Ft(!(t in this.entries_),"Tried to set a value for a key that is used already");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 Ru(t,e,i,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=i,n):[t,e,i]}function bu(t,e,i){return t+"/"+e+"/"+i}function Pu(t){return bu(t[0],t[1],t[2])}function Iu(t){return Fu(t[0],t[1],t[2])}function Fu(t,e,i){return(e<i||i>e.getMaxZoom())return!1;const s=e.getFullTileRange(i);return!s||s.containsXY(n,r)}const Lu=[0,0,0];class Au{constructor(t){let e;if(this.minZoom=void 0!==t.minZoom?t.minZoom:0,this.resolutions_=t.resolutions,Ft(T(this.resolutions_,((t,e)=>e-t),!0),"`resolutions` must be sorted in descending order"),!t.origins)for(let t=0,i=this.resolutions_.length-1;t{const n=new Zc(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})):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(void 0!==s&&void 0!==o?(s=Math.floor(s/2),o=Math.floor(o/2),r=Yc(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||e0)||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 Ou({extent:e,origins:s,resolutions:n,matrixIds:r,tileSizes:o,sizes:a})}function Nu(t){let e=t.getDefaultTileGrid();return e||(e=Bu(t),t.setDefaultTileGrid(e)),e}function ku(t,e,i){const n=e[0],r=t.getTileCoordCenter(e),s=zu(i);if(!Xt(s,r)){const e=ye(s),i=Math.ceil((s[0]-r[0])/e);return r[0]+=e*i,t.getTileCoordForCoordAndZ(r,n)}return e}function Gu(t,e,i,n){n=void 0!==n?n:"top-left";const r=ju(t,e,i);return new Au({extent:t,origin:ue(t,n),resolutions:r,tileSize:i})}function Uu(t){const e=t||{},i=e.extent||xn("EPSG:3857").getExtent(),n={extent:i,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:ju(i,e.maxZoom,e.tileSize,e.maxResolution)};return new Au(n)}function ju(t,e,i,n){e=void 0!==e?e:42,i=jl(void 0!==i?i:Eo);const r=fe(t),s=ye(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;tKn(o,Mn(t,this.targetProj_,this.sourceProj_)))):Fn(this.targetProj_,this.sourceProj_);this.transformInv_=function(t){const e=t[0]+"/"+t[1];return a[e]||(a[e]=l(t)),a[e]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&ye(n)>=ye(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ye(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ye(this.targetProj_.getExtent()):null;const h=_e(i),c=me(i),u=he(i),d=le(i),g=this.transformInv_(h),f=this.transformInv_(c),p=this.transformInv_(u),_=this.transformInv_(d),m=10+(s?Math.max(0,Math.ceil(Math.log2(ae(i)/(s*s*256*256)))):0);if(this.addQuad_(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.5&&c<1;let g=!1;if(l>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){g=ye(Ut([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])&&!xe(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=(Ae(r[0],u)+Ae(o[0],u))/2-Ae(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}11&f||this.addTriangle_(t,i,n,r,o,a),14&f||this.addTriangle_(t,i,e,r,o,s),f&&(13&f||this.addTriangle_(e,n,t,s,a,r),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;ee(t,r[0]),ee(t,r[1]),ee(t,r[2])})),t}getTriangles(){return this.triangles_}}const id=.5;class nd extends nt{constructor(t,e,i,n,r,s,o,a,l,h,c,u){super(r,Y,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,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const d=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let f=this.sourceTileGrid_.getExtent();const p=g?pe(d,g):d;if(0===ae(p))return void(this.state=J);const _=t.getExtent();_&&(f=f?pe(f,_):_);const m=n.getResolution(this.wrappedTileCoord_[0]),y=Eu(t,i,p,m);if(!isFinite(y)||y<=0)return void(this.state=J);const x=void 0!==h?h:id;if(this.triangulation_=new ed(t,i,p,f,y*x,m),0===this.triangulation_.getTriangles().length)return void(this.state=J);this.sourceZ_=e.getZForResolution(y);let v=this.triangulation_.calculateSourceExtent();if(f&&(t.canWrapX()?(v[1]=be(v[1],f[1],f[3]),v[3]=be(v[3],f[1],f[3])):v=pe(v,f)),ae(v)){let i=0,n=0;t.canWrapX()&&(i=ye(_),n=Math.floor((v[0]-_[0])/i));Re(v.slice(),t,!0).forEach((t=>{const r=e.getTileRangeForExtentAndZ(t,this.sourceZ_);for(let t=r.minX;t<=r.maxX;t++)for(let e=r.minY;e<=r.maxY;e++){const r=l(this.sourceZ_,t,e,o);if(r){const t=n*i;this.sourceTiles_.push({tile:r,offset:t})}}++n})),0===this.sourceTiles_.length&&(this.state=J)}else this.state=J}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach((e=>{const i=e.tile;if(i&&i.getState()==K){const n=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);n[0]+=e.offset,n[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:n,clipExtent:r,image:i.getImage()})}})),this.sourceTiles_.length=0,0===t.length)this.state=q;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_=wu(n,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=K}this.changed()}load(){if(this.state==Y){this.state=H,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach((({tile:e})=>{const i=e.getState();if(i==Y||i==H){t++;const i=D(e,n,(n=>{const r=e.getState();r!=K&&r!=q&&r!=J||(k(i),t--,0===t&&(this.unlistenSources_(),this.reproject_()))}));this.sourcesListenerKeys_.push(i)}})),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function({tile:t},e,i){t.getState()==Y&&t.load()}))}}unlistenSources_(){this.sourcesListenerKeys_.forEach(k),this.sourcesListenerKeys_=null}release(){this.canvas_&&(mt(this.canvas_.getContext("2d")),yu.push(this.canvas_),this.canvas_=null),super.release()}}class rd extends V{constructor(t){super(),this.projection=xn(t.projection),this.attributions_=sd(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,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_=sd(t),this.changed()}setState(t){this.state_=t,this.changed()}}function sd(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}class od extends rd{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.tilePixelRatio_=void 0!==t.tilePixelRatio?t.tilePixelRatio:1,this.tileGrid=void 0!==t.tileGrid?t.tileGrid:null;const e=[256,256];this.tileGrid&&jl(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||z(this),this.tileOptions={transition:t.transition,interpolate:t.interpolate},this.zDirection=t.zDirection?t.zDirection:0}getGutterForProjection(t){return 0}getKey(){return this.key_}setKey(t){this.key_!==t&&(this.key_=t,this.changed())}getResolutions(t){const e=t?this.getTileGridForProjection(t):this.tileGrid;return e?e.getResolutions():null}getTile(t,e,i,n,r){return j()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Nu(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),s=jl(n.getTileSize(t),this.tmpSize);return 1==r?s:Ul(s,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){const i=void 0!==e?e:this.getProjection(),n=void 0!==e?this.getTileGridForProjection(i):this.tileGrid||this.getTileGridForProjection(i);return this.getWrapX()&&i.isGlobal()&&(t=ku(n,t,i)),Mu(t,n)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class ad extends L{constructor(t,e){super(t),this.tile=e}}var ld="tileloadstart",hd="tileloadend",cd="tileloaderror";class ud extends od{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,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===ud.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=z(e),n=e.getState();let r;n==H?(this.tileLoadingKeys_[i]=!0,r=ld):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==q?cd:n==K?hd:void 0),null!=r&&this.dispatchEvent(new ad(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,void 0!==e?this.setKey(e):this.changed()}setUrl(t){const e=Ku(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(Ju(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class dd extends ud{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:gd,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:Gs,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!bn(this.getProjection(),t)?0:this.getGutter()}getGutter(){return 0}getKey(){let t=super.getKey();return this.getInterpolate()||(t+=":disable-interpolation"),t}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||bn(e,t)))return this.tileGrid;const i=z(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Nu(t)),this.tileGridForProjection[i]}createTile_(t,e,i,r,s,o){const a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,s),h=l?this.tileUrlFunction(l,r,s):void 0,c=new this.tileClass(a,void 0!==h?Y:J,void 0!==h?h:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return c.key=o,c.addEventListener(n,this.handleTileChange.bind(this)),c}getTile(t,e,i,n,r){const s=this.getProjection();if(!s||!r||bn(s,r))return this.getTileInternal(t,e,i,n,s||r);const o=[t,e,i],a=this.getKey(),l=this.getTileGridForProjection(s),h=this.getTileGridForProjection(r),c=this.getTileCoordForTileUrlFunction(o,r),u=new nd(s,l,r,h,o,c,this.getTilePixelRatio(n),this.getGutter(),((t,e,i,n)=>this.getTileInternal(t,e,i,n,s)),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return u.key=a,u}getTileInternal(t,e,i,n,r){const s=this.getKey();return this.createTile_(t,e,i,n,r,s)}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=xn(t);if(i){const t=z(i);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}}function gd(t,e){t.getImage().src=e}function fd(t){const e=t[0],i=new Array(e);let n,r,s=1<>=1;return i.join("")}class pd extends dd{constructor(t){const e=void 0!==(t=t||{}).projection?t.projection:"EPSG:3857",i=void 0!==t.tileGrid?t.tileGrid:Uu({extent:zu(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,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_}}function _d(t,e,i,n){const r=[];let s=[1/0,1/0,-1/0,-1/0];for(let o=0,a=i.length;o1?o:2,s=s||new Array(o);for(let e=0;e>1;r=e[0]||(t[1]<=e[1]&&t[3]>=e[1]||oe(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;it.clone()))}function wd(t,e,i,n){let r=t[e],s=t[e+1],o=0;for(let a=e+n;a{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let n;switch(this.type_){case"LineString":i.length=Dr(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=Nr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=jr(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n)}return n&&(this.simplifiedGeometry_=new Id(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_})),this}}function Fd(t){const e=t.getType();switch(e){case"Point":return new Xr(t.getFlatCoordinates());case"MultiPoint":return new Rd(t.getFlatCoordinates(),"XY");case"LineString":return new Td(t.getFlatCoordinates(),"XY");case"MultiLineString":return new Cd(t.getFlatCoordinates(),"XY",t.getEnds());case"Polygon":const i=t.getFlatCoordinates(),n=t.getEnds(),r=hs(i,n);return r.length>1?new bd(i,"XY",r):new cs(i,"XY",n);default:throw new Error("Invalid geometry type:"+e)}}Id.prototype.getFlatCoordinates=Id.prototype.getOrientedFlatCoordinates;class Md{constructor(t){this.rbush_=new il(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_[z(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;n{n||(n=!0,this.addFeature(t.element),n=!1)})),i.addEventListener(e,(t=>{n||(n=!0,this.removeFeature(t.element),n=!1)})),this.featuresCollection_=i}clear(t){if(t){for(const t in this.featureChangeKeys_){this.featureChangeKeys_[t].forEach(k)}this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach((t=>{this.removeFeatureInternal(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 Ud(Od);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){const n=i.getGeometry();if(n instanceof Id||n.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){const n=i.getGeometry();if(n instanceof Id||n.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(),M(this.nullGeometryFeatures_)||E(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=Re(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||C,this.featuresRtree_.forEachInExtent(a,(function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof Id?0:e.closestPointXY(i,n,s,o),o{--this.loadingExtentsCount_,this.dispatchEvent(new Ud(kd,void 0,t))}),(()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Ud(Gd))})),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_,i=e.forEachInExtent(t,(function(e){if(Jt(e.extent,t))return e}));i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i 1.0 ||\n v_texcoord.y > 1.0\n ) {\n discard;\n }\n gl_FragColor = texture2D(u_texture, v_texcoord);\n }\n","\n attribute vec4 a_position;\n attribute vec4 a_texcoord;\n\n uniform mat4 u_matrix;\n uniform mat4 u_textureMatrix;\n\n varying vec2 v_texcoord;\n\n void main() {\n gl_Position = u_matrix * a_position;\n vec2 texcoord = (u_textureMatrix * a_texcoord).xy;\n v_texcoord = texcoord;\n }\n"),this.positionLocation=t.getAttribLocation(this.program_,"a_position"),this.texcoordLocation=t.getAttribLocation(this.program_,"a_texcoord"),this.matrixLocation=t.getUniformLocation(this.program_,"u_matrix"),this.textureMatrixLocation=t.getUniformLocation(this.program_,"u_textureMatrix"),this.textureLocation=t.getUniformLocation(this.program_,"u_texture"),this.positionBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),this.positions=[0,0,0,1,1,0,1,0,0,1,1,1],t.bufferData(t.ARRAY_BUFFER,new Float32Array(this.positions),t.STATIC_DRAW),this.texcoordBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),this.texcoords=[0,0,0,1,1,0,1,0,0,1,1,1],t.bufferData(t.ARRAY_BUFFER,new Float32Array(this.texcoords),t.STATIC_DRAW)}drawImage(t,e,i,n,r,s,o,a,l,h,c,u,d){const g=this.gl_;void 0===a&&(a=n),void 0===l&&(l=r),void 0===s&&(s=e),void 0===o&&(o=i),void 0===h&&(h=s),void 0===c&&(c=o),void 0===u&&(u=g.canvas.width),void 0===d&&(d=g.canvas.height),g.bindTexture(g.TEXTURE_2D,t),g.useProgram(this.program_),g.bindBuffer(g.ARRAY_BUFFER,this.positionBuffer),g.enableVertexAttribArray(this.positionLocation),g.vertexAttribPointer(this.positionLocation,2,g.FLOAT,!1,0,0),g.bindBuffer(g.ARRAY_BUFFER,this.texcoordBuffer),g.enableVertexAttribArray(this.texcoordLocation),g.vertexAttribPointer(this.texcoordLocation,2,g.FLOAT,!1,0,0);let f=Xd(0,u,0,d,-1,1);f=$d(f,a,l,0),f=Vd(f,h,c,1),g.uniformMatrix4fv(this.matrixLocation,!1,f);let p=Wd(n/e,r/i,0);p=Vd(p,s/e,o/i,1),g.uniformMatrix4fv(this.textureMatrixLocation,!1,p),g.uniform1i(this.textureLocation,0),g.drawArrays(g.TRIANGLES,0,this.positions.length/2)}}function Yd(t,e,i){const n=t.createShader(e);if(null===n)throw new Error("Shader compilation failed");if(t.shaderSource(n,i),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(n);if(null===e)throw new Error("Shader info log creation failed");throw new Error(e)}return n}function Hd(t,e,i){const n=t.createProgram(),r=Yd(t,t.VERTEX_SHADER,i),s=Yd(t,t.FRAGMENT_SHADER,e);if(null===n)throw new Error("Program creation failed");if(t.attachShader(n,r),t.attachShader(n,s),t.linkProgram(n),!t.getProgramParameter(n,t.LINK_STATUS)){if(null===t.getProgramInfoLog(n))throw new Error("Program info log creation failed");throw new Error}return n}function Kd(t,e,i,n){let r;return r=i&&i.length?i.shift():ct?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("webgl",n)}function qd(t){const e=t.canvas;e.width=1,e.height=1,t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)}const Jd=[];function Qd(t,e,i,n,r,s,o,a,l,h,c,u,d,g){const f=Math.round(n*e),p=Math.round(n*i);let _,m;if(t.canvas.width=f,t.canvas.height=p,m=t.createTexture(),t.bindTexture(t.TEXTURE_2D,m),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),d?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):(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,f,p,0,t.RGBA,c,null),_=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,_),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,m,0),null===_)throw new Error("Could not create framebuffer");if(null===m)throw new Error("Could not create texture");if(0===l.length)return{width:f,height:p,framebuffer:_,texture:m};const y=[1/0,1/0,-1/0,-1/0];let x,v,S;l.forEach((function(t,e,i){te(y,t.extent)}));const E=1/r;if(g&&1===l.length&&0===h)x=l[0].texture,v=l[0].width,S=l[0].width;else{if(x=t.createTexture(),null===m)throw new Error("Could not create texture");v=Math.round(ye(y)*E),S=Math.round(fe(y)*E);const e=t.getParameter(t.MAX_TEXTURE_SIZE),i=Math.max(v,S),n=i>e?e/i:1,r=Math.round(v*n),s=Math.round(S*n);t.bindTexture(t.TEXTURE_2D,x),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),d?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR)):(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,r,s,0,t.RGBA,c,null);const o=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,o),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,x,0);const a=new Zd(t);l.forEach((function(e,i,l){const c=(e.extent[0]-y[0])*E*n,u=-(e.extent[3]-y[3])*E*n,g=ye(e.extent)*E*n,f=fe(e.extent)*E*n;if(t.bindFramebuffer(t.FRAMEBUFFER,o),t.viewport(0,0,r,s),e.clipExtent){const i=(e.clipExtent[0]-y[0])*E*n,r=-(e.clipExtent[3]-y[3])*E*n,s=ye(e.clipExtent)*E*n,o=fe(e.clipExtent)*E*n;t.enable(t.SCISSOR_TEST),t.scissor(d?i:Math.round(i),d?r:Math.round(r),d?s:Math.round(i+s)-Math.round(i),d?o:Math.round(r+o)-Math.round(r))}a.drawImage(e.texture,e.width,e.height,h,h,e.width-2*h,e.height-2*h,d?c:Math.round(c),d?u:Math.round(u),d?g:Math.round(c+g)-Math.round(c),d?f:Math.round(u+f)-Math.round(u),r,s),t.disable(t.SCISSOR_TEST)})),t.deleteFramebuffer(o)}const w=_e(o),T=_e(y),C=t=>{const e=(t[0][0]-w[0])/s*n,i=-(t[0][1]-w[1])/s*n;return{u1:(t[1][0]-w[0])/s*n,v1:-(t[1][1]-w[1])/s*n,u0:e,v0:i,u2:(t[2][0]-w[0])/s*n,v2:-(t[2][1]-w[1])/s*n}};t.bindFramebuffer(t.FRAMEBUFFER,_),t.viewport(0,0,f,p);{const e=[],i=[],n=Hd(t,"\n precision mediump float;\n\n varying vec2 v_texcoord;\n\n uniform sampler2D u_texture;\n\n void main() {\n if (v_texcoord.x < 0.0 || v_texcoord.x > 1.0 || v_texcoord.y < 0.0 || v_texcoord.y > 1.0) {\n discard;\n }\n gl_FragColor = texture2D(u_texture, v_texcoord);\n }\n","\n attribute vec4 a_position;\n attribute vec2 a_texcoord;\n\n varying vec2 v_texcoord;\n\n uniform mat4 u_matrix;\n\n void main() {\n gl_Position = u_matrix * a_position;\n v_texcoord = a_texcoord;\n }\n");t.useProgram(n);const s=t.getUniformLocation(n,"u_texture");t.bindTexture(t.TEXTURE_2D,x),t.uniform1i(s,0),a.getTriangles().forEach((function(t,n,s){const o=t.source,a=t.target,{u1:l,v1:h,u0:c,v0:u,u2:d,v2:g}=C(a),f=(o[0][0]-T[0])/r/v,p=-(o[0][1]-T[1])/r/S,_=(o[1][0]-T[0])/r/v,m=-(o[1][1]-T[1])/r/S,y=(o[2][0]-T[0])/r/v,x=-(o[2][1]-T[1])/r/S;e.push(l,h,c,u,d,g),i.push(_,m,f,p,y,x)}));const o=Xd(0,f,p,0,-1,1),l=t.getUniformLocation(n,"u_matrix");t.uniformMatrix4fv(l,!1,o);const h=t.getAttribLocation(n,"a_position"),c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),t.vertexAttribPointer(h,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(h);const u=t.getAttribLocation(n,"a_texcoord"),d=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,d),t.bufferData(t.ARRAY_BUFFER,new Float32Array(i),t.STATIC_DRAW),t.vertexAttribPointer(u,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(u),t.drawArrays(t.TRIANGLES,0,e.length/2)}if(u){const e=Hd(t,"\n precision mediump float;\n\n uniform vec4 u_val;\n void main() {\n gl_FragColor = u_val;\n }\n","\n attribute vec4 a_position;\n\n uniform mat4 u_matrix;\n\n void main() {\n gl_Position = u_matrix * a_position;\n }\n");t.useProgram(e);const i=Xd(0,f,p,0,-1,1),n=t.getUniformLocation(e,"u_matrix");t.uniformMatrix4fv(n,!1,i);const r=Array.isArray(u)?u:[0,0,0,255],s=t.getUniformLocation(e,"u_val");t.uniform4fv(s,r);const o=t.getAttribLocation(e,"a_position"),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o);const h=a.getTriangles().reduce((function(t,e){const i=e.target,{u1:n,v1:r,u0:s,v0:o,u2:a,v2:l}=C(i);return t.concat([n,r,s,o,s,o,a,l,a,l,n,r])}),[]);t.bufferData(t.ARRAY_BUFFER,new Float32Array(h),t.STATIC_DRAW),t.drawArrays(t.LINES,0,h.length/2)}return{width:f,height:p,framebuffer:_,texture:m}}class tg extends It{constructor(t){super({tileCoord:t.tileCoord,loader:()=>Promise.resolve(new Uint8ClampedArray(4)),interpolate:t.interpolate,transition:t.transition}),this.renderEdges_=void 0!==t.renderEdges&&t.renderEdges,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=t.sourceProj,i=e.getExtent(),n=t.sourceTileGrid.getExtent();this.clipExtent_=e.canWrapX()?n?pe(i,n):i:n;const r=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),s=this.targetTileGrid_.getExtent();let o=this.sourceTileGrid_.getExtent();const a=s?pe(r,s):r;if(0===ae(a))return void(this.state=J);i&&(o=o?pe(o,i):i);const l=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),h=t.targetProj,c=Eu(e,h,a,l);if(!isFinite(c)||c<=0)return void(this.state=J);const u=void 0!==t.errorThreshold?t.errorThreshold:id;if(this.triangulation_=new ed(e,h,a,o,c*u,l,t.transformMatrix),0===this.triangulation_.getTriangles().length)return void(this.state=J);this.sourceZ_=this.sourceTileGrid_.getZForResolution(c);let d=this.triangulation_.calculateSourceExtent();if(o&&(e.canWrapX()?(d[1]=be(d[1],o[1],o[3]),d[3]=be(d[3],o[1],o[3])):d=pe(d,o)),ae(d)){let n=0,r=0;e.canWrapX()&&(n=ye(i),r=Math.floor((d[0]-i[0])/n));Re(d.slice(),e,!0).forEach((e=>{const i=this.sourceTileGrid_.getTileRangeForExtentAndZ(e,this.sourceZ_),s=t.getTileFunction;for(let t=i.minX;t<=i.maxX;t++)for(let e=i.minY;e<=i.maxY;e++){const i=s(this.sourceZ_,t,e,this.pixelRatio_);if(i){const t=r*n;this.sourceTiles_.push({tile:i,offset:t})}}++r})),0===this.sourceTiles_.length&&(this.state=J)}else this.state=J}getSize(){return this.reprojSize_}getData(){return this.reprojData_}getError(){return this.reprojError_}reproject_(){const t=[];let e=!1;if(this.sourceTiles_.forEach((i=>{const n=i.tile;if(!n||n.getState()!==K)return;const r=n.getSize(),s=this.gutter_;let o;const a=Tt(n.getData());a?o=a:(e=!0,o=bt(wt(n.getData())));const l=[r[0]+2*s,r[1]+2*s],h=o instanceof Float32Array,c=l[0]*l[1],u=h?Float32Array:Uint8ClampedArray,d=new u(o.buffer),g=u.BYTES_PER_ELEMENT,f=g*d.length/c,p=d.byteLength/l[1],_=Math.floor(p/g/l[0]),m=this.sourceTileGrid_.getTileCoordExtent(n.tileCoord);m[0]+=i.offset,m[2]+=i.offset;const y=this.clipExtent_?.slice();y&&(y[0]+=i.offset,y[2]+=i.offset),t.push({extent:m,clipExtent:y,data:d,dataType:u,bytesPerPixel:f,pixelSize:l,bandCount:_})})),this.sourceTiles_.length=0,0===t.length)return this.state=q,void this.changed();const i=this.wrappedTileCoord_[0],n=this.targetTileGrid_.getTileSize(i),r="number"==typeof n?n:n[0],s="number"==typeof n?n:n[1],o=r*this.pixelRatio_,a=s*this.pixelRatio_,l=this.targetTileGrid_.getResolution(i),h=this.sourceTileGrid_.getResolution(this.sourceZ_),c=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),u=t[0].bandCount,d=new t[0].dataType(u*o*a),g=Kd(o,a,Jd,{premultipliedAlpha:!1,antialias:!1});let f;const p=g.RGBA;let _;if(t[0].dataType==Float32Array){_=g.FLOAT,g.getExtension("WEBGL_color_buffer_float"),g.getExtension("OES_texture_float"),g.getExtension("EXT_float_blend");f=null!==g.getExtension("OES_texture_float_linear")&&this.interpolate}else _=g.UNSIGNED_BYTE,f=this.interpolate;for(let e=Math.ceil(u/4)-1;e>=0;--e){const i=[];for(let n=0,r=t.length;n{const i=e.getState();if(i!==Y&&i!==H)return;t++;const r=D(e,n,(()=>{const i=e.getState();i!=K&&i!=q&&i!=J||(k(r),t--,0===t&&(this.unlistenSources_(),this.reproject_()))}));this.sourcesListenerKeys_.push(r)})),0===t?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach((function({tile:t}){t.getState()==Y&&t.load()}))}unlistenSources_(){this.sourcesListenerKeys_.forEach(k),this.sourcesListenerKeys_=null}}class eg extends od{constructor(t){const e=void 0===t.projection?"EPSG:3857":t.projection;let i=t.tileGrid;void 0===i&&e&&(i=Uu({extent:zu(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,state:t.state,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate,key:t.key,zDirection:t.zDirection}),this.gutter_=void 0!==t.gutter?t.gutter:0,this.tileSize_=t.tileSize?jl(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.crossOrigin_=t.crossOrigin||"anonymous",this.transformMatrix=null}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?jl(e.getTileSize(t)):[256,256]}getGutterForProjection(t){const e=this.getProjection();return e&&!bn(e,t)||this.transformMatrix?0:this.gutter_}setLoader(t){this.loader_=t}getReprojTile_(t,e,i,n,r){const s=this.tileGrid||this.getTileGridForProjection(r||n),o=Math.max.apply(null,s.getResolutions().map(((t,e)=>{const i=jl(s.getTileSize(e)),n=this.getTileSize(e);return Math.max(n[0]/i[0],n[1]/i[1])}))),a=this.getTileGridForProjection(n),l=[t,e,i],h=this.getTileCoordForTileUrlFunction(l,n),c=Object.assign({sourceProj:r||n,sourceTileGrid:s,targetProj:n,targetTileGrid:a,tileCoord:l,wrappedTileCoord:h,pixelRatio:o,gutter:this.gutter_,getTileFunction:(t,e,i,n)=>this.getTile(t,e,i,n),transformMatrix:this.transformMatrix},this.tileOptions),u=new tg(c);return u.key=this.getKey(),u}getTile(t,e,i,r,s){const o=this.getProjection();if(s&&(o&&!bn(o,s)||this.transformMatrix))return this.getReprojTile_(t,e,i,s,o);const a=this.getTileSize(t),l=this.loader_,h=new AbortController,c={signal:h.signal,crossOrigin:this.crossOrigin_},u=this.getTileCoordForTileUrlFunction([t,e,i]);if(!u)return null;const d=u[0],g=u[1],f=u[2],p=this.getTileGrid()?.getFullTileRange(d);p&&(c.maxY=p.getHeight()-1);const _=Object.assign({tileCoord:[t,e,i],loader:function(){return I((function(){return l(d,g,f,c)}))},size:a,controller:h},this.tileOptions),m=new It(_);return m.key=this.getKey(),m.addEventListener(n,this.handleTileChange_),m}handleTileChange_(t){const e=t.target,i=z(e),n=e.getState();let r;n==H?(this.tileLoadingKeys_[i]=!0,r=ld):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==q?cd:n==K?hd:void 0),r&&this.dispatchEvent(new ad(r,e))}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||bn(e,t))&&!this.transformMatrix)return this.tileGrid;const i=z(t);return i in this.tileGridForProjection_||(this.tileGridForProjection_[i]=Nu(t)),this.tileGridForProjection_[i]}setTileGridForProjection(t,e){const i=xn(t);if(i){const t=z(i);t in this.tileGridForProjection_||(this.tileGridForProjection_[t]=e)}}}function ig(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 ng="STATISTICS_MAXIMUM",rg="STATISTICS_MINIMUM";let sg;function og(t){try{return t.getBoundingBox(!0)}catch{return[0,0,t.getWidth(),t.getHeight()]}}function ag(t){try{return t.getOrigin().slice(0,2)}catch{return[0,t.getHeight()]}}function lg(t,e){try{return t.getResolution(e)}catch{return[e.getWidth()/t.getWidth(),e.getHeight()/t.getHeight()]}}function hg(t){const e=t.geoKeys;if(!e)return null;if(e.ProjectedCSTypeGeoKey&&32767!==e.ProjectedCSTypeGeoKey){const t="EPSG:"+e.ProjectedCSTypeGeoKey;let i=xn(t);if(!i){const n=di(e.ProjLinearUnitsGeoKey);n&&(i=new fi({code:t,units:n}))}return i}if(e.GeographicTypeGeoKey&&32767!==e.GeographicTypeGeoKey){const t="EPSG:"+e.GeographicTypeGeoKey;let i=xn(t);if(!i){const n=di(e.GeogAngularUnitsGeoKey);n&&(i=new fi({code:t,units:n}))}return i}return null}function cg(t){return t.getImageCount().then((function(e){const i=new Array(e);for(let n=0;ni*t)throw new Error(n)}function gg(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 fg extends eg{constructor(t){super({state:"loading",tileGrid:null,projection:t.projection||null,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=0;--t){const i=hg(e[t]);if(i){this.projection=i;break}}}determineTransformMatrix(t){const e=t[0];for(let t=e.length-1;t>=0;--t){const i=e[t].fileDirectory.ModelTransformation;if(i){const[t,e,n,r,s,o,a,l]=i,h=Zn(Zn([1/Math.sqrt(t*t+s*s),0,0,-1/Math.sqrt(e*e+o*o),r,l],[t,s,e,o,0,0]),[1,0,0,1,-r,-l]);this.transformMatrix=h,this.addAlpha_=!0;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{4&~(t.fileDirectory.NewSubfileType||0)?c.push(t):d.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 _=new Array(g),m=new Array(g),y=new Array(g);a[u]=new Array(g),l[u]=new Array(g);for(let t=0;ty.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}]`;dg(s.slice(h,s.length),e,.02,i,this.viewRejector)}else s=y,this.resolutionFactors_[u]=1;n?dg(n.slice(h,n.length),m,.01,`Tile size mismatch for source ${u}`,this.viewRejector):n=m,r?dg(r.slice(h,r.length),_,0,`Tile size mismatch for source ${u}`,this.viewRejector):r=_,this.sourceImagery_[u]=c.reverse(),this.sourceMasks_[u]=d.reverse()}for(let t=0,e=this.sourceImagery_.length;tKn(t,e))))}this.viewResolver({showFullExtent:!0,projection:this.projection,resolutions:s,center:Nn(ce(g),this.projection),extent:Gn(g,this.projection),zoom:1})}loadTile_(t,e,i,n){const r=this.getTileSize(t),s=this.sourceImagery_.length,o=new Array(2*s),a=this.nodataValues_,l=this.sourceInfo_,h=(sg||(sg=new GeoTIFF.Pool),sg);for(let c=0;c1,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]}},Eg[mg]=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}};let wg=class extends Gs{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==K){const e=this.tileSize_;if(t.width==e[0]&&t.height==e[1])return this.zoomifyImage_=t,t;const i=ft(e[0],e[1]);return i.drawImage(t,0,0),this.zoomifyImage_=i.canvas,i.canvas}return t}};function Tg(t){return t.toLocaleString("en",{maximumFractionDigits:10})}class Cg extends Ls{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?pe(i,l):i,c=Su(t,e,ce(h),n),u=new ed(t,e,h,a,.5*c,n),d=u.calculateSourceExtent(),g=ve(d)?null:s(d,c,r),f=g?bs:Ms,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==Ps&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==Is){const t=ye(this.targetExtent_)/this.targetResolution_,e=fe(this.targetExtent_)/this.targetResolution_;this.canvas_=wu(t,e,this.sourcePixelRatio_,Tu(this.sourceImage_.getResolution()),this.maxSourceExtent_,this.targetResolution_,this.targetExtent_,this.triangulation_,[{extent:this.sourceImage_.getExtent(),image:this.sourceImage_.getImage()}],0,void 0,this.interpolate_,!0)}this.state=t,this.changed()}load(){if(this.state==bs){this.state=Ps,this.changed();const t=this.sourceImage_.getState();t==Is||t==Fs?this.reproject_():(this.sourceListenerKey_=D(this.sourceImage_,n,(t=>{const e=this.sourceImage_.getState();e!=Is&&e!=Fs||(this.unlistenSource_(),this.reproject_())})),this.sourceImage_.load())}}unlistenSource_(){k(this.sourceListenerKey_),this.sourceListenerKey_=null}}const Rg="imageloadstart",bg="imageloadend",Pg="imageloaderror";class Ig extends L{constructor(t,e){super(t),this.image=e}}class Fg extends rd{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.loader=t.loader||null,this.resolutions_=void 0!==t.resolutions?t.resolutions:null,this.reprojectedImage_=null,this.reprojectedRevision_=0,this.image=null,this.wantedExtent_,this.wantedResolution_,this.static_=!!t.loader&&0===t.loader.length,this.wantedProjection_=null}getResolutions(){return this.resolutions_}setResolutions(t){this.resolutions_=t}findNearestResolution(t){const e=this.getResolutions();if(e){t=e[v(e,t,0)]}return t}getImage(t,e,i,n){const r=this.getProjection();if(!r||!n||bn(r,n))return r&&(n=r),this.getImageInternal(t,e,i,n);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&bn(this.reprojectedImage_.getProjection(),n)&&this.reprojectedImage_.getResolution()==e&&Jt(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new Cg(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,r){if(this.loader){const s=Lg(t,e,i,1),o=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===r&&(this.wantedExtent_&&Vt(this.wantedExtent_,s)||Vt(this.image.getExtent(),s))&&(this.wantedResolution_&&Tu(this.wantedResolution_)===o||Tu(this.image.getResolution())===o)))return this.image;this.wantedProjection_=r,this.wantedExtent_=s,this.wantedResolution_=o,this.image=new Ls(s,o,i,this.loader),this.image.addEventListener(n,this.handleImageChange.bind(this))}return this.image}handleImageChange(t){const e=t.target;let i;switch(e.getState()){case Ps:this.loading=!0,i=Rg;break;case Is:this.loading=!1,i=bg;break;case Fs:this.loading=!1,i=Pg;break;default:return}this.hasListener(i)&&this.dispatchEvent(new Ig(i,e))}}function Mg(t,e){t.getImage().src=e}function Lg(t,e,i,n){const r=e/i,s=ce(t),o=Ge(ye(t)/r,4),a=Ge(fe(t)/r,4);return de(s,r,0,[o+2*Ge((n-1)*o/2,4),a+2*Ge((n-1)*a/2,4)])}function Ag(t,e,i,n,r,s){const o=r.getCode().split(/:(?=\d+$)/).pop(),a=i/n,l=[Ne(ye(e)/a,4),Ne(fe(e)/a,4)];s.SIZE=l[0]+","+l[1],s.BBOX=e.join(","),s.BBOXSR=o,s.IMAGESR=o,s.DPI=Math.round(s.DPI?s.DPI*n:90*n);return Xu(t.replace(/MapServer\/?$/,"MapServer/export").replace(/ImageServer\/?$/,"ImageServer/exportImage"),s)}function Og(t){const e=t.load?t.load:Ns,i=xn(t.projection||"EPSG:3857"),n=t.ratio??1.5,r=t.crossOrigin??null;return function(s,o,a){a=t.hidpi?a:1;const l={F:"image",FORMAT:"PNG32",TRANSPARENT:!0};Object.assign(l,t.params),s=Lg(s,o,a,n);const h=Ag(t.url,s,o,a,i,l),c=new Image;return c.crossOrigin=r,e(c,h).then((t=>{const e=ye(s)/t.width*a;return{image:t,extent:s,resolution:e,pixelRatio:a}}))}}function Dg(t,e,i,n,r,s,o){const a=function(t,e,i,n){const r=ye(t),s=fe(t),o=e[0],a=e[1],l=.0254/n;return a*r>o*s?r*i/(o*l):s*i/(a*l)}(i,n,s,o),l=ce(i),h={OPERATION:r?"GETDYNAMICMAPOVERLAYIMAGE":"GETMAPIMAGE",VERSION:"2.0.0",LOCALE:"en",CLIENTAGENT:"ol/source/ImageMapGuide source",CLIP:"1",SETDISPLAYDPI:o,SETDISPLAYWIDTH:Math.round(n[0]),SETDISPLAYHEIGHT:Math.round(n[1]),SETVIEWSCALE:a,SETVIEWCENTERX:l[0],SETVIEWCENTERY:l[1]};return Object.assign(h,e),Xu(t,h)}function Ng(t){const e=t.load||Ns,i=t.useOverlay??!1,n=t.metersPerUnit||1,r=t.displayDpi||96,s=t.ratio??1,o=t.crossOrigin??null;return function(a,l,h){const c=new Image;c.crossOrigin=o;const u=ye(a=Lg(a,l,h,s))/l,d=fe(a)/l,g=[u*h,d*h],f=Dg(t.url,t.params,a,g,i,n,r);return e(c,f).then((t=>({image:t,extent:a,pixelRatio:h})))}}function kg(t){const e=t.load||Ns,i=t.imageExtent,n=t.crossOrigin??null;return()=>{const r=new Image;return r.crossOrigin=n,e(r,t.url).then((t=>{const e=ye(i)/t.width,n=fe(i)/t.height;return{image:t,extent:i,resolution:e!==n?[e,n]:n,pixelRatio:1}}))}}const Gg=new Error("Image failed to load");function Ug(t,e,i,n,r){return new Promise(((s,o)=>{const a=new Image;a.crossOrigin=r.crossOrigin??null,a.addEventListener("load",(()=>s(a))),a.addEventListener("error",(()=>o(Gg))),a.src=Yu(t,e,i,n,r.maxY)}))}function jg(t){return function(e,i,n,r){return Ug(Hu(t,e,i,n),e,i,n,r)}}function Bg(t){let e;if(Array.isArray(t))e=jg(t);else if("string"==typeof t){e=jg(Ku(t))}else{if("function"!=typeof t)throw new Error("The url option must be a single template, an array of templates, or a function for getting a URL");i=t,e=function(t,e,n,r){return Ug(i(t,e,n,r),t,e,n,r)}}var i;return e}let zg=0;function Xg(t){return Array.isArray(t)?t.join("\n"):"string"==typeof t?t:(++zg,"url-function-key-"+zg)}class Vg extends eg{constructor(t){let e,i=(t=t||{}).loader;t.url&&(i=Bg(t.url),e=Xg(t.url));const n=i?t.state:"loading",r=void 0===t.wrapX||t.wrapX;super({loader:i,key:e,attributions:t.attributions,attributionsCollapsible:t.attributionsCollapsible,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize,gutter:t.gutter,maxResolution:t.maxResolution,projection:t.projection,tileGrid:t.tileGrid,state:n,wrapX:r,transition:t.transition,interpolate:!1!==t.interpolate,crossOrigin:t.crossOrigin,zDirection:t.zDirection})}setUrl(t){const e=Bg(t);this.setLoader(e),this.setKey(Xg(t)),"ready"!==this.getState()&&this.setState("ready")}}const $g="1.3.0",Wg=[101,101];function Zg(t,e,i,n,r){r.WIDTH=i[0],r.HEIGHT=i[1];const s=n.getAxisOrientation(),o=Ke(r.VERSION,"1.3")>=0;r[o?"CRS":"SRS"]=n.getCode();const a=o&&s.startsWith("ne")?[e[1],e[0],e[3],e[2]]:e;return r.BBOX=a.join(","),Xu(t,r)}function Yg(t,e,i,n,r,s,o){s=Object.assign({REQUEST:"GetMap"},s);const a=e/i,l=[Ne(ye(t)/a,4),Ne(fe(t)/a,4)];if(1!=i)switch(o){case"geoserver":const t=90*i+.5|0;"FORMAT_OPTIONS"in s?s.FORMAT_OPTIONS+=";dpi:"+t:s.FORMAT_OPTIONS="dpi:"+t;break;case"mapserver":s.MAP_RESOLUTION=90*i;break;case"carmentaserver":case"qgis":s.DPI=90*i;break;default:throw new Error("Unknown `serverType` configured")}return Zg(r,t,l,n,s)}function Hg(t,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:$g,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},t)}function Kg(t){const e=void 0===t.hidpi||t.hidpi,i=xn(t.projection||"EPSG:3857"),n=t.ratio||1.5,r=t.load||Ns,s=t.crossOrigin??null;return(o,a,l)=>{o=Lg(o,a,l,n),1==l||e&&void 0!==t.serverType||(l=1);const h=Yg(o,a,l,i,t.url,Hg(t.params,"GetMap"),t.serverType),c=new Image;return c.crossOrigin=s,r(c,h).then((t=>({image:t,extent:o,pixelRatio:l})))}}function qg(t,e,i){if(void 0===t.url)return;const n=xn(t.projection||"EPSG:3857"),r=de(e,i,0,Wg),s={QUERY_LAYERS:t.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,Hg(t.params,"GetFeatureInfo"),t.params);const o=ke((e[0]-r[0])/i,4),a=ke((r[3]-e[1])/i,4),l=Ke(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,Zg(t.url,r,Wg,n,s)}function Jg(t,e){if(void 0===t.url)return;const i={SERVICE:"WMS",VERSION:$g,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0!==e){const n=xn(t.projection||"EPSG:3857").getMetersPerUnit()||1,r=28e-5;i.SCALE=e*n/r}if(Object.assign(i,t.params),void 0!==t.params&&void 0===i.LAYER){const t=i.LAYERS;if(!(!Array.isArray(t)||1!==t.length))return;i.LAYER=t}return Xu(t.url,i)}const Qg={"image/png":!0,"image/jpeg":!0,"image/gif":!0,"image/webp":!0},tf={"application/vnd.mapbox-vector-tile":!0,"application/geo+json":!0};function ef(t,e){if(!e.length)return t;const i=new URL(t,"file:/");if(i.pathname.split("/").includes("collections"))return Ye('The "collections" query parameter cannot be added to collection endpoints'),t;const n=e.map((t=>encodeURIComponent(t))).join(",");i.searchParams.append("collections",n);return`${t.split("?")[0]}?${decodeURIComponent(i.searchParams.toString())}`}function nf(t,e,i){let n,r;for(let i=0;it.replace(/E|X|Lon/i,"e").replace(/N|Y|Lat/i,"n"))).join(""):r.getAxisOrientation()).startsWith("en"),a=e.tileMatrices,l={};for(let t=0;tt.maxTileCol||u.tileRowt.maxTileRow)return}Object.assign(u,y);const d=i.replace(/\{(\w+?)\}/g,(function(t,e){return u[e]}));return au(x,d)}}}function of(t){return ou(t.url).then((function(e){return function(t,e){const i=e.tileMatrixSetLimits;let n;if("map"===e.dataType)n=nf(e.links,t.mediaType,t.collections);else{if("vector"!==e.dataType)throw new Error('Expected tileset data type to be "map" or "vector"');n=rf(e.links,t.mediaType,t.supportedMediaTypes,t.collections)}if(e.tileMatrixSet)return sf(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 ou(au(t.url,s)).then((function(e){return sf(t,e,n,i)}))}(t,e)}))}class af extends ud{constructor(t){const e=t.projection||"EPSG:3857",i=t.extent||zu(e),n=t.tileGrid||Uu({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,projection:e,state:t.state,tileGrid:n,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:lf,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.tileKeysBySourceTileUrl_={},this.sourceTiles_={},this.overlaps_=null==t.overlaps||t.overlaps,this.tileClass=t.tileClass?t.tileClass:Jc,this.tileGrids_={}}getOverlaps(){return this.overlaps_}getSourceTiles(t,e,i){if(i.getState()===Y){i.setState(H);const r=i.wrappedTileCoord,s=this.getTileGridForProjection(e),o=s.getTileCoordExtent(r),a=r[0],l=s.getResolution(a);jt(o,-l,o);const h=this.tileGrid,c=h.getExtent();c&&pe(o,c,o);const u=h.getZForResolution(l,this.zDirection);h.forEachTileCoord(o,u,(r=>{const s=this.tileUrlFunction(r,t,e);this.sourceTiles_[s]||(this.sourceTiles_[s]=new this.tileClass(r,s?Y:J,s,this.format_,this.tileLoadFunction));const o=this.sourceTiles_[s];i.sourceTiles.push(o),this.tileKeysBySourceTileUrl_[s]||(this.tileKeysBySourceTileUrl_[s]=[]),this.tileKeysBySourceTileUrl_[s].push(i.getKey());const a=o.getState();if(a{this.handleTileChange(e);const r=o.getState();if(r===K||r===q){const e=o.getKey();e in i.errorTileKeys?o.getState()===K&&delete i.errorTileKeys[e]:i.loadingSourceTiles--,r===q?i.errorTileKeys[e]=!0:o.removeEventListener(n,t),0===i.loadingSourceTiles&&i.setState(M(i.errorTileKeys)?K:q)}};o.addEventListener(n,t),i.loadingSourceTiles++}a===Y&&(o.extent=h.getTileCoordExtent(r),o.projection=e,o.resolution=h.getResolution(r[0]),o.load())})),i.loadingSourceTiles||i.setState(i.sourceTiles.some((t=>t.getState()===q))?q:K)}return i.sourceTiles}removeSourceTiles(t){const e=t.getKey(),i=t.sourceTiles;for(let t=0,n=i.length;t{h=h&&!this.tileUrlFunction(t,n,r)}))}const c=new Kc(s,h?J:Y,o,this.getSourceTiles.bind(this,n,r),this.removeSourceTiles.bind(this));return c.key=this.getKey(),c}getTileGridForProjection(t){const e=t.getCode();let i=this.tileGrids_[e];if(!i){const n=this.getProjection();Ft(null===n||bn(n,t),"A VectorTile source can only be rendered if it has a projection compatible with the view projection.");const r=this.tileGrid,s=r.getResolutions().slice(),o=s.map((function(t,e){return r.getOrigin(e)})),a=s.map((function(t,e){return r.getTileSize(e)})),l=43;for(let t=s.length;t{if("function"==typeof _t()[e])return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach((e=>{for(let i=0,n=e.length;ithis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return j()}getData(t){return null}prepareFrame(t){return j()}renderFrame(t,e){return j()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;e.getState()!==Is&&e.getState()!==Fs||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=Is&&e!=Fs&&t.addEventListener(n,this.boundHandleImageChange_),e==bs&&(t.load(),e=t.getState()),e==Is}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const df=[];let gf=null;class ff extends uf{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.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){let n;gf||(gf=ft(1,1,void 0,{willReadFrequently:!0})),gf.clearRect(0,0,1,1);try{gf.drawImage(t,e,i,1,1,0,0,1,1),n=gf.getImageData(0,0,1,1).data}catch{return gf=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&&w(Nl(t.style.backgroundColor),Nl(i)))){const e=t.firstElementChild;e instanceof HTMLCanvasElement&&(s=e.getContext("2d"))}if(s&&or(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=ft();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=_e(i),r=me(i),s=he(i),o=le(i);Kn(e.coordinateToPixelTransform,n),Kn(e.coordinateToPixelTransform,r),Kn(e.coordinateToPixelTransform,s),Kn(e.coordinateToPixelTransform,o);const a=this.inversePixelTransform;Kn(a,n),Kn(a,r),Kn(a,s),Kn(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()}prepareContainer(t,e){const i=t.extent,n=t.viewState.resolution,r=t.viewState.rotation,s=t.pixelRatio,o=Math.round(ye(i)/n*s),a=Math.round(fe(i)/n*s);tr(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/s,1/s,r,-o/2,-a/2),er(this.inversePixelTransform,this.pixelTransform);const l=rr(this.pixelTransform);if(this.useContainer(e,l,this.getBackground(t)),!this.containerReused){const t=this.context.canvas;t.width!=o||t.height!=a?(t.width=o,t.height=a):this.context.clearRect(0,0,o,a),l!==t.style.transform&&(t.style.transform=l)}}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){const r=new Oc(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(Wa,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Za,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new cf),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Wa,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Za,this.context,t))}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 tr(this.tempTransform,a,l,h,c,-i,u,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class pf extends ff{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=pe(a,Un(e.extent,n.projection))),!o[ao]&&!o[lo]&&!ve(a))if(s){const t=n.projection,e=s.getImage(a,r,i,t);e&&(this.loadImage(e)?this.image=e:e.getState()===Ms&&(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=Kn(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Xt(r,n))return null;const s=this.image.getExtent(),o=this.image.getImage(),a=ye(s),l=Math.floor(o.width*((n[0]-s[0])/a));if(l<0||l>=o.width)return null;const h=fe(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,o]=Array.isArray(r)?r:[r,r],a=i.getPixelRatio(),l=t.layerStatesArray[t.layerIndex],h=t.pixelRatio,c=t.viewState,u=c.center,d=c.resolution,g=h*s/(d*a),f=h*o/(d*a);this.prepareContainer(t,e);const p=this.context.canvas.width,_=this.context.canvas.height,m=this.getRenderContext(t);let y=!1,x=!0;if(l.extent){const e=Un(l.extent,c.projection);x=xe(e,t.extent),y=x&&!Vt(e,t.extent),y&&this.clipUnrotated(m,t,e)}const v=i.getImage(),S=tr(this.tempTransform,p/2,_/2,g,f,0,a*(n[0]-u[0])/s,a*(u[1]-n[3])/o);this.renderedResolution=o*h/a;const E=v.width*S[0],w=v.height*S[3];if(this.getLayer().getSource().getInterpolate()||(m.imageSmoothingEnabled=!1),this.preRender(m,t),x&&E>=.5&&w>=.5){const t=S[4],e=S[5],i=l.opacity;1!==i&&(m.save(),m.globalAlpha=i),m.drawImage(v,0,0,+v.width,+v.height,t,e,E,w),1!==i&&m.restore()}return this.postRender(this.context,t),y&&m.restore(),m.imageSmoothingEnabled=!0,this.container}}class _f extends qa{constructor(t){super(t=t||{})}}class mf extends _f{constructor(t){super(t)}createRenderer(){return new pf(this)}getData(t){return super.getData(t)}}function yf(t,e,i,n){return`${t},${bu(e,i,n)}`}function xf(t,e,i){if(!(i in t))return t[i]=new Set([e]),!0;const n=t[i],r=n.has(e);return r||n.add(e),!r}function vf(t,e,i){const n=t[i];return!!n&&n.delete(e)}function Sf(t,e){const i=t.layerStatesArray[t.layerIndex];i.extent&&(e=pe(e,Un(i.extent,t.viewState.projection)));const n=i.layer.getRenderSource();if(!n.getWrapX()){const i=n.getTileGridForProjection(t.viewState.projection).getExtent();i&&(e=pe(e,i))}return e}class Ef extends ff{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision_,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new Zc(0,0,0,0),this.tempTileCoord_=Ru(0,0,0);const i=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new Cu(i),this.maxStaleKeys=.5*i}getTileCache(){return this.tileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,s=this.getLayer().getSource(),o=yf(s.getKey(),t,e,i);let a;if(r.containsKey(o))a=r.get(o);else{if(a=s.getTile(t,e,i,n.pixelRatio,n.viewState.projection),!a)return null;r.set(o,a)}return a}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=Kn(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Xt(r,n))return null;const s=e.viewState,o=i.getRenderSource(),a=o.getTileGridForProjection(s.projection),l=o.getTilePixelRatio(e.pixelRatio);for(let t=a.getZForResolution(s.resolution);t>=a.getMinZoom();--t){const i=a.getTileCoordForCoordAndZ(n,t),r=this.getTile(t,i[1],i[2],e);if(!r||r.getState()!==K)continue;const h=a.getOrigin(t),c=jl(a.getTileSize(t)),u=a.getResolution(t);let d;if(r instanceof Gs||r instanceof nd)d=r.getImage();else{if(!(r instanceof It))continue;if(d=wt(r.getData()),!d)continue}const g=Math.floor(l*((n[0]-h[0])/u-i[1]*c[0])),f=Math.floor(l*((h[1]-n[1])/u-i[2]*c[1])),p=Math.round(l*o.getGutterForProjection(s.projection));return this.getImageData(d,g+p,f+p)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedRevision_?this.renderedRevision_!==i&&(this.renderedRevision_=i,this.renderedSourceKey_===e.getKey()&&this.tileCache_.clear()):this.renderedRevision_=i,!0}enqueueTiles(t,e,i,n,r){const s=t.viewState,o=this.getLayer(),a=o.getRenderSource(),l=a.getTileGridForProjection(s.projection),h=z(a);h in t.wantedTiles||(t.wantedTiles[h]={});const c=t.wantedTiles[h],u=o.getMapInternal(),d=Math.max(i-r,l.getMinZoom(),l.getZForResolution(Math.min(o.getMaxResolution(),u?u.getView().getResolutionForZoom(Math.max(o.getMinZoom(),0)):l.getResolution(0)),a.zDirection)),g=s.rotation,f=g?ge(s.center,s.resolution,g,t.size):void 0;for(let r=i;r>=d;--r){const i=l.getTileRangeForExtentAndZ(e,r,this.tempTileRange_),s=l.getResolution(r);for(let e=i.minX;e<=i.maxX;++e)for(let o=i.minY;o<=i.maxY;++o){if(g&&!l.tileCoordIntersectsViewport([r,e,o],f))continue;const i=this.getTile(r,e,o,t);if(!i)continue;if(!xf(n,i,r))continue;const a=i.getKey();if(c[a]=!0,i.getState()===Y&&!t.tileQueue.isKeyQueued(a)){const n=Ru(r,e,o,this.tempTileCoord_);t.tileQueue.enqueue([i,h,l.getTileCoordCenter(n),s])}}}}findStaleTile_(t,e){const i=this.tileCache_,n=t[0],r=t[1],s=t[2],o=this.getStaleKeys();for(let t=0;t0&&setTimeout((()=>{this.enqueueTiles(t,C,u-1,w,T-1)}),0),!(u in w))return this.container;const R=z(this),b=t.time;for(const e of w[u]){const i=e.getState();if(i===J)continue;const n=e.tileCoord;if(i===K){if(1===e.getAlpha(R,b)){e.endTransition(R);continue}}i!==q&&(this.renderComplete=!1);if(this.findStaleTile_(n,w)){vf(w,e,u),t.animate=!0;continue}if(this.findAltTiles_(c,n,u+1,w))continue;const r=c.getMinZoom();for(let t=u-1;t>=r;--t){if(this.findAltTiles_(c,n,t,w))break}}const P=d/s*a/p,I=this.getRenderContext(t);tr(this.tempTransform,_/2,m/2,P,P,0,-_/2,-m/2),i.extent&&this.clipUnrotated(I,t,x),h.getInterpolate()||(I.imageSmoothingEnabled=!1),this.preRender(I,t);const F=Object.keys(w).map(Number);let M;F.sort(y);const L=[],A=[];for(let e=F.length-1;e>=0;--e){const i=F[e],n=h.getTilePixelSize(i,a,r),s=c.getResolution(i)/d,o=n[0]*s*P,l=n[1]*s*P,u=c.getTileCoordForCoordAndZ(_e(E),i),g=c.getTileCoordExtent(u),f=Kn(this.tempTransform,[p*(g[0]-E[0])/d,p*(E[3]-g[3])/d]),_=p*h.getGutterForProjection(r);for(const e of w[i]){if(e.getState()!==K)continue;const n=e.tileCoord,r=u[1]-n[1],s=Math.round(f[0]-(r-1)*o),a=u[2]-n[2],c=Math.round(f[1]-(a-1)*l),d=Math.round(f[0]-r*o),g=Math.round(f[1]-a*l),p=s-d,m=c-g,y=1===F.length;let x=!1;M=[d,g,d+p,g,d+p,g+m,d,g+m];for(let t=0,e=L.length;t{const i=z(h),n=e.wantedTiles[i],r=n?Object.keys(n).length:0;this.updateCacheSize(r),this.tileCache_.expireCache()};t.postRenderFunctions.push(e)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,2*t)}drawTile(t,e,i,n,r,s,o,a){let l;if(t instanceof It){if(l=wt(t.getData()),!l)throw new Error("Rendering array data is not yet supported")}else l=this.getTileImage(t);if(!l)return;const h=this.getRenderContext(e),c=z(this),u=e.layerStatesArray[e.layerIndex],d=u.opacity*(a?t.getAlpha(c,e.time):1),g=d!==h.globalAlpha;g&&(h.save(),h.globalAlpha=d),h.drawImage(l,o,o,l.width-2*o,l.height-2*o,i,n,r,s),g&&h.restore(),d!==u.opacity?e.animate=!0:a&&t.endTransition(c)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const n=z(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}var wf="preload",Tf="useInterimTilesOnError";class Cf extends qa{constructor(t){t=t||{};const e=Object.assign({},t),i=t.cacheSize;delete t.cacheSize,delete e.preload,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i,this.setPreload(void 0!==t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(wf)}setPreload(t){this.set(wf,t)}getUseInterimTilesOnError(){return this.get(Tf)}setUseInterimTilesOnError(t){this.set(Tf,t)}getData(t){return super.getData(t)}}class Rf extends Cf{constructor(t){super(t)}createRenderer(){return new Ef(this,{cacheSize:this.getCacheSize()})}}function bf(t){return function(e){const i=e.buffers,n=e.meta,r=e.imageOps,s=e.width,o=e.height,a=i.length,l=i[0].byteLength;if(r){const e=new Array(a);for(let t=0;tthis.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=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==J&&!0===i?(this.state=Y,N(this,n,(i=>{e(this.getData(t))})),this.loadInternal_()):!0===i?setTimeout((()=>{e(this.getData(t))}),0):e(this.getData(t))}getKey(){return this.src_}handleError_(){this.state=q,this.changed()}handleLoad_(t){this.grid_=t.grid,this.keys_=t.keys,this.data_=t.data,this.state=K,this.changed()}loadInternal_(){if(this.state==Y)if(this.state=H,this.jsonp_)nu(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{return void this.handleError_()}this.handleLoad_(t)}else this.handleError_()}onXHRError_(t){this.handleError_()}load(){this.preemptive_?this.loadInternal_():this.setState(J)}}const jf=34962,Bf=34963,zf=35044,Xf=35048,Vf=5126,$f=["experimental-webgl","webgl","webkit-3d","moz-webgl"];function Wf(t,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!ot},e);const i=$f.length;for(let n=0;n{this.uniforms_.push({value:t.uniforms[i],location:e.getUniformLocation(this.renderTargetProgram_,i)})}))}getRenderTargetTexture(){return this.renderTargetTexture_}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=z(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)}))}}const bp={PROJECTION_MATRIX:"u_projectionMatrix",SCREEN_TO_WORLD_MATRIX:"u_screenToWorldMatrix",TIME:"u_time",ZOOM:"u_zoom",RESOLUTION:"u_resolution",ROTATION:"u_rotation",VIEWPORT_SIZE_PX:"u_viewportSizePx",PIXEL_RATIO:"u_pixelRatio",HIT_DETECTION:"u_hitDetection"},Pp=5121,Ip=5123,Fp=5125,Mp=Vf,Lp={};function Ap(t){return"shared/"+t}let Op=0;class Dp extends _{constructor(t){super(),t=t||{},this.boundHandleWebGLContextLost_=this.handleWebGLContextLost.bind(this),this.boundHandleWebGLContextRestored_=this.handleWebGLContextRestored.bind(this),this.canvasCacheKey_=t.canvasCacheKey?Ap(t.canvasCacheKey):function(){const t="unique/"+Op;return Op+=1,t}(),this.gl_=function(t){let e=Lp[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:Wf(i)},Lp[t]=e}return e.users+=1,e.context}(this.canvasCacheKey_),this.bufferCache_={},this.extensionCache_={},this.currentProgram_=null,this.needsToBeRecreated_=!1;const e=this.gl_.canvas;e.addEventListener(Tp,this.boundHandleWebGLContextLost_),e.addEventListener(Cp,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 Rp({webGlContext:this.gl_,scaleRatio:t.scaleRatio,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms}))):[new Rp({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now()}setUniforms(t){this.uniforms_=[],this.addUniforms(t)}addUniforms(t){for(const e in t)this.uniforms_.push({name:e,value:t[e]})}canvasCacheKeyMatches(t){return this.canvasCacheKey_===Ap(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=z(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=z(t);delete this.bufferCache_[e]}disposeInternal(){const t=this.gl_.canvas;t.removeEventListener(Tp,this.boundHandleWebGLContextLost_),t.removeEventListener(Cp,this.boundHandleWebGLContextRestored_),function(t){const e=Lp[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 Lp[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)}bindFrameBuffer(t,e){const i=this.getGL();i.bindFramebuffer(i.FRAMEBUFFER,t),e&&i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0)}bindInitialFrameBuffer(){const t=this.getGL(),e=this.postProcessPasses_[0].getFrameBuffer();t.bindFramebuffer(t.FRAMEBUFFER,e);const i=this.postProcessPasses_[0].getRenderTargetTexture();t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0)}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)}bindAttribute(t,e,i){const n=this.getGL();this.bindBuffer(t);const r=this.getAttributeLocation(e);n.enableVertexAttribArray(r),n.vertexAttribPointer(r,i,n.FLOAT,!1,0,0)}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{if(i="function"==typeof r.value?r.value(t):r.value,i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof ImageData||i instanceof WebGLTexture){i instanceof WebGLTexture&&!r.texture?(r.prevValue=void 0,r.texture=i):r.texture||(r.prevValue=void 0,r.texture=e.createTexture()),this.bindTexture(r.texture,n,r.name),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);const t=!(i instanceof HTMLImageElement)||i.complete;i instanceof WebGLTexture||!t||r.prevValue===i||(r.prevValue=i,e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,i)),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,e&&(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=z(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=z(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 tr(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=Np(t);let i=0;for(let n=0;nthis.size_[0]||e>=this.size_[1])return Up[0]=0,Up[1]=0,Up[2]=0,Up[3]=0,Up;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return Up[0]=this.data_[4*i],Up[1]=this.data_[4*i+1],Up[2]=this.data_[4*i+2],Up[3]=this.data_[4*i+3],Up}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)}}class Bp{constructor(){this.globalCounter_=0,this.refToFeature_=new Map,this.uidToRef_=new Map,this.freeGlobalRef_=[],this.polygonBatch={entries:{},geometriesCount:0,verticesCount:0,ringsCount:0},this.pointBatch={entries:{},geometriesCount:0},this.lineStringBatch={entries:{},geometriesCount:0,verticesCount:0}}addFeatures(t,e){for(let i=0;i0?t[i-1]:null,h=l?l[l.length-1]:0,c=a[a.length-1];a=h>0?a.map((t=>t-h)):a,this.addCoordinates_("Polygon",e.slice(h,c),a,n,r,s,o)}break}case"MultiLineString":{const t=i;for(let i=0,a=t.length;i0?t[i-1]:0;this.addCoordinates_("LineString",e.slice(a,t[i]),null,n,r,s,o)}break}case"MultiPoint":for(let t=0,i=e.length;t1)return void this.addCoordinates_("MultiPolygon",e,i,n,r,s,o)}this.polygonBatch.entries[r]||(this.polygonBatch.entries[r]=this.addRefToEntry_(r,{feature:n,flatCoordss:[],verticesCount:0,ringsCount:0,ringsVerticesCounts:[]})),a=e.length/s;const l=i.length,h=i.map(((t,e,i)=>e>0?(t-i[e-1])/s:t/s));this.polygonBatch.verticesCount+=a,this.polygonBatch.ringsCount+=l,this.polygonBatch.geometriesCount++,this.polygonBatch.entries[r].flatCoordss.push(function(t,e){if(2===e)return t;return t.filter(((t,i)=>i%e<2))}(e,s)),this.polygonBatch.entries[r].ringsVerticesCounts.push(h),this.polygonBatch.entries[r].verticesCount+=a,this.polygonBatch.entries[r].ringsCount+=l;for(let i=0,a=t.length;i0?t[i-1]:0;this.addCoordinates_("LinearRing",e.slice(a,t[i]),null,n,r,s,o)}break}case"Point":this.pointBatch.entries[r]||(this.pointBatch.entries[r]=this.addRefToEntry_(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]=this.addRefToEntry_(r,{feature:n,flatCoordss:[],verticesCount:0})),a=e.length/s,this.lineStringBatch.verticesCount+=a,this.lineStringBatch.geometriesCount++,this.lineStringBatch.entries[r].flatCoordss.push(function(t,e,i){if(3===e&&"XYM"===i)return t;if(4===e)return t.filter(((t,i)=>i%e!=2));if(3===e)return t.map(((t,i)=>i%e!=2?t:0));return new Array(1.5*t.length).fill(0).map(((e,i)=>i%3==2?0:t[Math.round(i/1.5)]))}(e,s,o)),this.lineStringBatch.entries[r].verticesCount+=a}}addRefToEntry_(t,e){const i=this.uidToRef_.get(t),n=i||this.freeGlobalRef_.pop()||++this.globalCounter_;return e.ref=n,i||(this.refToFeature_.set(n,e.feature),this.uidToRef_.set(t,n)),e}removeRef_(t,e){if(!t)throw new Error("This feature has no ref: "+e);this.refToFeature_.delete(t),this.uidToRef_.delete(e),this.freeGlobalRef_.push(t)}changeFeature(t){if(!this.uidToRef_.get(z(t)))return;this.removeFeature(t);const e=t.getGeometry();e&&this.addGeometry_(e,t)}removeFeature(t){let e=this.clearFeatureEntryInPointBatch_(t);e=this.clearFeatureEntryInPolygonBatch_(t)||e,e=this.clearFeatureEntryInLineStringBatch_(t)||e,e&&this.removeRef_(e.ref,z(e.feature))}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,this.globalCounter_=0,this.freeGlobalRef_=[],this.refToFeature_.clear(),this.uidToRef_.clear()}getFeatureFromRef(t){return this.refToFeature_.get(t)}isEmpty(){return 0===this.globalCounter_}filter(t){const e=new Bp;e.globalCounter_=this.globalCounter_,e.uidToRef_=this.uidToRef_,e.refToFeature_=this.refToFeature_;let i=!0;for(const n of this.refToFeature_.values())t(n)&&(e.addFeature(n),i=!1);return i?new Bp:e}}class zp extends vp{constructor(t,e){super(t),this.batch_=new Bp,this.styleRenderers_=e,this.buffers=[],this.maskVertices=new Ep(jf,zf),this.setTile(t.tile)}generateMaskBuffer_(){const t=this.tile.getSourceTiles()[0].extent;this.maskVertices.fromArray([t[0],t[1],t[2],t[1],t[2],t[3],t[0],t[3]]),this.helper.flushBufferData(this.maskVertices)}uploadTile(){this.generateMaskBuffer_(),this.batch_.clear();const t=this.tile.getSourceTiles(),e=t.reduce(((t,e)=>t.concat(e.getFeatures())),[]);this.batch_.addFeatures(e);const i=Qn([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()}))}disposeInternal(){this.buffers.forEach((t=>{this.disposeBuffers(t)})),super.disposeInternal()}disposeBuffers(t){if(!t)return;const e=t=>{for(const e of t)e&&this.helper.deleteBuffer(e)};t.pointBuffers&&e(t.pointBuffers),t.lineStringBuffers&&e(t.lineStringBuffers),t.polygonBuffers&&e(t.polygonBuffers)}}function Xp(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 Vp(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;Xp(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 $p=null;class Wp extends vp{constructor(t){super(t),this.textures=[],this.renderSize_=jl(t.grid.getTileSize(t.tile.tileCoord[0])),this.bandCount=NaN;const e=new Ep(jf,zf);e.fromArray([0,1,1,1,1,0,0,0]),this.helper.flushBufferData(e),this.coords=e,this.setTile(t.tile)}setHelper(t){const e=this.helper?.getGL();if(e){this.helper.deleteBuffer(this.coords);for(let t=0;t{this.clearCache(),this.removeHelper()},t.addChangeListener(Ba,this.onMapChanged_),this.dispatchPreComposeEvent=this.dispatchPreComposeEvent.bind(this),this.dispatchPostComposeEvent=this.dispatchPostComposeEvent.bind(this)}dispatchPreComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Ya)){const n=new Oc(Ya,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(Ha)){const n=new Oc(Ha,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=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){if(p&&!l.tileCoordIntersectsViewport([r,e,g],_))continue;const i=Ru(r,e,g,this.tempTileCoord_),f=s_(a,i);let m,y;if(d.containsKey(f)&&(m=d.get(f),y=m.tile),!(m&&m.tile.key===a.getKey()||(y=a.getTile(r,e,g,t.pixelRatio,s.projection),y)))continue;if(i_(n,y))continue;m?m.setTile(y):(m=this.createTileRepresentation({tile:y,grid:l,helper:this.helper,gutter:h}),d.set(f,m)),n_(n,m,r);const x=y.getKey();u[x]=!0,y.getState()===Y&&(t.tileQueue.isKeyQueued(x)||t.tileQueue.enqueue([y,c,l.getTileCoordCenter(i),o]))}}}beforeTilesRender(t,e){this.helper.prepareDraw(this.frameState,!e,!0)}beforeTilesMaskRender(t){return!1}renderTile(t,e,i,n,r,s,o,a,l,h,c){}renderTileMask(t,e,i,n){}drawTile_(t,e,i,n,r,s,o){if(!e.ready)return;const a=e.tile.tileCoord,l=Pu(a),h=l in s?s[l]:1,c=o.getResolution(i),u=jl(o.getTileSize(i),this.tempSize_),d=o.getOrigin(i),g=o.getTileCoordExtent(a),f=h<1?-1:t_(i);h<1&&(t.animate=!0);const p=t.viewState,_=p.center[0],m=p.center[1],y=u[0]+2*n,x=u[1]+2*n,v=y/x,S=(_-d[0])/(u[0]*c),E=(d[1]-m)/(u[1]*c),w=p.resolution/c,T=a[1],C=a[2];Wn(this.tileTransform_),Jn(this.tileTransform_,2/(t.size[0]*w/y),-2/(t.size[1]*w/y)),qn(this.tileTransform_,p.rotation),Jn(this.tileTransform_,1,1/v),Qn(this.tileTransform_,(u[0]*(T-S)-n)/y,(u[1]*(C-E)-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=r_(t,t.extent),l=s.getZForResolution(i.resolution,r.zDirection),h=e_(),c=n.getPreload();if(t.nextExtent){const e=s.getZForResolution(i.nextResolution,r.zDirection),n=r_(t,t.nextExtent);this.enqueueTiles(t,n,e,h,c)}this.enqueueTiles(t,a,l,h,0),c>0&&setTimeout((()=>{this.enqueueTiles(t,a,l-1,h,c-1)}),0);const u={};let d=!1;const g=h.representationsByZ;if(l in g){const e=z(this),i=t.time;for(const t of g[l]){const n=t.tile;if(n.getState()===J)continue;const r=n.tileCoord;if(t.ready){const t=n.getAlpha(e,i);if(1===t){n.endTransition(e);continue}d=!0;u[Pu(r)]=t}this.renderComplete=!1;if(this.findAltTiles_(s,r,l+1,h))continue;const o=s.getMinZoom();for(let t=l-1;t>=o;--t){if(this.findAltTiles_(s,r,t,h))break}}}const f=Object.keys(g).map(Number).sort(x);if(this.beforeTilesMaskRender(t))for(let t=0,e=f.length;tt.dispose())),t.clear()}afterHelperCreated(){super.afterHelperCreated(),this.tileRepresentationCache.forEach((t=>t.setHelper(this.helper)))}disposeInternal(){super.disposeInternal(),delete this.frameState}}const a_={...Qp,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"},l_={TEXTURE_COORD:"a_textureCoord"},h_=[{name:l_.TEXTURE_COORD,size:2,type:Mp}];class c_ extends o_{constructor(t,e){super(t,e),this.program_,this.vertexShader_=e.vertexShader,this.fragmentShader_=e.fragmentShader,this.indices_=new Ep(Bf,zf),this.indices_.fromArray([0,1,3,1,2,3]),this.paletteTextures_=e.paletteTextures||[]}reset(t){if(super.reset(t),this.helper){const t=this.helper.getGL();for(const e of this.paletteTextures_)e.delete(t)}if(this.vertexShader_=t.vertexShader,this.fragmentShader_=t.fragmentShader,this.paletteTextures_=t.paletteTextures||[],this.helper){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_);const t=this.helper.getGL();for(const e of this.paletteTextures_)e.getTexture(t)}}afterHelperCreated(){super.afterHelperCreated();const t=this.helper.getGL();for(const e of this.paletteTextures_)e.getTexture(t);this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.helper.flushBufferData(this.indices_)}removeHelper(){if(this.helper){const t=this.helper.getGL();for(const e of this.paletteTextures_)e.delete(t)}super.removeHelper()}createTileRepresentation(t){return new Wp(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(h_);let d=0;for(;d0&&(x=a,pe(x,n,x)),this.helper.setUniformFloatVec4(a_.RENDER_EXTENT,x),this.helper.setUniformFloatValue(a_.RESOLUTION,g.resolution),this.helper.setUniformFloatValue(a_.ZOOM,g.zoom),this.helper.setUniformFloatValue(a_.TEXTURE_PIXEL_WIDTH,f),this.helper.setUniformFloatValue(a_.TEXTURE_PIXEL_HEIGHT,p),this.helper.setUniformFloatValue(a_.TEXTURE_RESOLUTION,r),this.helper.setUniformFloatValue(a_.TEXTURE_ORIGIN_X,o[0]+m*s[0]*r-h*r),this.helper.setUniformFloatValue(a_.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=Kn(e.pixelToCoordinateTransform,t.slice()),r=e.viewState,s=i.getExtent();if(s&&!Xt(Un(s,r.projection),n))return null;const o=i.getSources(Ut([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||Xt(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=s_(l,e);if(!c.containsKey(i))continue;const r=c.get(i);if(r.tile.getState()===J)return null;if(!r.loaded)continue;const s=h.getOrigin(t),o=jl(h.getTileSize(t)),a=h.getResolution(t),u=(n[0]-s[0])/a-e[1]*o[0],d=(s[1]-n[1])/a-e[2]*o[1];return r.getPixelData(u,d)}return null}disposeInternal(){const t=this.helper;if(t){const e=t.getGL();for(const t of this.paletteTextures_)t.delete(e);this.paletteTextures_.length=0,e.deleteProgram(this.program_),delete this.program_,t.deleteBuffer(this.indices_)}super.disposeInternal(),delete this.indices_}}const u_={TEXTURE:"u_texture",VELOCITY_TEXTURE:"u_velocityTexture",POSITION_TEXTURE:"u_positionTexture",PARTICLE_COUNT_SQRT:"u_particleCountSqrt",MAX_SPEED:"u_maxSpeed",RANDOM_SEED:"u_randomSeed",SPEED_FACTOR:"u_speedFactor",DROP_RATE:"u_dropRate",DROP_RATE_BUMP:"u_dropRateBump",OPACITY:"u_opacity",ROTATION:bp.ROTATION,VIEWPORT_SIZE_PX:bp.VIEWPORT_SIZE_PX},d_="a_position",g_="a_index",f_="v_position";class p_ extends c_{constructor(t,e){super(t,{vertexShader:e.tileVertexShader,fragmentShader:e.tileFragmentShader,cacheSize:e.cacheSize,postProcesses:[{}],uniforms:{[u_.MAX_SPEED]:e.maxSpeed}}),this.particleColorFragmentShader_=e.particleColorFragmentShader,this.velocityTexture_=null,this.particleCountSqrt_=e.particles?Math.ceil(Math.sqrt(e.particles)):256,this.particleIndexBuffer_,this.quadBuffer_,this.particlePositionProgram_,this.particlePositionVertexShader_=e.particlePositionVertexShader,this.particlePositionFragmentShader_=e.particlePositionFragmentShader,this.previousPositionTexture_,this.nextPositionTexture_,this.particleColorProgram_,this.particleColorVertexShader_=e.particleColorVertexShader,this.particleColorFragmentShader_=e.particleColorFragmentShader,this.textureProgram_,this.textureVertexShader_=e.textureVertexShader,this.textureFragmentShader_=e.textureFragmentShader,this.previousTrailsTexture_,this.nextTrailsTexture_,this.fadeOpacity_=.996,this.maxSpeed_=e.maxSpeed,this.speedFactor_=e.speedFactor||.001,this.dropRate_=.003,this.dropRateBump_=.01,this.tempVec2_=[0,0],this.renderedWidth_=0,this.renderedHeight_=0}afterHelperCreated(){super.afterHelperCreated();const t=this.helper,e=t.getGL();this.framebuffer_=e.createFramebuffer();const i=this.particleCountSqrt_*this.particleCountSqrt_,n=new Float32Array(i);for(let t=0;t{const e=t.data;if(e.type===m_){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,er(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,Ld,this.handleSourceFeatureAdded_,this),D(s,Ad,this.handleSourceFeatureChanged_,this),D(s,Dd,this.handleSourceFeatureDelete_,this),D(s,Od,this.handleSourceFeatureClear_,this)],s.forEachFeature((t=>{const e=t.getGeometry();e&&"Point"===e.getType()&&(this.featureCache_[z(t)]={feature:t,properties:t.getProperties(),flatCoordinates:e.getFlatCoordinates()},this.featureCount_++)}))}afterHelperCreated(){this.program_=this.helper.getProgram(this.fragmentShader_,this.vertexShader_),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new jp(this.helper)),this.verticesBuffer_.getArray()&&this.helper.flushBufferData(this.verticesBuffer_),this.indicesBuffer_.getArray()&&this.helper.flushBufferData(this.indicesBuffer_)}handleSourceFeatureAdded_(t){const e=t.feature,i=e.getGeometry();i&&"Point"===i.getType()&&(this.featureCache_[z(e)]={feature:e,properties:e.getProperties(),flatCoordinates:i.getFlatCoordinates()},this.featureCount_++)}handleSourceFeatureChanged_(t){const e=t.feature,i=z(e),n=this.featureCache_[i],r=e.getGeometry();n?r&&"Point"===r.getType()?(n.properties=e.getProperties(),n.flatCoordinates=r.getFlatCoordinates()):(delete this.featureCache_[i],this.featureCount_--):r&&"Point"===r.getType()&&(this.featureCache_[i]={feature:e,properties:e.getProperties(),flatCoordinates:r.getFlatCoordinates()},this.featureCount_++)}handleSourceFeatureDelete_(t){const e=z(t.feature);e in this.featureCache_&&(delete this.featureCache_[e],this.featureCount_--)}handleSourceFeatureClear_(){this.featureCache_={},this.featureCount_=0}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=E_(t,this.getLayer());this.renderWorlds(t,!1,i,n,r),this.helper.finalizeDraw(t,this.dispatchPreComposeEvent,this.dispatchPostComposeEvent),this.hitDetectionEnabled_&&(this.renderWorlds(t,!0,i,n,r),this.hitRenderTarget_.clearCachedData()),this.postRender(e,t);return this.helper.getCanvas()}prepareFrameInternal(t){const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[ao]&&!t.viewHints[lo],s=!Jt(this.previousExtent_,t.extent),o=this.sourceRevision_4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${t.length}(${t.map(T_).join(", ")})`}function R_(t){const e=Nl(t),i=e.length>3?e[3]:1;return C_([e[0]/255,e[1]/255,e[2]/255,i])}function b_(t){return C_(jl(t))}const P_={};let I_=0;function F_(t){return t in P_||(P_[t]=I_++),P_[t]}function M_(t){return T_(F_(t))}function L_(t){return"u_var_"+t}function A_(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const O_="getBandValue",D_="u_paletteTextures",N_="featureId",k_="geometryType",G_=-9999999;function U_(t,e,i,n){return z_(nh(t,e,i),e,n)}function j_(t){return(e,i,n)=>{const r=i.args.length,s=new Array(r);for(let t=0;t{const i=e.args[0].value;return i in t.properties||(t.properties[i]={name:i,type:e.type}),"a_prop_"+i},[rh.Id]:t=>(t.featureId=!0,"a_"+N_),[rh.GeometryType]:t=>(t.geometryType=!0,"a_"+k_),[rh.LineMetric]:()=>"currentLineMetric",[rh.Var]:(t,e)=>{const i=e.args[0].value;return i in t.variables||(t.variables[i]={name:i,type:e.type}),L_(i)},[rh.Has]:(t,e)=>{const i=e.args[0].value;return i in t.properties||(t.properties[i]={name:i,type:e.type}),`(a_prop_${i} != ${T_(G_)})`},[rh.Resolution]:()=>"u_resolution",[rh.Zoom]:()=>"u_zoom",[rh.Time]:()=>"u_time",[rh.Any]:j_((t=>`(${t.join(" || ")})`)),[rh.All]:j_((t=>`(${t.join(" && ")})`)),[rh.Not]:j_((([t])=>`(!${t})`)),[rh.Equal]:j_((([t,e])=>`(${t} == ${e})`)),[rh.NotEqual]:j_((([t,e])=>`(${t} != ${e})`)),[rh.GreaterThan]:j_((([t,e])=>`(${t} > ${e})`)),[rh.GreaterThanOrEqualTo]:j_((([t,e])=>`(${t} >= ${e})`)),[rh.LessThan]:j_((([t,e])=>`(${t} < ${e})`)),[rh.LessThanOrEqualTo]:j_((([t,e])=>`(${t} <= ${e})`)),[rh.Multiply]:j_((t=>`(${t.join(" * ")})`)),[rh.Divide]:j_((([t,e])=>`(${t} / ${e})`)),[rh.Add]:j_((t=>`(${t.join(" + ")})`)),[rh.Subtract]:j_((([t,e])=>`(${t} - ${e})`)),[rh.Clamp]:j_((([t,e,i])=>`clamp(${t}, ${e}, ${i})`)),[rh.Mod]:j_((([t,e])=>`mod(${t}, ${e})`)),[rh.Pow]:j_((([t,e])=>`pow(${t}, ${e})`)),[rh.Abs]:j_((([t])=>`abs(${t})`)),[rh.Floor]:j_((([t])=>`floor(${t})`)),[rh.Ceil]:j_((([t])=>`ceil(${t})`)),[rh.Round]:j_((([t])=>`floor(${t} + 0.5)`)),[rh.Sin]:j_((([t])=>`sin(${t})`)),[rh.Cos]:j_((([t])=>`cos(${t})`)),[rh.Atan]:j_((([t,e])=>void 0!==e?`atan(${t}, ${e})`:`atan(${t})`)),[rh.Sqrt]:j_((([t])=>`sqrt(${t})`)),[rh.Match]:j_((t=>{const e=t[0],i=t[t.length-1];let n=null;for(let r=t.length-3;r>=1;r-=2){n=`(${e} == ${t[r]} ? ${t[r+1]} : ${n||i})`}return n})),[rh.Between]:j_((([t,e,i])=>`(${t} >= ${e} && ${t} <= ${i})`)),[rh.Interpolate]:j_((([t,e,...i])=>{let n="";for(let r=0;r{const e=t[t.length-1];let i=null;for(let n=t.length-3;n>=0;n-=2){i=`(${t[n]} ? ${t[n+1]} : ${i||e})`}return i})),[rh.In]:j_((([t,...e],i)=>{const n=function(t,e){return`operator_${t}_${Object.keys(e.functions).length}`}("in",i),r=[];for(let t=0;t`vec${t.length}(${t.join(", ")})`)),[rh.Color]:j_((t=>{if(1===t.length)return`vec4(vec3(${t[0]} / 255.0), 1.0)`;if(2===t.length)return`vec4(vec3(${t[0]} / 255.0), ${t[1]})`;const e=t.slice(0,3).map((t=>`${t} / 255.0`));if(3===t.length)return`vec4(${e.join(", ")}, 1.0)`;const i=t[3];return`vec4(${e.join(", ")}, ${i})`})),[rh.Band]:j_((([t,e,i],n)=>{if(!(O_ in n.functions)){let t="";const e=n.bandCount||1;for(let i=0;i{const[i,...n]=e.args,r=n.length,s=new Uint8Array(4*r);for(let t=0;t0)return T_(t.value);if((t.type&zl)>0)return t.value.toString();if((t.type&Vl)>0)return M_(t.value.toString());if((t.type&$l)>0)return R_(t.value);if((t.type&Wl)>0)return C_(t.value);if((t.type&Zl)>0)return b_(t.value);throw new Error(`Unexpected expression ${t.value} (expected type ${ql(e)})`)}function X_(t,e,i,n){let r=0;for(const s in e){const o=e[s],a=o.callback.call(i,i.feature);let l=a?.[0]??a;l===G_&&console.warn('The "has" operator might return false positives.'),void 0===l?l=G_:null===l&&(l=0),t[n+r++]=l,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 V_(t){return Object.keys(t).reduce(((e,i)=>e+(t[i].size||1)),0)}function $_(t,e,i,n){const r=(2+V_(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;t80*i){a=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=i;se&&(e=i),r>n&&(n=r)}h=Math.max(e-a,n-l),h=0!==h?32767/h:0}return q_(s,o,i,a,l,h,0),o}function H_(t,e,i,n,r){let s;if(r===function(t,e,i,n){let r=0;for(let s=e,o=i-n;s0)for(let r=e;r=e;r-=n)s=mm(r/n|0,t[r],t[r+1],s);return s&&um(s,s.next)&&(ym(s),s=s.next),s}function K_(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!um(n,n.next)&&0!==cm(n.prev,n,n.next))n=n.next;else{if(ym(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function q_(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{0===r.z&&(r.z=sm(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){let e,i=1;do{let n,r=t;t=null;let s=null;for(e=0;r;){e++;let o=r,a=0;for(let t=0;t0||l>0&&o;)0!==a&&(0===l||!o||r.z<=o.z)?(n=r,r=r.nextZ,a--):(n=o,o=o.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=o}s.nextZ=null,i*=2}while(e>1)}(r)}(t,n,r,s);let a=t;for(;t.prev!==t.next;){const l=t.prev,h=t.next;if(s?Q_(t,n,r,s):J_(t))e.push(l.i,t.i,h.i),ym(t),t=h.next,a=h.next;else if((t=h)===a){o?1===o?q_(t=tm(K_(t),e),e,i,n,r,s,2):2===o&&em(t,e,i,n,r,s):q_(K_(t),e,i,n,r,s,1);break}}}function J_(t){const e=t.prev,i=t,n=t.next;if(cm(e,i,n)>=0)return!1;const r=e.x,s=i.x,o=n.x,a=e.y,l=i.y,h=n.y,c=Math.min(r,s,o),u=Math.min(a,l,h),d=Math.max(r,s,o),g=Math.max(a,l,h);let f=n.next;for(;f!==e;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=g&&lm(r,a,s,l,o,h,f.x,f.y)&&cm(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Q_(t,e,i,n){const r=t.prev,s=t,o=t.next;if(cm(r,s,o)>=0)return!1;const a=r.x,l=s.x,h=o.x,c=r.y,u=s.y,d=o.y,g=Math.min(a,l,h),f=Math.min(c,u,d),p=Math.max(a,l,h),_=Math.max(c,u,d),m=sm(g,f,e,i,n),y=sm(p,_,e,i,n);let x=t.prevZ,v=t.nextZ;for(;x&&x.z>=m&&v&&v.z<=y;){if(x.x>=g&&x.x<=p&&x.y>=f&&x.y<=_&&x!==r&&x!==o&&lm(a,c,l,u,h,d,x.x,x.y)&&cm(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=g&&v.x<=p&&v.y>=f&&v.y<=_&&v!==r&&v!==o&&lm(a,c,l,u,h,d,v.x,v.y)&&cm(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=m;){if(x.x>=g&&x.x<=p&&x.y>=f&&x.y<=_&&x!==r&&x!==o&&lm(a,c,l,u,h,d,x.x,x.y)&&cm(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<=_&&v!==r&&v!==o&&lm(a,c,l,u,h,d,v.x,v.y)&&cm(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function tm(t,e){let i=t;do{const n=i.prev,r=i.next.next;!um(n,r)&&dm(n,i,i.next,r)&&pm(n,r)&&pm(r,n)&&(e.push(n.i,i.i,r.i),ym(i),ym(i.next),i=t=r),i=i.next}while(i!==t);return K_(i)}function em(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&hm(o,t)){let a=_m(o,t);return o=K_(o,o.next),a=K_(a,a.next),q_(o,e,i,n,r,s,0),void q_(a,e,i,n,r,s,0)}t=t.next}o=o.next}while(o!==t)}function im(t,e){let i=t.x-e.x;if(0===i&&(i=t.y-e.y,0===i)){i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return i}function nm(t,e){const i=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;if(um(t,i))return i;do{if(um(t,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o&&(o=t,s=i.x=i.x&&i.x>=l&&n!==i.x&&am(rs.x||i.x===s.x&&rm(s,i)))&&(s=i,c=e)}i=i.next}while(i!==a);return s}(t,e);if(!i)return e;const n=_m(i,t);return K_(n,n.next),K_(i,i.next)}function rm(t,e){return cm(t.prev,t,e.prev)<0&&cm(e.next,t,t.next)<0}function sm(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 om(t){let e=t,i=t;do{(e.x=(t-o)*(s-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(s-a)>=(r-o)*(n-a)}function lm(t,e,i,n,r,s,o,a){return!(t===o&&e===a)&&am(t,e,i,n,r,s,o,a)}function hm(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&dm(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(pm(t,e)&&pm(e,t)&&function(t,e){let i=t,n=!1;const 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)&&(cm(t.prev,t,e.prev)||cm(t,e.prev,e))||um(t,e)&&cm(t.prev,t,t.next)>0&&cm(e.prev,e,e.next)>0)}function cm(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function um(t,e){return t.x===e.x&&t.y===e.y}function dm(t,e,i,n){const r=fm(cm(t,e,i)),s=fm(cm(t,e,n)),o=fm(cm(i,n,t)),a=fm(cm(i,n,e));return r!==s&&o!==a||(!(0!==r||!gm(t,i,e))||(!(0!==s||!gm(t,n,e))||(!(0!==o||!gm(i,t,n))||!(0!==a||!gm(i,e,n)))))}function gm(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 fm(t){return t>0?1:t<0?-1:0}function pm(t,e){return cm(t.prev,t,t.next)<0?cm(t,e,t.next)>=0&&cm(t,t.prev,e)>=0:cm(t,e,t.prev)<0||cm(t,t.next,e)<0}function _m(t,e){const i=xm(t.i,t.x,t.y),n=xm(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 mm(t,e,i,n){const r=xm(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 ym(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 xm(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}const vm=.985,Sm=[],Em={vertexPosition:0,indexPosition:0};function wm(t,e,i,n,r){t[e+0]=i,t[e+1]=n,t[e+2]=r}const Tm="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform 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 float u_rotation;\nuniform vec4 u_renderExtent;\nuniform vec2 u_patternOrigin;\nuniform float u_depth;\nuniform mediump int u_hitDetection;\n\nconst float PI = 3.141592653589793238;\nconst float TWO_PI = 2.0 * PI;\nfloat currentLineMetric = 0.; // an actual value will be used in the stroke shaders\n",Cm={"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 Rm{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${T_(Cm["circle-radius"])} + ${T_(.5*Cm["circle-stroke-width"])})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=R_(Cm["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_=T_(Cm["stroke-width"]),this.strokeColorExpression_=R_(Cm["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=M_("round"),this.strokeJoinExpression_=M_("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.hasFill_=!1,this.fillColorExpression_=R_(Cm["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t){return this.uniforms_.push(t),this}addAttribute(t,e,i,n){return this.attributes_.push({name:t,type:e,varyingName:t.replace(/^a_/,"v_"),varyingType:n??e,varyingExpression:i??t}),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}getSymbolOffsetExpression(){return this.symbolOffsetExpression_}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}getFragmentDiscardExpression(){return this.discardExpression_}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}getStrokeColorExpression(){return this.strokeColorExpression_}setStrokeOffsetExpression(t){return this.strokeOffsetExpression_=t,this}setStrokeCapExpression(t){return this.strokeCapExpression_=t,this}setStrokeJoinExpression(t){return this.strokeJoinExpression_=t,this}setStrokeMiterLimitExpression(t){return this.strokeMiterLimitExpression_=t,this}setStrokeDistanceFieldExpression(t){return this.strokeDistanceFieldExpression_=t,this}setFillColorExpression(t){return this.hasFill_=!0,this.fillColorExpression_=t,this}getFillColorExpression(){return this.fillColorExpression_}addVertexShaderFunction(t){return this.vertexShaderFunctions_.includes(t)||this.vertexShaderFunctions_.push(t),this}addFragmentShaderFunction(t){return this.fragmentShaderFunctions_.includes(t)||this.fragmentShaderFunctions_.push(t),this}getSymbolVertexShader(){return this.hasSymbol_?`${Tm}\n${this.uniforms_.map((t=>`uniform ${t};`)).join("\n")}\nattribute vec2 a_position;\nattribute float a_index;\nattribute vec4 a_hitColor;\n\nvarying vec2 v_texCoord;\nvarying vec2 v_quadCoord;\nvarying vec4 v_hitColor;\nvarying vec2 v_centerPx;\nvarying float v_angle;\nvarying vec2 v_quadSizePx;\n\n${this.attributes_.map((t=>`attribute ${t.type} ${t.name};\nvarying ${t.varyingType} ${t.varyingName};`)).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvec2 pxToScreen(vec2 coordPx) {\n vec2 scaled = coordPx / u_viewportSizePx / 0.5;\n return scaled;\n}\n\nvec2 screenToPx(vec2 coordScreen) {\n return (coordScreen * 0.5 + 0.5) * u_viewportSizePx;\n}\n\nvoid main(void) {\n v_quadSizePx = ${this.symbolSizeExpression_};\n vec2 halfSizePx = v_quadSizePx * 0.5;\n vec2 centerOffsetPx = ${this.symbolOffsetExpression_};\n vec2 offsetPx = centerOffsetPx;\n if (a_index == 0.0) {\n offsetPx -= halfSizePx;\n } else if (a_index == 1.0) {\n offsetPx += halfSizePx * vec2(1., -1.);\n } else if (a_index == 2.0) {\n offsetPx += halfSizePx;\n } else {\n offsetPx += halfSizePx * vec2(-1., 1.);\n }\n float angle = ${this.symbolRotationExpression_};\n ${this.symbolRotateWithView_?"angle += u_rotation;":""}\n float c = cos(-angle);\n float s = sin(-angle);\n offsetPx = vec2(c * offsetPx.x - s * offsetPx.y, s * offsetPx.x + c * offsetPx.y);\n vec4 center = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n gl_Position = center + vec4(pxToScreen(offsetPx), u_depth, 0.);\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 v_hitColor = a_hitColor;\n v_angle = angle;\n c = cos(-v_angle);\n s = sin(-v_angle);\n centerOffsetPx = vec2(c * centerOffsetPx.x - s * centerOffsetPx.y, s * centerOffsetPx.x + c * centerOffsetPx.y); \n v_centerPx = screenToPx(center.xy) + centerOffsetPx;\n${this.attributes_.map((t=>` ${t.varyingName} = ${t.varyingExpression};`)).join("\n")}\n}`:null}getSymbolFragmentShader(){return this.hasSymbol_?`${Tm}\n${this.uniforms_.map((t=>`uniform ${t};`)).join("\n")}\nvarying vec2 v_texCoord;\nvarying vec4 v_hitColor;\nvarying vec2 v_centerPx;\nvarying float v_angle;\nvarying vec2 v_quadSizePx;\n${this.attributes_.map((t=>`varying ${t.varyingType} ${t.varyingName};`)).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\n\nvoid main(void) {\n${this.attributes_.map((t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`)).join("\n")}\n if (${this.discardExpression_}) { discard; }\n vec2 coordsPx = gl_FragCoord.xy / u_pixelRatio - v_centerPx; // relative to center\n float c = cos(v_angle);\n float s = sin(v_angle);\n coordsPx = vec2(c * coordsPx.x - s * coordsPx.y, s * coordsPx.x + c * coordsPx.y);\n gl_FragColor = ${this.symbolColorExpression_};\n gl_FragColor.rgb *= gl_FragColor.a;\n if (u_hitDetection > 0) {\n if (gl_FragColor.a < 0.05) { discard; };\n gl_FragColor = v_hitColor;\n }\n}`:null}getStrokeVertexShader(){return this.hasStroke_?`${Tm}\n${this.uniforms_.map((t=>`uniform ${t};`)).join("\n")}\nattribute vec2 a_segmentStart;\nattribute vec2 a_segmentEnd;\nattribute float a_measureStart;\nattribute float a_measureEnd;\nattribute float a_parameters;\nattribute float a_distance;\nattribute vec2 a_joinAngles;\nattribute vec4 a_hitColor;\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;\nvarying float v_distanceOffsetPx;\nvarying float v_measureStart;\nvarying float v_measureEnd;\n\n${this.attributes_.map((t=>`attribute ${t.type} ${t.name};\nvarying ${t.varyingType} ${t.varyingName};`)).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 = 2.0 * pxPos / u_viewportSizePx - 1.0;\n return vec4(screenPos, u_depth, 1.0);\n}\n\nbool isCap(float joinAngle) {\n return joinAngle < -0.1;\n}\n\nvec2 getJoinOffsetDirection(vec2 normalPx, float joinAngle) {\n float halfAngle = joinAngle / 2.0;\n float c = cos(halfAngle);\n float s = sin(halfAngle);\n vec2 angleBisectorNormal = vec2(s * normalPx.x + c * normalPx.y, -c * normalPx.x + s * normalPx.y);\n float length = 1.0 / s;\n return angleBisectorNormal * length;\n}\n\nvec2 getOffsetPoint(vec2 point, vec2 normal, float joinAngle, float offsetPx) {\n // if on a cap or the join angle is too high, offset the line along the segment normal\n if (cos(joinAngle) > 0.998 || isCap(joinAngle)) {\n return point - normal * offsetPx;\n }\n // offset is applied along the inverted normal (positive offset goes "right" relative to line direction)\n return point - getJoinOffsetDirection(normal, joinAngle) * offsetPx;\n}\n\nvoid main(void) {\n v_angleStart = a_joinAngles.x;\n v_angleEnd = a_joinAngles.y;\n float vertexNumber = floor(abs(a_parameters) / 10000. + 0.5);\n currentLineMetric = vertexNumber < 1.5 ? a_measureStart : a_measureEnd;\n // we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)\n float angleTangentSum = fract(abs(a_parameters) / 10000.) * 10000. * sign(a_parameters);\n\n float lineWidth = ${this.strokeWidthExpression_};\n float lineOffsetPx = ${this.strokeOffsetExpression_};\n\n // compute segment start/end in px with offset\n vec2 segmentStartPx = worldToPx(a_segmentStart);\n vec2 segmentEndPx = worldToPx(a_segmentEnd);\n vec2 tangentPx = normalize(segmentEndPx - segmentStartPx);\n vec2 normalPx = vec2(-tangentPx.y, tangentPx.x);\n segmentStartPx = getOffsetPoint(segmentStartPx, normalPx, v_angleStart, lineOffsetPx),\n segmentEndPx = getOffsetPoint(segmentEndPx, normalPx, v_angleEnd, lineOffsetPx);\n \n // compute current vertex position\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 joinDirection;\n vec2 positionPx = vertexNumber < 1.5 ? segmentStartPx : segmentEndPx;\n // if angle is too high, do not make a proper join\n if (cos(angle) > 0.985 || isCap(angle)) {\n joinDirection = normalPx * normalDir - tangentPx * tangentDir;\n } else {\n joinDirection = getJoinOffsetDirection(normalPx * normalDir, angle);\n }\n positionPx = positionPx + joinDirection * (lineWidth * 0.5 + 1.); // adding 1 pixel for antialiasing\n gl_Position = pxToScreen(positionPx);\n\n v_segmentStart = segmentStartPx;\n v_segmentEnd = segmentEndPx;\n v_width = lineWidth;\n v_hitColor = a_hitColor;\n v_distanceOffsetPx = a_distance / u_resolution - (lineOffsetPx * angleTangentSum);\n v_measureStart = a_measureStart;\n v_measureEnd = a_measureEnd;\n${this.attributes_.map((t=>` ${t.varyingName} = ${t.varyingExpression};`)).join("\n")}\n}`:null}getStrokeFragmentShader(){return this.hasStroke_?`${Tm}\n${this.uniforms_.map((t=>`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;\nvarying float v_distanceOffsetPx;\nvarying float v_measureStart;\nvarying float v_measureEnd;\n${this.attributes_.map((t=>`varying ${t.varyingType} ${t.varyingName};`)).join("\n")}\n${this.fragmentShaderFunctions_.join("\n")}\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\nbool isCap(float joinAngle) {\n return joinAngle < -0.1;\n}\n\nfloat segmentDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n vec2 tangent = normalize(end - start);\n vec2 normal = vec2(-tangent.y, tangent.x);\n vec2 startToPoint = point - start;\n return abs(dot(startToPoint, normal)) - width * 0.5;\n}\n\nfloat buttCapDistanceField(vec2 point, vec2 start, vec2 end) {\n vec2 startToPoint = point - start;\n vec2 tangent = normalize(end - start);\n return dot(startToPoint, -tangent);\n}\n\nfloat squareCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n return buttCapDistanceField(point, start, end) - width * 0.5;\n}\n\nfloat roundCapDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n float onSegment = max(0., 1000. * dot(point - start, end - start)); // this is very high when inside the segment\n return length(point - start) - width * 0.5 - onSegment;\n}\n\nfloat roundJoinDistanceField(vec2 point, vec2 start, vec2 end, float width) {\n return roundCapDistanceField(point, start, end, width);\n}\n\nfloat bevelJoinField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {\n vec2 startToPoint = point - start;\n vec2 tangent = normalize(end - start);\n float c = cos(joinAngle * 0.5);\n float s = sin(joinAngle * 0.5);\n float direction = -sign(sin(joinAngle));\n vec2 bisector = vec2(c * tangent.x - s * tangent.y, s * tangent.x + c * tangent.y);\n float radius = width * 0.5 * s;\n return dot(startToPoint, bisector * direction) - radius;\n}\n\nfloat miterJoinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle) {\n if (cos(joinAngle) > 0.985) { // avoid risking a division by zero\n return bevelJoinField(point, start, end, width, joinAngle);\n }\n float miterLength = 1. / sin(joinAngle * 0.5);\n float miterLimit = ${this.strokeMiterLimitExpression_};\n if (miterLength > miterLimit) {\n return bevelJoinField(point, start, end, width, joinAngle);\n }\n return -1000.;\n}\n\nfloat capDistanceField(vec2 point, vec2 start, vec2 end, float width, float capType) {\n if (capType == ${M_("butt")}) {\n return buttCapDistanceField(point, start, end);\n } else if (capType == ${M_("square")}) {\n return squareCapDistanceField(point, start, end, width);\n }\n return roundCapDistanceField(point, start, end, width);\n}\n\nfloat joinDistanceField(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float joinType) {\n if (joinType == ${M_("bevel")}) {\n return bevelJoinField(point, start, end, width, joinAngle);\n } else if (joinType == ${M_("miter")}) {\n return miterJoinDistanceField(point, start, end, width, joinAngle);\n }\n return roundJoinDistanceField(point, start, end, width);\n}\n\nfloat computeSegmentPointDistance(vec2 point, vec2 start, vec2 end, float width, float joinAngle, float capType, float joinType) {\n if (isCap(joinAngle)) {\n return capDistanceField(point, start, end, width, capType);\n }\n return joinDistanceField(point, start, end, width, joinAngle, joinType);\n}\n\nfloat distanceFromSegment(vec2 point, vec2 start, vec2 end) {\n vec2 tangent = end - start;\n vec2 startToPoint = point - start;\n // inspire by capsule fn in https://iquilezles.org/articles/distfunctions/\n float h = clamp(dot(startToPoint, tangent) / dot(tangent, tangent), 0.0, 1.0);\n return length(startToPoint - tangent * h);\n}\n\nvoid main(void) {\n${this.attributes_.map((t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`)).join("\n")}\n \n vec2 currentPoint = gl_FragCoord.xy / u_pixelRatio;\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 worldPos = pxToWorld(currentPoint);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n worldPos[0] < u_renderExtent[0] ||\n worldPos[1] < u_renderExtent[1] ||\n worldPos[0] > u_renderExtent[2] ||\n worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n #endif\n\n float segmentLength = length(v_segmentEnd - v_segmentStart);\n vec2 segmentTangent = (v_segmentEnd - v_segmentStart) / segmentLength;\n vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);\n vec2 startToPoint = currentPoint - v_segmentStart;\n float lengthToPoint = max(0., min(dot(segmentTangent, startToPoint), segmentLength));\n float currentLengthPx = lengthToPoint + v_distanceOffsetPx;\n float currentRadiusPx = distanceFromSegment(currentPoint, v_segmentStart, v_segmentEnd);\n float currentRadiusRatio = dot(segmentNormal, startToPoint) * 2. / v_width;\n currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPoint / segmentLength);\n\n if (${this.discardExpression_}) { discard; }\n\n float capType = ${this.strokeCapExpression_};\n float joinType = ${this.strokeJoinExpression_};\n float segmentStartDistance = computeSegmentPointDistance(currentPoint, v_segmentStart, v_segmentEnd, v_width, v_angleStart, capType, joinType);\n float segmentEndDistance = computeSegmentPointDistance(currentPoint, v_segmentEnd, v_segmentStart, v_width, v_angleEnd, capType, joinType);\n float distanceField = max(\n segmentDistanceField(currentPoint, v_segmentStart, v_segmentEnd, v_width),\n max(segmentStartDistance, segmentEndDistance)\n );\n distanceField = max(distanceField, ${this.strokeDistanceFieldExpression_});\n\n vec4 color = ${this.strokeColorExpression_};\n color.a *= smoothstep(0.5, -0.5, distanceField);\n gl_FragColor = color;\n gl_FragColor.a *= u_globalAlpha;\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}getFillVertexShader(){return this.hasFill_?`${Tm}\n${this.uniforms_.map((t=>`uniform ${t};`)).join("\n")}\nattribute vec2 a_position;\nattribute vec4 a_hitColor;\n\nvarying vec4 v_hitColor;\n\n${this.attributes_.map((t=>`attribute ${t.type} ${t.name};\nvarying ${t.varyingType} ${t.varyingName};`)).join("\n")}\n${this.vertexShaderFunctions_.join("\n")}\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, u_depth, 1.0);\n v_hitColor = a_hitColor;\n${this.attributes_.map((t=>` ${t.varyingName} = ${t.varyingExpression};`)).join("\n")}\n}`:null}getFillFragmentShader(){return this.hasFill_?`${Tm}\n${this.uniforms_.map((t=>`uniform ${t};`)).join("\n")}\nvarying vec4 v_hitColor;\n${this.attributes_.map((t=>`varying ${t.varyingType} ${t.varyingName};`)).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\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\nvoid main(void) {\n${this.attributes_.map((t=>` ${t.varyingType} ${t.name} = ${t.varyingName}; // assign to original attribute name`)).join("\n")}\n vec2 pxPos = gl_FragCoord.xy / u_pixelRatio;\n vec2 pxOrigin = worldToPx(u_patternOrigin);\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 worldPos = pxToWorld(pxPos);\n if (\n abs(u_renderExtent[0] - u_renderExtent[2]) > 0.0 && (\n worldPos[0] < u_renderExtent[0] ||\n worldPos[1] < u_renderExtent[1] ||\n worldPos[0] > u_renderExtent[2] ||\n worldPos[1] > u_renderExtent[3]\n )\n ) {\n discard;\n }\n #endif\n if (${this.discardExpression_}) { discard; }\n gl_FragColor = ${this.fillColorExpression_};\n gl_FragColor.a *= u_globalAlpha;\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}}function bm(t,e,i){return U_(e,i,ih(),t)}function Pm(t){const e=Nl(t);return[256*e[0]+e[1],256*e[2]+Math.round(255*e[3])]}const Im="vec4 unpackColor(vec2 packedColor) {\n return 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 fract(packedColor[1] / 256.0)\n );\n}";function Fm(t){return t===$l||t===Zl?2:t===Wl?4:1}function Mm(t){const e=Fm(t);return e>1?`vec${e}`:"float"}function Lm(t,e){for(const i in e.variables){const n=e.variables[i],r=L_(n.name);let s=Mm(n.type);n.type===$l&&(s="vec4"),t.addUniform(`${s} ${r}`)}for(const i in e.properties){const n=e.properties[i],r=Mm(n.type),s=`a_prop_${n.name}`;n.type===$l?(t.addAttribute(s,r,`unpackColor(${s})`,"vec4"),t.addVertexShaderFunction(Im)):t.addAttribute(s,r)}for(const i in e.functions)t.addVertexShaderFunction(e.functions[i]),t.addFragmentShaderFunction(e.functions[i])}function Am(t,e){const i={};for(const n in t.variables){const r=t.variables[n];i[L_(r.name)]=()=>{const t=e[r.name];return"number"==typeof t?t:"boolean"==typeof t?t?1:0:r.type===$l?Nl(t||"#eee"):"string"==typeof t?F_(t):t}}return i}function Om(t){const e={};for(const i in t.properties){const n=t.properties[i],r=t=>{const e=t.get(n.name);return n.type===$l?Pm([...Nl(e||"#eee")]):"string"==typeof e?F_(e):"boolean"==typeof e?e?1:0:e};e[`prop_${n.name}`]={size:Fm(n.type),callback:r}}return e}function Dm(t){return(JSON.stringify(t).split("").reduce(((t,e)=>(t<<5)-t+e.charCodeAt(0)),0)>>>0).toString()}function Nm(t,e,i,n){if(`${n}radius`in t&&"icon-"!==n){let r=bm(i,t[`${n}radius`],Xl);if(`${n}radius2`in t){r=`max(${r}, ${bm(i,t[`${n}radius2`],Xl)})`}`${n}stroke-width`in t&&(r=`(${r} + ${bm(i,t[`${n}stroke-width`],Xl)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${r} * 2. + 0.5)`)}if(`${n}scale`in t){const r=bm(i,t[`${n}scale`],Zl);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${r}`)}`${n}displacement`in t&&e.setSymbolOffsetExpression(bm(i,t[`${n}displacement`],Wl)),`${n}rotation`in t&&e.setSymbolRotationExpression(bm(i,t[`${n}rotation`],Xl)),`${n}rotate-with-view`in t&&e.setSymbolRotateWithView(!!t[`${n}rotate-with-view`])}function km(t,e,i,n,r){let s="vec4(0.)";if(null!==e&&(s=e),null!==i&&null!==n){s=`mix(${i}, ${s}, ${`smoothstep(-${n} + 0.63, -${n} - 0.58, ${t})`})`}let o=`${s} * vec4(1.0, 1.0, 1.0, ${`(1.0 - smoothstep(-0.63, 0.58, ${t}))`})`;return null!==r&&(o=`${o} * vec4(1.0, 1.0, 1.0, ${r})`),o}function Gm(t,e,i,n,r){const s=new Image;s.crossOrigin=void 0===t[`${n}cross-origin`]?"anonymous":t[`${n}cross-origin`],Ft("string"==typeof t[`${n}src`],`WebGL layers do not support expressions for the ${n}src style property`),s.src=t[`${n}src`],i[`u_texture${r}_size`]=()=>s.complete?[s.width,s.height]:[0,0],e.addUniform(`vec2 u_texture${r}_size`);const o=`u_texture${r}_size`;return i[`u_texture${r}`]=s,e.addUniform(`sampler2D u_texture${r}`),o}function Um(t,e,i,n,r){let s=bm(i,t[`${e}offset`],Wl);if(`${e}offset-origin`in t)switch(t[`${e}offset-origin`]){case"top-right":s=`vec2(${n}.x, 0.) + ${r} * vec2(-1., 0.) + ${s} * vec2(-1., 1.)`;break;case"bottom-left":s=`vec2(0., ${n}.y) + ${r} * vec2(0., -1.) + ${s} * vec2(1., -1.)`;break;case"bottom-right":s=`${n} - ${r} - ${s}`}return s}function jm(t,e,i){const n={variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1},r=new Rm,s={};if("icon-src"in t?function(t,e,i,n){let r="vec4(1.0)";"icon-color"in t&&(r=bm(n,t["icon-color"],$l)),"icon-opacity"in t&&(r=`${r} * vec4(1.0, 1.0, 1.0, ${bm(n,t["icon-opacity"],Xl)})`);const s=Dm(t["icon-src"]),o=Gm(t,e,i,"icon-",s);if(e.setSymbolColorExpression(`${r} * texture2D(u_texture${s}, v_texCoord)`).setSymbolSizeExpression(o),"icon-width"in t&&"icon-height"in t&&e.setSymbolSizeExpression(`vec2(${bm(n,t["icon-width"],Xl)}, ${bm(n,t["icon-height"],Xl)})`),"icon-offset"in t&&"icon-size"in t){const i=bm(n,t["icon-size"],Wl),r=e.getSymbolSizeExpression();e.setSymbolSizeExpression(i);const s=Um(t,"icon-",n,"v_quadSizePx",i);e.setTextureCoordinateExpression(`(vec4((${s}).xyxy) + vec4(0., 0., ${i})) / (${r}).xyxy`)}if(Nm(t,e,n,"icon-"),"icon-anchor"in t){const i=bm(n,t["icon-anchor"],Wl);let r,s="1.0";"icon-scale"in t&&(s=bm(n,t["icon-scale"],Zl)),r="pixels"===t["icon-anchor-x-units"]&&"pixels"===t["icon-anchor-y-units"]?`${i} * ${s}`:"pixels"===t["icon-anchor-x-units"]?`${i} * vec2(vec2(${s}).x, v_quadSizePx.y)`:"pixels"===t["icon-anchor-y-units"]?`${i} * vec2(v_quadSizePx.x, vec2(${s}).x)`:`${i} * v_quadSizePx`;let o=`v_quadSizePx * vec2(0.5, -0.5) + ${r} * vec2(-1., 1.)`;if("icon-anchor-origin"in t)switch(t["icon-anchor-origin"]){case"top-right":o=`v_quadSizePx * -0.5 + ${r}`;break;case"bottom-left":o=`v_quadSizePx * 0.5 - ${r}`;break;case"bottom-right":o=`v_quadSizePx * vec2(-0.5, 0.5) + ${r} * vec2(1., -1.)`}e.setSymbolOffsetExpression(`${e.getSymbolOffsetExpression()} + ${o}`)}}(t,r,s,n):"shape-points"in t?function(t,e,i,n){n.functions.round="float round(float v) {\n return sign(v) * floor(abs(v) + 0.5);\n}",n.functions.starDistanceField="float starDistanceField(vec2 point, float numPoints, float radius, float radius2, float angle) {\n float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle\n float c = cos(startAngle);\n float s = sin(startAngle);\n vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);\n float alpha = TWO_PI / numPoints; // the angle of one sector\n float beta = atan(pointRotated.y, pointRotated.x);\n float gamma = round(beta / alpha) * alpha; // angle in sector\n c = cos(-gamma);\n s = sin(-gamma);\n vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));\n vec2 tipToPoint = inSector + vec2(-radius, 0.);\n vec2 edgeNormal = vec2(radius2 * sin(alpha * 0.5), -radius2 * cos(alpha * 0.5) + radius);\n return dot(normalize(edgeNormal), tipToPoint);\n}",n.functions.regularDistanceField="float regularDistanceField(vec2 point, float numPoints, float radius, float angle) {\n float startAngle = -PI * 0.5 + angle; // tip starts upwards and rotates clockwise with angle\n float c = cos(startAngle);\n float s = sin(startAngle);\n vec2 pointRotated = vec2(c * point.x - s * point.y, s * point.x + c * point.y);\n float alpha = TWO_PI / numPoints; // the angle of one sector\n float radiusIn = radius * cos(PI / numPoints);\n float beta = atan(pointRotated.y, pointRotated.x);\n float gamma = round((beta - alpha * 0.5) / alpha) * alpha + alpha * 0.5; // angle in sector from mid\n c = cos(-gamma);\n s = sin(-gamma);\n vec2 inSector = vec2(c * pointRotated.x - s * pointRotated.y, abs(s * pointRotated.x + c * pointRotated.y));\n return inSector.x - radiusIn;\n}",Nm(t,e,n,"shape-");let r=null;"shape-opacity"in t&&(r=bm(n,t["shape-opacity"],Xl));let s="coordsPx";"shape-scale"in t&&(s=`coordsPx / ${bm(n,t["shape-scale"],Zl)}`);let o=null;"shape-fill-color"in t&&(o=bm(n,t["shape-fill-color"],$l));let a=null;"shape-stroke-color"in t&&(a=bm(n,t["shape-stroke-color"],$l));let l=null;"shape-stroke-width"in t&&(l=bm(n,t["shape-stroke-width"],Xl));const h=bm(n,t["shape-points"],Xl);let c,u="0.";"shape-angle"in t&&(u=bm(n,t["shape-angle"],Xl));let d=bm(n,t["shape-radius"],Xl);if(null!==l&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in t){let e=bm(n,t["shape-radius2"],Xl);null!==l&&(e=`${e} + ${l} * 0.5`),c=`starDistanceField(${s}, ${h}, ${d}, ${e}, ${u})`}else c=`regularDistanceField(${s}, ${h}, ${d}, ${u})`;const g=km(c,o,a,l,r);e.setSymbolColorExpression(g)}(t,r,0,n):"circle-radius"in t&&function(t,e,i,n){n.functions.circleDistanceField="float circleDistanceField(vec2 point, float radius) {\n return length(point) - radius;\n}",Nm(t,e,n,"circle-");let r=null;"circle-opacity"in t&&(r=bm(n,t["circle-opacity"],Xl));let s="coordsPx";"circle-scale"in t&&(s=`coordsPx / ${bm(n,t["circle-scale"],Zl)}`);let o=null;"circle-fill-color"in t&&(o=bm(n,t["circle-fill-color"],$l));let a=null;"circle-stroke-color"in t&&(a=bm(n,t["circle-stroke-color"],$l));let l=bm(n,t["circle-radius"],Xl),h=null;"circle-stroke-width"in t&&(h=bm(n,t["circle-stroke-width"],Xl),l=`(${l} + ${h} * 0.5)`);const c=km(`circleDistanceField(${s}, ${l})`,o,a,h,r);e.setSymbolColorExpression(c)}(t,r,0,n),function(t,e,i,n){if("stroke-color"in t&&e.setStrokeColorExpression(bm(n,t["stroke-color"],$l)),"stroke-pattern-src"in t){const r=Dm(t["stroke-pattern-src"]),s=Gm(t,e,i,"stroke-pattern-",r);let o=s,a="vec2(0.)";"stroke-pattern-offset"in t&&"stroke-pattern-size"in t&&(o=bm(n,t["stroke-pattern-size"],Wl),a=Um(t,"stroke-pattern-",n,s,o));let l="0.";"stroke-pattern-spacing"in t&&(l=bm(n,t["stroke-pattern-spacing"],Xl)),n.functions.sampleStrokePattern="vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {\n float currentLengthScaled = currentLengthPx * sampleSize.y / lineWidth;\n float spacingScaled = spacingPx * sampleSize.y / lineWidth;\n float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));\n // make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels\n uCoordPx = clamp(uCoordPx, 0.5, sampleSize.x - 0.5);\n float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;\n vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;\n return texture2D(texture, texCoord);\n}";const h=`u_texture${r}`;let c="1.";"stroke-color"in t&&(c=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${c} * sampleStrokePattern(${h}, ${s}, ${a}, ${o}, ${l}, currentLengthPx, currentRadiusRatio, v_width)`)}if("stroke-width"in t&&e.setStrokeWidthExpression(bm(n,t["stroke-width"],Xl)),"stroke-offset"in t&&e.setStrokeOffsetExpression(bm(n,t["stroke-offset"],Xl)),"stroke-line-cap"in t&&e.setStrokeCapExpression(bm(n,t["stroke-line-cap"],Vl)),"stroke-line-join"in t&&e.setStrokeJoinExpression(bm(n,t["stroke-line-join"],Vl)),"stroke-miter-limit"in t&&e.setStrokeMiterLimitExpression(bm(n,t["stroke-miter-limit"],Xl)),"stroke-line-dash"in t){n.functions.getSingleDashDistance=`float getSingleDashDistance(float distance, float radius, float dashOffset, float dashLength, float dashLengthTotal, float capType, float lineWidth) {\n float localDistance = mod(distance, dashLengthTotal);\n float distanceSegment = abs(localDistance - dashOffset - dashLength * 0.5) - dashLength * 0.5;\n distanceSegment = min(distanceSegment, dashLengthTotal - localDistance);\n if (capType == ${M_("square")}) {\n distanceSegment -= lineWidth * 0.5;\n } else if (capType == ${M_("round")}) {\n distanceSegment = min(distanceSegment, sqrt(distanceSegment * distanceSegment + radius * radius) - lineWidth * 0.5);\n }\n return distanceSegment;\n}`;let i=t["stroke-line-dash"].map((t=>bm(n,t,Xl)));i.length%2==1&&(i=[...i,...i]);let r="0.";"stroke-line-dash-offset"in t&&(r=bm(n,t["stroke-line-dash-offset"],Xl));const s=`dashDistanceField_${Dm(t["stroke-line-dash"])}`,o=i.map(((t,e)=>`float dashLength${e} = ${t};`)),a=i.map(((t,e)=>`dashLength${e}`)).join(" + ");let l="0.",h=`getSingleDashDistance(distance, radius, ${l}, dashLength0, totalDashLength, capType, lineWidth)`;for(let t=2;tF_(fh(t.getGeometry())))),a("featureId",N_,Vl|Xl,(t=>{const e=t.getId()??null;return"string"==typeof e?F_(e):e})),Lm(r,n),{builder:r,attributes:{...o,...Om(n)},uniforms:{...s,...Am(n,e)}}}function Bm(t){const e=Array.isArray(t)?t:[t];if("style"in e[0]){const t=[],i=e,n=[];for(const e of i){const i=Array.isArray(e.style)?e.style:[e.style];let r=e.filter;e.else&&n.length&&(r=["all",...n.map((t=>["!",t]))],e.filter&&r.push(e.filter),r.length<3&&(r=r[1])),e.filter&&n.push(e.filter);const s=i.map((t=>({style:t,...r&&{filter:r}})));t.push(...s)}return t}return"builder"in e[0]?e:e.map((t=>({style:t})))}const zm=[];let Xm;function Vm(){return Xm||(Xm=S_()),Xm}let $m=0;const Wm="a_position",Zm="a_index",Ym="a_segmentStart",Hm="a_segmentEnd",Km="a_measureStart",qm="a_measureEnd",Jm="a_parameters",Qm="a_joinAngles",ty="a_distance";class ey{constructor(t,e,i,n,r){this.helper_,this.hitDetectionEnabled_=!!n;let s=t;if(!("builder"in t)){const i=t,n=jm(i.style,e,i.filter);s={builder:n.builder,attributes:n.attributes,uniforms:n.uniforms}}this.fillProgram_,this.strokeProgram_,this.symbolProgram_,this.hasFill_=!!s.builder.getFillVertexShader(),this.hasFill_&&(this.fillVertexShader_=s.builder.getFillVertexShader(),this.fillFragmentShader_=s.builder.getFillFragmentShader()),this.hasStroke_=!!s.builder.getStrokeVertexShader(),this.hasStroke_&&(this.strokeVertexShader_=s.builder.getStrokeVertexShader(),this.strokeFragmentShader_=s.builder.getStrokeFragmentShader()),this.hasSymbol_=!!s.builder.getSymbolVertexShader(),this.hasSymbol_&&(this.symbolVertexShader_=s.builder.getSymbolVertexShader(),this.symbolFragmentShader_=s.builder.getSymbolFragmentShader()),this.featureFilter_=null,r&&(this.featureFilter_=this.computeFeatureFilter(r));const o=this.hitDetectionEnabled_?{hitColor:{callback(){return x_(this.ref,zm)},size:4}}:{};this.customAttributes_=Object.assign({},o,s.attributes),this.uniforms_=s.uniforms;const a=Object.entries(this.customAttributes_).map((([t,e])=>({name:`a_${t}`,size:e.size||1,type:Mp})));this.polygonAttributesDesc_=[{name:Wm,size:2,type:Mp},...a],this.lineStringAttributesDesc_=[{name:Ym,size:2,type:Mp},{name:Km,size:1,type:Mp},{name:Hm,size:2,type:Mp},{name:qm,size:1,type:Mp},{name:Qm,size:2,type:Mp},{name:ty,size:1,type:Mp},{name:Jm,size:1,type:Mp},...a],this.pointAttributesDesc_=[{name:Wm,size:2,type:Mp},{name:Zm,size:1,type:Mp},...a],this.setHelper(i)}computeFeatureFilter(t){const e=ih();let i;try{i=_h(t,zl,e)}catch{return null}if(e.mapState||e.variables.size>0)return null;const n={variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""};return t=>{if(n.properties=t.getPropertiesInternal(),e.featureId){const e=t.getId();n.featureId=void 0!==e?e:null}return n.geometryType=fh(t.getGeometry()),i(n)}}async generateBuffers(t,e){let i=t;if(this.featureFilter_&&(i=i.filter(this.featureFilter_),i.isEmpty()))return null;const n=this.generateRenderInstructions_(i,e),[r,s,o]=await Promise.all([this.generateBuffersForType_(n.polygonInstructions,"Polygon",e),this.generateBuffersForType_(n.lineStringInstructions,"LineString",e),this.generateBuffersForType_(n.pointInstructions,"Point",e)]);return{polygonBuffers:r,lineStringBuffers:s,pointBuffers:o,invertVerticesTransform:er([1,0,0,1,0,0],e)}}generateRenderInstructions_(t,e){return{polygonInstructions:this.hasFill_?Z_(t.polygonBatch,new Float32Array(0),this.customAttributes_,e):null,lineStringInstructions:this.hasStroke_?W_(t.lineStringBatch,new Float32Array(0),this.customAttributes_,e):null,pointInstructions:this.hasSymbol_?$_(t.pointBatch,new Float32Array(0),this.customAttributes_,e):null}}generateBuffersForType_(t,e,i){if(null===t)return null;const n=$m++;let r;switch(e){case"Polygon":r=__;break;case"LineString":r=y_;break;case"Point":r=m_}const s={id:n,type:r,renderInstructions:t.buffer,renderInstructionsTransform:i,customAttributesSize:V_(this.customAttributes_)},o=Vm();return o.postMessage(s,[t.buffer]),t=null,new Promise((t=>{const e=i=>{const r=i.data;if(r.id!==n)return;if(o.removeEventListener("message",e),!this.helper_.getGL())return;const s=new Ep(jf,Xf).fromArrayBuffer(r.vertexBuffer),a=new Ep(Bf,Xf).fromArrayBuffer(r.indexBuffer);this.helper_.flushBufferData(s),this.helper_.flushBufferData(a),t([a,s])};o.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){const o=t.getSize();0!==o&&(this.helper_.useProgram(i,r),this.helper_.bindBuffer(e),this.helper_.bindBuffer(t),this.helper_.enableAttributes(n),s(),this.helper_.drawElements(0,o))}setHelper(t,e=null){this.helper_=t,this.hasFill_&&(this.fillProgram_=this.helper_.getProgram(this.fillFragmentShader_,this.fillVertexShader_)),this.hasStroke_&&(this.strokeProgram_=this.helper_.getProgram(this.strokeFragmentShader_,this.strokeVertexShader_)),this.hasSymbol_&&(this.symbolProgram_=this.helper_.getProgram(this.symbolFragmentShader_,this.symbolVertexShader_)),this.helper_.addUniforms(this.uniforms_),e&&(e.polygonBuffers&&(this.helper_.flushBufferData(e.polygonBuffers[0]),this.helper_.flushBufferData(e.polygonBuffers[1])),e.lineStringBuffers&&(this.helper_.flushBufferData(e.lineStringBuffers[0]),this.helper_.flushBufferData(e.lineStringBuffers[1])),e.pointBuffers&&(this.helper_.flushBufferData(e.pointBuffers[0]),this.helper_.flushBufferData(e.pointBuffers[1])))}}const iy={...bp,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class ny extends Jp{constructor(t,e){super(t,{uniforms:{[iy.RENDER_EXTENT]:[0,0,0,0],[iy.PATTERN_ORIGIN]:[0,0],[iy.GLOBAL_ALPHA]:1},postProcesses:e.postProcesses}),this.hitDetectionEnabled_=!e.disableHitDetection,this.hitRenderTarget_,this.sourceRevision_=-1,this.previousExtent_=[1/0,1/0,-1/0,-1/0],this.currentTransform_=[1,0,0,1,0,0],this.tmpCoords_=[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.styleVariables_={},this.styles_=[],this.styleRenderers_=[],this.buffers_=[],this.applyOptions_(e),this.batch_=new Bp,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource(),i=Dn();let n;i&&(n=Pn(i,t.viewState.projection)),this.batch_.addFeatures(e.getFeatures(),n),this.sourceListenKeys_=[D(e,Ld,this.handleSourceFeatureAdded_.bind(this,n)),D(e,Ad,this.handleSourceFeatureChanged_,this),D(e,Dd,this.handleSourceFeatureDelete_,this),D(e,Od,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.styles_=Bm(t.style)}createRenderers_(){this.buffers_=[],this.styleRenderers_=this.styles_.map((t=>new ey(t,this.styleVariables_,this.helper,this.hitDetectionEnabled_,"filter"in t?t.filter:null)))}reset(t){this.applyOptions_(t),this.helper&&this.createRenderers_(),super.reset(t)}afterHelperCreated(){this.styleRenderers_.length?this.styleRenderers_.forEach(((t,e)=>t.setHelper(this.helper,this.buffers_[e]))):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new jp(this.helper))}handleSourceFeatureAdded_(t,e){const i=e.feature;this.batch_.addFeature(i,t)}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){Hn(this.tmpTransform_,this.currentFrameStateTransform_),Zn(this.tmpTransform_,t),this.helper.setUniformMatrixValue(iy.PROJECTION_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),er(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(iy.SCREEN_TO_WORLD_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,er(this.tmpTransform_,t),Kn(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(iy.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=E_(t,this.getLayer());this.helper.prepareDraw(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}prepareFrameInternal(t){this.initialFeaturesAdded_||(this.addInitialFeatures_(t),this.initialFeaturesAdded_=!0);const e=this.getLayer(),i=e.getSource(),n=t.viewState,r=!t.viewHints[ao]&&!t.viewHints[lo],s=!Jt(this.previousExtent_,t.extent),o=this.sourceRevision_t.generateBuffers(this.batch_,h).then((t=>{this.buffers_[e]&&this.disposeBuffers(this.buffers_[e]),this.buffers_[e]=t}))));Promise.all(c).then((()=>{this.ready=!0,this.getLayer().changed()})),this.previousExtent_=t.extent.slice()}return!0}renderWorlds(t,e,i,n,r){let s=i;e&&(this.hitRenderTarget_.setSize([Math.floor(t.size[0]/2),Math.floor(t.size[1]/2)]),this.helper.prepareDrawToRenderTarget(t,this.hitRenderTarget_,!0));do{this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_),Qn(this.currentFrameStateTransform_,s*r,0);for(let i=0,n=this.styleRenderers_.length;i{this.applyUniforms_(r.invertVerticesTransform),this.helper.applyHitDetectionUniform(e)}))}}while(++s{for(const e of t)e&&this.helper.deleteBuffer(e)};t.pointBuffers&&e(t.pointBuffers),t.lineStringBuffers&&e(t.lineStringBuffers),t.polygonBuffers&&e(t.polygonBuffers)}disposeInternal(){this.buffers_.forEach((t=>{t&&this.disposeBuffers(t)})),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach((function(t){k(t)})),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const ry={...Qp,TILE_MASK_TEXTURE:"u_depthMask",TILE_ZOOM_LEVEL:"u_tileZoomLevel"},sy={POSITION:"a_position"};class oy extends o_{constructor(t,e){super(t,{cacheSize:e.cacheSize,uniforms:{[ry.PATTERN_ORIGIN]:[0,0],[ry.TILE_MASK_TEXTURE]:()=>this.tileMaskTarget_.getTexture()}}),this.hitDetectionEnabled_=!e.disableHitDetection,this.styles_=[],this.styleVariables_=e.variables||{},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.tileMaskTarget_=null,this.tileMaskIndices_=new Ep(Bf,zf),this.tileMaskIndices_.fromArray([0,1,3,1,2,3]),this.tileMaskAttributes_=[{name:sy.POSITION,size:2,type:Mp}],this.tileMaskProgram_,this.applyOptions_(e)}reset(t){super.reset(t),this.applyOptions_(t),this.helper&&(this.createRenderers_(),this.initTileMask_())}applyOptions_(t){this.styles_=Bm(t.style)}createRenderers_(){function t(t){const e=t.getFragmentDiscardExpression(),i=`texture2D(${ry.TILE_MASK_TEXTURE}, gl_FragCoord.xy / u_pixelRatio / u_viewportSizePx).r * 50. > ${ry.TILE_ZOOM_LEVEL} + 0.5`;t.setFragmentDiscardExpression("false"!==e?`(${e}) || (${i})`:i),t.addUniform(`sampler2D ${ry.TILE_MASK_TEXTURE}`),t.addUniform(`float ${ry.TILE_ZOOM_LEVEL}`)}this.styleRenderers_=this.styles_.map((e=>{let i;if("builder"in e)t(e.builder),i=e;else{const n=jm(e.style,this.styleVariables_,e.filter);t(n.builder),i={builder:n.builder,attributes:n.attributes,uniforms:n.uniforms}}return new ey(i,this.styleVariables_,this.helper,this.hitDetectionEnabled_,"filter"in e?e.filter:null)}))}initTileMask_(){this.tileMaskTarget_=new jp(this.helper);const t=(new Rm).setFillColorExpression(`vec4(${ry.TILE_ZOOM_LEVEL} / 50., 0., 0., 1.)`).addUniform(`float ${ry.TILE_ZOOM_LEVEL}`);this.tileMaskProgram_=this.helper.getProgram(t.getFillFragmentShader(),t.getFillVertexShader()),this.helper.flushBufferData(this.tileMaskIndices_)}afterHelperCreated(){this.createRenderers_(),this.initTileMask_()}createTileRepresentation(t){const e=new zp(t,this.styleRenderers_),i=()=>{e.ready&&(this.getLayer().changed(),e.removeEventListener(n,i))};return e.addEventListener(n,i),e}beforeTilesRender(t,e){super.beforeTilesRender(t,!0),this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_)}beforeTilesMaskRender(t){this.helper.makeProjectionTransform(t,this.currentFrameStateTransform_);const e=t.pixelRatio,i=t.size;return this.tileMaskTarget_.setSize([i[0]*e,i[1]*e]),this.helper.prepareDrawToRenderTarget(t,this.tileMaskTarget_,!0,!0),this.helper.useProgram(this.tileMaskProgram_,t),Hn(this.tmpTransform_,this.currentFrameStateTransform_),this.helper.setUniformMatrixValue(ry.PROJECTION_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),er(this.tmpTransform_,this.currentFrameStateTransform_),this.helper.setUniformMatrixValue(ry.SCREEN_TO_WORLD_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),!0}renderTileMask(t,e,i,n){if(!t.ready)return;this.helper.setUniformFloatValue(ry.DEPTH,n),this.helper.setUniformFloatValue(ry.TILE_ZOOM_LEVEL,e),this.helper.setUniformFloatVec4(ry.RENDER_EXTENT,i),this.helper.setUniformFloatValue(ry.GLOBAL_ALPHA,1),this.helper.bindBuffer(t.maskVertices),this.helper.bindBuffer(this.tileMaskIndices_),this.helper.enableAttributes(this.tileMaskAttributes_);const r=this.tileMaskIndices_.getSize();this.helper.drawElements(0,r)}applyUniforms_(t,e,i,n,r){Hn(this.tmpTransform_,this.currentFrameStateTransform_),Zn(this.tmpTransform_,i),this.helper.setUniformMatrixValue(ry.PROJECTION_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),er(this.tmpTransform_,this.currentFrameStateTransform_),this.helper.setUniformMatrixValue(ry.SCREEN_TO_WORLD_MATRIX,zd(this.tmpMat4_,this.tmpTransform_)),this.helper.setUniformFloatValue(ry.GLOBAL_ALPHA,t),this.helper.setUniformFloatValue(ry.DEPTH,r),this.helper.setUniformFloatValue(ry.TILE_ZOOM_LEVEL,n),this.helper.setUniformFloatVec4(ry.RENDER_EXTENT,e)}renderTile(t,e,i,n,r,s,o,a,l,h,c){const u=pe(a,n,a),d=t.tile.getTileCoord()[0];for(let e=0,n=this.styleRenderers_.length;e{this.applyUniforms_(c,u,r.invertVerticesTransform,d,l)}))}}renderDeclutter(t){}disposeInternal(){super.disposeInternal()}}const ay=0,ly=1,hy=2,cy=3,uy=4,dy=5,gy=6,fy=7,py=8,_y=9,my=10,yy=11,xy=12,vy=[py],Sy=[xy],Ey=[ly],wy=[cy];class Ty extends lu{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;oa&&(this.instructions.push([uy,a,h,t,i,Lr,r]),this.hitDetectionInstructions.push([uy,a,h,t,n||i,Lr,r]));break;case"Point":l=t.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),h=this.coordinates.length,this.instructions.push([uy,a,h,t,i,void 0,r]),this.hitDetectionInstructions.push([uy,a,h,t,n||i,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[ay,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[ay,e,0,t,i],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;ethis.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[my,e];return"string"!=typeof e&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[yy,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,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&&!w(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=[fy,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Bt(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;jt(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Cy extends Ty{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,i){if(!this.image_||this.maxExtent&&!Xt(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=t.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(n,r);this.instructions.push([gy,s,o,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([gy,s,o,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,i){if(!this.image_)return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=[];for(let e=0,i=n.length;e=t){const e=(t-a+u)/u,d=Oe(i,h,e),g=Oe(n,c,e);l.push(d,g),s.push(l),l=[d,g],a==t&&(o+=r),a=0}else if(a0&&s.push(l),s}function Iy(t,e,i,n,r){let s,o,a,l,h,c,u,d,g,f,p=i,_=i,m=0,y=0,x=i;for(o=i;ot&&(y>m&&(m=y,p=x,_=o),y=0,x=o-r)),a=l,u=g,d=f),h=i,c=n}return y+=l,y>m?[x,o]:[p,_]}const Fy={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class My extends Ty{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.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Ph]={fillStyle:Ph},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,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,i){const n=this.textFillState_,r=this.textStrokeState_,s=this.textState_;if(""===this.text_||!s||!n&&!r)return;const o=this.coordinates;let a=o.length;const l=t.getType();let h=null,c=t.getStride();if("line"!==s.placement||"LineString"!=l&&"MultiLineString"!=l&&"Polygon"!=l&&"MultiPolygon"!=l){let n=s.overflow?null:[];switch(l){case"Point":case"MultiPoint":h=t.getFlatCoordinates();break;case"LineString":h=t.getFlatMidpoint();break;case"Circle":h=t.getCenter();break;case"MultiLineString":h=t.getFlatMidpoints(),c=2;break;case"Polygon":h=t.getFlatInteriorPoint(),s.overflow||n.push(h[2]/this.resolution),c=3;break;case"MultiPolygon":const e=t.getFlatInteriorPoints();h=[];for(let t=0,i=e.length;t{const n=o[2*(t+i)]===h[i*c]&&o[2*(t+i)+1]===h[i*c+1];return n||--t,n}))}this.saveTextStates_();const u=s.backgroundFill?this.createFill(this.fillStyleToState(s.backgroundFill)):null,d=s.backgroundStroke?this.createStroke(this.strokeStyleToState(s.backgroundStroke)):null;this.beginGeometry(t,e,i);let g=s.padding;if(g!=Nh&&(s.scale[0]<0||s.scale[1]<0)){let t=s.padding[0],e=s.padding[1],i=s.padding[2],n=s.padding[3];s.scale[0]<0&&(e=-e,n=-n),s.scale[1]<0&&(t=-t,i=-i),g=[t,e,i,n]}const f=this.pixelRatio;this.instructions.push([gy,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==Nh?Nh:g.map((function(t){return t*f})),u,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,n]);const p=1/f,_=u?u.slice(0):null;_&&(_[1]=Ph),this.hitDetectionInstructions.push([gy,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,this.declutterMode_,this.declutterImageWithText_,g,_,d,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ph:this.fillKey_,this.textOffsetX_,this.textOffsetY_,n]),this.endGeometry(e)}else{if(!xe(this.maxExtent,t.getExtent()))return;let n;if(h=t.getFlatCoordinates(),"LineString"==l)n=[h.length];else if("MultiLineString"==l)n=t.getEnds();else if("Polygon"==l)n=t.getEnds().slice(0,1);else if("MultiPolygon"==l){const e=t.getEndss();n=[];for(let t=0,i=e.length;tt[2]}else P=S>R;const I=Math.PI,F=[],M=w+n===e;let L;if(m=0,y=T,g=t[e=w],f=t[e+1],M){x(),L=Math.atan2(f-_,g-p),P&&(L+=L>0?-I:I);const t=(R+S)/2,e=(b+E)/2;return F[0]=[t,e,(C-s)/2,L,r],F}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t0?-I:I),void 0!==L){let t=d-L;if(t+=t>I?-2*I:t<-I?2*I:0,Math.abs(t)>o)return null}L=d;const S=t;let E=0;for(;t0&&t.push("\n",""),t.push(e,""),t}function Vy(t,e,i){return i%2==0&&(t+=e),t}class $y{constructor(t,e,i,n,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,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_={},this.zIndexContext_=r?new cf:null}getZIndexContext(){return this.zIndexContext_}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=a.justify?Fy[a.justify]:zy(Array.isArray(t)?t[0]:t,a.textAlign||Oh),u=n&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(Xy,[]),{width:g,height:f,widths:p,heights:_,lineWidths:m}=Wh(a,d),y=g+u,x=[],v=(y+2)*h[0],S=(f+u)*h[1],E={width:v<0?Math.floor(v):Math.ceil(v),height:S<0?Math.floor(S):Math.ceil(S),contextInstructions:x};1==h[0]&&1==h[1]||x.push("scale",h),n&&(x.push("strokeStyle",s.strokeStyle),x.push("lineWidth",u),x.push("lineCap",s.lineCap),x.push("lineJoin",s.lineJoin),x.push("miterLimit",s.miterLimit),x.push("setLineDash",[s.lineDash]),x.push("lineDashOffset",s.lineDashOffset)),i&&x.push("fillStyle",o.fillStyle),x.push("textBaseline","middle"),x.push("textAlign","center");const w=.5-c;let T=c*y+w*u;const C=[],R=[];let b,P=0,I=0,F=0,M=0;for(let t=0,e=d.length;tt?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],E=_-g[3],w=m-g[0];let T;return(f||0!==c)&&(Ny[0]=E,Uy[0]=E,Ny[1]=w,ky[1]=w,ky[0]=E+v,Gy[0]=ky[0],Gy[1]=w+S,Uy[1]=Gy[1]),0!==c?(T=tr([1,0,0,1,0,0],i,n,1,1,c,-i,-n),Kn(T,Ny),Kn(T,ky),Kn(T,Gy),Kn(T,Uy),Yt(Math.min(Ny[0],ky[0],Gy[0],Uy[0]),Math.min(Ny[1],ky[1],Gy[1],Uy[1]),Math.max(Ny[0],ky[0],Gy[0],Uy[0]),Math.max(Ny[1],ky[1],Gy[1],Uy[1]),Dy)):Yt(Math.min(E,E+v),Math.min(w,w+S),Math.max(E,E+v),Math.max(w,w+S),Dy),d&&(_=Math.round(_),m=Math.round(m)),{drawImageX:_,drawImageY:m,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:Dy[0],minY:Dy[1],maxX:Dy[2],maxY:Dy[3],value:p},canvasTransform:T,scale:u}}replayImageOrLabel_(t,e,i,n,r,s,o){const a=!(!s&&!o),l=n.declutterBox,h=o?o[2]*n.scale[0]/2:0;return l.minX-h<=e[0]&&l.maxX+h>=0&&l.minY-h<=e[1]&&l.maxY+h>=0&&(a&&this.replayTextBackground_(t,Ny,ky,Gy,Uy,s,o),Zh(t,n.canvasTransform,r,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=Kn(this.renderedTransform_,[0,0]),n=512*this.pixelRatio;t.save(),t.translate(i[0]%n,i[1]%n),1!==e&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&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=zy(Array.isArray(t)?t[0]:t,r.textAlign||Oh),h=Fy[r.textBaseline||Dh],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){const l=this.zIndexContext_;let h;this.pixelCoordinates_&&w(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=ar(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Hn(this.renderedTransform_,i));let c=0;const u=n.length;let d,g,f,p,_,m,y,x,v,S,E,T,C,R=0,b=0,P=0;const I=this.coordinateCache_,F=this.viewRotation_,M=Math.round(1e12*Math.atan2(-i[1],i[0]))/1e12,L={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:F},A=this.instructions!=n||this.overlaps?0:200;let O,D,N,k;for(;cA&&(this.fill_(t),b=0),P>A&&(t.stroke(),P=0),b||P||(t.beginPath(),_=NaN,m=NaN),++c;break;case hy:R=i[1];const n=h[R],u=h[R+1],w=h[R+2]-n,G=h[R+3]-u,U=Math.sqrt(w*w+G*G);t.moveTo(n+U,u),t.arc(n,u,U,0,2*Math.PI,!0),++c;break;case cy:t.closePath(),++c;break;case uy:R=i[1],d=i[2];const j=i[3],B=i[4],z=i[5];L.geometry=j,L.feature=O,c in I||(I[c]=[]);const X=I[c];z?z(h,R,d,2,X):(X[0]=h[R],X[1]=h[R+1],X.length=2),l&&(l.zIndex=i[6]),B(X,L),++c;break;case gy:R=i[1],d=i[2],v=i[3],g=i[4],f=i[5];let V=i[6];const $=i[7],W=i[8],Z=i[9],Y=i[10];let H=i[11];const K=i[12];let q=i[13];p=i[14]||"declutter";const J=i[15];if(!v&&i.length>=20){S=i[19],E=i[20],T=i[21],C=i[22];const t=this.drawLabelWithPointPlacement_(S,E,T,C);v=t.label,i[3]=v;const e=i[23];g=(t.anchorX-e)*this.pixelRatio,i[4]=g;const n=i[24];f=(t.anchorY-n)*this.pixelRatio,i[5]=f,V=v.height,i[6]=V,q=v.width,i[13]=q}let Q,tt,et,it;i.length>25&&(Q=i[25]),i.length>17?(tt=i[16],et=i[17],it=i[18]):(tt=Nh,et=null,it=null),Y&&M?H+=F:Y||M||(H-=F);let nt=0;for(;R!Zy.includes(t)));class Hy{constructor(t,e,i,n,r,s,o){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.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,o)}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,e){for(const i in t){let n=this.executorsByZIndex_[i];void 0===n&&(n={},this.executorsByZIndex_[i]=n);const r=t[i];for(const t in r){const i=r[t];n[t]=new $y(this.resolution_,this.pixelRatio_,this.overlaps_,i,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let e=0,n=t.length;e0){if(!s||"none"===i||"Image"!==d&&"Text"!==d||s.includes(t)){const i=(u[l]-3)/4,s=n-i%o,a=n-(i/o|0),h=r(t,e,s*s+a*a);if(h)return h}h.clearRect(0,0,o,o);break}}const f=Object.keys(this.executorsByZIndex_).map(Number);let p,_,m,x,v;for(f.sort(y),p=f.length-1;p>=0;--p){const t=f[p].toString();for(m=this.executorsByZIndex_[t],_=Wy.length-1;_>=0;--_)if(d=Wy[_],x=m[d],void 0!==x&&(v=x.executeHitDetection(h,a,i,g,c),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 ar(o,0,8,2,t,o),o}isEmpty(){return M(this.executorsByZIndex_)}execute(t,e,i,n,r,s,o){const a=Object.keys(this.executorsByZIndex_).map(Number);a.sort(o?x:y),s=s||Wy;const l=Wy.length;for(let h=0,c=a.length;hg.execute(t,e,i,n,r,o))):g.execute(u,e,i,n,r,o),f&&u.restore(),s){s.offset();const t=a[h]*l+c;this.deferredZIndexContexts_[t]||(this.deferredZIndexContexts_[t]=[]),this.deferredZIndexContexts_[t].push(s)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(y);for(let i=0,n=e.length;i{t.draw(this.renderedContext_),t.clear()})),t[e[i]].length=0}}const Ky={};function qy(t){if(void 0!==Ky[t])return Ky[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{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const t=this.frameState.size.slice(),e=this.renderedCenter_,i=this.renderedResolution_,n=this.renderedRotation_,r=this.renderedProjection_,s=this.wrappedRenderedExtent_,o=this.getLayer(),a=[],l=t[0]*Jy,h=t[1]*Jy;a.push(this.getRenderTransform(e,i,n,Jy,l,h,0).slice());const c=o.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!Vt(u,s)){let t=s[0];const r=ye(u);let o,c=0;for(;tu[2];)++c,o=r*c,a.push(this.getRenderTransform(e,i,n,Jy,l,h,o).slice()),t-=r}const d=Dn();this.hitDetectionImageData_=Qy(t,a,this.renderedFeatures_,o.getStyleFunction(),s,i,n,du(i,this.renderedPixelRatio_),d?r:null)}e(tx(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=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,s,o,i,(function(t,e,i){const s=z(t),o=l[s];if(o){if(!0!==o&&it.value)):null)}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[ao],r=t.viewHints[lo],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(),g=e.getRenderBuffer();let f=e.getRenderOrder();void 0===f&&(f=uu);const p=l.center.slice(),_=jt(a,g*c),m=_.slice(),y=[_.slice()],x=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!Vt(x,t.extent)){const t=ye(x),e=Math.max(ye(_)/2,t);_[0]=x[0]-e,_[2]=x[2]+e,hi(p,h);const i=Ce(y[0],h);i[0]x[0]&&i[2]>x[2]&&y.push([i[0]-t,i[1],i[2]-t,i[3]])}if(this.ready&&this.renderedResolution_==c&&this.renderedRevision_==d&&this.renderedRenderOrder_==f&&this.renderedFrameDeclutter_===!!t.declutter&&Vt(this.wrappedRenderedExtent_,_))return w(this.renderedExtent_,m)||(this.hitDetectionImageData_=null,this.renderedExtent_=m),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const v=new Ay(gu(c,u),_,c,u),S=Dn();let E;if(S){for(let t=0,e=y.length;t{let n;const r=t.getStyleFunction()||e.getStyleFunction();if(r&&(n=r(t,c)),n){const e=this.renderFeature(t,T,n,v,E,this.getLayer().getDeclutter(),i);C=C&&!e}},b=Gn(_,h),P=i.getFeaturesInExtent(b);f&&P.sort(f);for(let t=0,e=P.length;t{if(f.getState()!==Is)return;this.image=f;const t=f.getPixelRatio(),n=Tu(f.getResolution())*e/t;this.renderedResolution=n,this.coordinateToVectorPixelTransform_=tr(this.coordinateToVectorPixelTransform_,l/2,h/2,1/n,-1/n,0,-i.center[0],-i.center[1])})),f.load()}return this.image&&(this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice()),!this.getLayer().getSource().loading&&!!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 nx={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},rx={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class sx extends Ef{constructor(t,e){super(t,e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.renderedOpacity_=1,this.tmpTransform_=[1,0,0,1,0,0],this.tileClipContexts_=null}drawTile(t,e,i,n,r,s,o,a){this.updateExecutorGroup_(t,e.pixelRatio,e.viewState.projection),this.tileImageNeedsRender_(t)&&this.renderTileImage_(t,e),super.drawTile(t,e,i,n,r,s,o,a)}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);if(!r)return null;const s=n.viewState.resolution,o=n.viewHints;return!!(o[ao]||o[lo])&&r.wantedResolution||(r.wantedResolution=s),r}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=z(n);delete t.hitDetectionImageData[g],t.executorGroups[g]=[],a.dirty=!1;for(let i=0,r=d.length;it.value)):null;let _;t:for(let e=0,n=d.length;e{const n=this.getLayer(),r=n.getSource(),s=this.renderedProjection,o=s.getExtent(),a=this.renderedResolution,l=r.getTileGridForProjection(s),h=Kn(this.renderedPixelToCoordinateTransform_,t.slice()),c=l.getTileCoordForCoordAndResolution(h,a).toString(),u=this.renderedTiles.find((t=>t.tileCoord.toString()===c&&t.getState()===K));if(!u||u.loadingSourceTiles>0)return void e([]);r.getWrapX()&&s.canWrapX()&&!Vt(o,l.getTileCoordExtent(u.tileCoord))&&hi(h,s);const d=z(n),g=_e(l.getTileCoordExtent(u.wrappedTileCoord)),f=[(h[0]-g[0])/a,(g[1]-h[1])/a],p=u.getSourceTiles().reduce(((t,e)=>t.concat(e.getFeatures())),[]);let _=u.hitDetectionImageData[d];if(!_){const t=jl(l.getTileSize(l.getZForResolution(a,r.zDirection))),e=this.renderedRotation_;_=Qy(t,[this.getRenderTransform(l.getTileCoordCenter(u.wrappedTileCoord),a,0,Jy,t[0]*Jy,t[1]*Jy,0)],p,n.getStyleFunction(),l.getTileCoordExtent(u.wrappedTileCoord),u.getReplayState(n).renderedResolution,e),u.hitDetectionImageData[d]=_}e(tx(f,p,_))}))}getFeaturesInExtent(t){const e=[],i=this.getTileCache();if(0===i.getCount())return e;const n=this.getLayer().getSource().getTileGridForProjection(this.frameState.viewState.projection),r=n.getZForResolution(this.renderedResolution),s={};return i.forEach((i=>{if(i.tileCoord[0]!==r||i.getState()!==K)return;const o=i.getSourceTiles();for(let i=0,r=o.length;i=0;--e)n[e].execute(this.context,o,this.getTileRenderTransform(i,t),t.viewState.rotation,s,Zy,l)}i.globalAlpha=n}renderDeferredInternal(t){const e=this.renderedTiles,i=z(this.getLayer()),n=e.reduce(((t,e,n)=>(e.executorGroups[i].forEach((e=>t.push({executorGroup:e,index:n}))),t)),[]),r=n.map((({executorGroup:t})=>t.getDeferredZIndexContexts())),s={};for(let t=0,e=n.length;t{r.forEach(((e,i)=>{e[t]&&(e[t].forEach((t=>{const{executorGroup:e,index:r}=n[i],s=e.getRenderedContext(),o=s.globalAlpha;s.globalAlpha=this.renderedOpacity_;const a=this.tileClipContexts_[r];a&&a.draw(s),t.draw(s),a&&s.restore(),s.globalAlpha=o,t.clear()})),e[t].length=0)}))}))}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.tempExtent)[0]-d[0];return Zn(Jn(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[ao]||i[lo]);this.renderedPixelToCoordinateTransform_=e.pixelToCoordinateTransform.slice(),this.renderedRotation_=e.viewState.rotation,this.renderedOpacity_=e.layerStatesArray[e.layerIndex].opacity;const r=this.getLayer(),s=r.getRenderMode(),o=t.globalAlpha;t.globalAlpha=this.renderedOpacity_;const a=r.getDeclutter(),l=a?rx[s].filter((t=>!Zy.includes(t))):rx[s],h=e.viewState,c=h.rotation,u=r.getSource(),d=u.getTileGridForProjection(h.projection).getZForResolution(h.resolution,u.zDirection),g=this.renderedTiles,f=[],p=[],_=[],m=z(r);let y=!0;for(let i=g.length-1;i>=0;--i){const s=g[i];y=y&&!s.getReplayState(r).dirty;const o=s.executorGroups[m].filter((t=>t.hasExecutors(l)));if(0===o.length)continue;const h=this.getTileRenderTransform(s,e),u=s.tileCoord[0];let x=!1;const v=o[0].getClipCoords(h);let S,E=t;if(v){S=new cf,E=S.getContext();for(let t=0,e=f.length;t ${a_.RENDER_EXTENT}[2] ||\n v_mapCoord[1] > ${a_.RENDER_EXTENT}[3]\n ) {\n discard;\n }\n\n vec4 velocity = texture2D(${a_.TILE_TEXTURE_ARRAY}[0], v_textureCoord);\n gl_FragColor = vec4((velocity.xy + ${u_.MAX_SPEED}) / (2.0 * ${u_.MAX_SPEED}), 0, 1);\n }\n`,ux=`\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n\n attribute vec2 ${d_};\n\n varying vec2 ${f_};\n\n void main() {\n ${f_} = ${d_};\n gl_Position = vec4(1.0 - 2.0 * ${d_}, 0, 1);\n }\n`,dx=`\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n\n uniform sampler2D ${u_.TEXTURE};\n uniform float ${u_.OPACITY};\n\n varying vec2 ${f_};\n\n void main() {\n vec4 color = texture2D(${u_.TEXTURE}, 1.0 - ${f_});\n gl_FragColor = vec4(floor(255.0 * color * ${u_.OPACITY}) / 255.0);\n }\n`,gx=`\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n\n uniform sampler2D ${u_.POSITION_TEXTURE};\n uniform sampler2D ${u_.VELOCITY_TEXTURE};\n uniform float ${u_.RANDOM_SEED};\n uniform float ${u_.SPEED_FACTOR};\n uniform float ${u_.DROP_RATE};\n uniform float ${u_.DROP_RATE_BUMP};\n uniform vec2 ${u_.ROTATION};\n uniform vec2 ${u_.VIEWPORT_SIZE_PX};\n\n varying vec2 ${f_};\n\n // pseudo-random generator\n const vec3 randConstants = vec3(12.9898, 78.233, 4375.85453);\n\n float rand(const vec2 co) {\n float t = dot(randConstants.xy, co);\n return fract(sin(t) * (randConstants.z + t));\n }\n\n void main() {\n vec4 positionColor = texture2D(${u_.POSITION_TEXTURE}, ${f_});\n\n // decode particle position from pixel RGBA\n vec2 particlePosition = vec2(\n positionColor.r / 255.0 + positionColor.b,\n positionColor.g / 255.0 + positionColor.a\n );\n\n vec4 velocityColor = texture2D(${u_.VELOCITY_TEXTURE}, particlePosition);\n if (velocityColor.a == 0.0) {\n discard;\n }\n\n float vx = 2.0 * velocityColor.r - 1.0;\n float vy = 2.0 * velocityColor.g - 1.0;\n\n // normalized veloicty (magnitude 0 - 1)\n vec2 velocity = vec2(\n vx * ${u_.ROTATION}.x - vy * ${u_.ROTATION}.y,\n vx * ${u_.ROTATION}.y + vy * ${u_.ROTATION}.x\n );\n\n // account for aspect ratio (square particle position texture, non-square map)\n float aspectRatio = ${u_.VIEWPORT_SIZE_PX}.x / ${u_.VIEWPORT_SIZE_PX}.y;\n vec2 offset = vec2(velocity.x / aspectRatio, velocity.y) * ${u_.SPEED_FACTOR};\n\n // update particle position, wrapping around the edge\n particlePosition = fract(1.0 + particlePosition + offset);\n\n // a random seed to use for the particle drop\n vec2 seed = (particlePosition + ${f_}) * ${u_.RANDOM_SEED};\n\n // drop rate is a chance a particle will restart at random position, to avoid degeneration\n float dropRate = ${u_.DROP_RATE} + length(velocity) * ${u_.DROP_RATE_BUMP};\n float drop = step(1.0 - dropRate, rand(seed));\n\n vec2 randomPosition = vec2(rand(seed + 1.3), rand(seed + 2.1));\n particlePosition = mix(particlePosition, randomPosition, drop);\n\n // encode the new particle position back into RGBA\n gl_FragColor = vec4(\n fract(particlePosition * 255.0),\n floor(particlePosition * 255.0) / 255.0\n );\n }\n`,fx=`\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n\n attribute float ${g_};\n\n uniform sampler2D ${u_.POSITION_TEXTURE};\n uniform float ${u_.PARTICLE_COUNT_SQRT};\n\n varying vec2 ${f_};\n\n void main() {\n vec4 color = texture2D(\n ${u_.POSITION_TEXTURE},\n vec2(\n fract(${g_} / ${u_.PARTICLE_COUNT_SQRT}),\n floor(${g_} / ${u_.PARTICLE_COUNT_SQRT}) / ${u_.PARTICLE_COUNT_SQRT}\n )\n );\n\n ${f_} = vec2(\n color.r / 255.0 + color.b,\n color.g / 255.0 + color.a\n );\n\n gl_PointSize = 1.0;\n gl_Position = vec4(\n 2.0 * ${f_}.x - 1.0,\n 2.0 * ${f_}.y - 1.0,\n 0,\n 1\n );\n }\n`;const px=[];class _x extends Cf{constructor(t){const e=Object.assign({},t);if(delete e.maxSpeed,delete e.speedFactor,delete e.particles,super(e),this.style_=t.style||{},!(t.maxSpeed>0))throw new Error("maxSpeed is required");this.maxSpeed_=t.maxSpeed,this.speedFactor_=t.speedFactor,this.particles_=t.particles,this.styleVariables_=this.style_.variables||{},this.addChangeListener(ja,this.handleSourceUpdate_)}handleSourceUpdate_(){this.hasRenderer()&&this.getRenderer().clearCache()}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}getSources(t,e){const i=this.getSource();return px[0]=i,px}createRenderer(){const t=function(t){const e={variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1},i=[];if(void 0!==t.color){const n=bm(e,t.color,$l);i.push(`color = ${n};`)}const n=Object.keys(e.variables);if(n.length>1&&!t.variables)throw new Error(`Missing variables in style (expected ${e.variables})`);const r={};for(const e of n){if(!(e in t.variables))throw new Error(`Missing '${e}' in style variables`);r[L_(e)]=function(){let i=t.variables[e];return"string"==typeof i&&(i=F_(i)),void 0!==i?i:-9999999}}const s=Object.keys(r).map((function(t){return`uniform float ${t};`})),o=Object.keys(e.functions).map((function(t){return e.functions[t]})),a=`\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n #endif\n\n uniform sampler2D ${u_.VELOCITY_TEXTURE};\n uniform float ${u_.MAX_SPEED};\n uniform vec2 ${u_.ROTATION};\n\n ${s.join("\n")}\n\n varying vec2 ${f_};\n \n ${o.join("\n")}\n\n void main() {\n vec4 velocityColor = texture2D(${u_.VELOCITY_TEXTURE}, ${f_});\n\n float vx = mix(-${u_.MAX_SPEED}, ${u_.MAX_SPEED}, velocityColor.r);\n float vy = mix(-${u_.MAX_SPEED}, ${u_.MAX_SPEED}, velocityColor.g);\n\n vec2 velocity = vec2(\n vx * ${u_.ROTATION}.x - vy * ${u_.ROTATION}.y,\n vx * ${u_.ROTATION}.y + vy * ${u_.ROTATION}.x\n );\n\n float a_prop_speed = length(velocity);\n\n vec4 color;\n\n ${i.join("\n")}\n\n if (color.a == 0.0) {\n discard;\n }\n\n gl_FragColor = color;\n }\n `;return{tileVertexShader:hx,tileFragmentShader:cx,particleColorVertexShader:fx,particleColorFragmentShader:a,particlePositionVertexShader:ux,particlePositionFragmentShader:gx,textureVertexShader:ux,textureFragmentShader:dx}}(this.style_);return new p_(this,{...t,cacheSize:this.getCacheSize(),maxSpeed:this.maxSpeed_,speedFactor:this.speedFactor_,particles:this.particles_})}}function mx(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(),m=f.toString(),m in u||(n.push(o[0],o[1]),u[m]=!0),p=c.pop(),s=l.pop(),a=h.pop(),_=(f+p)/2,d=t(_),g=e(d),Pe(g[0],g[1],o[0],o[1],a[0],a[1])1&&!t.variables)throw new Error(`Missing variables in style (expected ${n.variables})`);for(let e=0;e ${a_.RENDER_EXTENT}[2] ||\n v_mapCoord[1] > ${a_.RENDER_EXTENT}[3]\n ) {\n discard;\n }\n\n vec4 color = texture2D(${a_.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 *= ${a_.TRANSITION_ALPHA};\n }`,uniforms:s,paletteTextures:n.paletteTextures}}class Px extends Cf{constructor(t){const e=(t=t?Object.assign({},t):{}).style||{};delete t.style,super(t),this.sources_=t.sources,this.renderedSource_=null,this.renderedResolution_=NaN,this.style_=e,this.styleVariables_=this.style_.variables||{},this.handleSourceUpdate_(),this.addChangeListener(ja,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();const t=this.getSource();if(t)if("loading"===t.getState()){const e=()=>{"ready"===t.getState()&&(t.removeEventListener("change",e),this.setStyle(this.style_))};t.addEventListener("change",e)}else 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=bx(this.style_,this.getSourceBandCount_());return new c_(this,{vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms,cacheSize:this.getCacheSize(),paletteTextures:t.paletteTextures})}renderSources(t,e){const i=this.getRenderer();let n;for(let r=0,s=e.length;r{"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){if(this.styleVariables_=t.variables||{},this.style_=t,this.hasRenderer()){const t=bx(this.style_,this.getSourceBandCount_());this.getRenderer().reset({vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms,paletteTextures:t.paletteTextures}),this.changed()}}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}}Px.prototype.dispose;const Ix="addfeatures";class Fx extends L{constructor(t,e,i,n){super(t),this.features=i,this.file=e,this.projection=n}}const Mx="drawstart",Lx="drawend",Ax="drawabort";class Ox extends L{constructor(t,e){super(t),this.feature=e}}function Dx(t,e){return Ie(t[0],t[1],e[0],e[1])}function Nx(t,e){const i=t.length;return e<0?t[e+i]:e>=i?t[e-i]:t[e]}function kx(t,e,i){let n,r;eo){return Dx(Xx(t,n),Xx(t,r))}let a=0;if(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 Vx(){const t=sc();return function(e,i){return t[e.getGeometry().getType()]}}const $x="extentchanged";class Wx extends L{constructor(t){super($x),this.extent=t}}function Zx(){const t=sc();return function(e,i){return t.Polygon}}function Yx(){const t=sc();return function(e,i){return t.Point}}function Hx(t){return function(e){return Ut([t,e])}}function Kx(t,e){return t[0]==e[0]?function(i){return Ut([t,[i[0],e[1]]])}:t[1]==e[1]?function(i){return Ut([t,[e[0],i[1]]])}:null}function qx(t){return parseFloat(t)}function Jx(t){return function(t){return De(t,5)}(t).toString()}function Qx(t,e){return!isNaN(t)&&t!==qx(Jx(e))}const tv=[0,0,0,0],ev=[],iv="modifystart",nv="modifyend";class rv extends L{constructor(t,e,i){super(t),this.features=e,this.mapBrowserEvent=i}}function sv(t,e){return t.index-e.index}function ov(t,e,i){const n=e.geometry;if("Circle"===n.getType()){let r=n;if(1===e.index){const e=Dn();e&&(r=r.clone().transform(e,i));const n=si(r.getCenter(),kn(t,i)),s=Math.sqrt(n)-r.getRadius();return s*s}}const r=kn(t,i);return ev[0]=kn(e.segment[0],i),ev[1]=kn(e.segment[1],i),ai(r,ev)}function av(t,e,i){const n=e.geometry;if("Circle"===n.getType()&&1===e.index){let e=n;const r=Dn();return r&&(e=e.clone().transform(r,i)),Nn(e.getClosestPoint(kn(t,i)),i)}const r=kn(t,i);return ev[0]=kn(e.segment[0],i),ev[1]=kn(e.segment[1],i),Nn(Qe(r,ev),i)}function lv(){const t=sc();return function(e,i){return t.Point}}const hv="select";class cv extends L{constructor(t,e,i,n){super(t),this.selected=e,this.deselected=i,this.mapBrowserEvent=n}}const uv={};class dv extends $o{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:na,this.addCondition_=t.addCondition?t.addCondition:ia,this.removeCondition_=t.removeCondition?t.removeCondition:ia,this.toggleCondition_=t.toggleCondition?t.toggleCondition:oa,this.multi_=!!t.multi&&t.multi,this.filter_=t.filter?t.filter:C,this.hitTolerance_=t.hitTolerance?t.hitTolerance:0,this.style_=void 0!==t.style?t.style:function(){const t=sc();return E(t.Polygon,t.LineString),E(t.GeometryCollection,t.LineString),function(e){return e.getGeometry()?t[e.getGeometry().getType()]:null}}(),this.features_=t.features||new Z,t.layers)if("function"==typeof t.layers)e=t.layers;else{const i=t.layers;e=function(t){return i.includes(t)}}else e=C;this.layerFilter_=e,this.featureLayerAssociation_={}}addFeatureLayerAssociation_(t,e){this.featureLayerAssociation_[z(t)]=e}getFeatures(){return this.features_}getHitTolerance(){return this.hitTolerance_}getLayer(t){return this.featureLayerAssociation_[z(t)]}setHitTolerance(t){this.hitTolerance_=t}setMap(i){this.getMap()&&this.style_&&this.features_.forEach(this.restorePreviousStyle_.bind(this)),super.setMap(i),i?(this.features_.addEventListener(t,this.boundAddFeature_),this.features_.addEventListener(e,this.boundRemoveFeature_),this.style_&&this.features_.forEach(this.applySelectedStyle_.bind(this))):(this.features_.removeEventListener(t,this.boundAddFeature_),this.features_.removeEventListener(e,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 vx&&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=z(t);e in uv||(uv[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 dv&&n.getStyle()&&-1!==n.getFeatures().getArray().lastIndexOf(t))return void t.setStyle(n.getStyle())}const i=z(t);t.setStyle(uv[i]),delete uv[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[z(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){F(this.featureLayerAssociation_),s.forEachFeatureAtPixel(t.pixel,((t,e)=>{if(t instanceof Mt&&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 Mt&&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 cv(hv,l,a,t)),!0}}const gv="snap",fv="unsnap";class pv extends L{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}const _v={Circle(t,e){let i=t;const n=Dn();n&&(i=i.clone().transform(n,e));const r=gs(i);return n&&r.transform(e,n),_v.Polygon(r)},GeometryCollection(t,e){const i=[],n=t.getGeometriesArray();for(let t=0;t[[t.getFlatCoordinates().slice(0,2)]],Polygon(t){const e=[],i=t.getFlatCoordinates(),n=t.getStride(),r=t.getEnds();let s=0;for(let t=0,o=r.length;tFv({...t,geometry:e}))).flat();const n="MultiPolygon"===i.type?"Polygon":i.type;if("GeometryCollection"===n||"Circle"===n)throw new Error("Unsupported geometry type: "+n);const r=i.layout.length;return bv(new Id(n,"Polygon"===n?function(t,e,i){return Array.isArray(e[0])?(os(t,0,e,i)||ls(t=t.slice(),0,e,i),t):(ss(t,0,e,i)||as(t=t.slice(),0,e,i),t)}(i.flatCoordinates,i.ends,r):i.flatCoordinates,i.ends?.flat(),r,t.properties||{},t.id).enableSimplifyTransformed(),!1,e)}function Mv(t,e){if(!t)return null;if(Array.isArray(t)){const i=t.map((t=>Mv(t,e)));return new Sd(i)}return bv(new(0,Iv[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}class Lv extends Rv{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(Av(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(Av(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return j()}readFeaturesFromObject(t,e){return j()}readGeometry(t,e){return this.readGeometryFromObject(Av(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return j()}readProjection(t){return this.readProjectionFromObject(Av(t))}readProjectionFromObject(t){return j()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return j()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return j()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return j()}}function Av(t){if("string"==typeof t){const e=JSON.parse(t);return e||null}return null!==t?t:null}const Ov={Point:function(t){let e;e=void 0!==t.m&&void 0!==t.z?new Xr([t.x,t.y,t.z,t.m],"XYZM"):void 0!==t.z?new Xr([t.x,t.y,t.z],"XYZ"):void 0!==t.m?new Xr([t.x,t.y,t.m],"XYM"):new Xr([t.x,t.y]);return e},LineString:function(t){const e=kv(t);return new Td(t.paths[0],e)},Polygon:function(t){const e=kv(t);return new cs(t.rings,e)},MultiPoint:function(t){const e=kv(t);return new Rd(t.points,e)},MultiLineString:function(t){const e=kv(t);return new Cd(t.paths,e)},MultiPolygon:function(t){const e=kv(t);return new bd(t.rings,e)}},Dv={Point:function(t,e){const i=t.getCoordinates();let n;const r=t.getLayout();if("XYZ"===r)n={x:i[0],y:i[1],z:i[2]};else if("XYM"===r)n={x:i[0],y:i[1],m:i[2]};else if("XYZM"===r)n={x:i[0],y:i[1],z:i[2],m:i[3]};else{if("XY"!==r)throw new Error("Invalid geometry layout");n={x:i[0],y:i[1]}}return n},LineString:function(t,e){const i=Gv(t);return{hasZ:i.hasZ,hasM:i.hasM,paths:[t.getCoordinates()]}},Polygon:function(t,e){const i=Gv(t);return{hasZ:i.hasZ,hasM:i.hasM,rings:t.getCoordinates(!1)}},MultiPoint:function(t,e){const i=Gv(t);return{hasZ:i.hasZ,hasM:i.hasM,points:t.getCoordinates()}},MultiLineString:function(t,e){const i=Gv(t);return{hasZ:i.hasZ,hasM:i.hasM,paths:t.getCoordinates()}},MultiPolygon:function(t,e){const i=Gv(t),n=t.getCoordinates(!1),r=[];for(let t=0;t=0;e--)r.push(n[t][e]);return{hasZ:i.hasZ,hasM:i.hasM,rings:r}}};function Nv(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=kv(e),r=function(t,e){const i=[],n=[],r=[];let s,o;for(s=0,o=t.length;s=0;s--){const i=n[s][0];if(Vt(new zr(i).getExtent(),new zr(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 bv((0,Ov[i])(t),!1,e)}function kv(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 Gv(t){const e=t.getLayout();return{hasZ:"XYZ"===e||"XYZM"===e,hasM:"XYM"===e||"XYZM"===e}}function Uv(t,e){return(0,Dv[t.getType()])(bv(t,!0,e),e)}class jv extends Rv{constructor(){super(),this.xmlSerializer_=yp()}getType(){return"xml"}readFeature(t,e){if(!t)return null;if("string"==typeof t){const i=tp(t);return this.readFeatureFromDocument(i,e)}return Jf(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=tp(t);return this.readFeaturesFromDocument(i,e)}return Jf(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&&E(i,this.readFeaturesFromNode(n,e));return i}readFeaturesFromNode(t,e){return j()}readGeometry(t,e){if(!t)return null;if("string"==typeof t){const i=tp(t);return this.readGeometryFromDocument(i,e)}return Jf(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=tp(t);return this.readProjectionFromDocument(e)}return Jf(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 Bv="http://www.opengis.net/gml",zv=/^\s*$/;class Xv extends jv{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:ip(this.readFeaturesInternal),featureMembers:np(this.readFeaturesInternal)},this.supportedMediaTypes=["application/gml+xml"]}readFeaturesInternal(t,e){const i=t.localName;let n=null;if("FeatureCollection"==i)n=gp([],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;e0&&!(t instanceof gr)){t={_content_:t};for(let e=0;e").forEach(((e,i,n)=>{i0&&(e=">"+e),Qv(t,e)})):t.appendChild(xp().createTextNode(e))}const aS=Bv+" http://schemas.opengis.net/gml/2.1.2/feature.xsd",lS={MultiLineString:"lineStringMember",MultiCurve:"curveMember",MultiPolygon:"polygonMember",MultiSurface:"surfaceMember"};class hS extends Xv{constructor(t){super(t=t||{}),this.FEATURE_COLLECTION_PARSERS[Bv].featureMember=ip(this.readFeaturesInternal),this.schemaLocation=t.schemaLocation?t.schemaLocation:aS}readFlatCoordinates(t,e){const i=Kf(t,!1).replace(/^\s*|\s*$/g,""),n=e[0].srsName;let r="enu";if(n){const t=xn(n);t&&(r=t.getAxisOrientation())}const s=i.trim().split(/\s+/),o=[];for(let t=0,e=s.length;t0){e[e.length-1].push(...i)}},outerBoundaryIs:function(t,e){const i=gp(void 0,xw,t,e);if(i){e[e.length-1][0]=i}}});function ow(t,e){const i=gp({},QE,t,e),n=gp([null],sw,t,e);if(n&&n[0]){const t=n[0],e=[t.length];for(let i=1,r=n.length;i0;let o;const a=r.href;let l,h,c;a?o=a:s&&(o=SE);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=mE,h=yE,c=xE):o.includes("arrow-reverse")?(l=[54,42],h=yE,c=xE):o.includes("paddle")&&(l=[32,1],h=yE,c=xE));const f=r.x,p=r.y;let _;void 0!==f&&void 0!==p&&(g=[f,p]);const m=r.w,y=r.h;let x;void 0!==m&&void 0!==y&&(_=[m,y]);const v=i.heading;void 0!==v&&(x=Le(v));const S=i.scale,E=i.color;if(s){o==SE&&(_=vE);const t=new Qh({anchor:l,anchorOrigin:u,anchorXUnits:h,anchorYUnits:c,crossOrigin:this.crossOrigin_,offset:g,offsetOrigin:"bottom-left",rotation:x,scale:S,size:_,src:this.iconUrlFunction_(o),color:E}),e=t.getScaleArray()[0],i=t.getSize();if(null===i){const i=t.getImageState();if(i===bs||i===Ps){const n=function(){const i=t.getImageState();if(i!==bs&&i!==Ps){const i=t.getSize();if(i&&2==i.length){const n=ME(i);t.setScale(e*n)}t.unlistenImageChange(n)}};t.listenImageChange(n),i===bs&&t.load()}}else if(2==i.length){const n=ME(i);t.setScale(e*n)}n.imageStyle=t}else n.imageStyle=wE},LabelStyle:function(t,e){const i=gp({},zE,t,e);if(!i)return;const n=e[e.length-1],r=new ac({fill:new qh({color:"color"in i?i.color:_E}),scale:i.scale});n.textStyle=r},LineStyle:function(t,e){const i=gp({},XE,t,e);if(!i)return;const n=e[e.length-1],r=new tc({color:"color"in i?i.color:_E,width:"width"in i?i.width:1});n.strokeStyle=r},PolyStyle:function(t,e){const i=gp({},VE,t,e);if(!i)return;const n=e[e.length-1],r=new qh({color:"color"in i?i.color:_E});n.fillStyle=r;const s=i.fill;void 0!==s&&(n.fill=s);const o=i.outline;void 0!==o&&(n.outline=o)}});function lw(t,e){const i=gp({},aw,t,e,this);if(!i)return null;let n="fillStyle"in i?i.fillStyle:EE;const r=i.fill;let s;void 0===r||r||(n=null),"imageStyle"in i?i.imageStyle!=wE&&(s=i.imageStyle):s=TE;const o="textStyle"in i?i.textStyle:bE,a="strokeStyle"in i?i.strokeStyle:RE,l=i.outline;return void 0===l||l?[new ec({fill:n,image:s,stroke:a,text:o,zIndex:void 0})]:[new ec({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new Sd(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 ec({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new Sd(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 hw(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;t0){const t=cp(r,o);pp(n,Vw,Ww,[{names:o,values:t}],i)}const u=i[0];let d=e.getGeometry();d&&(d=bv(d,!0,u)),pp(n,Vw,Dw,[d],i)}const Yw=up(aE,["extrude","tessellate","altitudeMode","coordinates"]),Hw=up(aE,{extrude:op(Jv),tessellate:op(Jv),altitudeMode:op(oS),coordinates:op((function(t,e,i){const n=i[i.length-1],r=n.layout,s=n.stride;let o;if("XY"==r||"XYM"==r)o=2;else{if("XYZ"!=r&&"XYZM"!=r)throw new Error("Invalid geometry layout");o=3}const a=e.length;let l="";if(a>0){l+=e[0];for(let t=1;t>3,r=this.pos;this.type=7&i,t(n,e,this),this.pos===r&&this.skip(i)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*oT;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*oT;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let i,n;return n=e[this.pos++],i=127&n,n<128?i:(n=e[this.pos++],i|=(127&n)<<7,n<128?i:(n=e[this.pos++],i|=(127&n)<<14,n<128?i:(n=e[this.pos++],i|=(127&n)<<21,n<128?i:(n=e[this.pos],i|=(15&n)<<28,function(t,e,i){const n=i.buf;let r,s;if(s=n[i.pos++],r=(112&s)>>4,s<128)return cT(t,r,e);if(s=n[i.pos++],r|=(127&s)<<3,s<128)return cT(t,r,e);if(s=n[i.pos++],r|=(127&s)<<10,s<128)return cT(t,r,e);if(s=n[i.pos++],r|=(127&s)<<17,s<128)return cT(t,r,e);if(s=n[i.pos++],r|=(127&s)<<24,s<128)return cT(t,r,e);if(s=n[i.pos++],r|=(1&s)<<31,s<128)return cT(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&lT?lT.decode(this.buf.subarray(e,t)):function(t,e,i){let n="",r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+h>i)break;1===h?e<128&&(l=e):2===h?(s=t[r+1],128==(192&s)&&(l=(31&e)<<6|63&s,l<=127&&(l=null))):3===h?(s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(l=(15&e)<<12|(63&s)<<6|63&o,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(l=(15&e)<<18|(63&s)<<12|(63&o)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=h}return n}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const i=this.readPackedEnd();for(;this.pos127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e268435455||t<0?function(t,e){let i,n;t>=0?(i=t%4294967296|0,n=t/4294967296|0):(i=~(-t%4294967296),n=~(-t/4294967296),4294967295^i?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){const 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(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,i){for(let n,r,s=0;s55295&&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);const i=this.pos-e;i>=128&&uT(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let i=0;i=128&&uT(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(t,e,i){this.writeTag(t,2),this.writeRawMessage(e,i)}writePackedVarint(t,e){e.length&&this.writeMessage(t,dT,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,gT,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,_T,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,fT,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,pT,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,mT,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,yT,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,xT,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,vT,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function cT(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function uT(t,e,i){const n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(let e=i.pos-1;e>=t;e--)i.buf[e+n]=i.buf[e]}function dT(t,e){for(let i=0;i>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 wT(t,e,i){if(1==t)e.id=i.readVarint();else if(2==t){const t=i.readVarint()+i.pos;for(;i.pos>1):i>>1}return e}function tC(t){let e="";for(let i=0,n=t.length;i=32;)e=63+(32|31&t),i+=String.fromCharCode(e),t>>=5;return e=t+63,i+=String.fromCharCode(e),i}const nC={Point:function(t,e,i){const n=t.coordinates;e&&i&&lC(n,e,i);return new Xr(n)},LineString:function(t,e){const i=rC(t.arcs,e);return new Td(i)},Polygon:function(t,e){const i=[];for(let n=0,r=t.arcs.length;n0&&i.pop(),n>=0){const t=e[n];for(let e=0,n=t.length;e=0;--e)i.push(t[e].slice(0))}return i}function sC(t,e,i,n,r,s,o){const a=t.geometries,l=[];for(let t=0,h=a.length;t=2,"At least 2 conditions are required")}}class uC extends cC{constructor(t){super("And",Array.prototype.slice.call(arguments))}}class dC extends hC{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}}class gC extends hC{constructor(t,e,i,n){super(t),this.geometryName=e||"the_geom",this.geometry=i,this.srsName=n}}class fC extends gC{constructor(t,e,i){super("Contains",t,e,i)}}class pC extends gC{constructor(t,e,i,n,r){super("DWithin",t,e,r),this.distance=i,this.unit=n}}class _C extends gC{constructor(t,e,i){super("Disjoint",t,e,i)}}class mC extends hC{constructor(t,e){super(t),this.propertyName=e}}class yC extends mC{constructor(t,e,i){super("During",t),this.begin=e,this.end=i}}class xC extends mC{constructor(t,e,i,n){super(t,e),this.expression=i,this.matchCase=n}}class vC extends xC{constructor(t,e,i){super("PropertyIsEqualTo",t,e,i)}}class SC extends xC{constructor(t,e){super("PropertyIsGreaterThan",t,e)}}class EC extends xC{constructor(t,e){super("PropertyIsGreaterThanOrEqualTo",t,e)}}class wC extends gC{constructor(t,e,i){super("Intersects",t,e,i)}}class TC extends mC{constructor(t,e,i){super("PropertyIsBetween",t),this.lowerBoundary=e,this.upperBoundary=i}}class CC extends mC{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}}class RC extends mC{constructor(t){super("PropertyIsNull",t)}}class bC extends xC{constructor(t,e){super("PropertyIsLessThan",t,e)}}class PC extends xC{constructor(t,e){super("PropertyIsLessThanOrEqualTo",t,e)}}class IC extends hC{constructor(t){super("Not"),this.condition=t}}class FC extends xC{constructor(t,e,i){super("PropertyIsNotEqualTo",t,e,i)}}class MC extends cC{constructor(t){super("Or",Array.prototype.slice.call(arguments))}}class LC extends hC{constructor(t){super("ResourceId"),this.rid=t}}class AC extends gC{constructor(t,e,i){super("Within",t,e,i)}}function OC(t){const e=[null].concat(Array.prototype.slice.call(arguments));return new(Function.prototype.bind.apply(uC,e))}function DC(t,e,i){return new dC(t,e,i)}const NC={"http://www.opengis.net/gml":{boundedBy:sp(Xv.prototype.readExtentElement,"bounds")},"http://www.opengis.net/wfs/2.0":{member:ip(Xv.prototype.readFeaturesInternal)}},kC={"http://www.opengis.net/wfs":{totalInserted:sp(Hv),totalUpdated:sp(Hv),totalDeleted:sp(Hv)},"http://www.opengis.net/wfs/2.0":{totalInserted:sp(Hv),totalUpdated:sp(Hv),totalDeleted:sp(Hv)}},GC={"http://www.opengis.net/wfs":{TransactionSummary:sp(HC,"transactionSummary"),InsertResults:sp(QC,"insertIds")},"http://www.opengis.net/wfs/2.0":{TransactionSummary:sp(HC,"transactionSummary"),InsertResults:sp(QC,"insertIds")}},UC={"http://www.opengis.net/wfs":{PropertyName:op(oS)},"http://www.opengis.net/wfs/2.0":{PropertyName:op(oS)}},jC={"http://www.opengis.net/wfs":{Insert:op(tR),Update:op(rR),Delete:op(nR),Property:op(sR),Native:op(oR)},"http://www.opengis.net/wfs/2.0":{Insert:op(tR),Update:op(rR),Delete:op(nR),Property:op(sR),Native:op(oR)}},BC="feature",zC="http://www.w3.org/2000/xmlns/",XC={"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"},VC={"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"},$C={"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"},WC={"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"},ZC={"2.0.0":fS,"1.1.0":dS,"1.0.0":hS};function YC(t,e,i,n){pp(n,jC,lp(t),e,i)}function HC(t,e){return gp({},kC,t,e)}const KC={"http://www.opengis.net/ogc":{FeatureId:ip((function(t,e){return t.getAttribute("fid")}))},"http://www.opengis.net/ogc/1.1":{FeatureId:ip((function(t,e){return t.getAttribute("fid")}))}};function qC(t,e){dp(KC,t,e)}const JC={"http://www.opengis.net/wfs":{Feature:qC},"http://www.opengis.net/wfs/2.0":{Feature:qC}};function QC(t,e){return gp([],JC,t,e)}function tR(t,e,i){const n=i[i.length-1],r=n.featureType,s=n.featureNS,o=n.gmlVersion,a=Hf(s,r);t.appendChild(a),2===o?hS.prototype.writeFeatureElement(a,e,i):3===o?dS.prototype.writeFeatureElement(a,e,i):fS.prototype.writeFeatureElement(a,e,i)}function eR(t,e,i){const n=i[i.length-1].version,r=XC[n],s=Hf(r,"Filter"),o=Hf(r,"FeatureId");s.appendChild(o),o.setAttribute("fid",e),t.appendChild(s)}function iR(t,e){const i=(t=t||BC)+":";return e.startsWith(i)?e:i+e}function nR(t,e,i){const n=i[i.length-1];Ft(void 0!==e.getId(),"Features must have an id set");const r=n.featureType,s=n.featurePrefix,o=n.featureNS,a=iR(s,r);t.setAttribute("typeName",a),t.setAttributeNS(zC,"xmlns:"+s,o);const l=e.getId();void 0!==l&&eR(t,l,i)}function rR(t,e,i){const n=i[i.length-1];Ft(void 0!==e.getId(),"Features must have an id set");const r=n.version,s=n.featureType,o=n.featurePrefix,a=n.featureNS,l=iR(o,s),h=e.getGeometryName();t.setAttribute("typeName",l),t.setAttributeNS(zC,"xmlns:"+o,a);const c=e.getId();if(void 0!==c){const s=e.getKeys(),o=[];for(let t=0,i=s.length;t0,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 RR:return this.readPoint();case bR:return this.readLineString();case PR:case DR:return this.readPolygon();case IR:return this.readMultiPoint();case FR:return this.readMultiLineString();case MR:case AR:case OR:return this.readMultiPolygon();case LR: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({[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;it+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 GR(t){return"string"==typeof t?function(t){const e=new Uint8Array(t.length/2);for(let i=0;i="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=XR;else if(","==t)i=WR;else if(")"==t)i=VR;else if(this.isNumeric_(t)||"-"==t)i=$R,n=this.readNumber_();else if(this.isAlpha_(t))i=zR,n=this.readText_();else{if(this.isWhiteSpace_(t))return this.nextToken();if(""!==t)throw new Error("Unexpected character: "+t);i=ZR}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 KR{constructor(t){this.lexer_=t,this.token_={position:0,type:BR},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(zR)){const i=e.value;"Z"===i?t="XYZ":"M"===i?t="XYM":"ZM"===i&&(t="XYZM"),"XY"!==t&&this.consume_()}return t}parseGeometryCollectionText_(){if(this.match(XR)){const t=[];do{t.push(this.parseGeometry_())}while(this.match(WR));if(this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(XR)){const t=this.parsePoint_();if(this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(XR)){const t=this.parsePointList_();if(this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(XR)){const t=this.parseLineStringTextList_();if(this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(XR)){let t;if(t=this.token_.type==XR?this.parsePointTextList_():this.parsePointList_(),this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(XR)){const t=this.parseLineStringTextList_();if(this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(XR)){const t=this.parsePolygonTextList_();if(this.match(VR))return t}throw new Error(this.formatErrorMessage_())}parsePoint_(){const t=[],e=this.layout_.length;for(let i=0;i0&&(n+=" "+e)}return 0===i.length?n+" "+jR:n+"("+i+")"}const ib=[null,"http://www.opengis.net/wms"];function nb(t){return Ke(t[0].version,"1.3")>=0}const rb=up(ib,{Service:sp((function(t,e){return gp({},nb(e)?cb:hb,t,e)})),Capability:sp((function(t,e){return gp({},nb(e)?ab:ob,t,e)}))}),sb={Request:sp((function(t,e){return gp({},vb,t,e)})),Exception:sp((function(t,e){return gp([],fb,t,e)})),Layer:sp((function(t,e){const i=gp({},nb(e)?mb:_b,t,e);if(void 0===i.Layer)return Object.assign(i,Pb(t,e));return i}))},ob=up(ib,{...sb,UserDefinedSymbolization:sp((function(t,e){return{SupportSLD:!!$v(t.getAttribute("UserDefinedSymbolization")),UserLayer:!!$v(t.getAttribute("UserLayer")),UserStyle:!!$v(t.getAttribute("UserStyle")),RemoteWFS:!!$v(t.getAttribute("RemoteWFS"))}}))}),ab=up(ib,sb);const lb={Name:sp(qv),Title:sp(qv),Abstract:sp(qv),KeywordList:sp(Lb),OnlineResource:sp(MT),ContactInformation:sp((function(t,e){return gp({},ub,t,e)})),Fees:sp(qv),AccessConstraints:sp(qv)},hb=up(ib,lb),cb=up(ib,{...lb,LayerLimit:sp(Hv),MaxWidth:sp(Hv),MaxHeight:sp(Hv)}),ub=up(ib,{ContactPersonPrimary:sp((function(t,e){return gp({},db,t,e)})),ContactPosition:sp(qv),ContactAddress:sp((function(t,e){return gp({},gb,t,e)})),ContactVoiceTelephone:sp(qv),ContactFacsimileTelephone:sp(qv),ContactElectronicMailAddress:sp(qv)}),db=up(ib,{ContactPerson:sp(qv),ContactOrganization:sp(qv)}),gb=up(ib,{AddressType:sp(qv),Address:sp(qv),City:sp(qv),StateOrProvince:sp(qv),PostCode:sp(qv),Country:sp(qv)}),fb=up(ib,{Format:ip(qv)}),pb={Name:sp(qv),Title:sp(qv),Abstract:sp(qv),KeywordList:sp(Lb),BoundingBox:rp(bb),Dimension:rp((function(t,e){const i={name:t.getAttribute("name"),units:t.getAttribute("units"),unitSymbol:t.getAttribute("unitSymbol")};nb(e)&&Object.assign(i,{default:t.getAttribute("default"),multipleValues:$v(t.getAttribute("multipleValues")),nearestValue:$v(t.getAttribute("nearestValue")),current:$v(t.getAttribute("current")),values:qv(t)});return i})),Attribution:sp((function(t,e){return gp({},yb,t,e)})),AuthorityURL:rp((function(t,e){const i=Ib(t,e);if(i)return i.name=t.getAttribute("name"),i;return})),Identifier:rp(qv),MetadataURL:rp((function(t,e){const i=Ib(t,e);if(i)return i.type=t.getAttribute("type"),i;return})),DataURL:rp(Ib),FeatureListURL:rp(Ib),Style:rp((function(t,e){return gp({},Tb,t,e)})),Layer:rp(Pb)},_b=up(ib,{...pb,SRS:rp(qv),Extent:sp((function(t,e){return{name:t.getAttribute("name"),default:t.getAttribute("default"),nearestValue:$v(t.getAttribute("nearestValue"))}})),ScaleHint:rp((function(t,e){return{min:Yv(t.getAttribute("min")),max:Yv(t.getAttribute("max"))}})),LatLonBoundingBox:sp(((t,e)=>bb(t,e,!1))),Layer:rp(Pb)}),mb=up(ib,{...pb,CRS:rp(qv),EX_GeographicBoundingBox:sp((function(t,e){const i=gp({},xb,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]})),MinScaleDenominator:sp(Zv),MaxScaleDenominator:sp(Zv),Layer:rp(Pb)}),yb=up(ib,{Title:sp(qv),OnlineResource:sp(MT),LogoURL:sp(Mb)}),xb=up(ib,{westBoundLongitude:sp(Zv),eastBoundLongitude:sp(Zv),southBoundLatitude:sp(Zv),northBoundLatitude:sp(Zv)}),vb=up(ib,{GetCapabilities:sp(Fb),GetMap:sp(Fb),GetFeatureInfo:sp(Fb)}),Sb=up(ib,{Format:rp(qv),DCPType:rp((function(t,e){return gp({},Eb,t,e)}))}),Eb=up(ib,{HTTP:sp((function(t,e){return gp({},wb,t,e)}))}),wb=up(ib,{Get:sp(Ib),Post:sp(Ib)}),Tb=up(ib,{Name:sp(qv),Title:sp(qv),Abstract:sp(qv),LegendURL:rp(Mb),StyleSheetURL:sp(Ib),StyleURL:sp(Ib)}),Cb=up(ib,{Format:sp(qv),OnlineResource:sp(MT)}),Rb=up(ib,{Keyword:ip(qv)});function bb(t,e,i=!0){const n={extent:[Yv(t.getAttribute("minx")),Yv(t.getAttribute("miny")),Yv(t.getAttribute("maxx")),Yv(t.getAttribute("maxy"))],res:[Yv(t.getAttribute("resx")),Yv(t.getAttribute("resy"))]};return i?(nb(e)?n.crs=t.getAttribute("CRS"):n.srs=t.getAttribute("SRS"),n):n}function Pb(t,e){const i=nb(e),n=e[e.length-1],r=gp({},i?mb:_b,t,e);if(!r)return;let s=$v(t.getAttribute("queryable"));void 0===s&&(s=n.queryable),r.queryable=void 0!==s&&s;let o=Kv(t.getAttribute("cascaded"));void 0===o&&(o=n.cascaded),r.cascaded=o;let a=$v(t.getAttribute("opaque"));void 0===a&&(a=n.opaque),r.opaque=void 0!==a&&a;let l=$v(t.getAttribute("noSubsets"));void 0===l&&(l=n.noSubsets),r.noSubsets=void 0!==l&&l;let h=Yv(t.getAttribute("fixedWidth"));h||(h=n.fixedWidth),r.fixedWidth=h;let c=Yv(t.getAttribute("fixedHeight"));c||(c=n.fixedHeight),r.fixedHeight=c;const u=["Style","AuthorityURL"];i?u.push("CRS"):u.push("SRS","Dimension"),u.forEach((function(t){if(t in n){const e=r[t]||[];r[t]=e.concat(n[t])}}));const d=["BoundingBox","Attribution"];return i?d.push("Dimension","EX_GeographicBoundingBox","MinScaleDenominator","MaxScaleDenominator"):d.push("LatLonBoundingBox","ScaleHint","Extent"),d.forEach((function(t){if(!(t in r)){const e=n[t];r[t]=e}})),r}function Ib(t,e){return gp({},Cb,t,e)}function Fb(t,e){return gp({},Sb,t,e)}function Mb(t,e){const i=Ib(t,e);if(i){const e=[Kv(t.getAttribute("width")),Kv(t.getAttribute("height"))];return i.size=e,i}}function Lb(t,e){return gp([],Rb,t,e)}const Ab=[null,"http://www.opengis.net/wmts/1.0"],Ob=[null,"http://www.opengis.net/ows/1.1"],Db=up(Ab,{Contents:sp((function(t,e){return gp({},Nb,t,e)}))});const Nb=up(Ab,{Layer:rp((function(t,e){return gp({},kb,t,e)})),TileMatrixSet:rp((function(t,e){return gp({},Vb,t,e)}))}),kb=up(Ab,{Style:rp((function(t,e){const i=gp({},Gb,t,e);if(!i)return;const n="true"===t.getAttribute("isDefault");return i.isDefault=n,i})),Format:rp(qv),TileMatrixSetLink:rp((function(t,e){return gp({},Ub,t,e)})),Dimension:rp((function(t,e){return gp({},zb,t,e)})),ResourceURL:rp((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}))},up(Ob,{Title:sp(qv),Abstract:sp(qv),WGS84BoundingBox:sp(Wb),BoundingBox:rp((function(t,e){const i=t.getAttribute("crs"),n=gp([],Xb,t,e);if(2!=n.length)return;return{extent:Ut(n),crs:i}})),Identifier:sp(qv)})),Gb=up(Ab,{LegendURL:rp((function(t,e){const i={};return i.format=t.getAttribute("format"),i.href=MT(t),i}))},up(Ob,{Title:sp(qv),Identifier:sp(qv)})),Ub=up(Ab,{TileMatrixSet:sp(qv),TileMatrixSetLimits:sp((function(t,e){return gp([],jb,t,e)}))}),jb=up(Ab,{TileMatrixLimits:ip((function(t,e){return gp({},Bb,t,e)}))}),Bb=up(Ab,{TileMatrix:sp(qv),MinTileRow:sp(Hv),MaxTileRow:sp(Hv),MinTileCol:sp(Hv),MaxTileCol:sp(Hv)}),zb=up(Ab,{Default:sp(qv),Value:rp(qv)},up(Ob,{Identifier:sp(qv)})),Xb=up(Ob,{LowerCorner:ip(Zb),UpperCorner:ip(Zb)}),Vb=up(Ab,{WellKnownScaleSet:sp(qv),TileMatrix:rp((function(t,e){return gp({},$b,t,e)}))},up(Ob,{SupportedCRS:sp(qv),Identifier:sp(qv),BoundingBox:sp(Wb)})),$b=up(Ab,{TopLeftCorner:sp(Zb),ScaleDenominator:sp(Zv),TileWidth:sp(Hv),TileHeight:sp(Hv),MatrixWidth:sp(Hv),MatrixHeight:sp(Hv)},up(Ob,{Identifier:sp(qv)}));function Wb(t,e){const i=gp([],Xb,t,e);if(2==i.length)return Ut(i)}function Zb(t,e){const i=qv(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]}const Yb=["fullscreenchange","webkitfullscreenchange"],Hb="enterfullscreen",Kb="leavefullscreen";function qb(t){const e=t.body;return!!(e.webkitRequestFullscreen||e.requestFullscreen&&t.fullscreenEnabled)}function Jb(t){return!(!t.webkitIsFullScreen&&!t.fullscreenElement)}function Qb(t){t.requestFullscreen?t.requestFullscreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen()}const tP="projection",eP="coordinateFormat";const iP=.75,nP=.1;const rP="units",sP=[1,2,5],oP=25.4/.28;const aP=0,lP=1;var hP={};return hP.Collection=Z,hP.Collection.CollectionEvent=W,hP.DataTile=It,hP.DataTile.asArrayLike=Tt,hP.DataTile.asImageLike=wt,hP.DataTile.disposedError=Ct,hP.DataTile.toArray=bt,hP.Disposable=_,hP.Feature=Mt,hP.Feature.createStyleFunction=Lt,hP.Geolocation=class extends V{constructor(t){super(),this.on,this.once,this.un,t=t||{},this.position_=null,this.transform_=_n,this.watchId_=void 0,this.addChangeListener(Ss,this.handleProjectionChanged_),this.addChangeListener(ws,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_=Pn(xn("EPSG:4326"),t),this.position_&&this.set(vs,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(ps,e.accuracy),this.set(ms,null===e.altitude?void 0:e.altitude),this.set(ys,null===e.altitudeAccuracy?void 0:e.altitudeAccuracy),this.set(xs,null===e.heading?void 0:Le(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(vs,i.slice()),this.set(Es,null===e.speed?void 0:e.speed);const n=us(this.position_,e.accuracy);n.applyTransform(this.transform_),this.set(_s,n),this.changed()}positionError_(t){this.dispatchEvent(new Rs(t))}getAccuracy(){return this.get(ps)}getAccuracyGeometry(){return this.get(_s)||null}getAltitude(){return this.get(ms)}getAltitudeAccuracy(){return this.get(ys)}getHeading(){return this.get(xs)}getPosition(){return this.get(vs)}getProjection(){return this.get(Ss)}getSpeed(){return this.get(Es)}getTracking(){return this.get(ws)}getTrackingOptions(){return this.get(Ts)}setProjection(t){this.set(Ss,xn(t))}setTracking(t){this.set(ws,t)}setTrackingOptions(t){this.set(Ts,t)}},hP.Geolocation.GeolocationError=Rs,hP.Image=Ls,hP.Image.decode=Ns,hP.Image.decodeFallback=Ds,hP.Image.listenImage=As,hP.Image.load=Os,hP.ImageCanvas=ks,hP.ImageTile=Gs,hP.Kinetic=Us,hP.Map=jc,hP.MapBrowserEvent=Bs,hP.MapBrowserEventHandler=Zs,hP.MapEvent=js,hP.Object=V,hP.Object.ObjectEvent=X,hP.Observable=G,hP.Observable.unByKey=U,hP.Overlay=Wc,hP.Tile=nt,hP.TileQueue=so,hP.TileQueue.getTilePriority=oo,hP.TileRange=Zc,hP.TileRange.createOrUpdate=Yc,hP.VectorRenderTile=Kc,hP.VectorTile=Jc,hP.View=wo,hP.View.createCenterConstraint=Co,hP.View.createResolutionConstraint=Ro,hP.View.createRotationConstraint=bo,hP.View.isNoopAnimation=Po,hP.array={},hP.array.ascending=y,hP.array.binarySearch=m,hP.array.descending=x,hP.array.equals=w,hP.array.extend=E,hP.array.isSorted=T,hP.array.linearFindNearest=v,hP.array.remove=function(t,e){const i=t.indexOf(e),n=i>-1;return n&&t.splice(i,1),n},hP.array.reverseSubArray=S,hP.array.stableSort=function(t,e){const i=t.length,n=Array(t.length);let r;for(r=0;r$e.info||console.log(...t)},hP.console.setLevel=function(t){We=$e[t]},hP.console.warn=Ze,hP.control={},hP.control.Attribution=jo,hP.control.Control=Uo,hP.control.FullScreen=class extends Uo{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(o,this.handleClick_.bind(this),!1),this.setClassName_(this.button_,this.isInFullscreen_),this.element.className=`${this.cssClassName_} ${Lo} ${Oo}`,this.element.appendChild(this.button_)}handleClick_(t){t.preventDefault(),this.handleFullScreen_()}handleFullScreen_(){const t=this.getMap();if(!t)return;const e=t.getOwnerDocument();if(qb(e))if(Jb(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():Qb(t)}(i):Qb(i)}}handleFullScreenChange_(){const t=this.getMap();if(!t)return;const e=this.isInFullscreen_;this.isInFullscreen_=Jb(t.getOwnerDocument()),e!==this.isInFullscreen_&&(this.setClassName_(this.button_,this.isInFullscreen_),this.isInFullscreen_?(vt(this.labelActiveNode_,this.labelNode_),this.dispatchEvent(Hb)):(vt(this.labelNode_,this.labelActiveNode_),this.dispatchEvent(Kb)),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(eo,this.boundHandleMapTargetChange_),super.setMap(t),this.handleMapTargetChange_(),t&&t.addChangeListener(eo,this.boundHandleMapTargetChange_)}handleMapTargetChange_(){const t=this.documentListeners_;for(let e=0,i=t.length;e{const e=l.getEventCoordinateInternal(t),i=this.getMap();i.getView().setCenterInternal(e);const n=i.getOwnerDocument();n.removeEventListener("pointermove",f),n.removeEventListener("pointerup",p)};this.ovmapDiv_.addEventListener("pointerdown",(t=>{const e=this.getMap().getOwnerDocument();t.target===g&&e.addEventListener("pointermove",f),e.addEventListener("pointerup",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,i,this.handleMapPropertyChange_,this));const e=t.getView();e&&this.bindView_(e),this.ovmap_.isRendered()||this.updateBoxAfterOvmapIsRendered_()}}}handleMapPropertyChange_(t){if(t.key===io){const e=t.oldValue;e&&this.unbindView_(e);const i=this.getMap().getView();this.bindView_(i)}else this.ovmap_.isRendered()||t.key!==eo&&t.key!==to||this.ovmap_.updateSize()}bindView_(t){if(!this.view_){const e=new wo({projection:t.getProjection()});this.ovmap_.setView(e)}t.addChangeListener(ho.ROTATION,this.boundHandleRotationChanged_),this.handleRotationChanged_(),t.isDef()&&(this.ovmap_.updateSize(),this.resetExtent_())}unbindView_(t){t.removeChangeListener(ho.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_&&Jt(n,this.viewExtent_))return;this.viewExtent_=n;const r=e.getSize(),s=e.getView().calculateExtentInternal(r),o=e.getPixelFromCoordinateInternal(_e(n)),a=e.getPixelFromCoordinateInternal(he(n)),l=Math.abs(o[0]-a[0]),h=Math.abs(o[1]-a[1]),c=r[0],u=r[1];lc*iP||h>u*iP?this.resetExtent_():Vt(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;Ee(n,1/(Math.pow(2,s/2)*nP)),r.fitInternal(ds(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.getCenter(),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_=N(this.ovmap_,Ys,(t=>{delete this.ovmapPostrenderKey_,this.updateBox_()})))}handleClick_(t){t.preventDefault(),this.handleToggle_()}handleToggle_(){this.element.classList.toggle(Do),this.collapsed_?vt(this.collapseLabel_,this.label_):vt(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_()}},hP.control.Rotate=Bo,hP.control.ScaleLine=class extends Uo{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+" "+Lo,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(rP,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(rP)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(rP,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=vn(i,t.resolution,e,r);const o=this.minWidth_*(this.dpi_||oP)/oP,a=void 0!==this.maxWidth_?this.maxWidth_*(this.dpi_||oP)/oP:void 0;let l=o*s,h="";if("degrees"==n){const t=gi.degrees;l*=t,l=a){c=_,u=g,d=f;break}if(u>=o)break;_=c,g=u,f=d,++p}const m=this.scaleBar_?this.createScaleBar(u,c,h):c.toFixed(d<0?-d:0)+" "+h;this.renderedHTML_!=m&&(this.innerElement_.innerHTML=m,this.renderedHTML_=m),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
`+this.createMarker("relative")+(n%2==0||2===s?this.createStepText(n,t,!1,e,i):"")+"")}a.push(this.createStepText(s,t,!0,e,i));return(this.scaleBarText_?`
`+r+"
":"")+a.join("")}createMarker(t){return`
`}createStepText(t,e,i,n,r){const s=(0===t?0:Math.round(n/this.scaleBarSteps_*t*100)/100)+(0===t?"":" "+r);return`
`+s+"
"}getScaleForResolution(){return vn(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m")*(1e3/25.4)*(this.dpi_||oP)}render(t){const e=t.frameState;this.viewState_=e?e.viewState:null,this.updateElement_()}},hP.control.Zoom=zo,hP.control.ZoomSlider=class extends Uo{constructor(t){super({target:(t=t||{}).target,element:document.createElement("div"),render:t.render}),this.dragListenerKeys_=[],this.currentResolution_=void 0,this.direction_=aP,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 "+Lo;const n=this.element;n.className=e+" "+Lo+" "+Oo,n.appendChild(i),n.addEventListener(Vs,this.handleDraggerStart_.bind(this),!1),n.addEventListener(Xs,this.handleDraggerDrag_.bind(this),!1),n.addEventListener($s,this.handleDraggerEnd_.bind(this),!1),n.addEventListener(o,this.handleContainerClick_.bind(this),!1),i.addEventListener(o,A,!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_=lP,this.widthLimit_=e-o):(this.direction_=aP,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:tt})}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,Xs,t,this),D(i,$s,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(k),this.dragListenerKeys_.length=0}}setThumbPosition_(t){const e=this.getPositionForResolution_(t),i=this.element.firstElementChild;this.direction_==lP?i.style.left=this.widthLimit_*e+"px":i.style.top=this.heightLimit_*e+"px"}getRelativePosition_(t,e){let i;return i=this.direction_===lP?t/this.widthLimit_:e/this.heightLimit_,be(i,0,1)}getResolutionForPosition_(t){return this.getMap().getView().getResolutionForValueFunction()(1-t)}getPositionForResolution_(t){return be(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)}},hP.control.ZoomToExtent=class extends Uo{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(o,this.handleClick_.bind(this),!1);const s=e+" "+Lo+" "+Oo,a=this.element;a.className=s,a.appendChild(r)}handleClick_(t){t.preventDefault(),this.handleZoomToExtent()}handleZoomToExtent(){const t=this.getMap().getView(),e=this.extent?Un(this.extent,t.getProjection()):t.getProjection().getExtent();t.fitInternal(ds(e))}},hP.control.defaults={},hP.control.defaults.defaults=Xo,hP.coordinate={},hP.coordinate.add=qe,hP.coordinate.closestOnCircle=Je,hP.coordinate.closestOnSegment=Qe,hP.coordinate.createStringXY=function(t){return function(e){return li(e,t)}},hP.coordinate.degreesToStringHDMS=ti,hP.coordinate.distance=oi,hP.coordinate.equals=ii,hP.coordinate.format=ei,hP.coordinate.getWorldsAway=ci,hP.coordinate.rotate=ni,hP.coordinate.scale=ri,hP.coordinate.squaredDistance=si,hP.coordinate.squaredDistanceToSegment=ai,hP.coordinate.toStringHDMS=function(t,e){return t?ti("NS",t[1],e)+" "+ti("EW",t[0],e):""},hP.coordinate.toStringXY=li,hP.coordinate.wrapX=hi,hP.css={},hP.css.CLASS_COLLAPSED=Do,hP.css.CLASS_CONTROL=Oo,hP.css.CLASS_HIDDEN=Fo,hP.css.CLASS_SELECTABLE=Mo,hP.css.CLASS_UNSELECTABLE=Lo,hP.css.CLASS_UNSUPPORTED=Ao,hP.css.getFontParameters=Go,hP.dom={},hP.dom.createCanvasContext2D=ft,hP.dom.getSharedCanvasContext2D=_t,hP.dom.outerHeight=xt,hP.dom.outerWidth=yt,hP.dom.releaseCanvas=mt,hP.dom.removeChildren=St,hP.dom.replaceChildren=Et,hP.dom.replaceNode=vt,hP.easing={},hP.easing.easeIn=Q,hP.easing.easeOut=tt,hP.easing.inAndOut=et,hP.easing.linear=it,hP.easing.upAndDown=function(t){return t<.5?et(2*t):1-et(2*(t-.5))},hP.events={},hP.events.Event=L,hP.events.Event.preventDefault=function(t){t.preventDefault()},hP.events.Event.stopPropagation=A,hP.events.SnapEvent={},hP.events.SnapEvent.SnapEvent=pv,hP.events.Target=O,hP.events.condition={},hP.events.condition.all=Ho,hP.events.condition.altKeyOnly=Ko,hP.events.condition.altShiftKeysOnly=qo,hP.events.condition.always=ta,hP.events.condition.click=function(t){return t.type==zs.CLICK},hP.events.condition.doubleClick=function(t){return t.type==zs.DBLCLICK},hP.events.condition.focus=Jo,hP.events.condition.focusWithTabindex=Qo,hP.events.condition.mouseActionButton=ea,hP.events.condition.mouseOnly=la,hP.events.condition.never=ia,hP.events.condition.noModifierKeys=ra,hP.events.condition.penOnly=function(t){const e=t.originalEvent;return e instanceof PointerEvent&&"pen"===e.pointerType},hP.events.condition.platformModifierKey=sa,hP.events.condition.platformModifierKeyOnly=function(t){const e=t.originalEvent;return!e.altKey&&(lt?e.metaKey:e.ctrlKey)&&!e.shiftKey},hP.events.condition.pointerMove=function(t){return"pointermove"==t.type},hP.events.condition.primaryAction=ha,hP.events.condition.shiftKeyOnly=oa,hP.events.condition.singleClick=na,hP.events.condition.targetNotEditable=aa,hP.events.condition.touchOnly=function(t){const e=t.originalEvent;return e instanceof PointerEvent&&"touch"===e.pointerType},hP.events.listen=D,hP.events.listenOnce=N,hP.events.unlistenByKey=k,hP.expr={},hP.expr.cpu={},hP.expr.cpu.buildExpression=_h,hP.expr.cpu.newEvaluationContext=ph,hP.expr.expression={},hP.expr.expression.AnyType=Yl,hP.expr.expression.BooleanType=zl,hP.expr.expression.CallExpression=eh,hP.expr.expression.ColorType=$l,hP.expr.expression.LiteralExpression=th,hP.expr.expression.NoneType=0,hP.expr.expression.NumberArrayType=Wl,hP.expr.expression.NumberType=Xl,hP.expr.expression.Ops=rh,hP.expr.expression.SizeType=Zl,hP.expr.expression.StringType=Vl,hP.expr.expression.computeGeometryType=fh,hP.expr.expression.includesType=Jl,hP.expr.expression.isType=Ql,hP.expr.expression.newParsingContext=ih,hP.expr.expression.overlapsType=function(t,e){return!!(t&e)},hP.expr.expression.parse=nh,hP.expr.expression.typeName=ql,hP.expr.gpu={},hP.expr.gpu.FEATURE_ID_PROPERTY_NAME=N_,hP.expr.gpu.GEOMETRY_TYPE_PROPERTY_NAME=k_,hP.expr.gpu.PALETTE_TEXTURE_ARRAY=D_,hP.expr.gpu.UNDEFINED_PROP_VALUE=G_,hP.expr.gpu.arrayToGlsl=C_,hP.expr.gpu.buildExpression=U_,hP.expr.gpu.colorToGlsl=R_,hP.expr.gpu.getStringNumberEquivalent=F_,hP.expr.gpu.newCompilationContext=A_,hP.expr.gpu.numberToGlsl=T_,hP.expr.gpu.sizeToGlsl=b_,hP.expr.gpu.stringToGlsl=M_,hP.expr.gpu.uniformNameForVariable=L_,hP.extent={},hP.extent.applyTransform=Te,hP.extent.approximatelyEquals=Qt,hP.extent.boundingExtent=Ut,hP.extent.buffer=jt,hP.extent.clone=Bt,hP.extent.closestSquaredDistanceXY=zt,hP.extent.containsCoordinate=Xt,hP.extent.containsExtent=Vt,hP.extent.containsXY=$t,hP.extent.coordinateRelationship=Wt,hP.extent.createEmpty=Zt,hP.extent.createOrUpdate=Yt,hP.extent.createOrUpdateEmpty=Ht,hP.extent.createOrUpdateFromCoordinate=Kt,hP.extent.createOrUpdateFromCoordinates=function(t,e){return ie(Ht(e),t)},hP.extent.createOrUpdateFromFlatCoordinates=qt,hP.extent.createOrUpdateFromRings=function(t,e){return re(Ht(e),t)},hP.extent.equals=Jt,hP.extent.extend=te,hP.extent.extendCoordinate=ee,hP.extent.extendCoordinates=ie,hP.extent.extendFlatCoordinates=ne,hP.extent.extendRings=re,hP.extent.extendXY=se,hP.extent.forEachCorner=oe,hP.extent.getArea=ae,hP.extent.getBottomLeft=le,hP.extent.getBottomRight=he,hP.extent.getCenter=ce,hP.extent.getCorner=ue,hP.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)},hP.extent.getForViewAndSize=de,hP.extent.getHeight=fe,hP.extent.getIntersection=pe,hP.extent.getIntersectionArea=function(t,e){return ae(pe(t,e))},hP.extent.getMargin=function(t){return ye(t)+fe(t)},hP.extent.getRotatedViewport=ge,hP.extent.getSize=function(t){return[t[2]-t[0],t[3]-t[1]]},hP.extent.getTopLeft=_e,hP.extent.getTopRight=me,hP.extent.getWidth=ye,hP.extent.intersects=xe,hP.extent.intersectsSegment=we,hP.extent.isEmpty=ve,hP.extent.returnOrUpdate=Se,hP.extent.scaleFromCenter=Ee,hP.extent.wrapAndSliceX=Re,hP.extent.wrapX=Ce,hP.featureloader={},hP.featureloader.loadFeaturesXhr=tu,hP.featureloader.setWithCredentials=function(t){Qc=t},hP.featureloader.xhr=eu,hP.format={},hP.format.EsriJSON=class extends Lv{constructor(t){t=t||{},super(),this.geometryName_=t.geometryName}readFeatureFromObject(t,e,i){const n=t,r=Nv(n.geometry,e),s=new Mt;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;r0&&"string"==typeof this.imageInfo.profile[0]&&vg.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?yg.none.none:yg[t][e]}getTileSourceOptions(t){const e=t||{},i=this.getImageApiVersion();if(void 0===i)return;const n=void 0===i?void 0:Eg[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}},hP.format.JSONFeature=Lv,hP.format.KML=class extends jv{constructor(t){super(),t=t||{},FE||(_E=[255,255,255,1],EE=new qh({color:_E}),mE=[20,2],yE="pixels",xE="pixels",vE=[64,64],SE="https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png",TE=new Qh({anchor:mE,anchorOrigin:"bottom-left",anchorXUnits:yE,anchorYUnits:xE,crossOrigin:"anonymous",rotation:0,scale:ME(vE),size:vE,src:SE}),wE="NO_IMAGE",RE=new tc({color:_E,width:1}),CE=new tc({color:[51,51,51,1],width:2}),bE=new ac({font:"bold 16px Helvetica",fill:EE,stroke:CE,scale:.8}),PE=new ec({fill:EE,image:TE,text:bE,stroke:RE,zIndex:0}),FE=[PE]),this.dataProjection=xn("EPSG:4326"),this.defaultStyle_=t.defaultStyle?t.defaultStyle:FE,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:LE,this.supportedMediaTypes=["application/vnd.google-earth.kml+xml"]}readDocumentOrFolder_(t,e){const i=gp([],up(aE,{Document:ep(this.readDocumentOrFolder_,this),Folder:ep(this.readDocumentOrFolder_,this),Placemark:ip(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=gp({geometry:null},hE,t,e,this);if(!i)return;const n=new Mt,r=t.getAttribute("id");null!==r&&n.setId(r);const s=e[0],o=i.geometry;if(o&&bv(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 Sd)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)&&(IE||(IE=document.createElement("textarea")),IE.innerHTML=l,l=IE.value));let c=i;if(t?c=t:e&&(c=AE(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()||bE.getFont()),s.setScale(s.getScale()||bE.getScale()),s.setFill(s.getFill()||bE.getFill()),s.setStroke(s.getStroke()||CE)):s=bE.clone();s.setText(e),s.setOffsetX(i[0]),s.setOffsetY(i[1]),s.setTextAlign(n);const o=new ec({image:r,text:s});return o}(c[0],l);if(h.length>0){t.setGeometry(new Sd(h));return[t,new ec({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=lw.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=jE.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(!aE.includes(t.namespaceURI))return null;const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i||null}readFeaturesFromNode(t,e){if(!aE.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&&E(i,t)}return i}return[]}readName(t){if(t){if("string"==typeof t){const e=tp(t);return this.readNameFromDocument(e)}return Jf(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(aE.includes(e.namespaceURI)&&"name"==e.localName)return qv(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(aE.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=tp(t);E(e,this.readNetworkLinksFromDocument(i))}else Jf(t)?E(e,this.readNetworkLinksFromDocument(t)):E(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&E(e,this.readNetworkLinksFromNode(i));return e}readNetworkLinksFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(aE.includes(i.namespaceURI)&&"NetworkLink"==i.localName){const t=gp({},cE,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!aE.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||E(e,this.readNetworkLinksFromNode(i))}return e}readRegion(t){const e=[];if("string"==typeof t){const i=tp(t);E(e,this.readRegionFromDocument(i))}else Jf(t)?E(e,this.readRegionFromDocument(t)):E(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&E(e,this.readRegionFromNode(i));return e}readRegionFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(aE.includes(i.namespaceURI)&&"Region"==i.localName){const t=gp({},gE,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!aE.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||E(e,this.readRegionFromNode(i))}return e}readCamera(t){const e=[];if("string"==typeof t){const i=tp(t);E(e,this.readCameraFromDocument(i))}else Jf(t)?E(e,this.readCameraFromDocument(t)):E(e,this.readCameraFromNode(t));return e}readCameraFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&E(e,this.readCameraFromNode(i));return e}readCameraFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(aE.includes(i.namespaceURI)&&"Camera"===i.localName){const t=gp({},dE,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!aE.includes(i.namespaceURI)||"Document"!==t&&"Folder"!==t&&"Placemark"!==t&&"kml"!==t||E(e,this.readCameraFromNode(i))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=Hf(aE[4],"kml"),n="http://www.w3.org/2000/xmlns/";i.setAttributeNS(n,"xmlns:gx",oE[0]),i.setAttributeNS(n,"xmlns:xsi",Yf),i.setAttributeNS(Yf,"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=fE[i.namespaceURI],a=cp(s,o);return pp(r,pE,hp,a,[e],o,this),i}},hP.format.KML.getDefaultFillStyle=function(){return EE},hP.format.KML.getDefaultImageStyle=function(){return TE},hP.format.KML.getDefaultStrokeStyle=function(){return RE},hP.format.KML.getDefaultStyle=function(){return PE},hP.format.KML.getDefaultStyleArray=function(){return FE},hP.format.KML.getDefaultTextStyle=function(){return bE},hP.format.KML.readFlatCoordinates=DE,hP.format.MVT=class extends Rv{constructor(t){super(),t=t||{},this.dataProjection=new fi({code:"",units:"tile-pixels"}),this.featureClass=t.featureClass?t.featureClass:Id,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>3}if(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;else{if(7!==s)throw new Error("Invalid command found in the PBF");h>c&&(i.push(i[c],i[c+1]),h+=2)}}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===Id)r=new this.featureClass(h,a,l,2,s,o),r.transform(i.dataProjection);else{let t;if("Polygon"==h){const e=hs(a,l);t=e.length>1?new bd(a,"XY",e):new cs(a,"XY",l)}else t="Point"===h?new Xr(a,"XY"):"LineString"===h?new Td(a,"XY"):"MultiPoint"===h?new Rd(a,"XY"):"MultiLineString"===h?new Cd(a,"XY",l):null;r=new(0,this.featureClass),this.geometryName_&&r.setGeometryName(this.geometryName_);const e=bv(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=xn((e=this.adaptOptions(e)).dataProjection);n.setWorldExtent(e.extent),e.dataProjection=n;const r=new hT(t),s=r.readFields(ST,{}),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{const r=this.combineBboxAndFilter(n.geometryName,n.bbox,t.srsName,t.filter);Object.assign(i,{geometryName:n.geometryName,filter:r}),TR(e,[n.name],[i])}));return e}combineBboxAndFilter(t,e,i,n){const r=DC(t,e,i);return n?OC(n,r):r}writeTransaction(t,e,i,n){const r=[],s=n.version?n.version:this.version_,o=Hf(VC[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(Yf,"xsi:schemaLocation",WC[s]);const l=function(t,e,i,n){const r=n.featurePrefix?n.featurePrefix:BC;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&&YC("Insert",t,r,l),e&&YC("Update",e,r,l),i&&YC("Delete",i,r,l),n.nativeElements&&YC("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),xn(t.pop().srsName)}return null}},hP.format.WFS.writeFilter=function(t,e){const i=Hf(CR(e=e||"1.1.0"),"Filter"),n={node:i};return Object.assign(n,{version:e,filter:t}),hR(i,t,[n]),i},hP.format.WKB=class extends Rv{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 Mt({geometry:this.readGeometry(t,e)})}readFeatures(t,e){let i=[];const n=this.readGeometry(t,e);return i=this.splitCollection&&n instanceof Sd?n.getGeometriesArray():[n],i.map((t=>new Mt({geometry:t})))}readGeometry(t,e){const i=GR(t);if(!i)return null;const n=new NR(i).readGeometry();return this.viewCache_=i,e=this.getReadOptions(t,e),this.viewCache_=null,bv(n,!1,e)}readProjection(t){const e=this.viewCache_||GR(t);if(!e)return;const i=new NR(e);return i.readWkbHeader(),i.getSrid()&&xn("EPSG:"+i.getSrid())||void 0}writeFeature(t,e){return this.writeGeometry(t.getGeometry(),e)}writeFeatures(t,e){return this.writeGeometry(new Sd(t.map((t=>t.getGeometry()))),e)}writeGeometry(t,e){e=this.adaptOptions(e);const i=new kR({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&&xn(e.dataProjection);if(t){const e=t.getCode();e.startsWith("EPSG:")&&(n=Number(e.substring(5)))}}i.writeGeometry(bv(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}},hP.format.WKT=class extends QS{constructor(t){super(),t=t||{},this.splitCollection_=void 0!==t.splitCollection&&t.splitCollection}parse_(t){const e=new HR(t);return new KR(e).parse()}readFeatureFromText(t,e){const i=this.readGeometryFromText(t,e),n=new Mt;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;t3&&!!yr(t,e,i,n)},hP.geom.flat.transform={},hP.geom.flat.transform.rotate=lr,hP.geom.flat.transform.scale=hr,hP.geom.flat.transform.transform2D=ar,hP.geom.flat.transform.translate=cr,hP.has={},hP.has.CREATE_IMAGE_BITMAP=dt,hP.has.DEVICE_PIXEL_RATIO=ht,hP.has.IMAGE_DECODE=ut,hP.has.MAC=lt,hP.has.PASSIVE_EVENT_LISTENERS=gt,hP.has.SAFARI=st,hP.has.SAFARI_BUG_237906=ot,hP.has.WEBKIT=at,hP.has.WORKER_OFFSCREEN_CANVAS=ct,hP.interaction={},hP.interaction.DblClickDragZoom=class extends $o{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.down_=null,this.targetPointers=[]}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence_){if(t.type==zs.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==zs.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence_=e}}else if(t.type==zs.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_,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.originalEvent,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===zs.POINTERDOWN||e===zs.POINTERDRAG||e===zs.POINTERUP}(t)){const e=t.originalEvent,i=e.pointerId.toString();t.type==zs.POINTERUP?delete this.trackedPointers_[i]:(t.type==zs.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}},hP.interaction.DoubleClickZoom=Yo,hP.interaction.DragAndDrop=class extends $o{constructor(t){t=t||{},super({handleEvent:C}),this.on,this.once,this.un,this.readAsBuffer_=!1,this.formats_=[];const e=t.formatConstructors?t.formatConstructors:[];for(let t=0,i=e.length;t0){this.source_&&(this.source_.clear(),this.source_.addFeatures(l)),this.dispatchEvent(new Fx(Ix,t,l,s));break}}}registerListeners_(){const t=this.getMap();if(t){const e=this.target?this.target:t.getViewport();this.dropListenKeys_=[D(e,c,this.handleDrop,this),D(e,l,this.handleStop,this),D(e,h,this.handleStop,this),D(e,c,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{return null}}unregisterListeners_(){this.dropListenKeys_&&(this.dropListenKeys_.forEach(k),this.dropListenKeys_=null)}handleDrop(t){const e=t.dataTransfer.files;for(let t=0,i=e.length;t1?1:-1;return e.endInteraction(this.duration_,i),this.lastScaleDelta_=0,!1}handleDownEvent(t){return!!la(t)&&(!!this.condition_(t)&&(t.map.getView().beginInteraction(),this.lastAngle_=void 0,this.lastMagnitude_=void 0,!0))}},hP.interaction.DragZoom=Sa,hP.interaction.Draw=class extends ca{constructor(t){const e=t;e.stopDown||(e.stopDown=R),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:C,this.geometryLayout_=t.geometryLayout?t.geometryLayout:"XY";let i=t.geometryFunction;if(!i){const t=this.mode_;if("Circle"===t)i=(t,e,i)=>{const n=e||new vd([NaN,NaN]),r=kn(t[0],i),s=si(r,kn(t[t.length-1],i));n.setCenterAndRadius(r,Math.sqrt(s),this.geometryLayout_);const o=Dn();return o&&n.transform(i,o),n};else{let e;"Point"===t?e=Xr:"LineString"===t?e=Td:"Polygon"===t&&(e=cs),i=(i,n,r)=>(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 vx({source:new jd({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:Vx(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:ra,this.freehandCondition_,t.freehand?this.freehandCondition_=ta:this.freehandCondition_=t.freehandCondition?t.freehandCondition:oa,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(Vo,this.updateState_)}setTrace(t){let e;e=t?!0===t?ta:t:ia,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}getOverlay(){return this.overlay_}handleEvent(t){t.originalEvent.type===s&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===zs.POINTERMOVE,i=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===zs.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===zs.POINTERDRAG&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===zs.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===zs.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===zs.POINTERDRAG&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):t.type===zs.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 Bs(zs.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=Ut([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;nt.endIndex||!i&&et.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(t0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e=s;--e)n.push(Nx(t.coordinates,e))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex&&oi(e.startPx,t.pixel)i.startIndex?hi.startIndex&&(h-=n.length)),l=h,a=t)}const h=e.targets[a];let c=h.ring;if(e.targetIndex===a&&c){const t=Xx(h.coordinates,l);oi(i.getPixelFromCoordinate(t),e.startPx)>n&&(c=!1)}if(c){const t=h.coordinates,e=t.length,i=h.startIndex,n=l;if(ithis.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=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():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let r=0;r=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 null;let e=this.sketchCoords_;const i=t.getGeometry(),n=this.getMap().getView().getProjection();return"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 Rd([e])):"MultiLineString"===this.type_?t.setGeometry(new Cd([e])):"MultiPolygon"===this.type_&&t.setGeometry(new bd([e])),this.dispatchEvent(new Ox(Lx,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),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 Ox(Ax,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;er?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(ds(t)):e.setGeometry(void 0):(e=new Mt(t?ds(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 Mt(new Xr(t)),this.vertexFeature_=e,this.vertexOverlay_.getSource().addFeature(e);return e}handleEvent(t){return!t.originalEvent||!this.condition_(t)||(t.type!=zs.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_=Hx(s(r)):null!==t?this.pointerHandler_=Kx(s([t,n[1]]),s([t,n[3]])):null!==e&&(this.pointerHandler_=Kx(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_=Hx(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!==ae(e)||this.setExtent(null),!1}setMap(t){this.extentOverlay_.setMap(t),this.vertexOverlay_.setMap(t),super.setMap(t)}getExtent(){return Gn(this.getExtentInternal(),this.getMap().getView().getProjection())}getExtentInternal(){return this.extent_}setExtent(t){this.extent_=t||null,this.createOrUpdateExtentFeature_(t),this.dispatchEvent(new Wx(this.extent_))}},hP.interaction.Extent.ExtentEvent=Wx,hP.interaction.Interaction=$o,hP.interaction.Interaction.pan=Wo,hP.interaction.Interaction.zoomByDelta=Zo,hP.interaction.KeyboardPan=Ra,hP.interaction.KeyboardZoom=ba,hP.interaction.Link=class extends $o{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),this.trackedCallbacks_={},this.trackedValues_={}}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,Ks,this.updateUrl_,this),D(t.getLayerGroup(),n,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=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;nt)));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=0;--e)this.insertVertex_(i[e],t);this.ignoreNextSingleClick_=!0}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,r=e.getCenter(),s=i.featureSegments[0],o=i.featureSegments[1];s.segment[0]=r,s.segment[1]=r,o.segment[0]=r,o.segment[1]=r,this.rBush_.update(Kt(r),s);let a=e;const l=Dn();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=gs(a).transform(e,l)}this.rBush_.update(a.getExtent(),o)}else this.rBush_.update(Ut(i.segment),i)}return this.featuresBeingModified_&&(this.dispatchEvent(new rv(nv,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.coordinate)}handlePointerAtPixel_(t){const e=this.getMap(),i=e.getPixelFromCoordinate(t),n=e.getView().getProjection(),r=function(e,i){return ov(t,e,n)-ov(t,i,n)};let s,o;if(this.hitDetection_){const t="object"==typeof this.hitDetection_?t=>t===this.hitDetection_:void 0;e.forEachFeatureAtPixel(i,((t,e,i)=>{i&&"Point"===i.getType()&&(i=new Xr(Nn(i.getCoordinates(),n)));const r=i||t.getGeometry();if(r&&"Point"===r.getType()&&t instanceof Mt&&this.features_.getArray().includes(t)){o=r;const e=t.getGeometry().getFlatCoordinates().slice(0,2);s=[{feature:t,geometry:o,segment:[e,e]}]}return!0}),{layerFilter:t})}if(!s){const i=Gn(jt(Un(Kt(t,tv),n),e.getView().getResolution()*this.pixelTolerance_,tv),n);s=this.rBush_.getInExtent(i)}if(s&&s.length>0){const a=s.sort(r)[0],l=a.segment;let h=av(t,a,n);const c=e.getPixelFromCoordinate(h);let u=oi(i,c);if(o||u<=this.pixelTolerance_){const i={};if(i[z(l)]=!0,this.snapToPointer_||(this.delta_[0]=h[0]-t[0],this.delta_[1]=h[1]-t[1]),"Circle"===a.geometry.getType()&&1===a.index)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);else{const t=e.getPixelFromCoordinate(l[0]),n=e.getPixelFromCoordinate(l[1]),r=si(c,t),o=si(c,n);if(u=Math.sqrt(Math.min(r,o)),this.snappedToVertex_=u<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_))return void(this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null));this.snappedToVertex_&&(h=r>o?l[1]:l[0]),this.createOrUpdateVertexFeature_(h,[a.feature],[a.geometry],this.snappedToVertex_);const d={};d[z(a.geometry)]=!0;for(let t=1,e=s.length;t"Circle"===t.getType()||t.getType().endsWith("Point"))))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Ut([t])).some((({segment:e})=>ii(e[0],t)||ii(e[1],t)))}removePoint(t){if(t&&(t=kn(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=zs.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map((([t])=>t)));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new rv(nv,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=z(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(Ut(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}canInsertPoint(){if(!this.vertexFeature_)return!1;if(this.vertexFeature_.get("geometries").every((t=>"Circle"===t.getType()||t.getType().endsWith("Point"))))return!1;const t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Ut([t])).some((({segment:e})=>!(ii(e[0],t)||ii(e[1],t))))}insertPoint(t){const e=t?kn(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();if(!e)return!1;return this.findInsertVerticesAndUpdateDragSegments_(e).reduce(((t,i)=>t||this.insertVertex_(i,e)),!1)}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||w(r.depth,i))&&r.index>e&&(r.index+=n)}))}},hP.interaction.Modify.ModifyEvent=rv,hP.interaction.MouseWheelZoom=Pa,hP.interaction.PinchRotate=Ia,hP.interaction.PinchZoom=Fa,hP.interaction.Pointer=ca,hP.interaction.Pointer.centroid=ua,hP.interaction.Select=dv,hP.interaction.Select.SelectEvent=cv,hP.interaction.Snap=class extends ca{constructor(t){const e=t=t||{};e.handleDownEvent||(e.handleDownEvent=C),e.stopDown||(e.stopDown=R),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.intersection_=void 0!==t.intersection&&t.intersection,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 Md,this.snapped_=null,this.segmenters_=Object.assign({},_v,t.segmenters)}addFeature(t,e){e=void 0===e||e;const i=z(t),r=t.getGeometry();if(r){const e=this.segmenters_[r.getType()];if(e){this.indexedFeaturesExtents_[i]=r.getExtent([1/0,1/0,-1/0,-1/0]);const n=e(r,this.getMap().getView().getProjection());let s=n.length;for(let e=0;e=0;--t)e.remove(i[t])}i&&(k(this.featureChangeListenerKeys_[n]),delete this.featureChangeListenerKeys_[n])}setMap(i){const n=this.getMap(),r=this.featuresListenerKeys_;let s=this.getFeatures_();if(Array.isArray(s)||(s=s.getArray()),n&&(r.forEach(k),r.length=0,this.rBush_.clear(),Object.values(this.featureChangeListenerKeys_).forEach(k),this.featureChangeListenerKeys_={}),super.setMap(i),i){this.features_?r.push(D(this.features_,t,this.handleFeatureAdd_,this),D(this.features_,e,this.handleFeatureRemove_,this)):this.source_&&r.push(D(this.source_,Ld,this.handleFeatureAdd_,this),D(this.source_,Dd,this.handleFeatureRemove_,this));for(const t of s)this.addFeature(t)}}snapTo(t,e,i){const n=i.getView().getProjection(),r=kn(e,n),s=Gn(jt(Ut([r]),i.getView().getResolution()*this.pixelTolerance_),n),o=this.rBush_.getInExtent(s),a=o.length;if(0===a)return null;let l,h,c,u=1/0,d=null;const g=this.pixelTolerance_*this.pixelTolerance_,f=()=>{if(l){const e=i.getPixelFromCoordinate(l);if(si(t,e)<=g&&(c&&this.intersection_||!c&&(this.vertex_||this.edge_)))return{vertex:l,vertexPixel:[Math.round(e[0]),Math.round(e[1])],feature:h,segment:d}}return null};if(this.vertex_||this.intersection_){for(let t=0;t{if(t instanceof Mt&&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")}}},hP.interaction.Translate.TranslateEvent=Tv,hP.interaction.defaults={},hP.interaction.defaults.defaults=Ma,hP.layer={},hP.layer.Base=za,hP.layer.BaseImage=_f,hP.layer.BaseTile=Cf,hP.layer.BaseVector=Ac,hP.layer.Flow=_x,hP.layer.Graticule=class extends vx{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:Sx,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?ti.bind(this,"EW"):t.lonLabelFormatter,this.latLabelFormatter_=null==t.latLabelFormatter?ti.bind(this,"NS"):t.latLabelFormatter,this.lonLabelPosition_=null==t.lonLabelPosition?0:t.lonLabelPosition,this.latLabelPosition_=null==t.latLabelPosition?1:t.latLabelPosition,this.lonLabelStyleBase_=new ec({text:void 0!==t.lonLabelStyle?t.lonLabelStyle.clone():new ac({font:"12px Calibri,sans-serif",textBaseline:"bottom",fill:new qh({color:"rgba(0,0,0,1)"}),stroke:new tc({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 ec({text:void 0!==t.latLabelStyle?t.latLabelStyle.clone():new ac({font:"12px Calibri,sans-serif",textAlign:"right",fill:new qh({color:"rgba(0,0,0,1)"}),stroke:new tc({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(Za,this.drawLabels_.bind(this))),this.intervals_=void 0!==t.intervals?t.intervals:Ex,this.setSource(new jd({loader:this.loaderFunction.bind(this),strategy:this.strategyFunction.bind(this),features:new Z,overlaps:!1,useSpatialIndex:!1,wrapX:t.wrapX})),this.featurePool_=[],this.lineStyle_=new ec({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()&&Ce(i,this.projection_),this.loadedExtent_&&(Qt(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=pe(this.getExtent()||[-1/0,-1/0,1/0,1/0],t);if(this.renderedExtent_&&Jt(this.renderedExtent_,r)&&this.renderedResolution_===e)return;if(this.renderedExtent_=r,this.renderedResolution_=e,ve(r))return;const s=ce(r),o=e*e/4;(!this.projection_||!bn(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 Mt,this.featurePool_.push(a);const h=n.getFeaturesCollection();h.clear();let c,u,d=0;for(c=0,u=this.meridians_.length;cMath.PI/2}const d=_u(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=a?(t[0]=o[0],t[2]=o[2]):s=!0);const l=[be(e[0],this.minX_,this.maxX_),be(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=be(h[0],this.minLon_,this.maxLon_),u=be(h[1],this.minLat_,this.maxLat_);const d=this.maxLines_;let g,f,p,_,m=t;s||(m=[be(t[0],this.minX_,this.maxX_),be(t[1],this.minY_,this.maxY_),be(t[2],this.minX_,this.maxX_),be(t[3],this.minY_,this.maxY_)]);const y=Te(m,this.toLonLatTransform_,void 0,8);let x=y[3],v=y[2],S=y[1],E=y[0];if(s||(Xt(m,this.bottomLeft_)&&(E=this.minLon_,S=this.minLat_),Xt(m,this.bottomRight_)&&(v=this.maxLon_,S=this.minLat_),Xt(m,this.topLeft_)&&(E=this.minLon_,x=this.maxLat_),Xt(m,this.topRight_)&&(v=this.maxLon_,x=this.maxLat_),x=be(x,u,this.maxLat_),v=be(v,c,this.maxLon_),S=be(S,this.minLat_,u),E=be(E,this.minLon_,c)),c=Math.floor(c/r)*r,_=be(c,this.minLon_,this.maxLon_),f=this.addMeridian_(_,S,x,n,t,0),g=0,s)for(;(_-=r)>=E&&g++n[s]&&(r=s,s=1);const o=Math.max(e[1],n[r]),a=Math.min(e[3],n[s]),l=be(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=xx(t,e,i,this.projection_,n);let o=this.parallels_[r];return o?(o.setFlatCoordinates("XY",s),o.changed()):o=new Td(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=be(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=xn("EPSG:4326"),i=t.getWorldExtent();this.maxLat_=i[3],this.maxLon_=i[2],this.minLat_=i[1],this.minLon_=i[0];const n=Fn(t,e);if(this.minLon_=Math.abs(this.minLat_)?this.maxLat_:this.minLat_),this.projection_=t}},hP.layer.Group=$a,hP.layer.Group.GroupEvent=Xa,hP.layer.Heatmap=class extends Ac{constructor(t){t=t||{};const e=Object.assign({},t);delete e.gradient,delete e.radius,delete e.blur,delete e.weight,super(e),this.filter_=t.filter??!0,this.styleVariables_=t.variables||{},this.gradient_=null,this.addChangeListener(Tx,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:Rx),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.weight_=i,this.setRenderOrder(null)}getBlur(){return this.get(wx)}getGradient(){return this.get(Tx)}getRadius(){return this.get(Cx)}handleGradientChanged_(){this.gradient_=function(t){const e=1,i=256,n=ft(e,i),r=n.createLinearGradient(0,0,e,i),s=1/(t.length-1);for(let e=0,i=t.length;ethis.getBlur(),t.addUniform("float a_blur")),"number"==typeof this.getRadius()&&(n="a_radius",s.a_radius=()=>this.getRadius(),t.addUniform("float a_radius"));const o={};let a=null;if("string"==typeof this.weight_||"function"==typeof this.weight_){const e="string"==typeof this.weight_?t=>t.get(this.weight_):this.weight_;o.prop_weight={size:1,callback:t=>{const i=e(t);return void 0!==i?be(i,0,1):1}},a="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{a=bm(e,["clamp",this.weight_,0,1],Xl)}t.addFragmentShaderFunction(`float getBlurSlope() {\n float blur = max(1., ${r});\n float radius = ${n};\n return radius / blur;\n}`).setSymbolSizeExpression(`vec2(${n} + ${r}) * 2.`).setSymbolColorExpression(`vec4(smoothstep(0., 1., (1. - length(coordsPx * 2. / v_quadSizePx)) * getBlurSlope()) * ${a})`).setStrokeColorExpression(`vec4(smoothstep(0., 1., (1. - length(currentRadiusPx * 2. / v_width)) * getBlurSlope()) * ${a})`).setStrokeWidthExpression(`(${n} + ${r}) * 2.`).setFillColorExpression(`vec4(${a})`).setFragmentDiscardExpression(`!${i}`),Lm(t,e);const l=Om(e),h=Am(e,this.styleVariables_);return new ny(this,{className:this.getClassName(),variables:this.styleVariables_,style:{builder:t,attributes:{...l,...o},uniforms:{...h,...s}},disableHitDetection:!1,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()}}]})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}renderDeclutter(){}},hP.layer.Image=mf,hP.layer.Layer=qa,hP.layer.Layer.inView=Ja,hP.layer.Tile=Rf,hP.layer.Vector=vx,hP.layer.VectorImage=class extends Ac{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 ix(this)}},hP.layer.VectorTile=class extends Ac{constructor(t){t=t||{};const e=Object.assign({},t);delete e.preload;const i=void 0===t.cacheSize?0:t.cacheSize;delete t.cacheSize,delete e.useInterimTilesOnError,super(e),this.on,this.once,this.un,this.cacheSize_=i;const n=t.renderMode||"hybrid";Ft("hybrid"==n||"vector"==n,"`renderMode` must be `'hybrid'` or `'vector'`"),this.renderMode_=n,this.setPreload(t.preload?t.preload:0),this.setUseInterimTilesOnError(void 0===t.useInterimTilesOnError||t.useInterimTilesOnError),this.getBackground,this.setBackground}createRenderer(){return new sx(this,{cacheSize:this.cacheSize_})}getFeatures(t){return super.getFeatures(t)}getFeaturesInExtent(t){return this.getRenderer().getFeaturesInExtent(t)}getRenderMode(){return this.renderMode_}getPreload(){return this.get(wf)}getUseInterimTilesOnError(){return this.get(Tf)}setPreload(t){this.set(wf,t)}setUseInterimTilesOnError(t){this.set(Tf,t)}},hP.layer.WebGLPoints=class extends qa{constructor(t){super(Object.assign({},t)),this.styleVariables_=t.variables||{},this.parseResult_=jm(t.style,this.styleVariables_,t.filter),this.hitDetectionDisabled_=!!t.disableHitDetection}createRenderer(){const t=Object.keys(this.parseResult_.attributes).map((t=>({name:t,...this.parseResult_.attributes[t]})));return new w_(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()}},hP.layer.WebGLTile=Px,hP.layer.WebGLVector=class extends qa{constructor(t){super(Object.assign({},t)),this.styleVariables_=t.variables||{},this.style_=t.style,this.hitDetectionDisabled_=!!t.disableHitDetection}createRenderer(){return new ny(this,{style:this.style_,variables:this.styleVariables_,disableHitDetection:this.hitDetectionDisabled_})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}setStyle(t){this.style_=t,this.clearRenderer(),this.changed()}},hP.layer.WebGLVectorTile=class extends Cf{constructor(t){super(Object.assign({},t)),this.styleVariables_=t.variables||{},this.style_=t.style,this.hitDetectionDisabled_=!!t.disableHitDetection}createRenderer(){return new oy(this,{style:this.style_,variables:this.styleVariables_,disableHitDetection:this.hitDetectionDisabled_})}updateStyleVariables(t){Object.assign(this.styleVariables_,t),this.changed()}setStyle(t){this.style_=t,this.clearRenderer(),this.changed()}},hP.loadingstrategy={},hP.loadingstrategy.all=iu,hP.loadingstrategy.bbox=function(t,e){return[t]},hP.loadingstrategy.tile=function(t){return function(e,i,n){const r=t.getZForResolution(Bn(i,n)),s=t.getTileRangeForExtentAndZ(Un(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(Gn(t.getTileCoordExtent(a),n));return o}},hP.math={},hP.math.ceil=Ge,hP.math.clamp=be,hP.math.floor=ke,hP.math.lerp=Oe,hP.math.modulo=Ae,hP.math.round=Ne,hP.math.solveLinearSystem=Fe,hP.math.squaredDistance=Ie,hP.math.squaredSegmentDistance=Pe,hP.math.toDegrees=Me,hP.math.toFixed=De,hP.math.toRadians=Le,hP.math.wrap=Ue,hP.net={},hP.net.ClientError=su,hP.net.ResponseError=ru,hP.net.getJSON=ou,hP.net.jsonp=nu,hP.net.overrideXHR=function(t){"undefined"!=typeof XMLHttpRequest&&(qc=XMLHttpRequest),global.XMLHttpRequest=t},hP.net.resolveUrl=au,hP.net.restoreXHR=function(){global.XMLHttpRequest=qc},hP.obj={},hP.obj.clear=F,hP.obj.isEmpty=M,hP.proj={},hP.proj.Projection=fi,hP.proj.Units={},hP.proj.Units.METERS_PER_UNIT=gi,hP.proj.Units.fromCode=di,hP.proj.addCommon=Xn,hP.proj.addCoordinateTransforms=Cn,hP.proj.addEquivalentProjections=Sn,hP.proj.addEquivalentTransforms=En,hP.proj.addProjection=mn,hP.proj.addProjections=yn,hP.proj.clearAllProjections=function(){Fi(),Oi()},hP.proj.clearUserProjection=function(){An=null},hP.proj.cloneTransform=pn,hP.proj.createProjection=wn,hP.proj.createSafeCoordinateTransform=zn,hP.proj.createTransformFromCoordinateTransform=Tn,hP.proj.disableCoordinateWarning=fn,hP.proj.epsg3857={},hP.proj.epsg3857.EXTENT=mi,hP.proj.epsg3857.HALF_SIZE=_i,hP.proj.epsg3857.MAX_SAFE_Y=xi,hP.proj.epsg3857.PROJECTIONS=Si,hP.proj.epsg3857.RADIUS=pi,hP.proj.epsg3857.WORLD_EXTENT=yi,hP.proj.epsg3857.fromEPSG4326=Ei,hP.proj.epsg3857.toEPSG4326=wi,hP.proj.epsg4326={},hP.proj.epsg4326.EXTENT=Ci,hP.proj.epsg4326.METERS_PER_UNIT=Ri,hP.proj.epsg4326.PROJECTIONS=Pi,hP.proj.epsg4326.RADIUS=Ti,hP.proj.equivalent=bn,hP.proj.fromLonLat=function(t,e){return fn(),Mn(t,"EPSG:4326",void 0!==e?e:"EPSG:3857")},hP.proj.fromUserCoordinate=kn,hP.proj.fromUserExtent=Un,hP.proj.fromUserResolution=Bn,hP.proj.get=xn,hP.proj.getPointResolution=vn,hP.proj.getTransform=Fn,hP.proj.getTransformFromProjections=Pn,hP.proj.getUserProjection=Dn,hP.proj.identityTransform=_n,hP.proj.proj4={},hP.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}}}))}},hP.proj.proj4.fromEPSGCode=async function(t){"string"==typeof t&&(t=parseInt(t.split(":").pop(),10));const e=ox;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 lx(t)),ax(e)),Mi(i)},hP.proj.proj4.getEPSGLookup=function(){return lx},hP.proj.proj4.isRegistered=function(){return!!ox},hP.proj.proj4.register=ax,hP.proj.proj4.setEPSGLookup=function(t){lx=t},hP.proj.proj4.unregister=function(){ox=null},hP.proj.projections={},hP.proj.projections.add=Li,hP.proj.projections.clear=Fi,hP.proj.projections.get=Mi,hP.proj.setUserProjection=On,hP.proj.toLonLat=Rn,hP.proj.toUserCoordinate=Nn,hP.proj.toUserExtent=Gn,hP.proj.toUserResolution=jn,hP.proj.transform=Mn,hP.proj.transformExtent=Ln,hP.proj.transformWithProjections=function(t,e,i){return Pn(e,i)(t)},hP.proj.transforms={},hP.proj.transforms.add=Di,hP.proj.transforms.clear=Oi,hP.proj.transforms.get=Ni,hP.proj.transforms.remove=function(t,e){const i=t.getCode(),n=e.getCode(),r=Ai[i][n];return delete Ai[i][n],M(Ai[i])&&delete Ai[i],r},hP.proj.useGeographic=function(){On("EPSG:4326")},hP.proj.utm={},hP.proj.utm.makeProjection=hn,hP.proj.utm.makeTransforms=cn,hP.proj.utm.zoneFromCode=an,hP.render={},hP.render.Box=fa,hP.render.Event=Oc,hP.render.Feature=Id,hP.render.Feature.toFeature=function(t,e){const i=t.getId(),n=Fd(t),r=t.getProperties(),s=new Mt;return void 0!==e&&s.setGeometryName(e),s.setGeometry(n),void 0!==i&&s.setId(i),s.setProperties(r,!0),s},hP.render.Feature.toGeometry=Fd,hP.render.VectorContext=lu,hP.render.canvas={},hP.render.canvas.Builder=Ty,hP.render.canvas.BuilderGroup=Ay,hP.render.canvas.Executor=$y,hP.render.canvas.ExecutorGroup=Hy,hP.render.canvas.ExecutorGroup.ALL=Wy,hP.render.canvas.ExecutorGroup.DECLUTTER=Zy,hP.render.canvas.ExecutorGroup.NON_DECLUTTER=Yy,hP.render.canvas.ExecutorGroup.getPixelIndexArray=qy,hP.render.canvas.ImageBuilder=Cy,hP.render.canvas.Immediate=hu,hP.render.canvas.Instruction={},hP.render.canvas.Instruction.beginPathInstruction=Ey,hP.render.canvas.Instruction.closePathInstruction=wy,hP.render.canvas.Instruction.fillInstruction=vy,hP.render.canvas.Instruction.strokeInstruction=Sy,hP.render.canvas.LineStringBuilder=Ry,hP.render.canvas.PolygonBuilder=by,hP.render.canvas.TextBuilder=My,hP.render.canvas.TextBuilder.TEXT_ALIGN=Fy,hP.render.canvas.ZIndexContext=cf,hP.render.canvas.checkedFonts=kh,hP.render.canvas.defaultFillStyle=Ph,hP.render.canvas.defaultFont=bh,hP.render.canvas.defaultLineCap=Ih,hP.render.canvas.defaultLineDash=Fh,hP.render.canvas.defaultLineDashOffset=0,hP.render.canvas.defaultLineJoin=Mh,hP.render.canvas.defaultLineWidth=1,hP.render.canvas.defaultMiterLimit=Lh,hP.render.canvas.defaultPadding=Nh,hP.render.canvas.defaultStrokeStyle=Ah,hP.render.canvas.defaultTextAlign=Oh,hP.render.canvas.defaultTextBaseline=Dh,hP.render.canvas.drawImageOrLabel=Zh,hP.render.canvas.getTextDimensions=Wh,hP.render.canvas.hitdetect={},hP.render.canvas.hitdetect.HIT_DETECT_RESOLUTION=Jy,hP.render.canvas.hitdetect.createHitDetectionImageData=Qy,hP.render.canvas.hitdetect.hitDetect=tx,hP.render.canvas.measureAndCacheTextWidth=$h,hP.render.canvas.measureTextHeight=zh,hP.render.canvas.measureTextWidth=Vh,hP.render.canvas.registerFont=Bh,hP.render.canvas.rotateAtOffset=function(t,e,i,n){0!==e&&(t.translate(i,n),t.rotate(e),t.translate(-i,-n))},hP.render.canvas.style={},hP.render.canvas.style.buildRuleSet=uc,hP.render.canvas.style.buildStyle=dc,hP.render.canvas.style.flatStylesToStyleFunction=cc,hP.render.canvas.style.rulesToStyleFunction=hc,hP.render.canvas.textHeights=jh,hP.render.getRenderPixel=function(t,e){return Kn(t.inversePixelTransform,e.slice(0))},hP.render.getVectorContext=_u,hP.render.toContext=function(t,e){const i=t.canvas,n=(e=e||{}).pixelRatio||ht,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=Jn([1,0,0,1,0,0],n,n);return new hu(t,n,s,o,0)},hP.render.webgl={},hP.render.webgl.MixedGeometryBatch=Bp,hP.render.webgl.ShaderBuilder={},hP.render.webgl.ShaderBuilder.COMMON_HEADER=Tm,hP.render.webgl.ShaderBuilder.ShaderBuilder=Rm,hP.render.webgl.VectorStyleRenderer=ey,hP.render.webgl.bufferUtil={},hP.render.webgl.bufferUtil.LINESTRING_ANGLE_COSINE_CUTOFF=vm,hP.render.webgl.bufferUtil.writeLineSegmentToBuffers=function(t,e,i,n,r,s,o,a,l,h,c){const u=10+a.length,d=s.length/u,g=[t[e+0],t[e+1]],f=[t[i],t[i+1]],p=t[e+2],_=t[i+2],m=Kn(l,[...g]),y=Kn(l,[...f]);function x(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(be(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}let v=-1,S=-1,E=c;const w=null!==r;if(null!==n){v=x(m,y,Kn(l,[...[t[n],t[n+1]]])),Math.cos(v)<=vm&&(E+=Math.tan((v-Math.PI)/2))}if(w){S=x(y,m,Kn(l,[...[t[r],t[r+1]]])),Math.cos(S)<=vm&&(E+=Math.tan((Math.PI-S)/2))}function T(t,e){return 0===e?1e4*t:Math.sign(e)*(1e4*t+Math.abs(e))}return s.push(g[0],g[1],p,f[0],f[1],_,v,S,h,T(0,c)),s.push(...a),s.push(g[0],g[1],p,f[0],f[1],_,v,S,h,T(1,c)),s.push(...a),s.push(g[0],g[1],p,f[0],f[1],_,v,S,h,T(2,c)),s.push(...a),s.push(g[0],g[1],p,f[0],f[1],_,v,S,h,T(3,c)),s.push(...a),o.push(d,d+1,d+2,d+1,d+3,d+2),{length:h+Math.sqrt((y[0]-m[0])*(y[0]-m[0])+(y[1]-m[1])*(y[1]-m[1])),angle:E}},hP.render.webgl.bufferUtil.writePointFeatureToBuffers=function(t,e,i,n,r,s){const o=3+r,a=t[e+0],l=t[e+1],h=Sm;h.length=r;for(let i=0;it.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=zu(this.getProjection()),r=this.hidpi_?2:1,s=e.imageWidth==e.imageHeight?e.imageWidth/r:[e.imageWidth/r,e.imageHeight/r],o=Uu({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=Qu(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;Ru(t[0],t[1],t[2],i);const s=new URL(n.replace("{quadkey}",fd(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=Pn(xn("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.zoomMin&&a<=n.zoomMax){const e=n.bbox;if(xe(Te([e[1],e[0],e[3],e[2]],t),i.extent)){r=!0;break}}}r&&n.push(e.attribution)})),n.push('Terms of Use'),n}))}this.setState("ready")}},hP.source.BingMaps.quadKey=fd,hP.source.CartoDB=class extends pd{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{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)}},hP.source.Cluster=class extends jd{constructor(t){super({attributions:(t=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 Ft(!e||"Point"===e.getType(),"The default `geometryFunction` can only handle `Point` or null geometries"),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(n,this.boundRefresh_),this.source=t,t&&t.addEventListener(n,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=0;--e){const n=this.geometryFunction(t[e]);n?qe(i,n.getCoordinates()):t.splice(e,1)}ri(i,1/t.length);const n=ce(e),r=this.interpolationRatio,s=new Xr([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(s,t):new Mt({geometry:s,features:t})}},hP.source.DataTile=eg,hP.source.GeoTIFF=fg,hP.source.Google=class extends dd{constructor(t){const e=!!t.highDpi;super({attributionsCollapsible:t.attributionsCollapsible,cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,projection:"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.apiKey_=t.key,this.error_=null;const i={mapType:t.mapType||"roadmap",language:t.language||"en-US",region:t.region||"US"};t.imageFormat&&(i.imageFormat=t.imageFormat),t.scale&&(i.scale=t.scale),e&&(i.highDpi=!0),t.layerTypes&&(i.layerTypes=t.layerTypes),t.styles&&(i.styles=t.styles),!0===t.overlay&&(i.overlay=!0),t.apiOptions&&(i.apiOptions=t.apiOptions),this.sessionTokenRequest_=i,this.sessionTokenValue_,this.sessionRefreshId_,this.previousViewportAttribution_,this.previousViewportExtent_,this.createSession_()}getError(){return this.error_}fetchSessionToken(t,e){return fetch(t,e)}async createSession_(){const t="https://tile.googleapis.com/v1/createSession?key="+this.apiKey_,e={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.sessionTokenRequest_)},i=await this.fetchSessionToken(t,e);if(!i.ok){try{const t=await i.json();this.error_=new Error(t.error.message)}catch{this.error_=new Error("Error fetching session token")}return void this.setState("error")}const n=await i.json(),r=this.getTilePixelRatio(1),s=[n.tileWidth/r,n.tileHeight/r];this.tileGrid=Uu({extent:zu(this.getProjection()),maxZoom:22,tileSize:s});const o=n.session;this.sessionTokenValue_=o;const a=this.apiKey_;this.tileUrlFunction=function(t,e,i){return`https://tile.googleapis.com/v1/2dtiles/${t[0]}/${t[1]}/${t[2]}?session=${o}&key=${a}`};const l=1e3*parseInt(n.expiry,10),h=Math.max(l-Date.now()-6e4,1);this.sessionRefreshId_=setTimeout((()=>this.createSession_()),h),this.setAttributions(this.fetchAttributions_.bind(this)),this.setState("ready")}async fetchAttributions_(t){if(t.viewHints[ao]||t.viewHints[lo]||t.animate)return this.previousViewportAttribution_;const[e,i]=Rn(le(t.extent),t.viewState.projection),[n,r]=Rn(me(t.extent),t.viewState.projection),s=`zoom=${this.getTileGrid().getZForResolution(t.viewState.resolution,this.zDirection)}&north=${r}&south=${i}&east=${n}&west=${e}`;if(this.previousViewportExtent_==s)return this.previousViewportAttribution_;this.previousViewportExtent_=s;const o=`https://tile.googleapis.com/tile/v1/viewport?session=${this.sessionTokenValue_}&key=${this.apiKey_}&${s}`;return this.previousViewportAttribution_=await fetch(o).then((t=>t.json())).then((t=>t.copyright)),this.previousViewportAttribution_}disposeInternal(){clearTimeout(this.sessionRefreshId_),super.disposeInternal()}},hP.source.IIIF=class extends dd{constructor(t){const e=t||{};let i=e.url||"";i+=i.lastIndexOf("/")===i.length-1||""===i?"":"/";const n=e.version||_g,r=e.sizes||[],s=e.size;Ft(null!=s&&Array.isArray(s)&&2==s.length&&!isNaN(s[0])&&s[0]>0&&!isNaN(s[1])&&s[1]>0,"Missing or invalid `size`");const o=s[0],a=s[1],l=e.tileSize,h=e.tilePixelRatio||1,c=e.format||"jpg",u=e.quality||(e.version==pg?"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,_=void 0!==l&&("number"==typeof l&&Number.isInteger(l)&&l>0||Array.isArray(l)&&l.length>0),m=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=Eo,x=Eo),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;e0&&d[d.length-1]==i?t.push(e):(d.push(i),v++)}if(t.length>0)for(let e=0;ev)return;const S=t[1],E=t[2],w=d[f];if(!(void 0===S||void 0===E||void 0===w||S<0||Math.ceil(o/w/y)<=S||E<0||Math.ceil(a/w/x)<=E)){if(m||_){const t=S*y*w,e=E*x*w;let i=y*w,r=x*w,s=y,c=x;if(t+i>o&&(i=o-t),e+r>a&&(r=a-e),t+y*w>o&&(s=Math.floor((o-t+w-1)/w)),e+x*w>a&&(c=Math.floor((a-e+w-1)/w)),0==t&&i==o&&0==e&&r==a)l="full";else if(!m||g.includes("regionByPx"))l=t+","+e+","+i+","+r;else if(g.includes("regionByPct")){l="pct:"+Tg(t/o*100)+","+Tg(e/a*100)+","+Tg(i/o*100)+","+Tg(r/a*100)}n!=mg||m&&!g.includes("sizeByWh")?!m||g.includes("sizeByW")?h=s+",":g.includes("sizeByH")?h=","+c:g.includes("sizeByWh")?h=s+","+c:g.includes("sizeByPct")&&(h="pct:"+Tg(100/w)):h=s+","+c}else if(l="full",p){const t=r[f][0],e=r[f][1];h=n==mg?t==o&&e==a?"max":t+","+e:t==o?"full":t+","}else h=n==mg?"max":"full";return i+l+"/"+h+"/0/"+u+"."+c}},transition:e.transition}),this.zDirection=e.zDirection}},hP.source.Image=Fg,hP.source.Image.ImageSourceEvent=Ig,hP.source.Image.defaultImageLoadFunction=Mg,hP.source.Image.getRequestExtent=Lg,hP.source.ImageArcGISRest=class extends Fg{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),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:Mg,this.params_=Object.assign({},t.params),this.imageSize_=[0,0],this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5,this.loaderProjection_=null}getParams(){return this.params_}getImageInternal(t,e,i,n){return void 0===this.url_?null:(this.loader&&this.loaderProjection_===n||(this.loaderProjection_=n,this.loader=Og({crossOrigin:this.crossOrigin_,params:this.params_,projection:n,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(t,e)=>(this.image.setImage(t),this.imageLoadFunction_(this.image,e),Ns(t))})),super.getImageInternal(t,e,i,n))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(t){this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.loader=null,this.changed())}setParams(t){this.params_=Object.assign({},t),this.changed()}updateParams(t){Object.assign(this.params_,t),this.changed()}changed(){this.image=null,super.changed()}},hP.source.ImageCanvas=class extends Fg{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&&Vt(r.getExtent(),t))return r;Ee(t=t.slice(),this.ratio_);const s=[ye(t)/e*i,fe(t)/e*i],o=this.canvasFunction_.call(this,t,e,i,s,n);return o&&(r=new ks(t,e,i,o)),this.canvas_=r,this.renderedRevision_=this.getRevision(),r}},hP.source.ImageMapGuide=class extends Fg{constructor(t){super({interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.displayDpi_=void 0!==t.displayDpi?t.displayDpi:96,this.params_=Object.assign({},t.params),this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:Mg,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.renderedRevision_=0,this.loaderProjection_=null}getParams(){return this.params_}getImageInternal(t,e,i,n){return void 0===this.url_?null:(this.loader&&this.loaderProjection_===n||(this.loaderProjection_=n,this.loader=Ng({crossOrigin:this.crossOrigin_,params:this.params_,hidpi:this.hidpi_,metersPerUnit:this.metersPerUnit_,url:this.url_,useOverlay:this.useOverlay_,ratio:this.ratio_,load:(t,e)=>(this.image.setImage(t),this.imageLoadFunction_(this.image,e),Ns(t))})),super.getImageInternal(t,e,i,n))}getImageLoadFunction(){return this.imageLoadFunction_}setParams(t){this.params_=Object.assign({},t),this.changed()}updateParams(t){Object.assign(this.params_,t),this.changed()}setImageLoadFunction(t){this.imageLoadFunction_=t,this.changed()}changed(){this.image=null,super.changed()}},hP.source.ImageStatic=class extends Fg{constructor(t){const e=void 0!==t.crossOrigin?t.crossOrigin:null,i=void 0!==t.imageLoadFunction?t.imageLoadFunction:Mg;super({attributions:t.attributions,interpolate:t.interpolate,projection:xn(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new Ls(this.imageExtent_,void 0,1,kg({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,load:(t,e)=>(this.image.setImage(t),i(this.image,e),Ns(t))})),this.image.addEventListener(n,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,n){return xe(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}},hP.source.ImageTile=Vg,hP.source.ImageWMS=class extends Fg{constructor(t){super({attributions:(t=t||{}).attributions,interpolate:t.interpolate,projection:t.projection,resolutions:t.resolutions}),this.crossOrigin_=void 0!==t.crossOrigin?t.crossOrigin:null,this.url_=t.url,this.imageLoadFunction_=void 0!==t.imageLoadFunction?t.imageLoadFunction:Mg,this.params_=Object.assign({},t.params),this.serverType_=t.serverType,this.hidpi_=void 0===t.hidpi||t.hidpi,this.renderedRevision_=0,this.ratio_=void 0!==t.ratio?t.ratio:1.5,this.loaderProjection_=null}getFeatureInfoUrl(t,e,i,n){const r=xn(i),s=this.getProjection();s&&s!==r&&(e=Su(s,r,t,e),t=Mn(t,r,s));return qg({url:this.url_,params:{...this.params_,...n},projection:s||r},t,e)}getLegendUrl(t,e){return Jg({url:this.url_,params:{...this.params_,...e}},t)}getParams(){return this.params_}getImageInternal(t,e,i,n){return void 0===this.url_?null:(this.loader&&this.loaderProjection_===n||(this.loaderProjection_=n,this.loader=Kg({crossOrigin:this.crossOrigin_,params:this.params_,projection:n,serverType:this.serverType_,hidpi:this.hidpi_,url:this.url_,ratio:this.ratio_,load:(t,e)=>(this.image.setImage(t),this.imageLoadFunction_(this.image,e),Ns(t))})),super.getImageInternal(t,e,i,n))}getImageLoadFunction(){return this.imageLoadFunction_}getUrl(){return this.url_}setImageLoadFunction(t){this.imageLoadFunction_=t,this.changed()}setUrl(t){t!=this.url_&&(this.url_=t,this.loader=null,this.changed())}setParams(t){this.params_=Object.assign({},t),this.changed()}updateParams(t){Object.assign(this.params_,t),this.changed()}changed(){this.image=null,super.changed()}},hP.source.OGCMapTile=class extends dd{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});of({url:t.url,projection:this.getProjection(),mediaType:t.mediaType,context:t.context||null,collections:t.collections}).then(this.handleTileSetInfo_.bind(this)).catch(this.handleError_.bind(this))}handleTileSetInfo_(t){this.tileGrid=t.grid,this.projection=t.projection,this.setTileUrlFunction(t.urlFunction,t.urlTemplate),this.setState("ready")}handleError_(t){Ye(t),this.setState("error")}},hP.source.OGCVectorTile=class extends af{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"});of({url:t.url,projection:this.getProjection(),mediaType:t.mediaType,supportedMediaTypes:t.format.supportedMediaTypes,context:t.context||null,collections:t.collections}).then(this.handleTileSetInfo_.bind(this)).catch(this.handleError_.bind(this))}handleTileSetInfo_(t){this.tileGrid=t.grid,this.projection=t.projection,this.setTileUrlFunction(t.urlFunction,t.urlTemplate),this.setState("ready")}handleError_(t){Ye(t),this.setState("error")}},hP.source.OSM=class extends pd{constructor(t){let e;e=void 0!==(t=t||{}).attributions?t.attributions:[hf];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,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:n,wrapX:t.wrapX,zDirection:t.zDirection})}},hP.source.OSM.ATTRIBUTION=hf,hP.source.Raster=Af,hP.source.Raster.Processor=If,hP.source.Raster.RasterSourceEvent=Lf,hP.source.SentinelHub=class extends eg{constructor(t){const e=t||{};super({state:"loading",projection:e.projection,attributionsCollapsible:e.attributionsCollapsible,interpolate:e.interpolate,tileSize:e.tileSize||Yp,wrapX:void 0===e.wrapX||e.wrapX,transition:e.transition}),this.setLoader(((t,e,i)=>this.loadTile_(t,e,i,1))),this.error_=null,this.evalscript_="",this.inputData_=null,this.processUrl_=e.url||"https://services.sentinel-hub.com/api/v1/process",this.token_="",this.tokenRenewalId_,e.auth&&this.setAuth(e.auth),e.data&&this.setData(e.data),e.evalscript&&this.setEvalscript(e.evalscript)}async setAuth(t){if(clearTimeout(this.tokenRenewalId_),"string"==typeof t)return this.token_=t,void this.fireWhenReady_();let e,i;try{e=await async function(t){const e=t.tokenUrl||"https://services.sentinel-hub.com/auth/realms/main/protocol/openid-connect/token",i=new URLSearchParams;i.append("grant_type","client_credentials"),i.append("client_id",t.clientId),i.append("client_secret",t.clientSecret);const n={method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i},r=await fetch(e,n);if(!r.ok){if(401===r.status)throw new Error("Bad client id or secret");throw new Error("Failed to get token")}return(await r.json()).access_token}(t),i=Hp(e)}catch(t){return this.error_=t,void this.setState("error")}this.token_=e;const n=1e3*i.exp,r=Math.max(n-Date.now()-6e4,1);this.tokenRenewalId_=setTimeout((()=>this.setAuth(t)),r),this.fireWhenReady_()}setData(t){this.inputData_=t,this.fireWhenReady_()}setEvalscript(t){let e;if("string"==typeof t)e=t;else try{e=function(t){return`//VERSION=${t.version||"3"}\n ${qp("setup",t.setup)}\n ${qp("evaluatePixel",t.evaluatePixel)}\n ${qp("updateOutput",t.updateOutput)}\n `}(t)}catch(t){return this.error_=t,void this.setState("error")}this.evalscript_=e,this.fireWhenReady_()}fireWhenReady_(){if(!this.token_||!this.evalscript_||!this.inputData_)return;"ready"!==this.getState()?this.setState("ready"):this.changed()}async loadTile_(t,e,i,n){const r=this.getTileGrid().getTileCoordExtent([t,e,i]),s=this.getTileSize(t),o={input:{bounds:{bbox:r,properties:{crs:Kp(this.getProjection())}},data:this.inputData_},output:{width:s[0],height:s[1]},evalscript:this.evalscript_},a={method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token_}`,"Access-Control-Request-Headers":"Retry-After"},body:JSON.stringify(o),credentials:"include"},l=await fetch(this.processUrl_,a);if(!l.ok){if(429===l.status&&n<9){const r=500*2**n;return await(h=r,new Promise((t=>setTimeout(t,h)))),this.loadTile_(e,i,t,n+1)}throw new Error(`Failed to get tile: ${l.statusText}`)}var h;return async function(t){const e=await t.blob();return new Promise(((t,i)=>{const n=new Image,r=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(r),t(n)},n.onerror=()=>{URL.revokeObjectURL(r),i(new Error("Failed to load image"))},n.src=r}))}(l)}getError(){return this.error_}disposeInternal(){clearTimeout(this.tokenRenewalId_),super.disposeInternal()}},hP.source.SentinelHub.getProjectionIdentifier=Kp,hP.source.SentinelHub.parseTokenClaims=Hp,hP.source.SentinelHub.serializeFunction=qp,hP.source.Source=rd,hP.source.StadiaMaps=class extends pd{constructor(t){const e=t.layer.indexOf("-"),i=-1==e?t.layer:t.layer.slice(0,e),n=Gf[i]||{minZoom:0,maxZoom:20,retina:!0},r=kf[t.layer],s=t.apiKey?"?api_key="+t.apiKey:"",o=n.retina&&t.retina?"@2x":"",a=void 0!==t.url?t.url:"https://tiles.stadiamaps.com/tiles/"+t.layer+"/{z}/{x}/{y}"+o+"."+r.extension+s,l=['© Stadia Maps','© OpenMapTiles',hf];t.layer.startsWith("stamen_")&&l.splice(1,0,'© Stamen Design'),super({attributions:l,cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,maxZoom:void 0!==t.maxZoom?t.maxZoom:n.maxZoom,minZoom:void 0!==t.minZoom?t.minZoom:n.minZoom,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:a,tilePixelRatio:o?2:1,wrapX:t.wrapX,zDirection:t.zDirection})}},hP.source.Tile=od,hP.source.Tile.TileSourceEvent=ad,hP.source.TileArcGISRest=class extends dd{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_=Object.assign({},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;let a;if(1==o.length)a=o[0];else{a=o[Ae(Iu(t),o.length)]}return Ag(a,i,(this.tileGrid||this.getTileGridForProjection(r)).getResolution(t[0]),n,r,s)}getTilePixelRatio(t){return this.hidpi_?t:1}setParams(t){this.params_=Object.assign({},t),this.setKey(this.getKeyForParams_())}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=jl(n.getTileSize(t[0]),this.tmpSize);1!=e&&(s=Ul(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)}},hP.source.TileDebug=class extends Vg{constructor(t){const e=(t=t||{}).template||"z:{z} x:{x} y:{y}",i=t.source;super({transition:0,wrapX:void 0!==t.wrapX?t.wrapX:void 0!==i?i.getWrapX():void 0});const r=()=>{this.projection=void 0!==t.projection?xn(t.projection):void 0!==i?i.getProjection():this.projection,this.tileGrid=void 0!==t.tileGrid?t.tileGrid:void 0!==i?i.getTileGrid():this.tileGrid,this.zDirection=void 0!==t.zDirection?t.zDirection:void 0!==i?i.zDirection:this.zDirection,i instanceof eg&&(this.transformMatrix=i.transformMatrix?.slice()||null);const n=this.tileGrid;n&&this.setTileSizes(n.getResolutions().map(((t,e)=>jl(n.getTileSize(e)).map((t=>Math.max(Math.floor(t),1)))))),this.setLoader(((t,i,n,r)=>{const s=Yu(e,t,i,n,r.maxY),[o,a]=this.getTileSize(t),l=ft(o,a);return l.strokeStyle="grey",l.strokeRect(.5,.5,o+.5,a+.5),l.fillStyle="grey",l.strokeStyle="white",l.textAlign="center",l.textBaseline="middle",l.font="24px sans-serif",l.lineWidth=4,l.strokeText(s,o/2,a/2,o),l.fillText(s,o/2,a/2,o),Promise.resolve(l.canvas)})),this.setState("ready")};if(void 0===i||"ready"===i.getState())r();else{const t=()=>{"ready"===i.getState()&&(i.removeEventListener(n,t),r())};i.addEventListener(n,t)}}},hP.source.TileImage=dd,hP.source.TileJSON=class extends dd{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:xn("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)nu(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{if(!t.tileJSON)throw new Error("Either `url` or `tileJSON` options must be provided");this.handleTileJSONResponse(t.tileJSON)}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch{return void this.handleTileJSONError()}this.handleTileJSONResponse(t)}else this.handleTileJSONError()}onXHRError_(t){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(t){const e=xn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=Pn(e,i);n=Te(t.bounds,r)}const r=zu(i),s=t.minzoom||0,o=Uu({extent:r,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=Ju(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==n?n:r;this.setAttributions((function(i){return xe(e,i.extent)?[t.attribution]:null}))}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}},hP.source.TileWMS=class extends dd{constructor(t){t=t||{};const e=Object.assign({},t.params);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: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=xn(i),s=this.getProjection()||r;let o=this.getTileGrid();o||(o=this.getTileGridForProjection(s));const a=Mn(t,r,s),l=Su(s,r,t,e),h=o.getZForResolution(l,this.zDirection),c=o.getResolution(h),u=o.getTileCoordForCoordAndZ(a,h);if(o.getResolutions().length<=u[0])return;let d=o.getTileCoordExtent(u,this.tmpExtent_);const g=this.gutter_;0!==g&&(d=jt(d,c*g,d));const f={QUERY_LAYERS:this.params_.LAYERS};Object.assign(f,Hg(this.params_,"GetFeatureInfo"),n);const p=Math.floor((a[0]-d[0])/c),_=Math.floor((d[3]-a[1])/c);return f[this.v13_?"I":"X"]=p,f[this.v13_?"J":"Y"]=_,this.getRequestUrl_(u,d,1,s||r,f)}getLegendUrl(t,e){if(void 0===this.urls[0])return;const i={SERVICE:"WMS",VERSION:$g,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),Xu(this.urls[0],i)}getGutter(){return this.gutter_}getParams(){return this.params_}getRequestUrl_(t,e,i,n,r){const s=this.urls;if(!s)return;let o;if(1==s.length)o=s[0];else{o=s[Ae(Iu(t),s.length)]}return Yg(e,(this.tileGrid||this.getTileGridForProjection(n)).getResolution(t[0]),i,n,o,r,this.serverType_)}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("/")}setParams_(t){this.params_=t,this.updateV13_(),this.setKey(this.getKeyForParams_())}setParams(t){this.setParams_(Object.assign({},t))}updateParams(t){this.setParams_(Object.assign(this.params_,t))}updateV13_(){const t=this.params_.VERSION||$g;this.v13_=Ke(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_);const o=this.gutter_;0!==o&&(s=jt(s,r*o,s));const a=Object.assign({},Hg(this.params_,"GetMap"));return this.getRequestUrl_(t,s,e,i,a)}},hP.source.UTFGrid=class extends od{constructor(t){if(super({projection:xn("EPSG:3857"),state:"loading",wrapX:void 0===t.wrapX||t.wrapX,zDirection:t.zDirection}),this.preemptive_=void 0===t.preemptive||t.preemptive,this.tileUrlFunction_=td,this.template_=void 0,this.jsonp_=t.jsonp||!1,this.tileCache_=new Cu(512),t.url)if(this.jsonp_)nu(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{if(!t.tileJSON)throw new Error("Either `url` or `tileJSON` options must be provided");this.handleTileJSONResponse(t.tileJSON)}}onXHRLoad_(t){const e=t.target;if(!e.status||e.status>=200&&e.status<300){let t;try{t=JSON.parse(e.responseText)}catch{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),o=this.getTile(s[0],s[1],s[2],1,this.getProjection());o.getState()==Y&&o.load(),o.forDataAtCoordinate(t,i,n)}else!0===n?setTimeout((function(){i(null)}),0):i(null)}handleTileJSONError(){this.setState("error")}handleTileJSONResponse(t){const e=xn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=Pn(e,i);n=Te(t.bounds,r)}const r=zu(i),s=t.minzoom||0,o=Uu({extent:r,maxZoom:t.maxzoom||22,minZoom:s});this.tileGrid=o,this.template_=t.template;const a=t.grids;if(a){if(this.tileUrlFunction_=Ju(a,o),t.attribution){const e=void 0!==n?n:r;this.setAttributions((function(i){return xe(e,i.extent)?[t.attribution]:null}))}this.setState("ready")}else this.setState("error")}getTile(t,e,i,n,r){const s=[t,e,i],o=this.getTileCoordForTileUrlFunction(s,r),a=this.tileUrlFunction_(o,n,r),l=`${this.getKey()},${bu(t,e,i)}`;if(this.tileCache_.containsKey(l))return this.tileCache_.get(l);this.tileCache_.expireCache();const h=new Uf(s,void 0!==a?Y:J,void 0!==a?a:"",this.tileGrid.getTileCoordExtent(s),this.preemptive_,this.jsonp_);return this.tileCache_.set(l,h),h}},hP.source.UTFGrid.CustomTile=Uf,hP.source.UrlTile=ud,hP.source.Vector=jd,hP.source.Vector.VectorSourceEvent=Ud,hP.source.VectorTile=af,hP.source.VectorTile.defaultLoadFunction=lf,hP.source.WMTS=class extends dd{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=Ku(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=Qu(n.map(this.createFromWMTSTemplate.bind(this))))}setUrls(t){this.urls=t;const e=t.join("\n");this.setTileUrlFunction(Qu(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?Xu(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?Xu(l,a):l.replace(/\{(\w+?)\}/g,(function(t,e){return encodeURIComponent(a[e])})),l}}},hP.source.WMTS.optionsFromCapabilities=function(t,e){const i=t.Contents.Layer,n=i?.find((function(t){return t.Identifier==e.layer}));if(!n)return null;const r=t.Contents.TileMatrixSet;let s;s=n.TileMatrixSetLink.length>1?"projection"in e?n.TileMatrixSetLink.findIndex((function(t){const i=r.find((function(e){return e.Identifier==t.TileMatrixSet})).SupportedCRS,n=xn(i),s=xn(e.projection);return n&&s?bn(n,s):i==e.projection})):n.TileMatrixSetLink.findIndex((function(t){return t.TileMatrixSet==e.matrixSet})):0,s<0&&(s=0);const o=n.TileMatrixSetLink[s].TileMatrixSet,a=n.TileMatrixSetLink[s].TileMatrixSetLimits;let l=n.Format[0];"format"in e&&(l=e.format),s=n.Style.findIndex((function(t){return"style"in e?t.Title==e.style:t.isDefault})),s<0&&(s=0);const h=n.Style[s].Identifier,c={};"Dimension"in n&&n.Dimension.forEach((function(t,e,i){const n=t.Identifier;let r=t.Default;void 0===r&&(r=t.Value[0]),c[n]=r}));const u=t.Contents.TileMatrixSet.find((function(t){return t.Identifier==o}));let d;const g=u.SupportedCRS;if(g&&(d=xn(g)),"projection"in e){const t=xn(e.projection);t&&(d&&!bn(t,d)||(d=t))}let f=!1;const p=d.getAxisOrientation().startsWith("ne");let _=u.TileMatrix[0],m={MinTileCol:0,MinTileRow:0,MaxTileCol:_.MatrixWidth-1,MaxTileRow:_.MatrixHeight-1};if(a){m=a[a.length-1];const t=u.TileMatrix.find((t=>t.Identifier===m.TileMatrix||u.Identifier+":"+t.Identifier===m.TileMatrix));t&&(_=t)}const y=28e-5*_.ScaleDenominator/d.getMetersPerUnit(),x=p?[_.TopLeftCorner[1],_.TopLeftCorner[0]]:_.TopLeftCorner,v=_.TileWidth*y,S=_.TileHeight*y;let E=u.BoundingBox;E&&p&&(E=[E[1],E[0],E[3],E[2]]);let w=[x[0]+v*m.MinTileCol,x[1]-S*(1+m.MaxTileRow),x[0]+v*(1+m.MaxTileCol),x[1]-S*m.MinTileRow];if(void 0!==E&&!Vt(E,w)){const t=n.WGS84BoundingBox,e=xn("EPSG:4326").getExtent();if(w=E,t)f=t[0]===e[0]&&t[2]===e[2];else{const t=Ln(E,u.SupportedCRS,"EPSG:4326");f=t[0]-1e-10<=e[0]&&t[2]+1e-10>=e[2]}}const T=Du(u,w,a),C=[];let R=e.requestEncoding;if(R=void 0!==R?R:"","OperationsMetadata"in t&&"GetTile"in t.OperationsMetadata){const e=t.OperationsMetadata.GetTile.DCP.HTTP.Get;for(let t=0,i=e.length;tl||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:throw new Error("Unknown `tierSizeCalculation` configured")}o.push([1,1]),o.reverse();const h=[n],c=[0];for(let t=1,e=o.length;t{f=a,this.changed()})),y.src=m}},hP.source.Zoomify.CustomTile=wg,hP.source.arcgisRest={},hP.source.arcgisRest.createLoader=Og,hP.source.arcgisRest.getRequestUrl=Ag,hP.source.common={},hP.source.common.DECIMALS=4,hP.source.common.DEFAULT_WMS_VERSION="1.3.0",hP.source.mapguide={},hP.source.mapguide.createLoader=Ng,hP.source.mapserver={},hP.source.mapserver.createLoader=function(t){const e=t.load||Ns,i=t.ratio??1,n=t.crossOrigin??null;return function(r,s,o){const a=new Image;a.crossOrigin=n;const l=ye(r=Lg(r,s,o,i))/s,h=fe(r)/s,c=[l*o,h*o],u=function(t,e,i,n){const r=Math.round(n[0]),s=Math.round(n[1]),o=`${r} ${s}`,a=`${i[0]} ${i[1]} ${i[2]} ${i[3]}`,l={mode:"map",map_imagetype:"png",mapext:a,imgext:a,map_size:o,imgx:r/2,imgy:s/2,imgxy:o};return Object.assign(l,e),Xu(t,l)}(t.url,t.params,r,c);return e(a,u).then((t=>({image:t,extent:r,pixelRatio:o})))}},hP.source.ogcTileUtil={},hP.source.ogcTileUtil.appendCollectionsQueryParam=ef,hP.source.ogcTileUtil.getMapTileUrlTemplate=nf,hP.source.ogcTileUtil.getTileSetInfo=of,hP.source.ogcTileUtil.getVectorTileUrlTemplate=rf,hP.source.sourcesFromTileGrid=function(t,e){const i=new Cu(32),n=t.getExtent();return function(r,s){i.expireCache(),n&&(r=pe(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}},hP.source.static={},hP.source.static.createLoader=kg,hP.source.wms={},hP.source.wms.DEFAULT_VERSION=$g,hP.source.wms.createLoader=Kg,hP.source.wms.getFeatureInfoUrl=qg,hP.source.wms.getImageSrc=Yg,hP.source.wms.getLegendUrl=Jg,hP.source.wms.getRequestParams=Hg,hP.source.wms.getRequestUrl=Zg,hP.sphere={},hP.sphere.DEFAULT_RADIUS=je,hP.sphere.getArea=function t(e,i){const n=(i=i||{}).radius||je,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(Xe(o[0],n)),l=1,h=o.length;l - + - + @@ -229,9 +229,9 @@