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 T(){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&&E(r,i)||(n=this,i=r,e=t.apply(this,arguments)),e}}function F(t){return function(){let e;try{e=t()}catch(t){return Promise.reject(t)}return e instanceof Promise?e:Promise.resolve(e)}()}function M(t){for(const e in t)delete t[e]}function L(t){let e;for(e in t)return!1;return!e}class I{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 I(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),M(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){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){const i=this.array_;for(let n=0,r=i.length;nt)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){U()}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 class extends OffscreenCanvas{style={}}(t??300,e??150):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 wt(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 Et(){return new Proxy({childNodes:[],appendChild:function(t){return this.childNodes.push(t),t},remove:function(){},removeChild:function(t){const e=this.childNodes.indexOf(t);if(-1===e)throw new Error("Node to remove was not found");return this.childNodes.splice(e,1),t},insertBefore:function(t,e){const i=this.childNodes.indexOf(e);if(-1===i)throw new Error("Reference node not found");return this.childNodes.splice(i,0,t),t},style:{}},{get:(t,e,i)=>"firstElementChild"===e?t.childNodes.length>0?t.childNodes[0]:null:Reflect.get(t,e,i)})}function Ct(t){return"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas}function Tt(t){return t instanceof Image||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageBitmap?t:null}function Rt(t){return t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t instanceof DataView?t:null}const bt=new Error("disposed");let Pt=null;function Ft(t){Pt||(Pt=ft(t.width,t.height,void 0,{willReadFrequently:!0}));const e=Pt.canvas,i=t.width;e.width!==i&&(e.width=i);const n=t.height;return e.height!==n&&(e.height=n),Pt.clearRect(0,0,i,n),Pt.drawImage(t,0,0),Pt.getImageData(0,0,i,n).data}const Mt=[256,256];class Lt 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=Tt(this.data_);return t?[t.width,t.height]:Mt}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==Y&&this.state!==q)return;this.state=K,this.changed();const t=this;this.loader_().then((function(e){t.data_=e,t.state=H,t.changed()})).catch((function(e){t.error_=e,t.state=q,t.changed()}))}disposeInternal(){this.controller_&&(this.controller_.abort(bt),this.controller_=null),super.disposeInternal()}}function It(t,e){if(!t)throw new Error(e)}class At 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 At(this.hasProperties()?this.getProperties():null);t.setGeometryName(this.getGeometryName());const e=this.getGeometry();e&&t.setGeometry(e.clone());const i=this.getStyle();return i&&t.setStyle(i),t}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(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?Ot(t):void 0,this.changed()}setId(t){this.id_=t,this.changed()}setGeometryName(t){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=t,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}}function Ot(t){if("function"==typeof t)return t;let e;if(Array.isArray(t))e=t;else{It("function"==typeof t.getZIndex,"Expected an `ol/style/Style` or an array of `ol/style/Style.js`");e=[t]}return function(){return e}}var Dt=0,Nt=1,kt=2,Gt=4,jt=8,Ut=16;function Bt(t){const e=Kt();for(let i=0,n=t.length;ir&&(l|=Gt),as&&(l|=kt),l===Dt&&(l=Nt),l}function Kt(){return[1/0,1/0,-1/0,-1/0]}function Ht(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 qt(t){return Ht(1/0,1/0,-1/0,-1/0,t)}function Jt(t,e){const i=t[0],n=t[1];return Ht(i,n,i,n,e)}function Qt(t,e,i,n,r){return se(qt(r),t,e,i,n)}function te(t,e){return t[0]==e[0]&&t[2]==e[2]&&t[1]==e[1]&&t[3]==e[3]}function ee(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 ne(t,e){e[0]t[2]&&(t[2]=e[0]),e[1]t[3]&&(t[3]=e[1])}function re(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 we(t){return t[2]=o&&p<=l),n||!(s&Gt)||r&Gt||(_=g-(d-l)*f,n=_>=a&&_<=h),n||!(s&jt)||r&jt||(p=d-(g-a)/f,n=p>=o&&p<=l),n||!(s&Ut)||r&Ut||(_=g-(d-o)*f,n=_>=a&&_<=h)}return n}function Re(t,e,i,n){if(we(t))return qt(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=ve(i),r=Math.floor((n[0]-i[0])/e)*e;t[0]-=r,t[2]-=r}return t}function Pe(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]]];be(t,e);const r=ve(n);if(ve(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 Fe(t,e,i){return Math.min(Math.max(t,e),i)}function Me(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 Le(t,e,i,n)}function Le(t,e,i,n){const r=i-t,s=n-e;return r*r+s*s}function Ie(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 Ae(t){return 180*t/Math.PI}function Oe(t){return t*Math.PI/180}function De(t,e){const i=t%e;return i*e<0?i+e:i}function Ne(t,e,i){return t+i*(e-t)}function ke(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}function Ge(t,e){return Math.round(ke(t,e))}function je(t,e){return Math.floor(ke(t,e))}function Ue(t,e){return Math.ceil(ke(t,e))}function Be(t,e,i){if(t>=e&&tZe.warn||console.warn(...t)}function He(...t){Ye>Ze.error||console.error(...t)}function qe(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 Je(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 ti(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 ei(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 ii(t,e,i){const n=De(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=ke(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+=" "+qe(a,2)+"′"),0!==l&&(h+=" "+qe(l,2,s)+"″"),0!==n&&(h+=" "+t.charAt(n<0?1:0)),h}function ni(t,e,i){return t?e.replace("{x}",t[0].toFixed(i)).replace("{y}",t[1].toFixed(i)):""}function ri(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 si(t,e){const i=Math.cos(e),n=Math.sin(e),r=t[0]*i-t[1]*n,s=t[1]*i+t[0]*n;return t[0]=r,t[1]=s,t}function oi(t,e){return t[0]*=e,t[1]*=e,t}function ai(t,e){const i=t[0]-e[0],n=t[1]-e[1];return i*i+n*n}function li(t,e){return Math.sqrt(ai(t,e))}function hi(t,e){return ai(t,ei(t,e))}function ci(t,e){return ni(t,"{x}, {y}",e)}function ui(t,e){if(e.canWrapX()){const i=ve(e.getExtent()),n=di(t,e,i);n&&(t[0]-=n*i)}return t}function di(t,e,i){const n=e.getExtent();let r=0;return e.canWrapX()&&(t[0]n[2])&&(i=i||ve(n),r=Math.floor((t[0]-n[0])/i)),r}const gi={9001:"m",9002:"ft",9003:"us-ft",9101:"radians",9102:"degrees"};const fi={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class pi{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_||fi[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 _i=6378137,mi=Math.PI*_i,yi=[-mi,-mi,mi,mi],xi=[-180,-85,180,85],vi=_i*Math.log(Math.tan(Math.PI/2));class Si extends pi{constructor(t){super({code:t,units:"m",extent:yi,global:!0,worldExtent:xi,getPointResolution:function(t,e){return t/Math.cosh(e[1]/_i)}})}}const wi=[new Si("EPSG:3857"),new Si("EPSG:102100"),new Si("EPSG:102113"),new Si("EPSG:900913"),new Si("http://www.opengis.net/def/crs/EPSG/0/3857"),new Si("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;ivi?n=vi:n<-vi&&(n=-vi),e[i+1]=n}return e}function Ci(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=Oe(e),r=Math.sin(n),s=Math.cos(n),o=r/s,a=o*o,l=a*a,h=Oe(t),c=Oe(on(i.number)),u=nn/Math.sqrt(1-ji*r**2),d=zi*s**2,g=s*Be(h-c,-Math.PI,Math.PI),f=g*g,p=f*g,_=p*g,m=_*g,y=m*g,x=nn*(Ki*n-.002514607064228144*Math.sin(2*n)+Hi*Math.sin(4*n)-qi*Math.sin(6*n)),v=Gi*u*(g+p/6*(1-a+d)+m/120*(5-18*a+l+72*d-58*zi))+5e5;let S=Gi*(x+u*o*(f/2+_/24*(5-a+9*d+4*d**2)+y/720*(61-58*a+l+600*d-330*zi)));return i.north||(S+=1e7),[v,S]}function on(t){return 6*(t-1)-180+3}const an=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function ln(t){let e=0;for(const i of an){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 hn(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 Rn(t,e,i,n){const r=vn(t),s=vn(e);Ni(r,s,Tn(i)),Ni(s,r,Tn(n))}function bn(t,e){const i=In(t,void 0!==e?e:"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=De(n+180,360)-180),i}function Pn(t,e){if(t===e)return!0;const i=t.getUnits()===e.getUnits();if(t.getCode()===e.getCode())return i;return Fn(t,e)===_n&&i}function Fn(t,e){const i=t.getCode(),n=e.getCode();let r=ki(i,n);if(r)return r;let s=null,o=null;for(const i of dn)s||(s=i(t)),o||(o=i(e));if(!s&&!o)return null;const a="EPSG:4326";if(o)if(s)r=Mn(s.inverse,o.forward);else{const t=ki(i,a);t&&(r=Mn(t,o.forward))}else{const t=ki(a,n);t&&(r=Mn(s.inverse,t))}return r&&(yn(t),yn(e),Ni(t,e,r)),r}function Mn(t,e){return function(i,n,r,s){return n=t(i,n,r,s),e(n,n,r,s)}}function Ln(t,e){return Fn(vn(t),vn(e))}function In(t,e,i){const n=Ln(e,i);if(!n){const t=vn(e).getCode(),n=vn(i).getCode();throw new Error(`No transform available between ${t} and ${n}`)}return n(t,void 0,t.length)}function An(t,e,i,n){return Re(t,Ln(e,i),void 0,n)}let On=null;function Dn(t){On=vn(t)}function Nn(){return On}function kn(t,e){return On?In(t,e,On):t}function Gn(t,e){return On?In(t,On,e):(fn&&!ri(t,[0,0])&&t[0]>=-180&&t[0]<=180&&t[1]>=-90&&t[1]<=90&&(fn=!1,Ke("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),t)}function jn(t,e){return On?An(t,e,On):t}function Un(t,e){return On?An(t,On,e):t}function Bn(t,e){if(!On)return t;const i=vn(e).getMetersPerUnit(),n=On.getMetersPerUnit();return i&&n?t*i/n:t}function zn(t,e){if(!On)return t;const i=vn(e).getMetersPerUnit(),n=On.getMetersPerUnit();return i&&n?t*n/i:t}function Xn(t,e,i){return function(n){let r,s;if(t.canWrapX()){const e=t.getExtent(),o=ve(e);s=di(n=n.slice(0),t,o),s&&(n[0]=n[0]-s*o),n[0]=Fe(n[0],e[0],e[2]),n[1]=Fe(n[1],e[1],e[3]),r=i(n)}else r=i(n);return s&&e.canWrapX()&&(r[0]+=s*ve(e.getExtent())),r}}function Vn(){wn(wi),wn(Fi),En(Fi,wi,Ei,Ci)}Vn();const $n=new Array(6);function Wn(){return[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 Kn(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 Hn(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,i){return Zn(t,Yn($n,e,0,0,i,0,0))}function Jn(t,e,i){return Zn(t,Yn($n,1,0,0,1,e,i))}function Qn(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 tr(t,e){const i=er(e);It(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 er(t){return t[0]*t[3]-t[1]*t[2]}const ir=[1e5,1e5,1e5,1e5,2,2];function nr(t){return"matrix("+t.join(", ")+")"}function rr(t){return t.substring(7,t.length-1).split(",").map(parseFloat)}function sr(t,e){const i=rr(t),n=rr(e);for(let t=0;t<6;++t)if(0!==Math.round((i[t]-n[t])*ir[t]))return!1;return!0}function or(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 U()}closestPointXY(t,e,i,n){return U()}containsXY(t,e){return 0===this.closestPointXY(t,e,ur,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 U()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const t=this.computeExtent(this.extent_);(isNaN(t[0])||isNaN(t[1]))&&qt(t),this.extentRevision_=this.getRevision()}return Ee(this.extent_,t)}rotate(t,e){U()}scale(t,e,i){U()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return U()}getType(){return U()}applyTransform(t){U()}intersectsExtent(t){return U()}translate(t,e){U()}transform(t,e){const i=vn(t),n="tile-pixels"==i.getUnits()?function(t,n,r){const s=i.getExtent(),o=i.getWorldExtent(),a=_e(o)/_e(s);Qn(cr,o[0],o[3],a,-a,0,0,0);const l=or(t,0,t.length,r,cr,n),h=Ln(i,e);return h?h(l,l,r):l}:Ln(i,e);return this.applyTransform(n),this}}class gr extends dr{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 U()}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 kr(t,e){return e*Math.round(t/e)}function Gr(t,e,i,n,r,s,o){if(e==i)return o;let a,l,h=kr(t[e],r),c=kr(t[e+1],r);e+=n,s[o++]=h,s[o++]=c;do{if(a=kr(t[e],r),l=kr(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 $r(t,e,i,n,r,s){if(0===i.length)return!1;if(!Vr(t,e,i[0],n,r,s))return!1;for(let e=1,o=i.length;em&&(h=(c+u)/2,$r(t,e,i,n,h,f)&&(_=h,m=r)),c=u}return isNaN(_)&&(_=r[s]),o?(o.push(_,f,m),o):[_,f,m]}function Yr(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 Te(r,t,e)})))}function Jr(t,e,i,n,r){for(let s=0,o=i.length;s0}function rs(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=Ps})).catch((t=>{this.state=Fs,console.error(t)})).finally((()=>this.changed()))}}setImage(t){this.image_=t}setResolution(t){this.resolution=t}}function Is(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 As(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 Os(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))))):As(t)}function Ds(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})):Os(t)}class Ns extends Ls{constructor(t,e,i,n,r){super(t,e,i,void 0!==r?Rs:Ps),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=Ps,this.changed()}load(){this.state==Rs&&(this.state=bs,this.changed(),this.loader_(this.handleLoad_.bind(this)))}getImage(){return this.canvas_}}class ks extends nt{constructor(t,e,i,n,r,s){super(t,e,s),this.crossOrigin_=n,this.src_=i,this.key=i,this.image_,ct?this.image_=new OffscreenCanvas(1,1):(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=H,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}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_(){if(ct)this.state=H;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=H: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=K,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Is(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 Gs{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 I{constructor(t,e,i){super(t),this.map=e,this.frameState=void 0!==i?i:null}}class Us 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 Bs={SINGLECLICK:"singleclick",CLICK:o,DBLCLICK:a,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},zs="pointermove",Xs="pointerdown",Vs="pointerup",$s="pointerout";class Ws 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,Xs,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=D(i,zs,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(f,this.boundHandleTouchMove_,!!gt&&{passive:!1})}emulateClick_(t){let e=new Us(Bs.CLICK,this.map_,t);this.dispatchEvent(e),void 0!==this.clickTimeoutId_?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new Us(Bs.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout((()=>{this.clickTimeoutId_=void 0;const e=new Us(Bs.SINGLECLICK,this.map_,t);this.dispatchEvent(e)}),250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==Bs.POINTERUP||e.type==Bs.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!=Bs.POINTERDOWN&&e.type!=Bs.POINTERMOVE||(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new Us(Bs.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 Us(Bs.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,Bs.POINTERMOVE,this.handlePointerMove_,this),D(t,Bs.POINTERUP,this.handlePointerUp_,this),D(this.element_,Bs.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==t&&this.dragListenerKeys_.push(D(this.element_.getRootNode(),Bs.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new Us(Bs.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 Us(Bs.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 Zs="postrender",Ys="movestart",Ks="moveend",Hs="loadstart",qs="loadend",Js="layergroup",Qs="size",to="target",eo="view";const io=1/0;class no{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,M(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){It(!(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!=io&&(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===H||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 so(t,e,i,n,r){if(!t||!(i in t.wantedTiles))return io;if(!t.wantedTiles[i][e.getKey()])return io;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 oo=0,ao=1,lo={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function ho(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 _=Fe(n[0],d,g),m=Fe(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 co(t){return t}function uo(t,e,i,n){const r=ve(e)/i[0],s=_e(e)/i[1];return n?Math.min(t,Math.max(r,s)):Math.min(t,Math.min(r,s))}function go(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),Fe(n,i/2,2*e)}function fo(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?uo(l,i,o,n):l;if(a)return e?go(r,c,h):Fe(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_[ao]>0}cancelAnimations(){let t;this.setHint(oo,-this.hints_[oo]);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?De(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(oo,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const t=n[0].callback;t&&Eo(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]],si(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?kn(t,this.getProjection()):t}getCenterInternal(){return this.get(lo.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 jn(this.calculateExtentInternal(t),this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();It(e,"The view center is not defined");const i=this.getResolution();It(void 0!==i,"The view resolution is not defined");const n=this.getRotation();return It(void 0!==n,"The view rotation is not defined"),fe(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(lo.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=ve(t)/e[0],n=_e(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(lo.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=Po(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=Fe(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,Fe(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(It(Array.isArray(t)||"function"==typeof t.getSimplifiedGeometry,"Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){It(!we(t),"Cannot fit empty extent provided as `geometry`");i=us(Un(t,this.getProjection()))}else if("Circle"===t.getType()){const e=Un(t.getExtent(),this.getProjection());i=us(e),i.rotate(this.getRotation(),de(e))}else{const e=Nn();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;tt.trim().replace(/^['"]|['"]$/g,""))),i};class jo extends V{constructor(t){super();const e=t.element;!e||t.target||e.style.pointerEvents||(e.style.pointerEvents="auto"),this.element=e||null,this.target_=null,this.map_=null,this.listenerKeys=[],t.render&&(this.render=t.render),t.target&&this.setTarget(t.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(t){this.map_&&this.element?.remove();for(let t=0,e=this.listenerKeys.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=>F((()=>t))))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!E(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 jo{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+" "+Ao,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 Uo(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==Bs.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 Ko(t){const e=arguments;return function(t){let i=!0;for(let n=0,r=e.length;n0}}else if(t.type==Bs.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==Bs.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===mo)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 hs([i])}getGeometry(){return this.geometry_}}const pa="boxstart",_a="boxdrag",ma="boxend",ya="boxcancel";class xa extends I{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 wa="ArrowLeft",Ea="ArrowUp",Ca="ArrowRight",Ta="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==Ta||n==wa||n==Ca||n==Ea)){const r=t.map.getView(),s=r.getResolution()*this.pixelDelta_;let o=0,a=0;n==Ta?a=-s:n==wa?o=-s:n==Ca?o=s:a=s;const l=[o,a];si(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?Ko(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;i.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let n=i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_LINE:n*=40;break;case WheelEvent.DOM_DELTA_PAGE:n*=300}if(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=-Fe(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 Fa 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!==mo&&(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 Ma 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 La(t){t=t||{};const e=new Z,i=new Gs(-.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 Fa);(void 0===t.pinchZoom||t.pinchZoom)&&e.push(new Ma({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 Ia="opacity",Aa="visible",Oa="extent",Da="zIndex",Na="maxResolution",ka="minResolution",Ga="maxZoom",ja="minZoom",Ua="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[Ia]=void 0!==t.opacity?t.opacity:1,It("number"==typeof e[Ia],"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[ja]=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=Fe(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 U()}getLayerStatesArray(t){return U()}getExtent(){return this.get(Oa)}getMaxResolution(){return this.get(Na)}getMinResolution(){return this.get(ka)}getMinZoom(){return this.get(ja)}getMaxZoom(){return this.get(Ga)}getOpacity(){return this.get(Ia)}getSourceState(){return U()}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(ja,t)}setOpacity(t){It("number"==typeof t,"Layer opacity must be a number"),this.set(Ia,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()}}const Xa="addlayer",Va="removelayer";class $a extends I{constructor(t,e){super(t),this.layer=e}}const Wa="layers";class Za 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(Wa,this.handleLayersChanged_),i?Array.isArray(i)?i=new Z(i.slice(),{unique:!0}):It("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);M(this.listenerKeys_);const n=i.getArray();for(let t=0,e=n.length;t{this.dispatchEvent("sourceready")}),0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return this.renderer_&&this.rendered?this.renderer_.getData(t):null}isVisible(t){let e;const i=this.getMapInternal();let n;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 tl(n,e.viewState)&&(!r||Se(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,Ha,this.handlePrecompose_,this),this.mapRenderKey_=D(this,n,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);It(!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(Ua,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 tl(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 el(t,e,i=0,n=t.length-1,r=nl){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);el(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(il(t,i,e),r(t[n],s)>0&&il(t,i,n);o0;)a--}0===r(t[i],s)?il(t,i,a):(a++,il(t,a,n)),a<=e&&(i=a+1),e<=a&&(n=a-1)}}function il(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function nl(t,e){return te?1:0}let rl=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(!pl(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=_l(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,ol(i,this.toBBox),ol(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)}_splitRoot(t,e){this.data=_l([t,e]),this.data.height=t.height+1,this.data.leaf=!1,ol(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=al(t,0,o,this.toBBox),a=al(t,o,i,this.toBBox),l=gl(e,a),h=ul(e)+ul(a);l=e;n--){const e=t.children[n];ll(o,t.leaf?r(e):e),a+=dl(o)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)ll(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():ol(t[i],this.toBBox)}};function sl(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n=t.minX&&e.maxY>=t.minY}function _l(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ml(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;el(t,o,e,i,r),s.push(e,o,o,i)}}const yl=[NaN,NaN,NaN,0];let xl;const vl=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Sl=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,wl=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,El=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function Cl(t,e){return t.endsWith("%")?Number(t.substring(0,t.length-1))/e:Number(t)}function Tl(t){throw new Error('failed to parse "'+t+'" as color')}function Rl(t){if(t.toLowerCase().startsWith("rgb")){const e=t.match(Sl)||t.match(vl)||t.match(wl);if(e){const t=e[4],i=100/255;return[Fe(Cl(e[1],i)+.5|0,0,255),Fe(Cl(e[2],i)+.5|0,0,255),Fe(Cl(e[3],i)+.5|0,0,255),void 0!==t?Fe(Cl(t,100),0,1):1]}Tl(t)}if(t.startsWith("#")){if(El.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 Il(t){return t>.2068965?Math.pow(t,3):108/841*(t-4/29)}function Al(t){return t>10.314724?Math.pow((t+14.025)/269.025,2.4):t/3294.6}function Ol(t){return t>.0088564?Math.pow(t,1/3):t/(108/841)+4/29}function Dl(t){const e=Al(t[0]),i=Al(t[1]),n=Al(t[2]),r=Ol(.222488403*e+.716873169*i+.06060791*n),s=500*(Ol(.452247074*e+.399439023*i+.148375274*n)-r),o=200*(r-Ol(.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 Nl(t){const e=(t[0]+16)/116,i=t[1],n=t[2]*Math.PI/180,r=Il(e),s=Il(e+i/500*Math.cos(n)),o=Il(e-i/200*Math.sin(n)),a=Ll(3.021973625*s-1.617392459*r-.404875592*o),l=Ll(-.943766287*s+1.916279586*r+.027607165*o),h=Ll(.069407491*s-.22898585*r+1.159737864*o);return[Fe(a+.5|0,0,255),Fe(l+.5|0,0,255),Fe(h+.5|0,0,255),t[3]]}function kl(t){if("none"===t)return yl;if(Pl.hasOwnProperty(t))return Pl[t];if(Fl>=1024){let t=0;for(const e in Pl)3&t++||(delete Pl[e],--Fl)}const e=Rl(t);4!==e.length&&Tl(t);for(const i of e)isNaN(i)&&Tl(t);return Pl[t]=e,++Fl,e}function Gl(t){return Array.isArray(t)?t:kl(t)}function jl(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 Ul(t){return t[0]>0&&t[1]>0}function Bl(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 zl(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}let Xl=0;const Vl=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"},ah={[oh.Get]:ph(uh(1,1/0),lh),[oh.Var]:ph(uh(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 ih(Wl,n)]})),[oh.Has]:ph(uh(1,1/0),lh),[oh.Id]:ph((function(t,e,i){i.featureId=!0}),ch),[oh.Concat]:ph(uh(2,1/0),gh(Wl)),[oh.GeometryType]:ph((function(t,e,i){i.geometryType=!0}),ch),[oh.LineMetric]:ph(ch),[oh.Resolution]:ph(hh,ch),[oh.Zoom]:ph(hh,ch),[oh.Time]:ph(hh,ch),[oh.Any]:ph(uh(2,1/0),gh(Vl)),[oh.All]:ph(uh(2,1/0),gh(Vl)),[oh.Not]:ph(uh(1,1),gh(Vl)),[oh.Equal]:ph(uh(2,2),gh(Hl)),[oh.NotEqual]:ph(uh(2,2),gh(Hl)),[oh.GreaterThan]:ph(uh(2,2),gh($l)),[oh.GreaterThanOrEqualTo]:ph(uh(2,2),gh($l)),[oh.LessThan]:ph(uh(2,2),gh($l)),[oh.LessThanOrEqualTo]:ph(uh(2,2),gh($l)),[oh.Multiply]:ph(uh(2,1/0),dh),[oh.Coalesce]:ph(uh(2,1/0),dh),[oh.Divide]:ph(uh(2,2),gh($l)),[oh.Add]:ph(uh(2,1/0),gh($l)),[oh.Subtract]:ph(uh(2,2),gh($l)),[oh.Clamp]:ph(uh(3,3),gh($l)),[oh.Mod]:ph(uh(2,2),gh($l)),[oh.Pow]:ph(uh(2,2),gh($l)),[oh.Abs]:ph(uh(1,1),gh($l)),[oh.Floor]:ph(uh(1,1),gh($l)),[oh.Ceil]:ph(uh(1,1),gh($l)),[oh.Round]:ph(uh(1,1),gh($l)),[oh.Sin]:ph(uh(1,1),gh($l)),[oh.Cos]:ph(uh(1,1),gh($l)),[oh.Atan]:ph(uh(1,2),gh($l)),[oh.Sqrt]:ph(uh(1,1),gh($l)),[oh.Match]:ph(uh(4,1/0),fh,(function(t,e,i){const n=t.length-1,r=Wl|$l|Vl,s=sh(t[1],r,i),o=sh(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 dh(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 oh.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 oh.GeometryType:return t=>t.geometryType;case oh.Concat:{const e=t.args.map((t=>xh(t)));return t=>"".concat(...e.map((e=>e(t).toString())))}case oh.Resolution:return t=>t.resolution;case oh.Any:case oh.All:case oh.Between:case oh.In:case oh.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 oh.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 oh.Equal:case oh.NotEqual:case oh.LessThan:case oh.LessThanOrEqualTo:case oh.GreaterThan:case oh.GreaterThanOrEqualTo:return function(t){const e=t.operator,i=xh(t.args[0]),n=xh(t.args[1]);switch(e){case oh.Equal:return t=>i(t)===n(t);case oh.NotEqual:return t=>i(t)!==n(t);case oh.LessThan:return t=>i(t)i(t)<=n(t);case oh.GreaterThan:return t=>i(t)>n(t);case oh.GreaterThanOrEqualTo:return t=>i(t)>=n(t);default:throw new Error(`Unsupported comparison operator ${e}`)}}(t);case oh.Multiply:case oh.Divide:case oh.Add:case oh.Subtract:case oh.Clamp:case oh.Mod:case oh.Pow:case oh.Abs:case oh.Floor:case oh.Ceil:case oh.Round:case oh.Sin:case oh.Cos:case oh.Atan:case oh.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 oh.Add:return t=>{let e=0;for(let r=0;rn[0](t)-n[1](t);case oh.Clamp:return t=>{const e=n[0](t),i=n[1](t);if(er?r:e};case oh.Mod:return t=>n[0](t)%n[1](t);case oh.Pow:return t=>Math.pow(n[0](t),n[1](t));case oh.Abs:return t=>Math.abs(n[0](t));case oh.Floor:return t=>Math.floor(n[0](t));case oh.Ceil:return t=>Math.ceil(n[0](t));case oh.Round:return t=>Math.round(n[0](t));case oh.Sin:return t=>Math.sin(n[0](t));case oh.Cos:return t=>Math.cos(n[0](t));case oh.Atan:return 2===i?t=>Math.atan2(n[0](t),n[1](t)):t=>Math.atan(n[0](t));case oh.Sqrt:return t=>Math.sqrt(n[0](t));default:throw new Error(`Unsupported numeric operator ${e}`)}}(t);case oh.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?Sh(n,r,s,o,e,l):vh(n,r,s,o,e,l);s=e,o=l}return o}}(t);case oh.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===Zl?jl(i):i.toString()};throw new Error(`Unsupported convert operator ${e}`)}(t);default:throw new Error(`Unsupported operator ${i}`)}}function vh(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 Sh(t,e,i,n,r,s){if(0===r-i)return n;const o=Dl(n),a=Dl(s);let l=a[2]-o[2];l>180?l-=360:l<-180&&(l+=360);return Nl([vh(t,e,i,o[0],r,a[0]),vh(t,e,i,o[1],r,a[1]),o[2]+vh(t,e,i,0,r,l),vh(t,e,i,n[3],r,s[3])])}class wh{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=Eh(t,e,i);return n in this.cache_?this.cache_[n]:null}getPattern(t,e,i){const n=Eh(t,e,i);return n in this.patternCache_?this.patternCache_[n]:null}set(t,e,i,n,r){const s=Eh(t,e,i),o=s in this.cache_;this.cache_[s]=n,r&&(n.getImageState()===Rs&&n.load(),n.getImageState()===bs?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 Eh(t,e,i){return e+":"+t+":"+(i?Gl(i):"null")}const Ch=new wh;let Th=null;class Rh 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?Rs: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_===Ps){Th||(Th=ft(1,1,void 0,{willReadFrequently:!0})),Th.drawImage(this.image_,0,0);try{Th.getImageData(0,0,1,1),this.tainted_=!1}catch{Th=null,this.tainted_=!0}}return!0===this.tainted_}dispatchChangeEvent_(){this.dispatchEvent(n)}handleImageError_(){this.imageState_=Fs,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Ps,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_===Rs){this.image_||this.initializeImage_(),this.imageState_=bs;try{void 0!==this.src_&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Os(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_!==Ps)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=bl(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_===Ps||this.imageState_===Fs)t();else{const e=()=>{this.imageState_!==Ps&&this.imageState_!==Fs||(this.removeEventListener(n,e),t())};this.addEventListener(n,e)}}))),this.ready_}}function bh(t,e,i,n,r,s){let o=void 0===e?void 0:Ch.get(e,i,r);return o||(o=new Rh(t,t&&"src"in t?t.src||void 0:e,i,n,r),Ch.set(e,i,r,o,s)),s&&o&&!Ch.getPattern(e,i,r)&&Ch.set(e,i,r,o,s),o}function Ph(t){return t?Array.isArray(t)?jl(t):"object"==typeof t&&"src"in t?function(t){if(!t.offset||!t.size)return Ch.getPattern(t.src,"anonymous",t.color);const e=t.src+":"+t.offset,i=Ch.getPattern(e,void 0,t.color);if(i)return i;const n=Ch.get(t.src,"anonymous",null);if(n.getImageState()!==Ps)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]),bh(r.canvas,e,void 0,Ps,t.color,!0),Ch.getPattern(e,void 0,t.color)}(t):t:null}const Fh="10px sans-serif",Mh="#000",Lh="round",Ih=[],Ah="round",Oh=10,Dh="#000",Nh="center",kh="middle",Gh=[0,0,0,0],jh=new V;let Uh,Bh=null;const zh={},Xh=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Vh(t,e,i){return`${t} ${e} 16px "${i}"`}const $h=function(){const t=100;let e,i;async function n(t){await i.ready;const e=await i.load(t);if(0===e.length)return!1;const n=Go(t),r=n.families[0].toLowerCase(),s=n.weight;return e.some((t=>{const e=t.family.replace(/^['"]|['"]$/g,"").toLowerCase(),i=ko[t.weight]||t.weight;return e===r&&t.style===n.style&&i==s}))}async function r(){await i.ready;let s=!0;const o=jh.getProperties(),a=Object.keys(o).filter((e=>o[e]=0;--e){const i=a[e];let r=o[i];rMath.max(e,Yh(t,i))),0);return i[e]=n,n}function Hh(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=Yh(d,u);i.push(g),o+=g;const f=Wh(d);n.push(f),l=Math.max(l,f)}return{width:s,height:a,widths:i,heights:n,lineWidths:r}}function qh(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_=Ps)),this.render()}clone(){const t=this.getScale(),e=new Qh({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=Ch.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,Ch.set(i,null,null,new Rh(n,void 0,null,Ps,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()===Rs&&e.load(),e.getImageState()===bs&&(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:Gl(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function ic(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 nc extends Jh{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(It(!(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)),It(void 0!==a&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),It(!((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=Rs:void 0!==s&&(o="complete"in s?s.complete?s.src?Ps:Rs:bs:Ps),this.color_=void 0!==t.color?Gl(t.color):null,this.iconImage_=bh(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(ic(i[0],i[1],t.width,t.height))};return void this.listenImageChange(e)}}void 0!==e&&this.setScale(ic(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 nc({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()}setSrc(t){this.iconImage_=bh(null,t,this.crossOrigin_,Rs,this.color_)}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()==Ps?this.iconImage_.getSize()[0]*t[0]:void 0}getHeight(){const t=this.getScaleArray();return this.size_?this.size_[1]*t[1]:this.iconImage_.getImageState()==Ps?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 rc{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 rc({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 sc{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=cc,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 sc({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_=cc,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function oc(t){let e;if("function"==typeof t)e=t;else{let i;if(Array.isArray(t))i=t;else{It("function"==typeof t.getZIndex,"Expected an `Style` or an array of `Style`");i=[t]}e=function(){return i}}return e}let ac=null;function lc(t,e){if(!ac){const t=new ec({color:"rgba(255,255,255,0.4)"}),e=new rc({color:"#3399CC",width:1.25});ac=[new sc({image:new tc({fill:t,stroke:e,radius:5}),fill:t,stroke:e})]}return ac}function hc(){const t={},e=[255,255,255,1],i=[0,153,255,1];return t.Polygon=[new sc({fill:new ec({color:[255,255,255,.5]})})],t.MultiPolygon=t.Polygon,t.LineString=[new sc({stroke:new rc({color:e,width:5})}),new sc({stroke:new rc({color:i,width:3})})],t.MultiLineString=t.LineString,t.Circle=t.Polygon.concat(t.LineString),t.Point=[new sc({image:new tc({radius:6,fill:new ec({color:i}),stroke:new rc({color:e,width:1.5})}),zIndex:1/0})],t.MultiPoint=t.Point,t.GeometryCollection=t.Polygon.concat(t.LineString,t.Point),t}function cc(t){return t.getGeometry()}class uc{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_=zl(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 ec({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 uc({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()instanceof ec?this.getFill().clone():this.getFill(),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_=zl(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 dc(t){return!0}function gc(t){const e=rh(),i=pc(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=_h(t.getGeometry())),i(n)}}function fc(t){const e=rh(),i=t.length,n=new Array(i);for(let r=0;rnull;n=wc(t,e+"fill-color",i)}if(!n)return null;const r=new ec;return function(t){const e=n(t);return e===yl?null:(r.setColor(e),r)}}function yc(t,e,i){const n=xc(t,e+"stroke-width",i),r=wc(t,e+"stroke-color",i);if(!n&&!r)return null;const s=vc(t,e+"stroke-line-cap",i),o=vc(t,e+"stroke-line-join",i),a=Ec(t,e+"stroke-line-dash",i),l=xc(t,e+"stroke-line-dash-offset",i),h=xc(t,e+"stroke-miter-limit",i),c=new rc;return function(t){if(r){const e=r(t);if(e===yl)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 xc(t,e,i){if(!(e in t))return;const n=yh(t[e],$l,i);return function(t){return Ac(n(t),e)}}function vc(t,e,i){if(!(e in t))return null;const n=yh(t[e],Wl,i);return function(t){return Ic(n(t),e)}}function Sc(t,e,i){if(!(e in t))return null;const n=yh(t[e],Vl,i);return function(t){const i=n(t);if("boolean"!=typeof i)throw new Error(`Expected a boolean for ${e}`);return i}}function wc(t,e,i){if(!(e in t))return null;const n=yh(t[e],Zl,i);return function(t){return Oc(n(t),e)}}function Ec(t,e,i){if(!(e in t))return null;const n=yh(t[e],Yl,i);return function(t){return Lc(n(t),e)}}function Cc(t,e,i){if(!(e in t))return null;const n=yh(t[e],Yl,i);return function(t){const i=Lc(n(t),e);if(2!==i.length)throw new Error(`Expected two numbers for ${e}`);return i}}function Tc(t,e,i){if(!(e in t))return null;const n=yh(t[e],Yl,i);return function(t){return Dc(n(t),e)}}function Rc(t,e,i){if(!(e in t))return null;const n=yh(t[e],Yl|$l,i);return function(t){return function(t,e){if("number"==typeof t)return t;return Dc(t,e)}(n(t),e)}}function bc(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 Pc(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 Fc(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 Mc(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 Lc(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 Dc(t,e){const i=Lc(t,e);if(2!==i.length)throw new Error(`Expected an array of two numbers for ${e}`);return i}const Nc="renderOrder";class kc 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(Nc)}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 rl(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(Nc,t)}setStyle(t){this.style_=void 0===t?lc:t;const e=function(t){if(void 0===t)return lc;if(!t)return null;if("function"==typeof t)return t;if(t instanceof sc)return t;if(!Array.isArray(t))return fc([t]);if(0===t.length)return[];const e=t.length,i=t[0];if(i instanceof sc){const i=new Array(e);for(let n=0;n=0;--r){const s=f[r],u=s.layer;if(u.hasRenderer()&&tl(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,T,this,r,s)}getMap(){return this.map_}renderFrame(t){U()}scheduleExpireIconCache(t){Ch.canExpireCache()&&t.postRenderFunctions.push(Uc)}}function Uc(t,e){Ch.expire()}class Bc extends jc{constructor(t){super(t),this.fontChangeListenerKey_=D(jh,i,t.redrawText,t),this.element_=ct?Et():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&&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 Gc(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(Ha,t);const e=t.layerStatesArray.sort(((t,e)=>t.zIndex-e.zIndex));e.some((t=>t.layer instanceof kc&&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;s0)&&(t.fillStyle=n,t.fillRect(0,0,s.width,s.height)),Ct(i)&&i.width>0){const n=e.style.opacity||i.style.opacity;t.globalAlpha=""===n?1:Number(n);const r=i.style.transform;if(r)t.setTransform(...rr(r));else{const e=parseFloat(i.style.width)/i.width,n=parseFloat(i.style.height)/i.height;t.setTransform(e,0,0,n,0,0)}t.drawImage(i,0,0)}}t.globalAlpha=1,t.setTransform(1,0,0,1,0,0)}this.dispatchRenderEvent(qa,t),this.renderedVisible_||(this.element_.style.display="",this.renderedVisible_=!0),this.scheduleExpireIconCache(t)}declutter(t,e){if(t.declutter){for(let i=e.length-1;i>=0;--i){const n=e[i],r=n.layer;r.getDeclutter()&&r.renderDeclutter(t,n)}e.forEach((e=>e.layer.renderDeferred(t)))}}}function zc(t){t instanceof Qa?t.setMapInternal(null):t instanceof Za&&t.getLayers().forEach(zc)}function Xc(t,e){if(t instanceof Qa)t.setMapInternal(e);else if(t instanceof Za){const i=t.getLayers().getArray();for(let t=0,n=i.length;tthis.updateSize()))),this.controls=n.controls||(ct?new Z:Xo()),this.interactions=n.interactions||(ct?new Z:La({onFocusOnly:!0})),this.overlays_=n.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new ro(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Js,this.handleLayerGroupChanged_),this.addChangeListener(eo,this.handleViewChanged_),this.addChangeListener(Qs,this.handleSizeChanged_),this.addChangeListener(to,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){Xc(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:T,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 Za?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:T,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(to)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return kn(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?Hn(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(Js)}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[oo]||e[ao]){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 $a("removelayer",e)),this.set(Js,t)}setSize(t){this.set(Qs,t)}setTarget(t){this.set(to,t)}setView(t){if(!t||t instanceof wo)return void this.set(eo,t);this.set(eo,new wo);const e=this;t.then((function(t){e.setView(new wo(t))}))}updateSize(){const t=this.getTargetElement();let e;if(t){let i,n;if(Ct(t))i=t.width,n=t.height;else{const e=getComputedStyle(t);i=t.offsetWidth-parseFloat(e.borderLeftWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)-parseFloat(e.borderRightWidth),n=t.offsetHeight-parseFloat(e.borderTopWidth)-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)-parseFloat(e.borderBottomWidth)}isNaN(i)||isNaN(n)||(e=[Math.max(0,i),Math.max(0,n)],!Ul(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Ke("No map visible because the map container's width or height are 0."))}const i=this.getSize();!e||i&&E(e,i)||(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}};const $c="element",Wc="map",Zc="offset",Yc="position",Kc="positioning";class Hc 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($c,this.handleElementChanged),this.addChangeListener(Wc,this.handleMapChanged),this.addChangeListener(Zc,this.handleOffsetChanged),this.addChangeListener(Yc,this.handlePositionChanged),this.addChangeListener(Kc,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($c)}getId(){return this.id}getMap(){return this.get(Wc)||null}getOffset(){return this.get(Zc)}getPosition(){return this.get(Yc)}getPositioning(){return this.get(Kc)}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,Zs,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($c,t)}setMap(t){this.set(Wc,t)}setOffset(t){this.set(Zc,t)}setPosition(t){this.set(Yc,t)}performAutoPan(){this.autoPan&&this.panIntoView(this.autoPan)}panIntoView(t){const e=this.getMap();if(!e||!e.getTargetElement()||!this.get(Yc))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(!Wt(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(Kc,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(${`${t[0]+n[0]}px`}, ${`${t[1]+n[1]}px`})`;this.rendered.transform_!=a&&(this.rendered.transform_=a,i.transform=a)}getOptions(){return this.options}}class qc{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 Jc(t,e,i,n,r){return void 0!==r?(r.minX=t,r.maxX=e,r.minY=i,r.maxY=n,r):new qc(t,e,i,n)}const Qc=[];let tu,eu=!1;function iu(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=eu,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 nu(t,e){return function(i,n,r,s,o){iu(t,e,i,n,r,((t,e)=>{this.addFeatures(t),void 0!==s&&s(t)}),(()=>{this.changed(),void 0!==o&&o()}))}}function ru(t,e){return[[-1/0,-1/0,1/0,1/0]]}function su(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 ou extends Error{constructor(t){super("Unexpected response status: "+t.status),this.name="ResponseError",this.response=t}}class au extends Error{constructor(t){super("Failed to issue request"),this.name="ClientError",this.client=t}}function lu(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 ou(n))})),n.addEventListener("error",(function(t){i(new au(t.target))})),n.open("GET",t),n.setRequestHeader("Accept","application/json"),n.send()}))}function hu(t,e){return e.includes("://")?e:new URL(e,t).href}class cu{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 uu extends cu{constructor(t,e,i,n,r,s,o){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?ke(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=or(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:Ah,lineWidth:(void 0!==o?o:1)*this.pixelRatio_,miterLimit:void 0!==a?a:Oh,strokeStyle:Ph(t||Dh)}}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:Ph(t||Mh)}}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:Lh,lineDash:n||Ih,lineDashOffset:r||0,lineJoin:void 0!==s?s:Ah,lineWidth:void 0!==o?o:1,miterLimit:void 0!==a?a:Oh,strokeStyle:Ph(t||Dh)}}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:Fh,textAlign:void 0!==c?c:Nh,textBaseline:void 0!==u?u:kh},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 du={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()!=Ps)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()!=Ps)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)mu(t,l,i,e,o);else{(0,du[l.getType()])(t,l,i,e,o,s)}}(t,e,i,n,s,o,a),u}function mu(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 Eu(t,e,i,n){const r=In(i,e,t);let s=Sn(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||$t(l,r)){const e=Sn(t,s,r)/s;isFinite(e)&&e>0&&(s/=e)}return s}function Cu(t,e,i,n){const r=de(i);let s=Eu(t,e,r,n);return(!isFinite(s)||s<=0)&&le(i,(function(i){return s=Eu(t,e,i,n),isFinite(s)&&s>0})),s}function Tu(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),vu);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){ie(_,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(ve(_)*y),Math.round(_e(_)*y),vu),u||(m.imageSmoothingEnabled=!1),r&&g){const t=(r[0]-_[0])*y,e=-(r[3]-_[3])*y,i=ve(r)*y,n=_e(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=ve(t.clipExtent)*y,r=_e(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=ve(t.extent)*y,r=_e(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=ye(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),w=p((r[1][0]-v[0])/s),E=p(-(r[1][1]-v[1])/s),C=p((r[2][0]-v[0])/s),T=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=Ie([[h,c,0,0,w-y],[d,g,0,0,C-y],[0,0,h,c,E-S],[0,0,d,g,T-S]]);if(!P)return;if(f.save(),f.beginPath(),function(){if(void 0===xu){const t=ft(6,6,vu);t.globalCompositeOperation="lighter",t.fillStyle="rgba(210, 0, 0, 0.75)",Su(t,4,5,4,0),Su(t,4,5,0,5);const e=t.getImageData(0,0,3,3).data;xu=wu(e,0)||wu(e,4)||wu(e,8),mt(t),vu.push(t.canvas)}return xu}()||!u){f.moveTo(w,E);const t=4,e=y-w,i=S-E;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 It(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 It(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){It(!(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 Pu(t,e,i,n){return void 0!==n?(n[0]=t,n[1]=e,n[2]=i,n):[t,e,i]}function Fu(t,e,i){return t+"/"+e+"/"+i}function Mu(t,e,i,n,r){return`${z(t)},${e},${Fu(i,n,r)}`}function Lu(t){return Iu(t[0],t[1],t[2])}function Iu(t,e,i){return(e<i||i>e.getMaxZoom())return!1;const s=e.getFullTileRange(i);return!s||s.containsXY(n,r)}const Ou=[0,0,0];class Du{constructor(t){let e;if(this.minZoom=void 0!==t.minZoom?t.minZoom:0,this.resolutions_=t.resolutions,It(C(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 qc(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=Jc(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 Nu({extent:e,origins:s,resolutions:n,matrixIds:r,tileSizes:o,sizes:a})}function Gu(t){let e=t.getDefaultTileGrid();return e||(e=Xu(t),t.setDefaultTileGrid(e)),e}function ju(t,e,i){const n=e[0],r=t.getTileCoordCenter(e),s=Vu(i);if(!$t(s,r)){const e=ve(s),i=Math.ceil((s[0]-r[0])/e);return r[0]+=e*i,t.getTileCoordForCoordAndZ(r,n)}return e}function Uu(t,e,i,n){n=void 0!==n?n:"top-left";const r=zu(t,e,i);return new Du({extent:t,origin:ge(t,n),resolutions:r,tileSize:i})}function Bu(t){const e=t||{},i=e.extent||vn("EPSG:3857").getExtent(),n={extent:i,minZoom:e.minZoom,tileSize:e.tileSize,resolutions:zu(i,e.maxZoom,e.tileSize,e.maxResolution)};return new Du(n)}function zu(t,e,i,n){e=void 0!==e?e:42,i=zl(void 0!==i?i:So);const r=_e(t),s=ve(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;tHn(o,In(t,this.targetProj_,this.sourceProj_)))):Ln(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()&&ve(n)>=ve(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ve(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ve(this.targetProj_.getExtent()):null;const h=ye(i),c=xe(i),u=ue(i),d=ce(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(he(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=ve(Bt([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])&&!Se(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=(De(r[0],u)+De(o[0],u))/2-De(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;ne(t,r[0]),ne(t,r[1]),ne(t,r[2])})),t}getTriangles(){return this.triangles_}}const rd=.5;class sd 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?me(d,g):d;if(0===he(p))return void(this.state=J);const _=t.getExtent();_&&(f=f?me(f,_):_);const m=n.getResolution(this.wrappedTileCoord_[0]),y=Cu(t,i,p,m);if(!isFinite(y)||y<=0)return void(this.state=J);const x=void 0!==h?h:rd;if(this.triangulation_=new nd(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]=Fe(v[1],f[1],f[3]),v[3]=Fe(v[3],f[1],f[3])):v=me(v,f)),he(v)){let i=0,n=0;t.canWrapX()&&(i=ve(_),n=Math.floor((v[0]-_[0])/i));Pe(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()==H){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_=Tu(n,r,this.pixelRatio_,o,this.sourceTileGrid_.getExtent(),s,a,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=H}this.changed()}load(){if(this.state==Y){this.state=K,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach((({tile:e})=>{const i=e.getState();if(i==Y||i==K){t++;const i=D(e,n,(n=>{const r=e.getState();r!=H&&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")),vu.push(this.canvas_),this.canvas_=null),super.release()}}class od extends V{constructor(t){super(),this.projection=vn(t.projection),this.attributions_=ad(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_=ad(t),this.changed()}setState(t){this.state_=t,this.changed()}}function ad(t){return t?"function"==typeof t?t:(Array.isArray(t)||(t=[t]),e=>t):null}class ld extends od{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&&zl(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,s){return U()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Gu(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const n=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),s=zl(n.getTileSize(t),this.tmpSize);return 1==r?s:Bl(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=ju(n,t,i)),Au(t,n)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class hd extends I{constructor(t,e){super(t),this.tile=e}}var cd="tileloadstart",ud="tileloadend",dd="tileloaderror";class gd extends ld{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===gd.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==K?(this.tileLoadingKeys_[i]=!0,r=cd):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==q?dd:n==H?ud:void 0),null!=r&&this.dispatchEvent(new hd(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=Ju(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join("\n");this.generateTileUrlFunction_?this.setTileUrlFunction(td(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class fd extends gd{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:pd,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:ks,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!Pn(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||Pn(e,t)))return this.tileGrid;const i=z(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Gu(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,s){const o=this.getProjection();if(!o||!r||Pn(o,r))return this.getTileInternal(t,e,i,n,o||r);const a=[t,e,i],l=this.getKey(),h=this.getTileGridForProjection(o),c=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(a,r),d=new sd(o,h,r,c,a,u,this.getTilePixelRatio(n),this.getGutter(),((t,e,i,n)=>this.getTileInternal(t,e,i,n,o,s)),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,i,n,r,s){const o=this.getKey(),a=Mu(this,o,t,e,i);if(s&&s.containsKey(a)){return s.get(a)}const l=this.createTile_(t,e,i,n,r,o);return s?.set(a,l),l}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=vn(t);if(i){const t=z(i);t in this.tileGridForProjection||(this.tileGridForProjection[t]=e)}}}function pd(t,e){if(ct){const i=t.getCrossOrigin();let n="same-origin",r="same-origin";return"anonymous"===i||""===i?(n="cors",r="omit"):"use-credentials"===i&&(n="cors",r="include"),void fetch(e,{mode:n,credentials:r}).then((t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.blob()})).then((t=>createImageBitmap(t))).then((e=>{const i=t.getImage();i.width=e.width,i.height=e.height;i.getContext("2d").drawImage(e,0,0),e.close?.(),i.dispatchEvent(new Event("load"))})).catch((()=>{t.getImage().dispatchEvent(new Event("error"))}))}t.getImage().src=e}function _d(t){const e=t[0],i=new Array(e);let n,r,s=1<>=1;return i.join("")}class md extends fd{constructor(t){const e=void 0!==(t=t||{}).projection?t.projection:"EPSG:3857",i=void 0!==t.tileGrid?t.tileGrid:Bu({extent:Vu(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 yd(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]||le(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 Td(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=Or(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=Dr(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 Ld(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_})),this}}function Id(t){const e=t.getType();switch(e){case"Point":return new zr(t.getFlatCoordinates());case"MultiPoint":return new Pd(t.getFlatCoordinates(),"XY");case"LineString":return new Rd(t.getFlatCoordinates(),"XY");case"MultiLineString":return new bd(t.getFlatCoordinates(),"XY",t.getEnds());case"Polygon":const i=t.getFlatCoordinates(),n=t.getEnds(),r=ls(i,n);return r.length>1?new Fd(i,"XY",r):new hs(i,"XY",n);default:throw new Error("Invalid geometry type:"+e)}}Ld.prototype.getFlatCoordinates=Ld.prototype.getOrientedFlatCoordinates;class Ad{constructor(t){this.rbush_=new rl(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 Bd(Nd);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 Ld||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 Ld||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(),L(this.nullGeometryFeatures_)||w(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=Pe(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||T,this.featuresRtree_.forEachInExtent(a,(function(t){if(e(t)){const e=t.getGeometry(),l=o;if(o=e instanceof Ld?0:e.closestPointXY(i,n,s,o),o{--this.loadingExtentsCount_,this.dispatchEvent(new Bd(jd,void 0,t))}),(()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Bd(Ud))})),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(te(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=$d(0,u,0,d,-1,1);f=Zd(f,a,l,0),f=Wd(f,h,c,1),g.uniformMatrix4fv(this.matrixLocation,!1,f);let p=Yd(n/e,r/i,0);p=Wd(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 Hd(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 qd(t,e,i){const n=t.createProgram(),r=Hd(t,t.VERTEX_SHADER,i),s=Hd(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 Jd(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 tg=[];function eg(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){ie(y,t.extent)}));const w=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(ve(y)*w),S=Math.round(_e(y)*w);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 Kd(t);l.forEach((function(e,i,l){const c=(e.extent[0]-y[0])*w*n,u=-(e.extent[3]-y[3])*w*n,g=ve(e.extent)*w*n,f=_e(e.extent)*w*n;if(t.bindFramebuffer(t.FRAMEBUFFER,o),t.viewport(0,0,r,s),e.clipExtent){const i=(e.clipExtent[0]-y[0])*w*n,r=-(e.clipExtent[3]-y[3])*w*n,s=ve(e.clipExtent)*w*n,o=_e(e.clipExtent)*w*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 E=ye(o),C=ye(y),T=t=>{const e=(t[0][0]-E[0])/s*n,i=-(t[0][1]-E[1])/s*n;return{u1:(t[1][0]-E[0])/s*n,v1:-(t[1][1]-E[1])/s*n,u0:e,v0:i,u2:(t[2][0]-E[0])/s*n,v2:-(t[2][1]-E[1])/s*n}};t.bindFramebuffer(t.FRAMEBUFFER,_),t.viewport(0,0,f,p);{const e=[],i=[],n=qd(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}=T(a),f=(o[0][0]-C[0])/r/v,p=-(o[0][1]-C[1])/r/S,_=(o[1][0]-C[0])/r/v,m=-(o[1][1]-C[1])/r/S,y=(o[2][0]-C[0])/r/v,x=-(o[2][1]-C[1])/r/S;e.push(l,h,c,u,d,g),i.push(_,m,f,p,y,x)}));const o=$d(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=qd(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=$d(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}=T(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 ig extends Lt{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?me(i,n):i:n;const r=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),s=this.targetTileGrid_.getExtent();let o=this.sourceTileGrid_.getExtent();const a=s?me(r,s):r;if(0===he(a))return void(this.state=J);i&&(o=o?me(o,i):i);const l=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),h=t.targetProj,c=Cu(e,h,a,l);if(!isFinite(c)||c<=0)return void(this.state=J);const u=void 0!==t.errorThreshold?t.errorThreshold:rd;if(this.triangulation_=new nd(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]=Fe(d[1],o[1],o[3]),d[3]=Fe(d[3],o[1],o[3])):d=me(d,o)),he(d)){let n=0,r=0;e.canWrapX()&&(n=ve(i),r=Math.floor((d[0]-i[0])/n));Pe(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()!==H)return;const r=n.getSize(),s=this.gutter_;let o;const a=Rt(n.getData());a?o=a:(e=!0,o=Ft(Tt(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=Math.round(r*this.pixelRatio_),a=Math.round(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=Jd(o,a,tg,{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!==K)return;t++;const r=D(e,n,(()=>{const i=e.getState();i!=H&&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 ng extends ld{constructor(t){const e=void 0===t.projection?"EPSG:3857":t.projection;let i=t.tileGrid;void 0===i&&e&&(i=Bu({extent:Vu(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?zl(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?zl(e.getTileSize(t)):[256,256]}getGutterForProjection(t){const e=this.getProjection();return e&&!Pn(e,t)||this.transformMatrix?0:this.gutter_}setLoader(t){this.loader_=t}getReprojTile_(t,e,i,n,r,s){const o=this.tileGrid||this.getTileGridForProjection(r||n),a=Math.max.apply(null,o.getResolutions().map(((t,e)=>{const i=zl(o.getTileSize(e)),n=this.getTileSize(e);return Math.max(n[0]/i[0],n[1]/i[1])}))),l=this.getTileGridForProjection(n),h=[t,e,i],c=this.getTileCoordForTileUrlFunction(h,n),u=Object.assign({sourceProj:r||n,sourceTileGrid:o,targetProj:n,targetTileGrid:l,tileCoord:h,wrappedTileCoord:c,pixelRatio:a,gutter:this.gutter_,getTileFunction:(t,e,i,n)=>this.getTile(t,e,i,n,void 0,s),transformMatrix:this.transformMatrix},this.tileOptions),d=new ig(u);return d.key=this.getKey(),d}getTile(t,e,i,r,s,o){const a=this.getProjection();if(s&&(a&&!Pn(a,s)||this.transformMatrix))return this.getReprojTile_(t,e,i,s,a,o);const l=this.getTileSize(t),h=this.loader_,c=new AbortController,u={signal:c.signal,crossOrigin:this.crossOrigin_},d=this.getTileCoordForTileUrlFunction([t,e,i]);if(!d)return null;const g=Mu(this,this.getKey(),t,e,i);if(o&&o.containsKey(g))return o.get(g);const f=d[0],p=d[1],_=d[2],m=this.getTileGrid()?.getFullTileRange(f);m&&(u.maxY=m.getHeight()-1);const y=Object.assign({tileCoord:[t,e,i],loader:function(){return F((function(){return h(f,p,_,u)}))},size:l,controller:c},this.tileOptions),x=new Lt(y);return x.key=this.getKey(),x.addEventListener(n,this.handleTileChange_),o?.set(g,x),x}handleTileChange_(t){const e=t.target,i=z(e),n=e.getState();let r;n==K?(this.tileLoadingKeys_[i]=!0,r=cd):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=n==q?dd:n==H?ud:void 0),r&&this.dispatchEvent(new hd(r,e))}getTileGridForProjection(t){const e=this.getProjection();if(this.tileGrid&&(!e||Pn(e,t))&&!this.transformMatrix)return this.tileGrid;const i=z(t);return i in this.tileGridForProjection_||(this.tileGridForProjection_[i]=Gu(t)),this.tileGridForProjection_[i]}setTileGridForProjection(t,e){const i=vn(t);if(i){const t=z(i);t in this.tileGridForProjection_||(this.tileGridForProjection_[t]=e)}}}class rg 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?me(i,l):i,c=Eu(t,e,de(h),n),u=new nd(t,e,h,a,.5*c,n),d=u.calculateSourceExtent(),g=we(d)?null:s(d,c,r),f=g?Rs: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==bs&&this.unlistenSource_(),super.disposeInternal()}getImage(){return this.canvas_}getProjection(){return this.targetProj_}reproject_(){const t=this.sourceImage_.getState();if(t==Ps){const t=ve(this.targetExtent_)/this.targetResolution_,e=_e(this.targetExtent_)/this.targetResolution_;this.canvas_=Tu(t,e,this.sourcePixelRatio_,Ru(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==Rs){this.state=bs,this.changed();const t=this.sourceImage_.getState();t==Ps||t==Fs?this.reproject_():(this.sourceListenerKey_=D(this.sourceImage_,n,(t=>{const e=this.sourceImage_.getState();e!=Ps&&e!=Fs||(this.unlistenSource_(),this.reproject_())})),this.sourceImage_.load())}}unlistenSource_(){k(this.sourceListenerKey_),this.sourceListenerKey_=null}}const sg="imageloadstart",og="imageloadend",ag="imageloaderror";class lg extends I{constructor(t,e){super(t),this.image=e}}class hg extends od{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||Pn(r,n))return r&&(n=r),this.getImageInternal(t,e,i,n);if(this.reprojectedImage_){if(this.reprojectedRevision_==this.getRevision()&&Pn(this.reprojectedImage_.getProjection(),n)&&this.reprojectedImage_.getResolution()==e&&te(this.reprojectedImage_.getExtent(),t))return this.reprojectedImage_;this.reprojectedImage_.dispose(),this.reprojectedImage_=null}return this.reprojectedImage_=new rg(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=ug(t,e,i,1),o=this.findNearestResolution(e);if(this.image&&(this.static_||this.wantedProjection_===r&&(this.wantedExtent_&&Wt(this.wantedExtent_,s)||Wt(this.image.getExtent(),s))&&(this.wantedResolution_&&Ru(this.wantedResolution_)===o||Ru(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 bs:this.loading=!0,i=sg;break;case Ps:this.loading=!1,i=og;break;case Fs:this.loading=!1,i=ag;break;default:return}this.hasListener(i)&&this.dispatchEvent(new lg(i,e))}}function cg(t,e){t.getImage().src=e}function ug(t,e,i,n){const r=e/i,s=de(t),o=Ue(ve(t)/r,4),a=Ue(_e(t)/r,4);return fe(s,r,0,[o+2*Ue((n-1)*o/2,4),a+2*Ue((n-1)*a/2,4)])}function dg(t,e,i,n,r,s){const o=r.getCode().split(/:(?=\d+$)/).pop(),a=i/n,l=[Ge(ve(e)/a,4),Ge(_e(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 $u(t.replace(/MapServer\/?$/,"MapServer/export").replace(/ImageServer\/?$/,"ImageServer/exportImage"),s)}function gg(t){const e=t.load?t.load:Ds,i=vn(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=ug(s,o,a,n);const h=dg(t.url,s,o,a,i,l),c=new Image;return c.crossOrigin=r,e(c,h).then((t=>{const e=ve(s)/t.width*a;return{image:t,extent:s,resolution:e,pixelRatio:a}}))}}function fg(t){const e=t.load||Ds,i=t.imageExtent,n=t.crossOrigin??null;return()=>{const r=new Image;return r.crossOrigin=n,e(r,t.url).then((t=>{const e=ve(i)/t.width,n=_e(i)/t.height;return{image:t,extent:i,resolution:e!==n?[e,n]:n,pixelRatio:1}}))}}const pg=new Error("Image failed to load");function _g(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(pg))),a.src=Hu(t,e,i,n,r.maxY)}))}function mg(t){return function(e,i,n,r){return _g(qu(t,e,i,n),e,i,n,r)}}function yg(t){let e;if(Array.isArray(t))e=mg(t);else if("string"==typeof t){e=mg(Ju(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 _g(i(t,e,n,r),t,e,n,r)}}var i;return e}let xg=0;function vg(t){return Array.isArray(t)?t.join("\n"):"string"==typeof t?t:(++xg,"url-function-key-"+xg)}class Sg extends ng{constructor(t){let e,i=(t=t||{}).loader;t.url&&(i=yg(t.url),e=vg(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=yg(t);this.setLoader(e),this.setKey(vg(t)),"ready"!==this.getState()&&this.setState("ready")}}const wg="1.3.0",Eg=[101,101];function Cg(t,e,i,n,r){r.WIDTH=i[0],r.HEIGHT=i[1];const s=n.getAxisOrientation(),o=Je(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(","),$u(t,r)}function Tg(t,e,i,n,r,s,o){s=Object.assign({REQUEST:"GetMap"},s);const a=e/i,l=[Ge(ve(t)/a,4),Ge(_e(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 Cg(r,t,l,n,s)}function Rg(t,e){return Object.assign({REQUEST:e,SERVICE:"WMS",VERSION:wg,FORMAT:"image/png",STYLES:"",TRANSPARENT:"TRUE"},t)}function bg(t){const e=void 0===t.hidpi||t.hidpi,i=vn(t.projection||"EPSG:3857"),n=t.ratio||1.5,r=t.load||Ds,s=t.crossOrigin??null;return(o,a,l)=>{o=ug(o,a,l,n),1==l||e&&void 0!==t.serverType||(l=1);const h=Tg(o,a,l,i,t.url,Rg(t.params,"GetMap"),t.serverType),c=new Image;return c.crossOrigin=s,r(c,h).then((t=>({image:t,extent:o,pixelRatio:l})))}}function Pg(t,e,i){if(void 0===t.url)return;const n=vn(t.projection||"EPSG:3857"),r=fe(e,i,0,Eg),s={QUERY_LAYERS:t.params.LAYERS,INFO_FORMAT:"application/json"};Object.assign(s,Rg(t.params,"GetFeatureInfo"),t.params);const o=je((e[0]-r[0])/i,4),a=je((r[3]-e[1])/i,4),l=Je(s.VERSION,"1.3")>=0;return s[l?"I":"X"]=o,s[l?"J":"Y"]=a,Cg(t.url,r,Eg,n,s)}function Fg(t,e){if(void 0===t.url)return;const i={SERVICE:"WMS",VERSION:wg,REQUEST:"GetLegendGraphic",FORMAT:"image/png"};if(void 0!==e){const n=vn(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 $u(t.url,i)}const Mg={"image/png":!0,"image/jpeg":!0,"image/gif":!0,"image/webp":!0},Lg={"application/vnd.mapbox-vector-tile":!0,"application/geo+json":!0};function Ig(t,e){if(!e.length)return t;const i=new URL(t,"file:/");if(i.pathname.split("/").includes("collections"))return He('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 Ag(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,{z:u.tileMatrix,x:u.tileCol,y:u.tileRow},y);const d=i.replace(/\{(\w+?)\}/g,(function(t,e){return u[e]}));return hu(x,d)}}}function Ng(t){return lu(t.url).then((function(e){return function(t,e){const i=e.tileMatrixSetLimits;let n;if("map"===e.dataType)n=Ag(e.links,t.mediaType,t.collections);else{if("vector"!==e.dataType)throw new Error('Expected tileset data type to be "map" or "vector"');n=Og(e.links,t.mediaType,t.supportedMediaTypes,t.collections)}if(e.tileMatrixSet)return Dg(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 lu(hu(t.url,s)).then((function(e){return Dg(t,e,n,i)}))}(t,e)}))}const kg='© OpenStreetMap contributors.';class Gg{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(_t(),{get:(t,e)=>{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 U()}getData(t){return null}prepareFrame(t){return U()}renderFrame(t,e){return U()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;e.getState()!==Ps&&e.getState()!==Fs||this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=Ps&&e!=Fs&&t.addEventListener(n,this.boundHandleImageChange_),e==Rs&&(t.load(),e=t.getState()),e==Ps}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&"ready"===t.getSourceState()&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Ug=[];let Bg=null;class zg extends jg{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;Bg||(Bg=ft(1,1,void 0,{willReadFrequently:!0})),Bg.clearRect(0,0,1,1);try{Bg.drawImage(t,e,i,1,1,0,0,1,1),n=Bg.getImageData(0,0,1,1).data}catch{return Bg=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&&E(Gl(t.style.backgroundColor),Gl(i)))){const e=t.firstElementChild;Ct(e)&&(s=e.getContext("2d"))}if(s&&sr(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=ct?Et():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=ye(i),r=xe(i),s=ue(i),o=ce(i);Hn(e.coordinateToPixelTransform,n),Hn(e.coordinateToPixelTransform,r),Hn(e.coordinateToPixelTransform,s),Hn(e.coordinateToPixelTransform,o);const a=this.inversePixelTransform;Hn(a,n),Hn(a,r),Hn(a,s),Hn(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(ve(i)/n*s),a=Math.round(_e(i)/n*s);Qn(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/s,1/s,r,-o/2,-a/2),tr(this.inversePixelTransform,this.pixelTransform);const l=nr(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 Gc(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,e.declutter||this.dispatchRenderEvent_(Ya,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ka,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Gg),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Ya,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ka,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 Qn(this.tempTransform,a,l,h,c,-i,u,d)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class Xg extends zg{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=me(a,Un(e.extent,n.projection))),!o[oo]&&!o[ao]&&!we(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=Hn(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!$t(r,n))return null;const s=this.image.getExtent(),o=this.image.getImage(),a=ve(s),l=Math.floor(o.width*((n[0]-s[0])/a));if(l<0||l>=o.width)return null;const h=_e(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=Se(e,t.extent),y=x&&!Wt(e,t.extent),y&&this.clipUnrotated(m,t,e)}const v=i.getImage(),S=Qn(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 w=v.width*S[0],E=v.height*S[3];if(this.getLayer().getSource().getInterpolate()||(m.imageSmoothingEnabled=!1),this.preRender(m,t),x&&w>=.5&&E>=.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,w,E),1!==i&&m.restore()}return this.postRender(this.context,t),y&&m.restore(),m.imageSmoothingEnabled=!0,this.container}}class Vg extends Qa{constructor(t){super(t=t||{})}}class $g extends Vg{constructor(t){super(t)}createRenderer(){return new Xg(this)}getData(t){return super.getData(t)}}function Wg(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 Zg(t,e,i){const n=t[i];return!!n&&n.delete(e)}function Yg(t,e){const i=t.layerStatesArray[t.layerIndex];i.extent&&(e=me(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=me(e,i))}return e}class Kg extends zg{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=[1/0,1/0,-1/0,-1/0],this.tempTileRange_=new qc(0,0,0,0),this.tempTileCoord_=Pu(0,0,0);const i=void 0!==e.cacheSize?e.cacheSize:512;this.tileCache_=new bu(i),this.sourceTileCache_=null,this.maxStaleKeys=.5*i}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new bu(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,s=this.getLayer().getSource(),o=Mu(s,s.getKey(),t,e,i);let a;if(r.containsKey(o))a=r.get(o);else{const l=n.viewState.projection,h=s.getProjection();if(a=s.getTile(t,e,i,n.pixelRatio,l,!h||Pn(h,l)?void 0:this.getSourceTileCache()),!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=Hn(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!$t(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()!==H)continue;const h=a.getOrigin(t),c=zl(a.getTileSize(t)),u=a.getResolution(t);let d;if(r instanceof ks||r instanceof sd)d=r.getImage();else{if(!(r instanceof Lt))continue;if(d=Tt(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.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!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?pe(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(!Wg(n,i,r))continue;const a=i.getKey();if(c[a]=!0,i.getState()===Y&&!t.tileQueue.isKeyQueued(a)){const n=Pu(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,T,u-1,E,C-1)}),0),!(u in E))return this.container;const R=z(this),b=t.time;for(const e of E[u]){const i=e.getState();if(i===J)continue;const n=e.tileCoord;if(i===H){if(1===e.getAlpha(R,b)){e.endTransition(R);continue}}i!==q&&(this.renderComplete=!1);if(this.findStaleTile_(n,E)){Zg(E,e,u),t.animate=!0;continue}if(this.findAltTiles_(c,n,u+1,E))continue;const r=c.getMinZoom();for(let t=u-1;t>=r;--t){if(this.findAltTiles_(c,n,t,E))break}}const P=d/s*a/p,F=this.getRenderContext(t);Qn(this.tempTransform,_/2,m/2,P,P,0,-_/2,-m/2),i.extent&&this.clipUnrotated(F,t,x),h.getInterpolate()||(F.imageSmoothingEnabled=!1),this.preRender(F,t);const M=Object.keys(E).map(Number);let L;M.sort(y);const I=[],A=[];for(let e=M.length-1;e>=0;--e){const i=M[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(ye(w),i),g=c.getTileCoordExtent(u),f=Hn(this.tempTransform,[p*(g[0]-w[0])/d,p*(w[3]-g[3])/d]),_=p*h.getGutterForProjection(r);for(const e of E[i]){if(e.getState()!==H)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===M.length;let x=!1;L=[d,g,d+p,g,d+p,g+m,d,g+m];for(let t=0,e=I.length;t{const i=z(h),n=e.wantedTiles[i],r=n?Object.keys(n).length:0;this.updateCacheSize(r),this.tileCache_.expireCache(),this.sourceTileCache_?.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 Lt){if(l=Tt(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 Hg="preload",qg="useInterimTilesOnError";class Jg 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(Hg)}setPreload(t){this.set(Hg,t)}getUseInterimTilesOnError(){return this.get(qg)}setUseInterimTilesOnError(t){this.set(qg,t)}getData(t){return super.getData(t)}}class Qg extends Jg{constructor(t){super(t)}createRenderer(){return new Kg(this,{cacheSize:this.getCacheSize()})}}function tf(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=H,this.changed()}loadInternal_(){if(this.state==Y)if(this.state=K,this.jsonp_)su(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 ff="http://www.w3.org/2001/XMLSchema-instance";function pf(t,e){return jf().createElementNS(t,e)}function _f(t,e){return mf(t,e,[]).join("")}function mf(t,e,i){if(t.nodeType==Node.CDATA_SECTION_NODE||t.nodeType==Node.TEXT_NODE)e?i.push(String(t.nodeValue).replace(/(\r\n|\r|\n)/g,"")):i.push(t.nodeValue);else{let n;for(n=t.firstChild;n;n=n.nextSibling)mf(n,e,i)}return i}function yf(t){return"documentElement"in t}function xf(t,e,i){return t.getAttributeNS(e,i)||""}function vf(t){return(new DOMParser).parseFromString(t,"application/xml")}function Sf(t,e){return function(i,n){const r=t.call(e??this,i,n);if(void 0!==r){w(n[n.length-1],r)}}}function wf(t,e){return function(i,n){const r=t.call(e??this,i,n);if(void 0!==r){n[n.length-1].push(r)}}}function Ef(t,e){return function(i,n){const r=t.call(e??this,i,n);void 0!==r&&(n[n.length-1]=r)}}function Cf(t,e,i){return function(n,r){const s=t.call(i??this,n,r);if(void 0!==s){const t=r[r.length-1],i=void 0!==e?e:n.localName;let o;i in t?o=t[i]:(o=[],t[i]=o),o.push(s)}}}function Tf(t,e,i){return function(n,r){const s=t.call(i??this,n,r);if(void 0!==s){r[r.length-1][void 0!==e?e:n.localName]=s}}}function Rf(t,e){return function(i,n,r){t.call(e??this,i,n,r);r[r.length-1].node.appendChild(i)}}function bf(t,e){let i,n;return function(e,r,s){if(void 0===i){i={};const r={};r[e.localName]=t,i[e.namespaceURI]=r,n=Pf(e.localName)}Of(i,n,r,s)}}function Pf(t,e){return function(i,n,r){const s=n[n.length-1].node;let o=t;void 0===o&&(o=r);return pf(void 0!==e?e:s.namespaceURI,o)}}const Ff=Pf();function Mf(t,e){const i=e.length,n=new Array(i);for(let r=0;ra&&(this.instructions.push([$f,a,h,t,i,Lr,r]),this.hitDetectionInstructions.push([$f,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([$f,a,h,t,i,void 0,r]),this.hitDetectionInstructions.push([$f,a,h,t,n||i,void 0,r])}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[Bf,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[Bf,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=[qf,e];return"string"!=typeof e&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[Jf,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||(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&&!E(t.currentLineDash,r)||t.currentLineDashOffset!=s||t.currentLineJoin!=o||t.currentLineWidth!=a||t.currentMiterLimit!=l)&&(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=[Yf,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Xt(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;zt(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class sp extends rp{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&&!$t(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([Zf,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([Zf,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=Ne(i,h,e),g=Ne(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 hp(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 cp={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class up extends rp{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[Mh]={fillStyle:Mh},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!=Gh&&(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([Zf,a,r,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==Gh?Gh: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]=Mh),this.hitDetectionInstructions.push([Zf,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_?Mh:this.fillKey_,this.textOffsetX_,this.textOffsetY_,n]),this.endGeometry(e)}else{if(!Se(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 F=Math.PI,M=[],L=E+n===e;let I;if(m=0,y=C,g=t[e=E],f=t[e+1],L){x(),I=Math.atan2(f-_,g-p),P&&(I+=I>0?-F:F);const t=(R+S)/2,e=(b+w)/2;return M[0]=[t,e,(T-s)/2,I,r],M}for(let t=0,u=(r=r.replace(/\n/g," ")).length;t0?-F:F),void 0!==I){let t=d-I;if(t+=t>F?-2*F:t<-F?2*F:0,Math.abs(t)>o)return null}I=d;const S=t;let w=0;for(;t0&&t.push("\n",""),t.push(e,""),t}function Cp(t,e,i){return i%2==0&&(t+=e),t}class Tp{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 Gg: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?cp[a.justify]:wp(Array.isArray(t)?t[0]:t,a.textAlign||Nh),u=n&&s.lineWidth?s.lineWidth:0,d=Array.isArray(t)?t:String(t).split("\n").reduce(Ep,[]),{width:g,height:f,widths:p,heights:_,lineWidths:m}=Hh(a,d),y=g+u,x=[],v=(y+2)*h[0],S=(f+u)*h[1],w={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 E=.5-c;let C=c*y+E*u;const T=[],R=[];let b,P=0,F=0,M=0,L=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],w=_-g[3],E=m-g[0];let C;return(f||0!==c)&&(_p[0]=w,xp[0]=w,_p[1]=E,mp[1]=E,mp[0]=w+v,yp[0]=mp[0],yp[1]=E+S,xp[1]=yp[1]),0!==c?(C=Qn([1,0,0,1,0,0],i,n,1,1,c,-i,-n),Hn(C,_p),Hn(C,mp),Hn(C,yp),Hn(C,xp),Ht(Math.min(_p[0],mp[0],yp[0],xp[0]),Math.min(_p[1],mp[1],yp[1],xp[1]),Math.max(_p[0],mp[0],yp[0],xp[0]),Math.max(_p[1],mp[1],yp[1],xp[1]),pp)):Ht(Math.min(w,w+v),Math.min(E,E+S),Math.max(w,w+v),Math.max(E,E+S),pp),d&&(_=Math.round(_),m=Math.round(m)),{drawImageX:_,drawImageY:m,drawImageW:y,drawImageH:x,originX:l,originY:h,declutterBox:{minX:pp[0],minY:pp[1],maxX:pp[2],maxY:pp[3],value:p},canvasTransform:C,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,_p,mp,yp,xp,s,o),qh(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=Hn(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],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=wp(Array.isArray(t)?t[0]:t,r.textAlign||Nh),h=cp[r.textBaseline||kh],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_&&E(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=or(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Kn(this.renderedTransform_,i));let c=0;const u=n.length;let d,g,f,p,_,m,y,x,v,S,w,C,T,R=0,b=0,P=0;const F=this.coordinateCache_,M=this.viewRotation_,L=Math.round(1e12*Math.atan2(-i[1],i[0]))/1e12,I={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:M},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 Xf:R=i[1];const n=h[R],u=h[R+1],E=h[R+2]-n,G=h[R+3]-u,j=Math.sqrt(E*E+G*G);t.moveTo(n+j,u),t.arc(n,u,j,0,2*Math.PI,!0),++c;break;case Vf:t.closePath(),++c;break;case $f:R=i[1],d=i[2];const U=i[3],B=i[4],z=i[5];I.geometry=U,I.feature=O,c in F||(F[c]=[]);const X=F[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,I),++c;break;case Zf: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 K=i[11];const H=i[12];let q=i[13];p=i[14]||"declutter";const J=i[15];if(!v&&i.length>=20){S=i[19],w=i[20],C=i[21],T=i[22];const t=this.drawLabelWithPointPlacement_(S,w,C,T);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=Gh,et=null,it=null),Y&&L?K+=M:Y||L||(K-=M);let nt=0;for(;R!bp.includes(t)));class Fp{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 Tp(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],_=Rp.length-1;_>=0;--_)if(d=Rp[_],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 or(o,0,8,2,t,o),o}isEmpty(){return L(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||Rp;const l=Rp.length;for(let h=0,c=a.length;hg.execute(t,e,i,n,r,o))):g.execute(c,e,i,n,r,o),u&&c.restore(),s){s.offset();const t=a[h]*l+Rp.indexOf(d);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 Mp={};function Lp(t){if(void 0!==Mp[t])return Mp[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]*Ip,h=t[1]*Ip;a.push(this.getRenderTransform(e,i,n,Ip,l,h,0).slice());const c=o.getSource(),u=r.getExtent();if(c.getWrapX()&&r.canWrapX()&&!Wt(u,s)){let t=s[0];const r=ve(u);let o,c=0;for(;tu[2];)++c,o=r*c,a.push(this.getRenderTransform(e,i,n,Ip,l,h,o).slice()),t-=r}const d=Nn();this.hitDetectionImageData_=Ap(t,a,this.renderedFeatures_,o.getStyleFunction(),s,i,n,fu(i,this.renderedPixelRatio_),d?r:null)}e(Op(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[oo],r=t.viewHints[ao],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=gu);const p=l.center.slice(),_=zt(a,g*c),m=_.slice(),y=[_.slice()],x=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!Wt(x,t.extent)){const t=ve(x),e=Math.max(ve(_)/2,t);_[0]=x[0]-e,_[2]=x[2]+e,ui(p,h);const i=be(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&&Wt(this.wrappedRenderedExtent_,_))return E(this.renderedExtent_,m)||(this.hitDetectionImageData_=null,this.renderedExtent_=m),this.renderedCenter_=p,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const v=new gp(pu(c,u),_,c,u),S=Nn();let w;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,C,n,v,w,this.getLayer().getDeclutter(),i);T=T&&!e}},b=jn(_,h),P=i.getFeaturesInExtent(b);f&&P.sort(f);for(let t=0,e=P.length;t{if(f.getState()!==Ps)return;this.image=f;const t=f.getPixelRatio(),n=Ru(f.getResolution())*e/t;this.renderedResolution=n,this.coordinateToVectorPixelTransform_=Qn(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)}}let kp=null;function Gp(t){kp=t;const e=Object.keys(t.defs),i=e.length;let n,r;for(n=0;n0&&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),Me(g[0],g[1],o[0],o[1],a[0],a[1]){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 i_={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"},n_=5121,r_=5123,s_=5125,o_=5126,a_={};function l_(t){return"shared/"+t}let h_=0;function c_(t){let e=a_[t];if(!e){const i=document.createElement("canvas");i.width=1,i.height=1,i.style.position="absolute",i.style.left="0";const n=function(t,e){e=Object.assign({preserveDrawingBuffer:!0,antialias:!ot},e);const i=Kp.length;for(let n=0;nnew e_({webGlContext:this.gl_,scaleRatio:t.scaleRatio,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,uniforms:t.uniforms}))):[new e_({webGlContext:this.gl_})],this.shaderCompileErrors_=null,this.startTime_=Date.now(),this.maxAttributeCount_=this.gl_.getParameter(this.gl_.MAX_VERTEX_ATTRIBS)}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_===l_(t)}getExtension(t){if(t in this.extensionCache_)return this.extensionCache_[t];const e=this.gl_.getExtension(t);return this.extensionCache_[t]=e,e}getInstancedRenderingExtension_(){const t=this.getExtension("ANGLE_instanced_arrays");return It(!!t,"WebGL extension 'ANGLE_instanced_arrays' is required for vector rendering"),t}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(Qp,this.boundHandleWebGLContextLost_),t.removeEventListener(t_,this.boundHandleWebGLContextRestored_),function(t){const e=a_[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 a_[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)}drawElementsInstanced(t,e,i){const n=this.gl_;this.getExtension("OES_element_index_uint");const r=this.getInstancedRenderingExtension_(),s=n.UNSIGNED_INT,o=e-t,a=4*t;r.drawElementsInstancedANGLE(n.TRIANGLES,o,s,a,i);for(let t=0;t{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,Vd(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.disableAllAttributes_();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 Qn(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)}disableAllAttributes_(){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(Ha)){const n=new Gc(Ha,void 0,e,t);i.dispatchEvent(n)}}dispatchPostComposeEvent(t,e){const i=this.getLayer();if(i.hasListener(qa)){const n=new Gc(qa,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;r4)throw new Error("`formatArray` can only output `vec2`, `vec3` or `vec4` arrays.");return`vec${t.length}(${t.map(y_).join(", ")})`}function v_(t){const e=Gl(t),i=e.length>3?e[3]:1;return x_([e[0]/255,e[1]/255,e[2]/255,i])}function S_(t){return x_(zl(t))}const w_={};let E_=0;function C_(t){return t in w_||(w_[t]=E_++),w_[t]}function T_(t){return y_(C_(t))}function R_(t){return"u_var_"+t}function b_(){return{variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1}}const P_="getBandValue",F_="u_paletteTextures",M_="featureId",L_="geometryType",I_=-9999999;function A_(t,e,i,n){return N_(sh(t,e,i),e,n)}function O_(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;i in t.properties||(t.properties[i]={name:i,type:e.type});let n="a_prop_"+i;return eh(e.type,Vl)&&(n=`(${n} > 0.0)`),n},[oh.Id]:t=>(t.featureId=!0,"a_"+M_),[oh.GeometryType]:t=>(t.geometryType=!0,"a_"+L_),[oh.LineMetric]:()=>"currentLineMetric",[oh.Var]:(t,e)=>{const i=e.args[0].value;i in t.variables||(t.variables[i]={name:i,type:e.type});let n=R_(i);return eh(e.type,Vl)&&(n=`(${n} > 0.0)`),n},[oh.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} != ${y_(I_)})`},[oh.Resolution]:()=>"u_resolution",[oh.Zoom]:()=>"u_zoom",[oh.Time]:()=>"u_time",[oh.Any]:O_((t=>`(${t.join(" || ")})`)),[oh.All]:O_((t=>`(${t.join(" && ")})`)),[oh.Not]:O_((([t])=>`(!${t})`)),[oh.Equal]:O_((([t,e])=>`(${t} == ${e})`)),[oh.NotEqual]:O_((([t,e])=>`(${t} != ${e})`)),[oh.GreaterThan]:O_((([t,e])=>`(${t} > ${e})`)),[oh.GreaterThanOrEqualTo]:O_((([t,e])=>`(${t} >= ${e})`)),[oh.LessThan]:O_((([t,e])=>`(${t} < ${e})`)),[oh.LessThanOrEqualTo]:O_((([t,e])=>`(${t} <= ${e})`)),[oh.Multiply]:O_((t=>`(${t.join(" * ")})`)),[oh.Divide]:O_((([t,e])=>`(${t} / ${e})`)),[oh.Add]:O_((t=>`(${t.join(" + ")})`)),[oh.Subtract]:O_((([t,e])=>`(${t} - ${e})`)),[oh.Clamp]:O_((([t,e,i])=>`clamp(${t}, ${e}, ${i})`)),[oh.Mod]:O_((([t,e])=>`mod(${t}, ${e})`)),[oh.Pow]:O_((([t,e])=>`pow(${t}, ${e})`)),[oh.Abs]:O_((([t])=>`abs(${t})`)),[oh.Floor]:O_((([t])=>`floor(${t})`)),[oh.Ceil]:O_((([t])=>`ceil(${t})`)),[oh.Round]:O_((([t])=>`floor(${t} + 0.5)`)),[oh.Sin]:O_((([t])=>`sin(${t})`)),[oh.Cos]:O_((([t])=>`cos(${t})`)),[oh.Atan]:O_((([t,e])=>void 0!==e?`atan(${t}, ${e})`:`atan(${t})`)),[oh.Sqrt]:O_((([t])=>`sqrt(${t})`)),[oh.Match]:O_((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})),[oh.Between]:O_((([t,e,i])=>`(${t} >= ${e} && ${t} <= ${i})`)),[oh.Interpolate]:O_((([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})),[oh.In]:O_((([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(", ")})`)),[oh.Color]:O_((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})`})),[oh.Band]:O_((([t,e,i],n)=>{if(!(P_ 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 y_(t.value);if((t.type&Vl)>0)return t.value.toString();if((t.type&Wl)>0)return T_(t.value.toString());if((t.type&Zl)>0)return v_(t.value);if((t.type&Yl)>0)return x_(t.value);if((t.type&Kl)>0)return S_(t.value);throw new Error(`Unexpected expression ${t.value} (expected type ${Ql(e)})`)}function k_(t,e,i){return A_(e,i,rh(),t)}function G_(t){const e=Gl(t);return[256*e[0]+e[1],256*e[2]+Math.round(255*e[3])]}function j_(t){return t===Zl||t===Kl?2:t===Yl?4:1}function U_(t){const e=j_(t);return e>1?`vec${e}`:"float"}function B_(t,e){for(const i in e.variables){const n=e.variables[i],r=R_(n.name);let s=U_(n.type);n.type===Zl&&(s="vec4"),t.addUniform(r,s)}for(const i in e.properties){const n=e.properties[i],r=U_(n.type),s=`a_prop_${n.name}`;n.type===Zl?t.addAttribute(s,r,`unpackColor(${s})`,"vec4"):t.addAttribute(s,r)}for(const i in e.functions)t.addVertexShaderFunction(e.functions[i]),t.addFragmentShaderFunction(e.functions[i])}function z_(t,e){const i={};for(const n in t.variables){const r=t.variables[n];i[R_(r.name)]=()=>{const t=e[r.name];if("number"==typeof t)return t;if("boolean"==typeof t)return t?1:0;if(r.type===Zl){const e=[...Gl(t||"#eee")];return e[0]/=255,e[1]/=255,e[2]/=255,e[3]??=1,e}return"string"==typeof t?C_(t):t}}return i}function X_(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===Zl?G_([...Gl(e||"#eee")]):"string"==typeof e?C_(e):"boolean"==typeof e?e?1:0:e};e[`prop_${n.name}`]={size:j_(n.type),callback:r}}return e}const V_="#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\nvec4 unpackColor(vec2 packedColor) {\n return vec4(\n min(floor(packedColor[0] / 256.0) / 255.0, 1.0),\n min(mod(packedColor[0], 256.0) / 255.0, 1.0),\n min(floor(packedColor[1] / 256.0) / 255.0, 1.0),\n min(mod(packedColor[1], 256.0) / 255.0, 1.0)\n );\n}\n",$_={"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 W_{constructor(){this.uniforms_=[],this.attributes_=[],this.hasSymbol_=!1,this.symbolSizeExpression_=`vec2(${y_($_["circle-radius"])} + ${y_(.5*$_["circle-stroke-width"])})`,this.symbolRotationExpression_="0.0",this.symbolOffsetExpression_="vec2(0.0)",this.symbolColorExpression_=v_($_["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_=y_($_["stroke-width"]),this.strokeColorExpression_=v_($_["stroke-color"]),this.strokeOffsetExpression_="0.",this.strokeCapExpression_=T_("round"),this.strokeJoinExpression_=T_("round"),this.strokeMiterLimitExpression_="10.",this.strokeDistanceFieldExpression_="-1000.",this.strokePatternLengthExpression_=null,this.hasFill_=!1,this.fillColorExpression_=v_($_["fill-color"]),this.vertexShaderFunctions_=[],this.fragmentShaderFunctions_=[]}addUniform(t,e){return this.uniforms_.push({name:t,type:e}),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}setStrokePatternLengthExpression(t){return this.strokePatternLengthExpression_=t,this}getStrokePatternLengthExpression(){return this.strokePatternLengthExpression_}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_?`${V_}\n${this.uniforms_.map((t=>`uniform ${t.type} ${t.name};`)).join("\n")}\nattribute vec2 a_position;\nattribute vec2 a_localPosition;\nattribute vec2 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 + a_localPosition * halfSizePx * vec2(1., -1.);\n float angle = ${this.symbolRotationExpression_}${this.symbolRotateWithView_?" + 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 = mix(texCoord.s, texCoord.p, a_localPosition.x * 0.5 + 0.5);\n float v = mix(texCoord.t, texCoord.q, a_localPosition.y * 0.5 + 0.5);\n v_texCoord = vec2(u, v);\n v_hitColor = unpackColor(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_?`${V_}\n${this.uniforms_.map((t=>`uniform ${t.type} ${t.name};`)).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_?`${V_}\n${this.uniforms_.map((t=>`uniform ${t.type} ${t.name};`)).join("\n")}\nattribute vec2 a_segmentStart;\nattribute vec2 a_segmentEnd;\nattribute vec2 a_localPosition;\nattribute float a_measureStart;\nattribute float a_measureEnd;\nattribute float a_angleTangentSum;\nattribute float a_distanceLow;\nattribute float a_distanceHigh;\nattribute vec2 a_joinAngles;\nattribute vec2 a_hitColor;\n\nvarying vec2 v_segmentStartPx;\nvarying vec2 v_segmentEndPx;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_hitColor;\nvarying float v_distancePx;\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 startEndRatio = a_localPosition.x * 0.5 + 0.5;\n currentLineMetric = mix(a_measureStart, a_measureEnd, startEndRatio);\n // we're reading the fractional part while keeping the sign (so -4.12 gives -0.12, 3.45 gives 0.45)\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 = -1. * a_localPosition.y;\n float tangentDir = -1. * a_localPosition.x;\n float angle = mix(v_angleStart, v_angleEnd, startEndRatio);\n vec2 joinDirection;\n vec2 positionPx = mix(segmentStartPx, segmentEndPx, startEndRatio);\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_segmentStartPx = segmentStartPx;\n v_segmentEndPx = segmentEndPx;\n v_width = lineWidth;\n v_hitColor = unpackColor(a_hitColor);\n\n v_distancePx = a_distanceLow / u_resolution - (lineOffsetPx * a_angleTangentSum);\n float distanceHighPx = a_distanceHigh / u_resolution;\n ${null!==this.strokePatternLengthExpression_?`v_distancePx = mod(v_distancePx, ${this.strokePatternLengthExpression_});\n distanceHighPx = mod(distanceHighPx, ${this.strokePatternLengthExpression_});\n `:""}v_distancePx += distanceHighPx;\n\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_?`${V_}\n${this.uniforms_.map((t=>`uniform ${t.type} ${t.name};`)).join("\n")}\nvarying vec2 v_segmentStartPx;\nvarying vec2 v_segmentEndPx;\nvarying float v_angleStart;\nvarying float v_angleEnd;\nvarying float v_width;\nvarying vec4 v_hitColor;\nvarying float v_distancePx;\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 == ${T_("butt")}) {\n return buttCapDistanceField(point, start, end);\n } else if (capType == ${T_("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 == ${T_("bevel")}) {\n return bevelJoinField(point, start, end, width, joinAngle);\n } else if (joinType == ${T_("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 currentPointPx = gl_FragCoord.xy / u_pixelRatio;\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n vec2 worldPos = pxToWorld(currentPointPx);\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 segmentLengthPx = length(v_segmentEndPx - v_segmentStartPx);\n segmentLengthPx = max(segmentLengthPx, 1.17549429e-38); // avoid divide by zero\n vec2 segmentTangent = (v_segmentEndPx - v_segmentStartPx) / segmentLengthPx;\n vec2 segmentNormal = vec2(-segmentTangent.y, segmentTangent.x);\n vec2 startToPointPx = currentPointPx - v_segmentStartPx;\n float lengthToPointPx = max(0., min(dot(segmentTangent, startToPointPx), segmentLengthPx));\n float currentLengthPx = lengthToPointPx + v_distancePx;\n float currentRadiusPx = distanceFromSegment(currentPointPx, v_segmentStartPx, v_segmentEndPx);\n float currentRadiusRatio = dot(segmentNormal, startToPointPx) * 2. / v_width;\n currentLineMetric = mix(v_measureStart, v_measureEnd, lengthToPointPx / segmentLengthPx);\n\n if (${this.discardExpression_}) { discard; }\n\n float capType = ${this.strokeCapExpression_};\n float joinType = ${this.strokeJoinExpression_};\n float segmentStartDistance = computeSegmentPointDistance(currentPointPx, v_segmentStartPx, v_segmentEndPx, v_width, v_angleStart, capType, joinType);\n float segmentEndDistance = computeSegmentPointDistance(currentPointPx, v_segmentEndPx, v_segmentStartPx, v_width, v_angleEnd, capType, joinType);\n float distanceField = max(\n segmentDistanceField(currentPointPx, v_segmentStartPx, v_segmentEndPx, 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_?`${V_}\n${this.uniforms_.map((t=>`uniform ${t.type} ${t.name};`)).join("\n")}\nattribute vec2 a_position;\nattribute vec2 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 = unpackColor(a_hitColor);\n${this.attributes_.map((t=>` ${t.varyingName} = ${t.varyingExpression};`)).join("\n")}\n}`:null}getFillFragmentShader(){return this.hasFill_?`${V_}\n${this.uniforms_.map((t=>`uniform ${t.type} ${t.name};`)).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}}class Z_{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,e){if(!this.uidToRef_.get(z(t)))return;this.removeFeature(t);let i=t.getGeometry();i&&(e&&(i=i.clone(),i.applyTransform(e)),this.addGeometry_(i,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 Z_;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 Z_:e}}const Y_="GENERATE_POLYGON_BUFFERS",K_="GENERATE_POINT_BUFFERS",H_="GENERATE_LINE_STRING_BUFFERS";function q_(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===I_&&console.warn('The "has" operator might return false positives.'),void 0===l?l=I_: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 J_(t){return Object.keys(t).reduce(((e,i)=>e+(t[i].size||1)),0)}function Q_(t){return(JSON.stringify(t).split("").reduce(((t,e)=>(t<<5)-t+e.charCodeAt(0)),0)>>>0).toString()}function tm(t,e,i,n){if(`${n}radius`in t&&"icon-"!==n){let r=k_(i,t[`${n}radius`],$l);if(`${n}radius2`in t){r=`max(${r}, ${k_(i,t[`${n}radius2`],$l)})`}`${n}stroke-width`in t&&(r=`(${r} + ${k_(i,t[`${n}stroke-width`],$l)} * 0.5)`),e.setSymbolSizeExpression(`vec2(${r} * 2. + 0.5)`)}if(`${n}scale`in t){const r=k_(i,t[`${n}scale`],Kl);e.setSymbolSizeExpression(`${e.getSymbolSizeExpression()} * ${r}`)}`${n}displacement`in t&&e.setSymbolOffsetExpression(k_(i,t[`${n}displacement`],Yl)),`${n}rotation`in t&&e.setSymbolRotationExpression(k_(i,t[`${n}rotation`],$l)),`${n}rotate-with-view`in t&&e.setSymbolRotateWithView(!!t[`${n}rotate-with-view`])}function em(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 im(t,e,i,n,r){const s=new Image;s.crossOrigin=void 0===t[`${n}cross-origin`]?"anonymous":t[`${n}cross-origin`],It("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(`u_texture${r}_size`,"vec2");const o=`u_texture${r}_size`;return i[`u_texture${r}`]=s,e.addUniform(`u_texture${r}`,"sampler2D"),o}function nm(t,e,i,n,r){let s=k_(i,t[`${e}offset`],Kl);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 rm(t,e,i){const n={variables:{},properties:{},functions:{},bandCount:0,featureId:!1,geometryType:!1},r=new W_,s={};if("icon-src"in t?function(t,e,i,n){let r="vec4(1.0)";"icon-color"in t&&(r=k_(n,t["icon-color"],Zl)),"icon-opacity"in t&&(r=`${r} * vec4(1.0, 1.0, 1.0, ${k_(n,t["icon-opacity"],$l)})`);const s=Q_(t["icon-src"]),o=im(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(${k_(n,t["icon-width"],$l)}, ${k_(n,t["icon-height"],$l)})`),"icon-offset"in t&&"icon-size"in t){const i=k_(n,t["icon-size"],Yl),r=e.getSymbolSizeExpression();e.setSymbolSizeExpression(i);const s=nm(t,"icon-",n,"v_quadSizePx",i);e.setTextureCoordinateExpression(`(vec4((${s}).xyxy) + vec4(0., 0., ${i})) / (${r}).xyxy`)}if(tm(t,e,n,"icon-"),"icon-anchor"in t){const i=k_(n,t["icon-anchor"],Yl);let r,s="1.0";"icon-scale"in t&&(s=k_(n,t["icon-scale"],Kl)),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}",tm(t,e,n,"shape-");let r=null;"shape-opacity"in t&&(r=k_(n,t["shape-opacity"],$l));let s="coordsPx";"shape-scale"in t&&(s=`coordsPx / ${k_(n,t["shape-scale"],Kl)}`);let o=null;"shape-fill-color"in t&&(o=k_(n,t["shape-fill-color"],Zl));let a=null;"shape-stroke-color"in t&&(a=k_(n,t["shape-stroke-color"],Zl));let l=null;"shape-stroke-width"in t&&(l=k_(n,t["shape-stroke-width"],$l));const h=k_(n,t["shape-points"],$l);let c,u="0.";"shape-angle"in t&&(u=k_(n,t["shape-angle"],$l));let d=k_(n,t["shape-radius"],$l);if(null!==l&&(d=`${d} + ${l} * 0.5`),"shape-radius2"in t){let e=k_(n,t["shape-radius2"],$l);null!==l&&(e=`${e} + ${l} * 0.5`),c=`starDistanceField(${s}, ${h}, ${d}, ${e}, ${u})`}else c=`regularDistanceField(${s}, ${h}, ${d}, ${u})`;const g=em(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}",tm(t,e,n,"circle-");let r=null;"circle-opacity"in t&&(r=k_(n,t["circle-opacity"],$l));let s="coordsPx";"circle-scale"in t&&(s=`coordsPx / ${k_(n,t["circle-scale"],Kl)}`);let o=null;"circle-fill-color"in t&&(o=k_(n,t["circle-fill-color"],Zl));let a=null;"circle-stroke-color"in t&&(a=k_(n,t["circle-stroke-color"],Zl));let l=k_(n,t["circle-radius"],$l),h=null;"circle-stroke-width"in t&&(h=k_(n,t["circle-stroke-width"],$l),l=`(${l} + ${h} * 0.5)`);const c=em(`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(k_(n,t["stroke-color"],Zl)),"stroke-pattern-src"in t){const r=Q_(t["stroke-pattern-src"]),s=im(t,e,i,"stroke-pattern-",r);let o=s,a="vec2(0.)";"stroke-pattern-offset"in t&&"stroke-pattern-size"in t&&(o=k_(n,t["stroke-pattern-size"],Yl),a=nm(t,"stroke-pattern-",n,s,o));let l="0.";"stroke-pattern-spacing"in t&&(l=k_(n,t["stroke-pattern-spacing"],$l));let h="0.";"stroke-pattern-start-offset"in t&&(h=k_(n,t["stroke-pattern-start-offset"],$l)),n.functions.sampleStrokePattern="vec4 sampleStrokePattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, float spacingPx, float startOffsetPx, float currentLengthPx, float currentRadiusRatio, float lineWidth) {\n float currentLengthScaled = (currentLengthPx - startOffsetPx) * sampleSize.y / lineWidth;\n float spacingScaled = spacingPx * sampleSize.y / lineWidth;\n float uCoordPx = mod(currentLengthScaled, (sampleSize.x + spacingScaled));\n float isInsideOfPattern = step(uCoordPx, sampleSize.x);\n float vCoordPx = (-currentRadiusRatio * 0.5 + 0.5) * sampleSize.y;\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 vCoordPx = clamp(vCoordPx, 0.5, sampleSize.y - 0.5);\n vec2 texCoord = (vec2(uCoordPx, vCoordPx) + textureOffset) / textureSize;\n return texture2D(texture, texCoord) * vec4(1.0, 1.0, 1.0, isInsideOfPattern);\n}";const c=`u_texture${r}`;let u="1.";"stroke-color"in t&&(u=e.getStrokeColorExpression()),e.setStrokeColorExpression(`${u} * sampleStrokePattern(${c}, ${s}, ${a}, ${o}, ${l}, ${h}, currentLengthPx, currentRadiusRatio, v_width)`),n.functions.computeStrokePatternLength="float computeStrokePatternLength(vec2 sampleSize, float spacingPx, float lineWidth) {\n float patternLengthPx = sampleSize.x / sampleSize.y * lineWidth;\n return patternLengthPx + spacingPx;\n}",e.setStrokePatternLengthExpression(`computeStrokePatternLength(${o}, ${l}, v_width)`)}if("stroke-width"in t&&e.setStrokeWidthExpression(k_(n,t["stroke-width"],$l)),"stroke-offset"in t&&e.setStrokeOffsetExpression(k_(n,t["stroke-offset"],$l)),"stroke-line-cap"in t&&e.setStrokeCapExpression(k_(n,t["stroke-line-cap"],Wl)),"stroke-line-join"in t&&e.setStrokeJoinExpression(k_(n,t["stroke-line-join"],Wl)),"stroke-miter-limit"in t&&e.setStrokeMiterLimitExpression(k_(n,t["stroke-miter-limit"],$l)),"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 == ${T_("square")}) {\n distanceSegment -= lineWidth * 0.5;\n } else if (capType == ${T_("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=>k_(n,t,$l)));i.length%2==1&&(i=[...i,...i]);let r="0.";"stroke-line-dash-offset"in t&&(r=k_(n,t["stroke-line-dash-offset"],$l));const s=`dashDistanceField_${Q_(t["stroke-line-dash"])}`,o=i.map(((t,e)=>`float dashLength${e}`)).join(", "),a=i.map(((t,e)=>`dashLength${e}`)).join(" + ");let l="0.",h=`getSingleDashDistance(distance, radius, ${l}, dashLength0, totalDashLength, capType, lineWidth)`;for(let t=2;t`${t}`)).join(", ");e.setStrokeDistanceFieldExpression(`${s}(currentLengthPx + ${r}, currentRadiusPx, capType, v_width, ${c})`);let u=i.join(" + ");e.getStrokePatternLengthExpression()&&(n.functions.combinePatternLengths="float combinePatternLengths(float patternLength1, float patternLength2) {\n return patternLength1 * patternLength2;\n}",u=`combinePatternLengths(${e.getStrokePatternLengthExpression()}, ${u})`),e.setStrokePatternLengthExpression(u)}}(t,r,s,n),function(t,e,i,n){if("fill-color"in t&&e.setFillColorExpression(k_(n,t["fill-color"],Zl)),"fill-pattern-src"in t){const r=Q_(t["fill-pattern-src"]),s=im(t,e,i,"fill-pattern-",r);let o=s,a="vec2(0.)";"fill-pattern-offset"in t&&"fill-pattern-size"in t&&(o=k_(n,t["fill-pattern-size"],Yl),a=nm(t,"fill-pattern-",n,s,o)),n.functions.sampleFillPattern="vec4 sampleFillPattern(sampler2D texture, vec2 textureSize, vec2 textureOffset, vec2 sampleSize, vec2 pxOrigin, vec2 pxPosition) {\n float scaleRatio = pow(2., mod(u_zoom + 0.5, 1.) - 0.5);\n vec2 pxRelativePos = pxPosition - pxOrigin;\n // rotate the relative position from origin by the current view rotation\n pxRelativePos = vec2(pxRelativePos.x * cos(u_rotation) - pxRelativePos.y * sin(u_rotation), pxRelativePos.x * sin(u_rotation) + pxRelativePos.y * cos(u_rotation));\n // sample position is computed according to the sample offset & size\n vec2 samplePos = mod(pxRelativePos / scaleRatio, sampleSize);\n // also make sure that we're not sampling too close to the borders to avoid interpolation with outside pixels\n samplePos = clamp(samplePos, vec2(0.5), sampleSize - vec2(0.5));\n samplePos.y = sampleSize.y - samplePos.y; // invert y axis so that images appear upright\n return texture2D(texture, (samplePos + textureOffset) / textureSize);\n}";const l=`u_texture${r}`;let h="1.";"fill-color"in t&&(h=e.getFillColorExpression()),e.setFillColorExpression(`${h} * sampleFillPattern(${l}, ${s}, ${a}, ${o}, pxOrigin, pxPos)`)}}(t,r,s,n),i){const t=k_(n,i,Vl);r.setFragmentDiscardExpression(`!${t}`)}const o={};function a(t,e,i,s){if(!n[t])return;const a=U_(i),l=j_(i);r.addAttribute(`a_${e}`,a),o[e]={size:l,callback:s}}return a("geometryType",L_,Wl,(t=>C_(_h(t.getGeometry())))),a("featureId",M_,Wl|$l,(t=>{const e=t.getId()??null;return"string"==typeof e?C_(e):e})),B_(r,n),{builder:r,attributes:{...o,...X_(n)},uniforms:{...s,...z_(n,e)}}}const sm=[];let om;function am(){return om||(om=function(){const t='function t(t,n,x=2){const o=n&&n.length,i=o?n[0]*x:t.length;let f=e(t,0,i,x,!0);const l=[];if(!f||f.next===f.prev)return l;let c,y,h;if(o&&(f=function(t,n,r,x){const o=[];for(let r=0,i=n.length;r80*x){c=t[0],y=t[1];let e=c,n=y;for(let r=x;re&&(e=x),o>n&&(n=o)}h=Math.max(e-c,n-y),h=0!==h?32767/h:0}return r(f,l,x,c,y,h,0),l}function e(t,e,n,r,x){let o;if(x===function(t,e,n,r){let x=0;for(let o=e,i=n-r;o0)for(let x=e;x=e;x-=r)o=d(x/r|0,t[x],t[x+1],o);return o&&b(o,o.next)&&(w(o),o=o.next),o}function n(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!b(r,r.next)&&0!==v(r.prev,r,r.next))r=r.next;else{if(w(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function r(t,e,u,s,l,a,y){if(!t)return;!y&&a&&function(t,e,n,r){let x=t;do{0===x.z&&(x.z=c(x.x,x.y,e,n,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next}while(x!==t);x.prevZ.nextZ=null,x.prevZ=null,function(t){let e,n=1;do{let r,x=t;t=null;let o=null;for(e=0;x;){e++;let i=x,f=0;for(let t=0;t0||u>0&&i;)0!==f&&(0===u||!i||x.z<=i.z)?(r=x,x=x.nextZ,f--):(r=i,i=i.nextZ,u--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;x=i}o.nextZ=null,n*=2}while(e>1)}(x)}(t,s,l,a);let h=t;for(;t.prev!==t.next;){const c=t.prev,p=t.next;if(a?o(t,s,l,a):x(t))e.push(c.i,t.i,p.i),w(t),t=p.next,h=p.next;else if((t=p)===h){y?1===y?r(t=i(n(t),e),e,u,s,l,a,2):2===y&&f(t,e,u,s,l,a):r(n(t),e,u,s,l,a,1);break}}}function x(t){const e=t.prev,n=t,r=t.next;if(v(e,n,r)>=0)return!1;const x=e.x,o=n.x,i=r.x,f=e.y,u=n.y,s=r.y,l=Math.min(x,o,i),c=Math.min(f,u,s),a=Math.max(x,o,i),y=Math.max(f,u,s);let p=r.next;for(;p!==e;){if(p.x>=l&&p.x<=a&&p.y>=c&&p.y<=y&&h(x,f,o,u,i,s,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function o(t,e,n,r){const x=t.prev,o=t,i=t.next;if(v(x,o,i)>=0)return!1;const f=x.x,u=o.x,s=i.x,l=x.y,a=o.y,y=i.y,p=Math.min(f,u,s),b=Math.min(l,a,y),M=Math.max(f,u,s),m=Math.max(l,a,y),A=c(p,b,e,n,r),g=c(M,m,e,n,r);let Z=t.prevZ,d=t.nextZ;for(;Z&&Z.z>=A&&d&&d.z<=g;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;if(Z=Z.prevZ,d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;Z&&Z.z>=A;){if(Z.x>=p&&Z.x<=M&&Z.y>=b&&Z.y<=m&&Z!==x&&Z!==i&&h(f,l,u,a,s,y,Z.x,Z.y)&&v(Z.prev,Z,Z.next)>=0)return!1;Z=Z.prevZ}for(;d&&d.z<=g;){if(d.x>=p&&d.x<=M&&d.y>=b&&d.y<=m&&d!==x&&d!==i&&h(f,l,u,a,s,y,d.x,d.y)&&v(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function i(t,e){let r=t;do{const n=r.prev,x=r.next.next;!b(n,x)&&M(n,r,r.next,x)&&g(n,x)&&g(x,n)&&(e.push(n.i,r.i,x.i),w(r),w(r.next),r=t=x),r=r.next}while(r!==t);return n(r)}function f(t,e,x,o,i,f){let u=t;do{let t=u.next.next;for(;t!==u.prev;){if(u.i!==t.i&&p(u,t)){let s=Z(u,t);return u=n(u,u.next),s=n(s,s.next),r(u,e,x,o,i,f,0),void r(s,e,x,o,i,f,0)}t=t.next}u=u.next}while(u!==t)}function u(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function s(t,e){const r=function(t,e){let n=e;const r=t.x,x=t.y;let o,i=-1/0;if(b(t,n))return n;do{if(b(t,n.next))return n.next;if(x<=n.y&&x>=n.next.y&&n.next.y!==n.y){const t=n.x+(x-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>i&&(i=t,o=n.x=n.x&&n.x>=u&&r!==n.x&&y(xo.x||n.x===o.x&&l(o,n)))&&(o=n,c=e)}n=n.next}while(n!==f);return o}(t,e);if(!r)return e;const x=Z(r,t);return n(x,x.next),n(r,r.next)}function l(t,e){return v(t.prev,t,e.prev)<0&&v(e.next,t,t.next)<0}function c(t,e,n,r,x){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*x|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*x|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function a(t){let e=t,n=t;do{(e.x=(t-i)*(o-f)&&(t-i)*(r-f)>=(n-i)*(e-f)&&(n-i)*(o-f)>=(x-i)*(r-f)}function h(t,e,n,r,x,o,i,f){return!(t===i&&e===f)&&y(t,e,n,r,x,o,i,f)}function p(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&M(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(g(t,e)&&g(e,t)&&function(t,e){let n=t,r=!1;const x=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&x<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(v(t.prev,t,e.prev)||v(t,e.prev,e))||b(t,e)&&v(t.prev,t,t.next)>0&&v(e.prev,e,e.next)>0)}function v(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function b(t,e){return t.x===e.x&&t.y===e.y}function M(t,e,n,r){const x=A(v(t,e,n)),o=A(v(t,e,r)),i=A(v(n,r,t)),f=A(v(n,r,e));return x!==o&&i!==f||(!(0!==x||!m(t,n,e))||(!(0!==o||!m(t,r,e))||(!(0!==i||!m(n,t,r))||!(0!==f||!m(n,e,r)))))}function m(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function A(t){return t>0?1:t<0?-1:0}function g(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function Z(t,e){const n=F(t.i,t.x,t.y),r=F(e.i,e.x,e.y),x=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=x,x.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function d(t,e,n,r){const x=F(t,e,n);return r?(x.next=r.next,x.prev=r,r.next.prev=x,r.next=x):(x.prev=x,x.next=x),x}function w(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 F(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function E(t,e){const n=e[0],r=e[1];return e[0]=t[0]*n+t[2]*r+t[4],e[1]=t[1]*n+t[3]*r+t[5],e}function I(t,e){const n=(r=e)[0]*r[3]-r[1]*r[2];var r;!function(t,e){if(!t)throw new Error(e)}(0!==n,"Transformation matrix cannot be inverted");const x=e[0],o=e[1],i=e[2],f=e[3],u=e[4],s=e[5];return t[0]=f/n,t[1]=-o/n,t[2]=-i/n,t[3]=x/n,t[4]=(i*s-f*u)/n,t[5]=-(x*s-o*u)/n,t}new Array(6);const z=[],B={vertexAttributesPosition:0,instanceAttributesPosition:0,indicesPosition:0};function P(t,e,n,r,x){const o=t[e++],i=t[e++],f=z;f.length=r;for(let n=0;n0?u:2*Math.PI-u}let b=-1,M=-1,m=s;const A=null!==x;if(null!==r){b=v(h,p,E(f,[...[t[r],t[r+1]]])),Math.cos(b)<=.985&&(m+=Math.tan((b-Math.PI)/2))}if(A){M=v(p,h,E(f,[...[t[x],t[x+1]]])),Math.cos(M)<=.985&&(m+=Math.tan((Math.PI-M)/2))}const g=Math.pow(2,24),Z=u%g,d=Math.floor(u/g)*g;return o.push(l[0],l[1],a,c[0],c[1],y,b,M,Z,d,s),o.push(...i),{length:u+Math.sqrt((p[0]-h[0])*(p[0]-h[0])+(p[1]-h[1])*(p[1]-h[1])),angle:m}}function R(e,n,r,x,o){const i=2+o;let f=n;const u=e.slice(f,f+o);f+=o;const s=e[f++];let l=0;const c=new Array(s-1);for(let t=0;t{const e=t.data;switch(e.type){case T:{const t=2,n=2,r=e.customAttributesSize,x=n+r,o=new Float32Array(e.renderInstructions),i=o.length/x*(t+r),f=Uint32Array.from([0,1,3,1,2,3]),u=Float32Array.from([-1,-1,1,-1,1,1,-1,1]),s=new Float32Array(i);let l;for(let t=0;t0?y=o+(n-1)*r:l&&(y=s-r);let h=null;n["!",t]))],i.filter&&s.push(i.filter),s.length<3&&(s=s[1])),i.filter&&r.push(i.filter);const o=n.map((t=>rm(t,e,s)));t.push(...o)}return t}if("builder"in i[0])return i;return i.map((t=>rm(t,e,null)))}(t,e),this.customAttributes_={},this.uniforms_={},this.hitDetectionEnabled_&&(this.customAttributes_.hitColor={callback(){return function(t,e){e=e||[];const i=256,n=255,r=Math.floor(t/i/i/i)/n,s=Math.floor(t/i/i)%i/n,o=Math.floor(t/i)%i/n,a=t%i/n;return e[0]=256*r*255+255*s,e[1]=256*o*255+255*a,e}(this.ref,sm)},size:2});for(const t of this.styleShaders){for(const e in t.attributes)e in this.customAttributes_||(this.customAttributes_[e]=t.attributes[e]);for(const e in t.uniforms)e in this.uniforms_||(this.uniforms_[e]=t.uniforms[e])}this.renderPasses_=this.styleShaders.map((t=>{const e={},i=Object.entries(this.customAttributes_).map((([e,i])=>({name:e in t.attributes||"hitColor"===e?`a_${e}`:null,size:i.size||1,type:o_})));return t.builder.getFillVertexShader()&&(e.fillRenderPass={vertexShader:t.builder.getFillVertexShader(),fragmentShader:t.builder.getFillFragmentShader(),attributesDesc:[{name:hm,size:2,type:o_},...i],instancedAttributesDesc:[],instancePrimitiveVertexCount:3}),t.builder.getStrokeVertexShader()&&(e.strokeRenderPass={vertexShader:t.builder.getStrokeVertexShader(),fragmentShader:t.builder.getStrokeFragmentShader(),attributesDesc:[{name:cm,size:2,type:o_}],instancedAttributesDesc:[{name:um,size:2,type:o_},{name:gm,size:1,type:o_},{name:dm,size:2,type:o_},{name:fm,size:1,type:o_},{name:_m,size:2,type:o_},{name:mm,size:1,type:o_},{name:ym,size:1,type:o_},{name:pm,size:1,type:o_},...i],instancePrimitiveVertexCount:6}),t.builder.getSymbolVertexShader()&&(e.symbolRenderPass={vertexShader:t.builder.getSymbolVertexShader(),fragmentShader:t.builder.getSymbolFragmentShader(),attributesDesc:[{name:cm,size:2,type:o_}],instancedAttributesDesc:[{name:hm,size:2,type:o_},...i],instancePrimitiveVertexCount:6}),e})),this.hasFill_=this.renderPasses_.some((t=>t.fillRenderPass)),this.hasStroke_=this.renderPasses_.some((t=>t.strokeRenderPass)),this.hasSymbol_=this.renderPasses_.some((t=>t.symbolRenderPass)),this.setHelper(i)}async generateBuffers(t,e){if(t.isEmpty())return null;const i=this.generateRenderInstructions_(t,e),[n,r,s]=await Promise.all([this.generateBuffersForType_(i.polygonInstructions,"Polygon",e),this.generateBuffersForType_(i.lineStringInstructions,"LineString",e),this.generateBuffersForType_(i.pointInstructions,"Point",e)]);return{polygonBuffers:n,lineStringBuffers:r,pointBuffers:s,invertVerticesTransform:tr([1,0,0,1,0,0],e)}}generateRenderInstructions_(t,e){const i=this.hasFill_?function(t,e,i,n){const r=2*t.verticesCount+(1+J_(i))*t.geometriesCount+t.ringsCount;e&&e.length===r||(e=new Float32Array(r));const s=[];let o=0;for(const r in t.entries){const a=t.entries[r];for(let t=0,r=a.flatCoordss.length;t{const e=i=>{const r=i.data;if(r.id!==n)return;if(o.removeEventListener("message",e),!this.helper_.getGL())return;const s=new qp(Zp,Yp).fromArrayBuffer(r.indicesBuffer),a=new qp(Wp,Yp).fromArrayBuffer(r.vertexAttributesBuffer),l=new qp(Wp,Yp).fromArrayBuffer(r.instanceAttributesBuffer);this.helper_.flushBufferData(s),this.helper_.flushBufferData(a),this.helper_.flushBufferData(l),t([s,a,l])};o.addEventListener("message",e)}))}render(t,e,i){for(const n of this.renderPasses_)n.fillRenderPass&&this.renderInternal_(t.polygonBuffers[0],t.polygonBuffers[1],t.polygonBuffers[2],n.fillRenderPass,e,i),n.strokeRenderPass&&this.renderInternal_(t.lineStringBuffers[0],t.lineStringBuffers[1],t.lineStringBuffers[2],n.strokeRenderPass,e,i),n.symbolRenderPass&&this.renderInternal_(t.pointBuffers[0],t.pointBuffers[1],t.pointBuffers[2],n.symbolRenderPass,e,i)}renderInternal_(t,e,i,n,r,s){const o=t.getSize();if(0===o)return;const a=n.instancedAttributesDesc.length;if(this.helper_.useProgram(n.program,r),this.helper_.bindBuffer(e),this.helper_.bindBuffer(t),this.helper_.enableAttributes(n.attributesDesc),this.helper_.bindBuffer(i),this.helper_.enableAttributesInstanced(n.instancedAttributesDesc),s(),a){const t=n.instancedAttributesDesc.reduce(((t,e)=>t+(e.size||1)),0),e=i.getSize()/t;this.helper_.drawElementsInstanced(0,o,e)}else this.helper_.drawElements(0,o)}setHelper(t,e=null){this.helper_=t;for(const t of this.renderPasses_)t.fillRenderPass&&(t.fillRenderPass.program=this.helper_.getProgram(t.fillRenderPass.fragmentShader,t.fillRenderPass.vertexShader)),t.strokeRenderPass&&(t.strokeRenderPass.program=this.helper_.getProgram(t.strokeRenderPass.fragmentShader,t.strokeRenderPass.vertexShader)),t.symbolRenderPass&&(t.symbolRenderPass.program=this.helper_.getProgram(t.symbolRenderPass.fragmentShader,t.symbolRenderPass.vertexShader));this.helper_.addUniforms(this.uniforms_),e&&(e.polygonBuffers&&(this.helper_.flushBufferData(e.polygonBuffers[0]),this.helper_.flushBufferData(e.polygonBuffers[1]),this.helper_.flushBufferData(e.polygonBuffers[2])),e.lineStringBuffers&&(this.helper_.flushBufferData(e.lineStringBuffers[0]),this.helper_.flushBufferData(e.lineStringBuffers[1]),this.helper_.flushBufferData(e.lineStringBuffers[2])),e.pointBuffers&&(this.helper_.flushBufferData(e.pointBuffers[0]),this.helper_.flushBufferData(e.pointBuffers[1]),this.helper_.flushBufferData(e.pointBuffers[2])))}}const vm=new Uint8Array(4);class Sm{constructor(t,e){this.helper_=t;const i=t.getGL();this.texture_=i.createTexture(),this.framebuffer_=i.createFramebuffer(),this.depthbuffer_=i.createRenderbuffer(),this.size_=e||[1,1],this.data_=new Uint8Array(0),this.dataCacheDirty_=!0,this.updateSize_()}setSize(t){E(t,this.size_)||(this.size_[0]=t[0],this.size_[1]=t[1],this.updateSize_())}getSize(){return this.size_}clearCachedData(){this.dataCacheDirty_=!0}readAll(){if(this.dataCacheDirty_){const t=this.size_,e=this.helper_.getGL();e.bindFramebuffer(e.FRAMEBUFFER,this.framebuffer_),e.readPixels(0,0,t[0],t[1],e.RGBA,e.UNSIGNED_BYTE,this.data_),this.dataCacheDirty_=!1}return this.data_}readPixel(t,e){if(t<0||e<0||t>this.size_[0]||e>=this.size_[1])return vm[0]=0,vm[1]=0,vm[2]=0,vm[3]=0,vm;this.readAll();const i=Math.floor(t)+(this.size_[1]-Math.floor(e)-1)*this.size_[0];return vm[0]=this.data_[4*i],vm[1]=this.data_[4*i+1],vm[2]=this.data_[4*i+2],vm[3]=this.data_[4*i+3],vm}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)}}const wm={...i_,RENDER_EXTENT:"u_renderExtent",PATTERN_ORIGIN:"u_patternOrigin",GLOBAL_ALPHA:"u_globalAlpha"};class Em extends g_{constructor(t,e){super(t,{uniforms:{[wm.RENDER_EXTENT]:[0,0,0,0],[wm.PATTERN_ORIGIN]:[0,0],[wm.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.style_=[],this.styleRenderer_=null,this.buffers_=null,this.applyOptions_(e),this.batch_=new Z_,this.initialFeaturesAdded_=!1,this.sourceListenKeys_=null}addInitialFeatures_(t){const e=this.getLayer().getSource(),i=Nn();let n;i&&(n=Fn(i,t.viewState.projection)),this.batch_.addFeatures(e.getFeatures(),n),this.sourceListenKeys_=[D(e,Od,this.handleSourceFeatureAdded_.bind(this,n)),D(e,Dd,this.handleSourceFeatureChanged_.bind(this,n),this),D(e,kd,this.handleSourceFeatureDelete_,this),D(e,Nd,this.handleSourceFeatureClear_,this)]}applyOptions_(t){this.styleVariables_=t.variables,this.style_=t.style}createRenderers_(){this.buffers_=null,this.styleRenderer_=new xm(this.style_,this.styleVariables_,this.helper,this.hitDetectionEnabled_)}reset(t){this.applyOptions_(t),this.helper&&this.createRenderers_(),super.reset(t)}afterHelperCreated(){this.styleRenderer_?this.styleRenderer_.setHelper(this.helper,this.buffers_):this.createRenderers_(),this.hitDetectionEnabled_&&(this.hitRenderTarget_=new Sm(this.helper))}handleSourceFeatureAdded_(t,e){const i=e.feature;this.batch_.addFeature(i,t)}handleSourceFeatureChanged_(t,e){const i=e.feature;this.batch_.changeFeature(i,t)}handleSourceFeatureDelete_(t){const e=t.feature;this.batch_.removeFeature(e)}handleSourceFeatureClear_(){this.batch_.clear()}applyUniforms_(t){Kn(this.tmpTransform_,this.currentFrameStateTransform_),Zn(this.tmpTransform_,t),this.helper.setUniformMatrixValue(wm.PROJECTION_MATRIX,Vd(this.tmpMat4_,this.tmpTransform_)),tr(this.tmpTransform_,this.tmpTransform_),this.helper.setUniformMatrixValue(wm.SCREEN_TO_WORLD_MATRIX,Vd(this.tmpMat4_,this.tmpTransform_)),this.tmpCoords_[0]=0,this.tmpCoords_[1]=0,tr(this.tmpTransform_,t),Hn(this.tmpTransform_,this.tmpCoords_),this.helper.setUniformFloatVec2(wm.PATTERN_ORIGIN,this.tmpCoords_)}renderFrame(t){const e=this.helper.getGL();this.preRender(e,t);const[i,n,r]=function(t,e){const i=t.viewState.projection,n=e.getSource().getWrapX()&&i.canWrapX(),r=i.getExtent(),s=t.extent,o=n?ve(r):null,a=n?Math.ceil((s[2]-r[2])/o)+1:1;return[n?Math.floor((s[0]-r[0])/o):0,a,o]}(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[oo]&&!t.viewHints[ao],s=!te(this.previousExtent_,t.extent),o=this.sourceRevision_{this.buffers_&&this.disposeBuffers(this.buffers_),this.buffers_=t,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_),Jn(this.currentFrameStateTransform_,s*r,0),this.buffers_&&this.styleRenderer_.render(this.buffers_,t,(()=>{this.applyUniforms_(this.buffers_.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_&&this.disposeBuffers(this.buffers_),this.sourceListenKeys_&&(this.sourceListenKeys_.forEach((function(t){k(t)})),this.sourceListenKeys_=null),super.disposeInternal()}renderDeclutter(){}}const Cm="blur",Tm="gradient",Rm="radius",bm=["#00f","#0ff","#0f0","#ff0","#f00"];const Pm="addfeatures";class Fm extends I{constructor(t,e,i,n){super(t),this.features=i,this.file=e,this.projection=n}}function Mm(t,e){const i=t.length;return e<0?t[e+i]:e>=i?t[e-i]:t[e]}function Lm(t,e){const i=t.length;let n=Math.floor(e);const r=e-n;n>=i?n-=i:n<0&&(n+=i);let s=n+1;s>=i&&(s-=i);const o=t[n],a=o[0],l=o[1],h=t[s];return[a+(h[0]-a)*r,l+(h[1]-l)*r]}const Im={index:-1,endIndex:NaN,closestTargetDistance:1/0};function Am(t,e,i,n){const r=t[0],s=t[1];let o=1/0,a=-1,l=NaN;for(let t=0;ti.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=Lm(h.coordinates,l);li(i.getPixelFromCoordinate(t),i.getPixelFromCoordinate(e.startCoord))>n&&(c=!1)}if(c){const t=h.coordinates,e=t.length,i=h.startIndex,n=l;if(io){return km(Lm(t,n),Lm(t,r))}let a=0;if(n=0;--i){const n=e[i];if(n!==this&&n instanceof fy&&n.getStyle()&&-1!==n.getFeatures().getArray().lastIndexOf(t))return void t.setStyle(n.getStyle())}const i=z(t);t.setStyle(gy[i]),delete gy[i]}removeFeatureLayerAssociation_(t){delete this.featureLayerAssociation_[z(t)]}selectFeatureInternal_(t,e,i){if(!(t instanceof At))return;if(!this.filter_(t,e))return;const n=this.getFeatures();return n.getArray().includes(t)||(this.addFeatureLayerAssociation_(t,e),n.push(t),i?.push(t)),t}selectFeature(t){const e=this.findLayerOfFeature_(t);if(!this.layerFilter_(e))return!1;const i=this.selectFeatureInternal_(t,e);return i&&this.dispatchEvent(new dy(uy,[i],[],void 0)),!!i}removeFeatureInternal_(t,e){const i=this.getFeatures();if(t instanceof At&&i.getArray().includes(t))return i.remove(t),this.removeFeatureLayerAssociation_(t),e?.push(t),t}deselectFeature(t){const e=this.removeFeatureInternal_(t);return e&&this.dispatchEvent(new dy(uy,[],[e],void 0)),!!e}toggleFeature(t){this.deselectFeature(t)||this.selectFeature(t)}clearSelection(){M(this.featureLayerAssociation_);const t=this.getFeatures(),e=t.getArray().slice();t.clear(),0!==e.length&&this.dispatchEvent(new dy(uy,[],e,void 0))}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){let e=!1;s.forEachFeatureAtPixel(t.pixel,((t,i)=>{if(e=!0,this.selectFeatureInternal_(t,i,l))return!this.multi_}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});for(let t=o.getLength()-1;t>=0;--t){const i=o.item(t);(l.length>0&&!l.includes(i)||!e)&&this.removeFeatureInternal_(i,a)}}else s.forEachFeatureAtPixel(t.pixel,((t,r)=>{let s;if((i||n)&&(s=this.removeFeatureInternal_(t,a)),!e&&!n||s||(s=this.selectFeatureInternal_(t,r,l)),s)return!this.multi_}),{layerFilter:this.layerFilter_,hitTolerance:this.hitTolerance_});return(l.length>0||a.length>0)&&this.dispatchEvent(new dy(uy,l,a,t)),!0}}const py="snap",_y="unsnap";class my extends I{constructor(t,e){super(t),this.vertex=e.vertex,this.vertexPixel=e.vertexPixel,this.feature=e.feature,this.segment=e.segment}}const yy={Circle(t,e){let i=t;const n=Nn();n&&(i=i.clone().transform(n,e));const r=ds(i);return n&&r.transform(e,n),yy.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;tIy({...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 Fy(new Ld(n,"Polygon"===n?function(t,e,i){return Array.isArray(e[0])?(ss(t,0,e,i)||as(t=t.slice(),0,e,i),t):(rs(t,0,e,i)||os(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 Ay(t,e){if(!t)return null;if(Array.isArray(t)){const i=t.map((t=>Ay(t,e)));return new Ed(i)}return Fy(new(0,Ly[t.type])(t.flatCoordinates,t.layout||"XY",t.ends),!1,e)}class Oy extends Py{constructor(){super(),this.xmlSerializer_=Gf()}getType(){return"xml"}readFeature(t,e){if(!t)return null;if("string"==typeof t){const i=vf(t);return this.readFeatureFromDocument(i,e)}return yf(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=vf(t);return this.readFeaturesFromDocument(i,e)}return yf(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&&w(i,this.readFeaturesFromNode(n,e));return i}readFeaturesFromNode(t,e){return U()}readGeometry(t,e){if(!t)return null;if("string"==typeof t){const i=vf(t);return this.readGeometryFromDocument(i,e)}return yf(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=vf(t);return this.readProjectionFromDocument(e)}return yf(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}}function Dy(t){return Ny(_f(t,!1))}function Ny(t){const e=/^\s*(true|1)|(false|0)\s*$/.exec(t);if(e)return void 0!==e[1]||!1}function ky(t){const e=_f(t,!1),i=Date.parse(e);return isNaN(i)?void 0:i/1e3}function Gy(t){return jy(_f(t,!1))}function jy(t){const e=/^\s*([+\-]?\d*\.?\d+(?:e[+\-]?\d+)?)\s*$/i.exec(t);if(e)return parseFloat(e[1])}function Uy(t){return By(_f(t,!1))}function By(t){const e=/^\s*(\d+)\s*$/.exec(t);if(e)return parseInt(e[1],10)}function zy(t){return _f(t,!1).trim()}function Xy(t,e){qy(t,e?"1":"0")}function Vy(t,e){t.appendChild(jf().createCDATASection(e))}function $y(t,e){const i=new Date(1e3*e),n=i.getUTCFullYear()+"-"+qe(i.getUTCMonth()+1,2)+"-"+qe(i.getUTCDate(),2)+"T"+qe(i.getUTCHours(),2)+":"+qe(i.getUTCMinutes(),2)+":"+qe(i.getUTCSeconds(),2)+"Z";t.appendChild(jf().createTextNode(n))}function Wy(t,e){const i=e.toPrecision();t.appendChild(jf().createTextNode(i))}function Zy(t,e){const i=e.toString();t.appendChild(jf().createTextNode(i))}const Yy=/^\s/,Ky=/\s$/,Hy=/(\n|\t|\r|<|&| {2})/;function qy(t,e){"string"==typeof e&&(Yy.test(e)||Ky.test(e)||Hy.test(e))?e.split("]]>").forEach(((e,i,n)=>{i0&&(e=">"+e),Vy(t,e)})):t.appendChild(jf().createTextNode(e))}const Jy=[null,"http://www.topografix.com/GPX/1/0","http://www.topografix.com/GPX/1/1"],Qy={rte:Fx,trk:Mx,wpt:Lx},tx=Lf(Jy,{rte:wf(Fx),trk:wf(Mx),wpt:wf(Lx)}),ex=Lf(Jy,{text:Tf(zy,"linkText"),type:Tf(zy,"linkType")}),ix=Lf(Jy,{name:Tf(zy),email:function(t,e){const i=e[e.length-1],n=t.getAttribute("id"),r=t.getAttribute("domain");null!==n&&null!==r&&(i.email=`${n}@${r}`)},link:bx}),nx=Lf(Jy,{name:Tf(zy),desc:Tf(zy),author:Tf((function(t,e){const i=Af({},ix,t,e);if(i)return i;return})),copyright:Tf((function(t,e){const i=Af({},rx,t,e);if(i){const e=t.getAttribute("author");return null!==e&&(i.author=e),i}return})),link:bx,time:Tf(ky),keywords:Tf(zy),bounds:function(t,e){const i=e[e.length-1],n=t.getAttribute("minlat"),r=t.getAttribute("minlon"),s=t.getAttribute("maxlat"),o=t.getAttribute("maxlon");null!==r&&null!==n&&null!==o&&null!==s&&(i.bounds=[[parseFloat(r),parseFloat(n)],[parseFloat(o),parseFloat(s)]])},extensions:Px}),rx=Lf(Jy,{year:Tf(Uy),license:Tf(zy)}),sx=Lf(Jy,{rte:Rf((function(t,e,i){const n=i[0],r=e.getProperties(),s={node:t};s.properties=r;const o=e.getGeometry();if("LineString"==o.getType()){const t=Fy(o,!0,n);s.geometryLayout=t.getLayout(),r.rtept=t.getCoordinates()}const a=i[i.length-1].node,l=fx[a.namespaceURI],h=Mf(r,l);Df(s,px,Ff,h,i,l)})),trk:Rf((function(t,e,i){const n=i[0],r=e.getProperties(),s={node:t};s.properties=r;const o=e.getGeometry();if("MultiLineString"==o.getType()){const t=Fy(o,!0,n);r.trkseg=t.getLineStrings()}const a=i[i.length-1].node,l=mx[a.namespaceURI],h=Mf(r,l);Df(s,yx,Ff,h,i,l)})),wpt:Rf((function(t,e,i){const n=i[0],r=i[i.length-1];r.properties=e.getProperties();const s=e.getGeometry();if("Point"==s.getType()){const e=Fy(s,!0,n);r.geometryLayout=e.getLayout(),Ax(t,e.getCoordinates(),i)}}))});const ox=Lf(Jy,{name:Tf(zy),cmt:Tf(zy),desc:Tf(zy),src:Tf(zy),link:bx,number:Tf(Uy),extensions:Px,type:Tf(zy),rtept:function(t,e){const i=Af({},ax,t,e);if(i){const n=e[e.length-1];Tx(n.flatCoordinates,n.layoutOptions,t,i)}}}),ax=Lf(Jy,{ele:Tf(Gy),time:Tf(ky)}),lx=Lf(Jy,{name:Tf(zy),cmt:Tf(zy),desc:Tf(zy),src:Tf(zy),link:bx,number:Tf(Uy),type:Tf(zy),extensions:Px,trkseg:function(t,e){const i=e[e.length-1];If(hx,t,e);const n=i.flatCoordinates;i.ends.push(n.length)}}),hx=Lf(Jy,{trkpt:function(t,e){const i=Af({},cx,t,e);if(i){const n=e[e.length-1];Tx(n.flatCoordinates,n.layoutOptions,t,i)}}}),cx=Lf(Jy,{ele:Tf(Gy),time:Tf(ky)}),ux=Lf(Jy,{ele:Tf(Gy),time:Tf(ky),magvar:Tf(Gy),geoidheight:Tf(Gy),name:Tf(zy),cmt:Tf(zy),desc:Tf(zy),src:Tf(zy),link:bx,sym:Tf(zy),type:Tf(zy),fix:Tf(zy),sat:Tf(Uy),hdop:Tf(Gy),vdop:Tf(Gy),pdop:Tf(Gy),ageofdgpsdata:Tf(Gy),dgpsid:Tf(Uy),extensions:Px}),dx=["text","type"],gx=Lf(Jy,{text:Rf(qy),type:Rf(qy)}),fx=Lf(Jy,["name","cmt","desc","src","link","number","type","rtept"]),px=Lf(Jy,{name:Rf(qy),cmt:Rf(qy),desc:Rf(qy),src:Rf(qy),link:Rf(Ix),number:Rf(Zy),type:Rf(qy),rtept:bf(Rf(Ax))}),_x=Lf(Jy,["ele","time"]),mx=Lf(Jy,["name","cmt","desc","src","link","number","type","trkseg"]),yx=Lf(Jy,{name:Rf(qy),cmt:Rf(qy),desc:Rf(qy),src:Rf(qy),link:Rf(Ix),number:Rf(Zy),type:Rf(qy),trkseg:bf(Rf((function(t,e,i){const n={node:t};n.geometryLayout=e.getLayout(),n.properties={},Df(n,vx,xx,e.getCoordinates(),i)})))}),xx=Pf("trkpt"),vx=Lf(Jy,{trkpt:Rf(Ax)}),Sx=Lf(Jy,["ele","time","magvar","geoidheight","name","cmt","desc","src","link","sym","type","fix","sat","hdop","vdop","pdop","ageofdgpsdata","dgpsid"]),wx=Lf(Jy,{ele:Rf(Wy),time:Rf($y),magvar:Rf(Wy),geoidheight:Rf(Wy),name:Rf(qy),cmt:Rf(qy),desc:Rf(qy),src:Rf(qy),link:Rf(Ix),sym:Rf(qy),type:Rf(qy),fix:Rf(qy),sat:Rf(Zy),hdop:Rf(Wy),vdop:Rf(Wy),pdop:Rf(Wy),ageofdgpsdata:Rf(Wy),dgpsid:Rf(Zy)}),Ex={Point:"wpt",LineString:"rte",MultiLineString:"trk"};function Cx(t,e,i){const n=t.getGeometry();if(n){const t=Ex[n.getType()];if(t){return pf(e[e.length-1].node.namespaceURI,t)}}}function Tx(t,e,i,n){return t.push(parseFloat(i.getAttribute("lon")),parseFloat(i.getAttribute("lat"))),"ele"in n?(t.push(n.ele),delete n.ele,e.hasZ=!0):t.push(0),"time"in n?(t.push(n.time),delete n.time,e.hasM=!0):t.push(0),t}function Rx(t,e,i){let n="XY",r=2;if(t.hasZ&&t.hasM?(n="XYZM",r=4):t.hasZ?(n="XYZ",r=3):t.hasM&&(n="XYM",r=3),4!==r){for(let i=0,n=e.length/4;i0){e[e.length-1].push(...i)}},outerBoundaryIs:function(t,e){const i=Af(void 0,rS,t,e);if(i){e[e.length-1][0]=i}}});function $v(t,e){const i=Af({},Gv,t,e),n=Af([null],Vv,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=ov);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=iv,h=nv,c=rv):o.includes("arrow-reverse")?(l=[54,42],h=nv,c=rv):o.includes("paddle")&&(l=[32,1],h=nv,c=rv));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=Oe(v));const S=i.scale,w=i.color;if(s){o==ov&&(_=sv);const t=new nc({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:w}),e=t.getScaleArray()[0],i=t.getSize();if(null===i){const i=t.getImageState();if(i===Rs||i===bs){const n=function(){const i=t.getImageState();if(i!==Rs&&i!==bs){const i=t.getSize();if(i&&2==i.length){const n=_v(i);t.setScale(e*n)}t.unlistenImageChange(n)}};t.listenImageChange(n),i===Rs&&t.load()}}else if(2==i.length){const n=_v(i);t.setScale(e*n)}n.imageStyle=t}else n.imageStyle=lv},LabelStyle:function(t,e){const i=Af({},bv,t,e);if(!i)return;const n=e[e.length-1],r=new uc({fill:new ec({color:"color"in i?i.color:ev}),scale:i.scale});n.textStyle=r},LineStyle:function(t,e){const i=Af({},Pv,t,e);if(!i)return;const n=e[e.length-1],r=new rc({color:"color"in i?i.color:ev,width:"width"in i?i.width:1});n.strokeStyle=r},PolyStyle:function(t,e){const i=Af({},Fv,t,e);if(!i)return;const n=e[e.length-1],r=new ec({color:"color"in i?i.color:ev});n.fillStyle=r;const s=i.fill;void 0!==s&&(n.fill=s);const o=i.outline;void 0!==o&&(n.outline=o)}});function Zv(t,e){const i=Af({},Wv,t,e,this);if(!i)return null;let n="fillStyle"in i?i.fillStyle:av;const r=i.fill;let s;void 0===r||r||(n=null),"imageStyle"in i?i.imageStyle!=lv&&(s=i.imageStyle):s=hv;const o="textStyle"in i?i.textStyle:dv,a="strokeStyle"in i?i.strokeStyle:uv,l=i.outline;return void 0===l||l?[new sc({fill:n,image:s,stroke:a,text:o,zIndex:void 0})]:[new sc({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new Ed(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 sc({geometry:function(t){const e=t.getGeometry(),i=e.getType();if("GeometryCollection"===i){return new Ed(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 Yv(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=Mf(r,o);Df(n,FS,LS,[{names:o,values:t}],i)}const u=i[0];let d=e.getGeometry();d&&(d=Fy(d,!0,u)),Df(n,FS,vS,[d],i)}const AS=Lf(Wx,["extrude","tessellate","altitudeMode","coordinates"]),OS=Lf(Wx,{extrude:Rf(Xy),tessellate:Rf(Xy),altitudeMode:Rf(qy),coordinates:Rf((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)*$S;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*$S;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 KS(t,r,e);if(s=n[i.pos++],r|=(127&s)<<3,s<128)return KS(t,r,e);if(s=n[i.pos++],r|=(127&s)<<10,s<128)return KS(t,r,e);if(s=n[i.pos++],r|=(127&s)<<17,s<128)return KS(t,r,e);if(s=n[i.pos++],r|=(127&s)<<24,s<128)return KS(t,r,e);if(s=n[i.pos++],r|=(1&s)<<31,s<128)return KS(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&&ZS?ZS.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&&HS(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&&HS(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,qS,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,JS,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,ew,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,QS,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,tw,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,iw,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,nw,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,rw,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,sw,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 KS(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function HS(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 qS(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 lw(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 kw(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 Uw={Point:function(t,e,i){const n=t.coordinates;e&&i&&$w(n,e,i);return new zr(n)},LineString:function(t,e){const i=Bw(t.arcs,e);return new Rd(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 zw(t,e,i,n,r,s,o){const a=t.geometries,l=[];for(let t=0,h=a.length;t0&&!(t instanceof dr)){t={_content_:t};for(let e=0;e=2,"At least 2 conditions are required")}}class rE extends nE{constructor(t){super("And",Array.prototype.slice.call(arguments))}}class sE extends iE{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}}const oE={"http://www.opengis.net/gml":{boundedBy:Tf(Yw.prototype.readExtentElement,"bounds")},"http://www.opengis.net/wfs/2.0":{member:wf(Yw.prototype.readFeaturesInternal)}},aE={"http://www.opengis.net/wfs":{totalInserted:Tf(Uy),totalUpdated:Tf(Uy),totalDeleted:Tf(Uy)},"http://www.opengis.net/wfs/2.0":{totalInserted:Tf(Uy),totalUpdated:Tf(Uy),totalDeleted:Tf(Uy)}},lE={"http://www.opengis.net/wfs":{TransactionSummary:Tf(xE,"transactionSummary"),InsertResults:Tf(EE,"insertIds")},"http://www.opengis.net/wfs/2.0":{TransactionSummary:Tf(xE,"transactionSummary"),InsertResults:Tf(EE,"insertIds")}},hE={"http://www.opengis.net/wfs":{PropertyName:Rf(qy)},"http://www.opengis.net/wfs/2.0":{PropertyName:Rf(qy)}},cE={"http://www.opengis.net/wfs":{Insert:Rf(CE),Update:Rf(PE),Delete:Rf(bE),Property:Rf(FE),Native:Rf(ME)},"http://www.opengis.net/wfs/2.0":{Insert:Rf(CE),Update:Rf(PE),Delete:Rf(bE),Property:Rf(FE),Native:Rf(ME)}},uE="feature",dE="http://www.w3.org/2000/xmlns/",gE={"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"},fE={"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"},pE={"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"},_E={"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"},mE={"2.0.0":eE,"1.1.0":tE,"1.0.0":qw};function yE(t,e,i,n){Df(n,cE,Pf(t),e,i)}function xE(t,e){return Af({},aE,t,e)}const vE={"http://www.opengis.net/ogc":{FeatureId:wf((function(t,e){return t.getAttribute("fid")}))},"http://www.opengis.net/ogc/1.1":{FeatureId:wf((function(t,e){return t.getAttribute("fid")}))}};function SE(t,e){If(vE,t,e)}const wE={"http://www.opengis.net/wfs":{Feature:SE},"http://www.opengis.net/wfs/2.0":{Feature:SE}};function EE(t,e){return Af([],wE,t,e)}function CE(t,e,i){const n=i[i.length-1],r=n.featureType,s=n.featureNS,o=n.gmlVersion,a=pf(s,r);t.appendChild(a),2===o?qw.prototype.writeFeatureElement(a,e,i):3===o?tE.prototype.writeFeatureElement(a,e,i):eE.prototype.writeFeatureElement(a,e,i)}function TE(t,e,i){const n=i[i.length-1].version,r=gE[n],s=pf(r,"Filter"),o=pf(r,"FeatureId");s.appendChild(o),o.setAttribute("fid",e),t.appendChild(s)}function RE(t,e){const i=(t=t||uE)+":";return e.startsWith(i)?e:i+e}function bE(t,e,i){const n=i[i.length-1];It(void 0!==e.getId(),"Features must have an id set");const r=n.featureType,s=n.featurePrefix,o=n.featureNS,a=RE(s,r);t.setAttribute("typeName",a),t.setAttributeNS(dE,"xmlns:"+s,o);const l=e.getId();void 0!==l&&TE(t,l,i)}function PE(t,e,i){const n=i[i.length-1];It(void 0!==e.getId(),"Features must have an id set");const r=n.version,s=n.featureType,o=n.featurePrefix,a=n.featureNS,l=RE(o,s),h=e.getGeometryName();t.setAttribute("typeName",l),t.setAttributeNS(dE,"xmlns:"+o,a);const c=e.getId();if(void 0!==c){const s=e.getKeys(),o=[];for(let t=0,i=s.length;t-1;return n&&t.splice(i,1),n},RC.array.reverseSubArray=S,RC.array.stableSort=function(t,e){const i=t.length,n=Array(t.length);let r;for(r=0;rZe.info||console.log(...t)},RC.console.setLevel=function(t){Ye=Ze[t]},RC.console.warn=Ke,RC.control={},RC.control.Attribution=Uo,RC.control.Control=jo,RC.control.FullScreen=class extends jo{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} ${Ao}`,this.element.appendChild(this.button_)}handleClick_(t){t.preventDefault(),this.handleFullScreen_()}handleFullScreen_(){const t=this.getMap();if(!t)return;const e=t.getOwnerDocument();if(fC(e))if(pC(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():_C(t)}(i):_C(i)}}handleFullScreenChange_(){const t=this.getMap();if(!t)return;const e=this.isInFullscreen_;this.isInFullscreen_=pC(t.getOwnerDocument()),e!==this.isInFullscreen_&&(this.setClassName_(this.button_,this.isInFullscreen_),this.isInFullscreen_?(vt(this.labelActiveNode_,this.labelNode_),this.dispatchEvent(dC)):(vt(this.labelNode_,this.labelActiveNode_),this.dispatchEvent(gC)),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(to,this.boundHandleMapTargetChange_),super.setMap(t),this.handleMapTargetChange_(),t&&t.addChangeListener(to,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===eo){const e=t.oldValue;e&&this.unbindView_(e);const i=this.getMap().getView();this.bindView_(i)}else this.ovmap_.isRendered()||t.key!==to&&t.key!==Qs||this.ovmap_.updateSize()}bindView_(t){if(!this.view_){const e=new wo({projection:t.getProjection()});this.ovmap_.setView(e)}t.addChangeListener(lo.ROTATION,this.boundHandleRotationChanged_),this.handleRotationChanged_(),t.isDef()&&(this.ovmap_.updateSize(),this.resetExtent_())}unbindView_(t){t.removeChangeListener(lo.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_&&te(n,this.viewExtent_))return;this.viewExtent_=n;const r=e.getSize(),s=e.getView().calculateExtentInternal(r),o=e.getPixelFromCoordinateInternal(ye(n)),a=e.getPixelFromCoordinateInternal(ue(n)),l=Math.abs(o[0]-a[0]),h=Math.abs(o[1]-a[1]),c=r[0],u=r[1];lc*xC||h>u*xC?this.resetExtent_():Wt(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;Ce(n,1/(Math.pow(2,s/2)*vC)),r.fitInternal(us(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_,Zs,(t=>{delete this.ovmapPostrenderKey_,this.updateBox_()})))}handleClick_(t){t.preventDefault(),this.handleToggle_()}handleToggle_(){this.element.classList.toggle(Oo),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_()}},RC.control.Rotate=Bo,RC.control.ScaleLine=class extends jo{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(SC,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(SC)}handleUnitsChanged_(){this.updateElement_()}setUnits(t){this.set(SC,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=Sn(i,t.resolution,e,r);const o=this.minWidth_*(this.dpi_||EC)/EC,a=void 0!==this.maxWidth_?this.maxWidth_*(this.dpi_||EC)/EC:void 0;let l=o*s,h="";if("degrees"==n){const t=fi.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 Sn(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m")*(1e3/25.4)*(this.dpi_||EC)}render(t){const e=t.frameState;this.viewState_=e?e.viewState:null,this.updateElement_()}},RC.control.Zoom=zo,RC.control.ZoomSlider=class extends jo{constructor(t){super({target:(t=t||{}).target,element:document.createElement("div"),render:t.render}),this.dragListenerKeys_=[],this.currentResolution_=void 0,this.direction_=CC,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+" "+Ao,n.appendChild(i),n.addEventListener(Xs,this.handleDraggerStart_.bind(this),!1),n.addEventListener(zs,this.handleDraggerDrag_.bind(this),!1),n.addEventListener(Vs,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_=TC,this.widthLimit_=e-o):(this.direction_=CC,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,zs,t,this),D(i,Vs,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_==TC?i.style.left=this.widthLimit_*e+"px":i.style.top=this.heightLimit_*e+"px"}getRelativePosition_(t,e){let i;return i=this.direction_===TC?t/this.widthLimit_:e/this.heightLimit_,Fe(i,0,1)}getResolutionForPosition_(t){return this.getMap().getView().getResolutionForValueFunction()(1-t)}getPositionForResolution_(t){return Fe(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)}},RC.control.ZoomToExtent=class extends jo{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target}),this.extent=t.extent?t.extent:null,this.fitOptions=t.fitOptions||{};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+" "+Ao,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(us(e),this.fitOptions)}},RC.control.defaults={},RC.control.defaults.defaults=Xo,RC.coordinate={},RC.coordinate.add=Qe,RC.coordinate.closestOnCircle=ti,RC.coordinate.closestOnSegment=ei,RC.coordinate.createStringXY=function(t){return function(e){return ci(e,t)}},RC.coordinate.degreesToStringHDMS=ii,RC.coordinate.distance=li,RC.coordinate.equals=ri,RC.coordinate.format=ni,RC.coordinate.getWorldsAway=di,RC.coordinate.rotate=si,RC.coordinate.scale=oi,RC.coordinate.squaredDistance=ai,RC.coordinate.squaredDistanceToSegment=hi,RC.coordinate.toStringHDMS=function(t,e){return t?ii("NS",t[1],e)+" "+ii("EW",t[0],e):""},RC.coordinate.toStringXY=ci,RC.coordinate.wrapX=ui,RC.css={},RC.css.CLASS_COLLAPSED=Oo,RC.css.CLASS_CONTROL=Ao,RC.css.CLASS_HIDDEN=Fo,RC.css.CLASS_SELECTABLE=Mo,RC.css.CLASS_UNSELECTABLE=Lo,RC.css.CLASS_UNSUPPORTED=Io,RC.css.fontWeights=ko,RC.css.getFontParameters=Go,RC.dom={},RC.dom.createCanvasContext2D=ft,RC.dom.createMockDiv=Et,RC.dom.getSharedCanvasContext2D=_t,RC.dom.isCanvas=Ct,RC.dom.outerHeight=xt,RC.dom.outerWidth=yt,RC.dom.releaseCanvas=mt,RC.dom.removeChildren=St,RC.dom.replaceChildren=wt,RC.dom.replaceNode=vt,RC.easing={},RC.easing.easeIn=Q,RC.easing.easeOut=tt,RC.easing.inAndOut=et,RC.easing.linear=it,RC.easing.upAndDown=function(t){return t<.5?et(2*t):1-et(2*(t-.5))},RC.events={},RC.events.Event=I,RC.events.Event.preventDefault=function(t){t.preventDefault()},RC.events.Event.stopPropagation=A,RC.events.SnapEvent={},RC.events.SnapEvent.SnapEvent=my,RC.events.Target=O,RC.events.condition={},RC.events.condition.all=Ko,RC.events.condition.altKeyOnly=Ho,RC.events.condition.altShiftKeysOnly=qo,RC.events.condition.always=ta,RC.events.condition.click=function(t){return t.type==Bs.CLICK},RC.events.condition.doubleClick=function(t){return t.type==Bs.DBLCLICK},RC.events.condition.focus=Jo,RC.events.condition.focusWithTabindex=Qo,RC.events.condition.mouseActionButton=ea,RC.events.condition.mouseOnly=la,RC.events.condition.never=ia,RC.events.condition.noModifierKeys=ra,RC.events.condition.penOnly=function(t){const e=t.originalEvent;return"pointerId"in e&&"pen"===e.pointerType},RC.events.condition.platformModifierKey=sa,RC.events.condition.platformModifierKeyOnly=function(t){const e=t.originalEvent;return!e.altKey&&(lt?e.metaKey:e.ctrlKey)&&!e.shiftKey},RC.events.condition.pointerMove=function(t){return"pointermove"==t.type},RC.events.condition.primaryAction=ha,RC.events.condition.shiftKeyOnly=oa,RC.events.condition.singleClick=na,RC.events.condition.targetNotEditable=aa,RC.events.condition.touchOnly=function(t){const e=t.originalEvent;return"pointerId"in e&&"touch"===e.pointerType},RC.events.listen=D,RC.events.listenOnce=N,RC.events.unlistenByKey=k,RC.expr={},RC.expr.cpu={},RC.expr.cpu.buildExpression=yh,RC.expr.cpu.newEvaluationContext=mh,RC.expr.expression={},RC.expr.expression.AnyType=Hl,RC.expr.expression.BooleanType=Vl,RC.expr.expression.CallExpression=nh,RC.expr.expression.ColorType=Zl,RC.expr.expression.LiteralExpression=ih,RC.expr.expression.NoneType=0,RC.expr.expression.NumberArrayType=Yl,RC.expr.expression.NumberType=$l,RC.expr.expression.Ops=oh,RC.expr.expression.SizeType=Kl,RC.expr.expression.StringType=Wl,RC.expr.expression.computeGeometryType=_h,RC.expr.expression.includesType=th,RC.expr.expression.isType=eh,RC.expr.expression.newParsingContext=rh,RC.expr.expression.overlapsType=function(t,e){return!!(t&e)},RC.expr.expression.parse=sh,RC.expr.expression.typeName=Ql,RC.expr.gpu={},RC.expr.gpu.FEATURE_ID_PROPERTY_NAME=M_,RC.expr.gpu.GEOMETRY_TYPE_PROPERTY_NAME=L_,RC.expr.gpu.PALETTE_TEXTURE_ARRAY=F_,RC.expr.gpu.UNDEFINED_PROP_VALUE=I_,RC.expr.gpu.arrayToGlsl=x_,RC.expr.gpu.buildExpression=A_,RC.expr.gpu.colorToGlsl=v_,RC.expr.gpu.getStringNumberEquivalent=C_,RC.expr.gpu.newCompilationContext=b_,RC.expr.gpu.numberToGlsl=y_,RC.expr.gpu.sizeToGlsl=S_,RC.expr.gpu.stringToGlsl=T_,RC.expr.gpu.uniformNameForVariable=R_,RC.extent={},RC.extent.applyTransform=Re,RC.extent.approximatelyEquals=ee,RC.extent.boundingExtent=Bt,RC.extent.buffer=zt,RC.extent.clone=Xt,RC.extent.closestSquaredDistanceXY=Vt,RC.extent.containsCoordinate=$t,RC.extent.containsExtent=Wt,RC.extent.containsXY=Zt,RC.extent.coordinateRelationship=Yt,RC.extent.createEmpty=Kt,RC.extent.createOrUpdate=Ht,RC.extent.createOrUpdateEmpty=qt,RC.extent.createOrUpdateFromCoordinate=Jt,RC.extent.createOrUpdateFromCoordinates=function(t,e){return re(qt(e),t)},RC.extent.createOrUpdateFromFlatCoordinates=Qt,RC.extent.createOrUpdateFromRings=function(t,e){return oe(qt(e),t)},RC.extent.equals=te,RC.extent.extend=ie,RC.extent.extendCoordinate=ne,RC.extent.extendCoordinates=re,RC.extent.extendFlatCoordinates=se,RC.extent.extendRings=oe,RC.extent.extendXY=ae,RC.extent.forEachCorner=le,RC.extent.getArea=he,RC.extent.getBottomLeft=ce,RC.extent.getBottomRight=ue,RC.extent.getCenter=de,RC.extent.getCorner=ge,RC.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)},RC.extent.getForViewAndSize=fe,RC.extent.getHeight=_e,RC.extent.getIntersection=me,RC.extent.getIntersectionArea=function(t,e){return he(me(t,e))},RC.extent.getMargin=function(t){return ve(t)+_e(t)},RC.extent.getRotatedViewport=pe,RC.extent.getSize=function(t){return[t[2]-t[0],t[3]-t[1]]},RC.extent.getTopLeft=ye,RC.extent.getTopRight=xe,RC.extent.getWidth=ve,RC.extent.intersects=Se,RC.extent.intersectsSegment=Te,RC.extent.isEmpty=we,RC.extent.returnOrUpdate=Ee,RC.extent.scaleFromCenter=Ce,RC.extent.wrapAndSliceX=Pe,RC.extent.wrapX=be,RC.featureloader={},RC.featureloader.loadFeaturesXhr=iu,RC.featureloader.setWithCredentials=function(t){eu=t},RC.featureloader.xhr=nu,RC.format={},RC.format.Feature=Py,RC.format.Feature.createGeometry=Ay,RC.format.Feature.createRenderFeature=Iy,RC.format.Feature.transformExtentWithOptions=My,RC.format.Feature.transformGeometryWithOptions=Fy,RC.format.GPX=class extends Oy{constructor(t){super(),t=t||{},this.dataProjection=vn("EPSG:4326"),this.readExtensions_=t.readExtensions}handleReadExtensions_(t){t||(t=[]);for(let e=0,i=t.length;e0;else{const e=t.getType();a="Point"===e||"MultiPoint"===e}}a&&(l=s.get("name"),a=a&&!!l,a&&/&[^&]+;/.test(l)&&(fv||(fv=document.createElement("textarea")),fv.innerHTML=l,l=fv.value));let c=i;if(t?c=t:e&&(c=yv(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()||dv.getFont()),s.setScale(s.getScale()||dv.getScale()),s.setFill(s.getFill()||dv.getFill()),s.setStroke(s.getStroke()||cv)):s=dv.clone();s.setText(e),s.setOffsetX(i[0]),s.setOffsetY(i[1]),s.setTextAlign(n);const o=new sc({image:r,text:s});return o}(c[0],l);if(h.length>0){t.setGeometry(new Ed(h));return[t,new sc({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=Zv.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=Tv.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(!Wx.includes(t.namespaceURI))return null;const i=this.readPlacemark_(t,[this.getReadOptions(t,e)]);return i||null}readFeaturesFromNode(t,e){if(!Wx.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&&w(i,t)}return i}return[]}readName(t){if(t){if("string"==typeof t){const e=vf(t);return this.readNameFromDocument(e)}return yf(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(Wx.includes(e.namespaceURI)&&"name"==e.localName)return zy(e);for(let e=t.firstElementChild;e;e=e.nextElementSibling){const t=e.localName;if(Wx.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=vf(t);w(e,this.readNetworkLinksFromDocument(i))}else yf(t)?w(e,this.readNetworkLinksFromDocument(t)):w(e,this.readNetworkLinksFromNode(t));return e}readNetworkLinksFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&w(e,this.readNetworkLinksFromNode(i));return e}readNetworkLinksFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Wx.includes(i.namespaceURI)&&"NetworkLink"==i.localName){const t=Af({},Kx,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Wx.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||w(e,this.readNetworkLinksFromNode(i))}return e}readRegion(t){const e=[];if("string"==typeof t){const i=vf(t);w(e,this.readRegionFromDocument(i))}else yf(t)?w(e,this.readRegionFromDocument(t)):w(e,this.readRegionFromNode(t));return e}readRegionFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType==Node.ELEMENT_NODE&&w(e,this.readRegionFromNode(i));return e}readRegionFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Wx.includes(i.namespaceURI)&&"Region"==i.localName){const t=Af({},Jx,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Wx.includes(i.namespaceURI)||"Document"!=t&&"Folder"!=t&&"kml"!=t||w(e,this.readRegionFromNode(i))}return e}readCamera(t){const e=[];if("string"==typeof t){const i=vf(t);w(e,this.readCameraFromDocument(i))}else yf(t)?w(e,this.readCameraFromDocument(t)):w(e,this.readCameraFromNode(t));return e}readCameraFromDocument(t){const e=[];for(let i=t.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&w(e,this.readCameraFromNode(i));return e}readCameraFromNode(t){const e=[];for(let i=t.firstElementChild;i;i=i.nextElementSibling)if(Wx.includes(i.namespaceURI)&&"Camera"===i.localName){const t=Af({},qx,i,[]);e.push(t)}for(let i=t.firstElementChild;i;i=i.nextElementSibling){const t=i.localName;!Wx.includes(i.namespaceURI)||"Document"!==t&&"Folder"!==t&&"Placemark"!==t&&"kml"!==t||w(e,this.readCameraFromNode(i))}return e}writeFeaturesNode(t,e){e=this.adaptOptions(e);const i=pf(Wx[4],"kml"),n="http://www.w3.org/2000/xmlns/";i.setAttributeNS(n,"xmlns:gx",$x[0]),i.setAttributeNS(n,"xmlns:xsi",ff),i.setAttributeNS(ff,"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=Qx[i.namespaceURI],a=Mf(s,o);return Df(r,tv,Ff,a,[e],o,this),i}},RC.format.KML.getDefaultFillStyle=function(){return av},RC.format.KML.getDefaultImageStyle=function(){return hv},RC.format.KML.getDefaultStrokeStyle=function(){return uv},RC.format.KML.getDefaultStyle=function(){return gv},RC.format.KML.getDefaultStyleArray=function(){return pv},RC.format.KML.getDefaultTextStyle=function(){return dv},RC.format.KML.readFlatCoordinates=vv,RC.format.MVT=class extends Py{constructor(t){super(),t=t||{},this.dataProjection=new pi({code:"",units:"tile-pixels"}),this.featureClass=t.featureClass?t.featureClass:Ld,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===Ld)r=new this.featureClass(h,a,l,2,s,o),r.transform(i.dataProjection);else{let t;if("Polygon"==h){const e=ls(a,l);t=e.length>1?new Fd(a,"XY",e):new hs(a,"XY",l)}else t="Point"===h?new zr(a,"XY"):"LineString"===h?new Rd(a,"XY"):"MultiPoint"===h?new Pd(a,"XY"):"MultiLineString"===h?new bd(a,"XY",l):null;r=new(0,this.featureClass),this.geometryName_&&r.setGeometryName(this.geometryName_);const e=Fy(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=vn((e=this.adaptOptions(e)).dataProjection);n.setWorldExtent(e.extent),e.dataProjection=n;const r=new YS(t),s=r.readFields(ow,{}),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}),YE(e,[n.name],[i])}));return e}combineBboxAndFilter(t,e,i,n){const r=function(t,e,i){return new sE(t,e,i)}(t,e,i);return n?function(t){const e=[null].concat(Array.prototype.slice.call(arguments));return new(Function.prototype.bind.apply(rE,e))}(n,r):r}writeTransaction(t,e,i,n){const r=[],s=n.version?n.version:this.version_,o=pf(fE[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(ff,"xsi:schemaLocation",_E[s]);const l=function(t,e,i,n){const r=n.featurePrefix?n.featurePrefix:uE;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&&yE("Insert",t,r,l),e&&yE("Update",e,r,l),i&&yE("Delete",i,r,l),n.nativeElements&&yE("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),vn(t.pop().srsName)}return null}},RC.format.WFS.writeFilter=function(t,e){const i=pf(KE(e=e||"1.1.0"),"Filter"),n={node:i};return Object.assign(n,{version:e,filter:t}),AE(i,t,[n]),i},RC.format.WMSGetFeatureInfo=class extends Oy{constructor(t){super(),t=t||{},this.featureNS_="http://mapserver.gis.umn.edu/mapserver",this.gmlFormat_=new qw,this.layers_=t.layers?t.layers:null}getLayers(){return this.layers_}setLayers(t){this.layers_=t}readFeatures_(t,e){t.setAttribute("namespaceURI",this.featureNS_);const i=t.localName;let n=[];if(0===t.childNodes.length)return n;if("msGMLOutput"==i)for(let i=0,r=t.childNodes.length;i3&&!!mr(t,e,i,n)},RC.geom.flat.transform={},RC.geom.flat.transform.rotate=ar,RC.geom.flat.transform.scale=lr,RC.geom.flat.transform.transform2D=or,RC.geom.flat.transform.translate=hr,RC.has={},RC.has.CREATE_IMAGE_BITMAP=dt,RC.has.DEVICE_PIXEL_RATIO=ht,RC.has.IMAGE_DECODE=ut,RC.has.MAC=lt,RC.has.PASSIVE_EVENT_LISTENERS=gt,RC.has.SAFARI=st,RC.has.SAFARI_BUG_237906=ot,RC.has.WEBKIT=at,RC.has.WORKER_OFFSCREEN_CANVAS=ct,RC.interaction={},RC.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==Bs.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Bs.POINTERUP){const e=this.handleUpEvent(t);this.handlingDownUpSequence_=e}}else if(t.type==Bs.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===Bs.POINTERDOWN||e===Bs.POINTERDRAG||e===Bs.POINTERUP}(t)){const e=t.originalEvent,i=e.pointerId.toString();t.type==Bs.POINTERUP?delete this.trackedPointers_[i]:(t.type==Bs.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}},RC.interaction.DoubleClickZoom=Yo,RC.interaction.DragAndDrop=class extends $o{constructor(t){t=t||{},super({handleEvent:T}),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 Fm(Pm,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))}},RC.interaction.DragZoom=Sa,RC.interaction.Draw=class extends ca{constructor(t){const e=t;e.stopDown||(e.stopDown=R),super(e),this.on,this.once,this.un,this.options_=t,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.ignoreNextUpEvent_=!1,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:T,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 wd([NaN,NaN]),r=Gn(t[0],i),s=ai(r,Gn(t[t.length-1],i));n.setCenterAndRadius(r,Math.sqrt(s),this.geometryLayout_);const o=Nn();return o&&n.transform(i,o),n};else{let e;"Point"===t?e=zr:"LineString"===t?e=Rd:"Polygon"===t&&(e=hs),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 Xp({source:new zd({useSpatialIndex:!1,wrapX:!!t.wrapX&&t.wrapX}),style:t.style?t.style:$m(),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_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=ta:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:oa}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===s&&t.originalEvent.preventDefault(),this.freehand_="Point"!==this.mode_&&this.freehandCondition_(t);let e=t.type===Bs.POINTERMOVE,i=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===Bs.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===Bs.POINTERDRAG&&null!==this.sketchFeature_?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===Bs.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===Bs.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):("mouse"===t.originalEvent.pointerType||t.type===Bs.POINTERDRAG&&void 0===this.downTimeout_)&&this.handlePointerMove_(t)):t.type===Bs.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 Us(Bs.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=Bt([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=Om(t.coordinate,n);r.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:r,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex;i===t.startIndex<=e?i&&e>t.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(Mm(t.coordinates,e))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(-1===e.targetIndex){if(li(t.map.getPixelFromCoordinate(e.startCoord),t.pixel)this.squaredClickTolerance_:s<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?(this.updateTrace_(t),this.modifyDrawing_(t.coordinate)):this.createOrUpdateSketchPoint_(t.coordinate.slice())}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let n=!1,r=[this.finishCoordinate_];const s=this.mode_;if("Point"===s)i=!0;else if("Circle"===s)i=2===this.sketchCoords_.length;else if("LineString"===s)n=!e&&this.sketchCoords_.length>this.minPoints_;else if("Polygon"===s){const t=this.sketchCoords_;n=t[0].length>this.minPoints_,r=[t[0][0],t[0][t[0].length-2]],r=e?[t[0][0]]:[t[0][0],t[0][t[0].length-2]]}if(n){const e=this.getMap();for(let n=0,s=r.length;n=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 Pd([e])):"MultiLineString"===this.type_?t.setGeometry(new bd([e])):"MultiPolygon"===this.type_&&t.setGeometry(new Fd([e])),this.dispatchEvent(new Vm(zm,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 Vm(Xm,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,n=this.drag_&&$t(this.extent_,t.coordinate);let r=this.snapToVertex_(e,i);return r||!this.createCondition_(t)||n||(r=i.getCoordinateFromPixelInternal(e)),n&&!r?this.getMap().getViewport().classList.add("ol-grab"):this.getMap().getViewport().classList.remove("ol-grab"),r?(this.updatePointerFeature_(r),!0):(this.noVertexFeature_(),!1)}createOrUpdateExtentFeature_(t){let e=this.extentFeature_;return e?t?e.setGeometry(us(t)):e.setGeometry(void 0):(e=new At(t?us(t):{}),this.extentFeature_=e,this.extentOverlay_.getSource().addFeature(e)),e}updatePointerFeature_(t,e=!0){let i=this.vertexFeature_;if(e&&!i&&(i=new At(new zr(t)),this.vertexFeature_=i,this.vertexOverlay_.getSource().addFeature(i)),i){i.getGeometry().setCoordinates(t)}return i}noVertexFeature_(){this.vertexFeature_&&(this.vertexOverlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}handleEvent(t){if(!t.originalEvent||!this.condition_(t))return this.noVertexFeature_(),!0;let e=this.handlingDownUpSequence;return t.type!=Bs.POINTERMOVE||this.handlingDownUpSequence||(e=this.handlePointerMove_(t)),super.handleEvent(t),!e}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_=Hm(s(r)):null!==t?this.pointerHandler_=qm(s([t,n[1]]),s([t,n[3]])):null!==e&&(this.pointerHandler_=qm(s([n[0],e]),s([n[2],e])))}else{r=i.getCoordinateFromPixelInternal(e);let s=!1;this.drag_&&$t(n,r)&&(this.pointerHandler_=function(t,e){return function(i){const n=i[0]-e[0],r=i[1]-e[1];return[t[0]+n,t[1]+r,t[2]+n,t[3]+r]}}(n,r),s=!0),!s&&this.createCondition_(t)&&(this.setExtent([r[0],r[1],r[0],r[1]]),this.pointerHandler_=Hm(r))}return!!this.pointerHandler_}handleDragEvent(t){if(this.pointerHandler_){const e=t.coordinate;this.setExtent(this.pointerHandler_(e)),this.updatePointerFeature_(e,!1)}}handleUpEvent(t){this.pointerHandler_=null;const e=this.getExtentInternal();return e&&0!==he(e)||this.setExtent(null),!1}setMap(t){this.extentOverlay_.setMap(t),this.vertexOverlay_.setMap(t),super.setMap(t)}getExtent(){return jn(this.getExtentInternal(),this.getMap().getView().getProjection())}getExtentInternal(){return this.extent_}setExtent(t){this.extent_=t||null,this.createOrUpdateExtentFeature_(t),this.dispatchEvent(new Zm(this.extent_))}},RC.interaction.Extent.ExtentEvent=Zm,RC.interaction.Interaction=$o,RC.interaction.Interaction.pan=Wo,RC.interaction.Interaction.zoomByDelta=Zo,RC.interaction.KeyboardPan=Ra,RC.interaction.KeyboardZoom=ba,RC.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;nthis.pixelTolerance_)return;if(e.targetIndex!==i.index){if(-1!==e.targetIndex){const t=e.targets[e.targetIndex];this.removeTracedCoordinates_(t.startIndex,t.endIndex)}else for(const t of this.traceSegments_){const e=t[0],i=e.geometry,n=t[1],r=i.getCoordinates();sy(r,i.getType(),e.depth).splice(e.index+n,1),i.setCoordinates(r),0===n&&(e.index-=1)}const t=e.targets[i.index];this.addTracedCoordinates_(t,t.startIndex,i.endIndex)}else{const t=e.targets[e.targetIndex];this.addOrRemoveTracedCoordinates_(t,i.endIndex)}e.targetIndex=i.index;e.targets[e.targetIndex].endIndex=i.endIndex}getTraceCandidates_(t){const e=this.getMap(),i=this.pixelTolerance_,n=Bt([e.getCoordinateFromPixel([t.pixel[0]-i,t.pixel[1]+i]),e.getCoordinateFromPixel([t.pixel[0]+i,t.pixel[1]-i])]);return this.traceSource_.getFeaturesInExtent(n)}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active)return this.deactivateTrace_(),void(this.traceSegments_=null);const e=this.getTraceCandidates_(t);if(0===e.length)return;const i=Om(t.coordinate,e);i.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:i,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex;i===t.startIndex<=e?i&&e>t.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)for(const t of this.traceSegments_){const e=t[0],n=e.geometry,r=t[1];let s=t[0].index+1;1===r&&(s-=i);const o=n.getCoordinates();sy(o,n.getType(),e.depth).splice(s,i),n.setCoordinates(o),1===r&&(e.index-=i)}}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e=s;--e)n.push(Mm(t.coordinates,e))}if(n.length)for(const t of this.traceSegments_){const e=t[0],i=e.geometry,r=t[1],s=e.index+1;0===r&&n.reverse();const o=i.getCoordinates();sy(o,i.getType(),e.depth).splice(s,0,...n),i.setCoordinates(o),1===r&&(e.index+=n.length)}}updateGeometry_(t,e){const i=e[0],n=i.depth;let r;const s=i.segment,o=i.geometry,a=e[1];for(;t.lengtht)));const e=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],i=[],n=[],r=this.traceState_.active&&!this.traceSegments_?this.traceState_.startCoord:null;if(r){this.traceSegments_=[];for(const e of this.dragSegments_){li(ei(r,e[0].segment),r)/t.map.getView().getResolution()<1&&this.traceSegments_.push(e)}}for(let t=0,r=this.dragSegments_.length;t=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(Jt(r),s);let a=e;const l=Nn();if(l){const e=t.map.getView().getProjection();a=a.clone().transform(l,e),a=ds(a).transform(e,l)}this.rBush_.update(a.getExtent(),o)}else this.rBush_.update(Bt(i.segment),i)}return this.featuresBeingModified_&&(this.toggleTraceState_(t),this.dispatchEvent(new oy(ry,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastCoordinate_=t.coordinate,this.handlePointerAtPixel_(this.lastCoordinate_)}handlePointerAtPixel_(t){const e=this.getMap(),i=e.getPixelFromCoordinate(t),n=e.getView().getProjection(),r=function(e,i){return ly(t,e,n)-ly(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 zr(kn(i.getCoordinates(),n)));const r=i||t.getGeometry();if(r&&"Point"===r.getType()&&t instanceof At&&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=jn(zt(Un(Jt(t,ey),n),e.getView().getResolution()*this.pixelTolerance_,ey),n);s=this.rBush_.getInExtent(i)}if(s&&s.length>0){const a=s.sort(r)[0],l=a.segment;let h=hy(t,a,n);const c=e.getPixelFromCoordinate(h);let u=li(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=ai(c,t),o=ai(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(Bt([t])).some((({segment:e})=>ri(e[0],t)||ri(e[1],t)))}removePoint(t){if(t&&(t=Gn(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Bs.POINTERDRAG){const t=this.lastPointerEvent_;this.willModifyFeatures_(t,this.dragSegments_.map((([t])=>t)));const e=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new oy(ry,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(Bt(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(Bt([t])).some((({segment:e})=>!(ri(e[0],t)||ri(e[1],t))))}insertPoint(t){const e=t?Gn(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||E(r.depth,i))&&r.index>e&&(r.index+=n)}))}},RC.interaction.Modify.ModifyEvent=oy,RC.interaction.MouseWheelZoom=Pa,RC.interaction.PinchRotate=Fa,RC.interaction.PinchZoom=Ma,RC.interaction.Pointer=ca,RC.interaction.Pointer.centroid=ua,RC.interaction.Select=fy,RC.interaction.Select.SelectEvent=dy,RC.interaction.Snap=class extends ca{constructor(t){t=t||{},super({handleDownEvent:T,stopDown:R}),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 Ad,this.snapped_=null,this.segmenters_=Object.assign({},yy,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.call(this.segmenters_,r,this.getMap().getView().getProjection());let s=n.length;for(let e=0;e{t!==i.feature&&t!==i.intersectionFeature||e.remove(i)}))}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_,Od,this.handleFeatureAdd_,this),D(this.source_,kd,this.handleFeatureRemove_,this));for(const t of s)this.addFeature(t)}}snapTo(t,e,i){const n=i.getView().getProjection(),r=Gn(e,n),s=jn(zt(Bt([r]),i.getView().getResolution()*this.pixelTolerance_),n),o=this.rBush_.getInExtent(s),a=o.length;if(0===a)return null;let l,h,c=1/0,u=null;const d=this.pixelTolerance_*this.pixelTolerance_,g=()=>{if(!l)return null;const e=i.getPixelFromCoordinate(l);return ai(t,e)>d?null:{vertex:l,vertexPixel:[Math.round(e[0]),Math.round(e[1])],feature:h,segment:u}};if(this.vertex_||this.intersection_){for(let t=0;t{if(t instanceof At&&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")}}},RC.interaction.Translate.TranslateEvent=Ry,RC.interaction.defaults={},RC.interaction.defaults.defaults=La,RC.layer={},RC.layer.Base=za,RC.layer.BaseImage=Vg,RC.layer.BaseTile=Jg,RC.layer.BaseVector=kc,RC.layer.Graticule=class extends Xp{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:Vp,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?ii.bind(this,"EW"):t.lonLabelFormatter,this.latLabelFormatter_=null==t.latLabelFormatter?ii.bind(this,"NS"):t.latLabelFormatter,this.lonLabelPosition_=null==t.lonLabelPosition?0:t.lonLabelPosition,this.latLabelPosition_=null==t.latLabelPosition?1:t.latLabelPosition,this.lonLabelStyleBase_=new sc({text:void 0!==t.lonLabelStyle?t.lonLabelStyle.clone():new uc({font:"12px Calibri,sans-serif",textBaseline:"bottom",fill:new ec({color:"rgba(0,0,0,1)"}),stroke:new rc({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 sc({text:void 0!==t.latLabelStyle?t.latLabelStyle.clone():new uc({font:"12px Calibri,sans-serif",textAlign:"right",fill:new ec({color:"rgba(0,0,0,1)"}),stroke:new rc({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(Ka,this.drawLabels_.bind(this))),this.intervals_=void 0!==t.intervals?t.intervals:$p,this.setSource(new zd({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 sc({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()&&be(i,this.projection_),this.loadedExtent_&&(ee(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=me(this.getExtent()||[-1/0,-1/0,1/0,1/0],t);if(this.renderedExtent_&&te(this.renderedExtent_,r)&&this.renderedResolution_===e)return;if(this.renderedExtent_=r,this.renderedResolution_=e,we(r))return;const s=de(r),o=e*e/4;(!this.projection_||!Pn(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 At,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=yu(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=[Fe(e[0],this.minX_,this.maxX_),Fe(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=Fe(h[0],this.minLon_,this.maxLon_),u=Fe(h[1],this.minLat_,this.maxLat_);const d=this.maxLines_;let g,f,p,_,m=t;s||(m=[Fe(t[0],this.minX_,this.maxX_),Fe(t[1],this.minY_,this.maxY_),Fe(t[2],this.minX_,this.maxX_),Fe(t[3],this.minY_,this.maxY_)]);const y=Re(m,this.toLonLatTransform_,void 0,8);let x=y[3],v=y[2],S=y[1],w=y[0];if(s||($t(m,this.bottomLeft_)&&(w=this.minLon_,S=this.minLat_),$t(m,this.bottomRight_)&&(v=this.maxLon_,S=this.minLat_),$t(m,this.topLeft_)&&(w=this.minLon_,x=this.maxLat_),$t(m,this.topRight_)&&(v=this.maxLon_,x=this.maxLat_),x=Fe(x,u,this.maxLat_),v=Fe(v,c,this.maxLon_),S=Fe(S,this.minLat_,u),w=Fe(w,this.minLon_,c)),c=Math.floor(c/r)*r,_=Fe(c,this.minLon_,this.maxLon_),f=this.addMeridian_(_,S,x,n,t,0),g=0,s)for(;(_-=r)>=w&&g++n[s]&&(r=s,s=1);const o=Math.max(e[1],n[r]),a=Math.min(e[3],n[s]),l=Fe(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=zp(t,e,i,this.projection_,n);let o=this.parallels_[r];return o?(o.setFlatCoordinates("XY",s),o.changed()):o=new Rd(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=Fe(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=vn("EPSG:4326"),i=t.getWorldExtent();this.maxLat_=i[3],this.maxLon_=i[2],this.minLat_=i[1],this.minLon_=i[0];const n=Ln(t,e);if(this.minLon_=Math.abs(this.minLat_)?this.maxLat_:this.minLat_),this.projection_=t}},RC.layer.Group=Za,RC.layer.Group.GroupEvent=$a,RC.layer.Heatmap=class extends kc{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(Tm,this.handleGradientChanged_),this.setGradient(t.gradient?t.gradient:bm),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(Cm)}getGradient(){return this.get(Tm)}getRadius(){return this.get(Rm)}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("a_blur","float")),"number"==typeof this.getRadius()&&(n="a_radius",s.a_radius=()=>this.getRadius(),t.addUniform("a_radius","float"));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?Fe(i,0,1):1}},a="a_prop_weight",t.addAttribute("a_prop_weight","float")}else{a=k_(e,["clamp",this.weight_,0,1],$l)}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}`),B_(t,e);const l=X_(e),h=z_(e,this.styleVariables_);return new Em(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(){}},RC.layer.Image=$g,RC.layer.Layer=Qa,RC.layer.Layer.inView=tl,RC.layer.Tile=Qg,RC.layer.Vector=Xp,RC.layer.VectorImage=class extends kc{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 Np(this)}},RC.loadingstrategy={},RC.loadingstrategy.all=ru,RC.loadingstrategy.bbox=function(t,e){return[t]},RC.loadingstrategy.tile=function(t){return function(e,i,n){const r=t.getZForResolution(zn(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(jn(t.getTileCoordExtent(a),n));return o}},RC.math={},RC.math.ceil=Ue,RC.math.clamp=Fe,RC.math.floor=je,RC.math.lerp=Ne,RC.math.modulo=De,RC.math.round=Ge,RC.math.solveLinearSystem=Ie,RC.math.squaredDistance=Le,RC.math.squaredSegmentDistance=Me,RC.math.toDegrees=Ae,RC.math.toFixed=ke,RC.math.toRadians=Oe,RC.math.wrap=Be,RC.net={},RC.net.ClientError=au,RC.net.ResponseError=ou,RC.net.getJSON=lu,RC.net.jsonp=su,RC.net.overrideXHR=function(t){"undefined"!=typeof XMLHttpRequest&&(tu=XMLHttpRequest),global.XMLHttpRequest=t},RC.net.resolveUrl=hu,RC.net.restoreXHR=function(){global.XMLHttpRequest=tu},RC.obj={},RC.obj.clear=M,RC.obj.isEmpty=L,RC.proj={},RC.proj.Projection=pi,RC.proj.Units={},RC.proj.Units.METERS_PER_UNIT=fi,RC.proj.Units.fromCode=function(t){return gi[t]},RC.proj.addCommon=Vn,RC.proj.addCoordinateTransforms=Rn,RC.proj.addEquivalentProjections=wn,RC.proj.addEquivalentTransforms=En,RC.proj.addProjection=yn,RC.proj.addProjections=xn,RC.proj.clearAllProjections=function(){Li(),Di()},RC.proj.clearUserProjection=function(){On=null},RC.proj.cloneTransform=_n,RC.proj.createProjection=Cn,RC.proj.createSafeCoordinateTransform=Xn,RC.proj.createTransformFromCoordinateTransform=Tn,RC.proj.disableCoordinateWarning=pn,RC.proj.epsg3857={},RC.proj.epsg3857.EXTENT=yi,RC.proj.epsg3857.HALF_SIZE=mi,RC.proj.epsg3857.MAX_SAFE_Y=vi,RC.proj.epsg3857.PROJECTIONS=wi,RC.proj.epsg3857.RADIUS=_i,RC.proj.epsg3857.WORLD_EXTENT=xi,RC.proj.epsg3857.fromEPSG4326=Ei,RC.proj.epsg3857.toEPSG4326=Ci,RC.proj.epsg4326={},RC.proj.epsg4326.EXTENT=Ri,RC.proj.epsg4326.METERS_PER_UNIT=bi,RC.proj.epsg4326.PROJECTIONS=Fi,RC.proj.epsg4326.RADIUS=Ti,RC.proj.equivalent=Pn,RC.proj.fromLonLat=function(t,e){return pn(),In(t,"EPSG:4326",void 0!==e?e:"EPSG:3857")},RC.proj.fromUserCoordinate=Gn,RC.proj.fromUserExtent=Un,RC.proj.fromUserResolution=zn,RC.proj.get=vn,RC.proj.getPointResolution=Sn,RC.proj.getTransform=Ln,RC.proj.getTransformFromProjections=Fn,RC.proj.getUserProjection=Nn,RC.proj.identityTransform=mn,RC.proj.proj4={},RC.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}}}))}},RC.proj.proj4.fromEPSGCode=async function(t){"string"==typeof t&&(t=parseInt(t.split(":").pop(),10));const e=kp;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 jp(t)),Gp(e)),Ii(i)},RC.proj.proj4.getEPSGLookup=function(){return jp},RC.proj.proj4.isRegistered=function(){return!!kp},RC.proj.proj4.register=Gp,RC.proj.proj4.setEPSGLookup=function(t){jp=t},RC.proj.proj4.unregister=function(){kp=null},RC.proj.projections={},RC.proj.projections.add=Ai,RC.proj.projections.clear=Li,RC.proj.projections.get=Ii,RC.proj.setUserProjection=Dn,RC.proj.toLonLat=bn,RC.proj.toUserCoordinate=kn,RC.proj.toUserExtent=jn,RC.proj.toUserResolution=Bn,RC.proj.transform=In,RC.proj.transformExtent=An,RC.proj.transformWithProjections=function(t,e,i){return Fn(e,i)(t)},RC.proj.transforms={},RC.proj.transforms.add=Ni,RC.proj.transforms.clear=Di,RC.proj.transforms.get=ki,RC.proj.transforms.remove=function(t,e){const i=t.getCode(),n=e.getCode(),r=Oi[i][n];return delete Oi[i][n],L(Oi[i])&&delete Oi[i],r},RC.proj.useGeographic=function(){Dn("EPSG:4326")},RC.proj.utm={},RC.proj.utm.makeProjection=cn,RC.proj.utm.makeTransforms=un,RC.proj.utm.zoneFromCode=ln,RC.render={},RC.render.Box=fa,RC.render.Event=Gc,RC.render.Feature=Ld,RC.render.Feature.toFeature=function(t,e){const i=t.getId(),n=Id(t),r=t.getProperties(),s=new At;return void 0!==e&&s.setGeometryName(e),s.setGeometry(n),void 0!==i&&s.setId(i),s.setProperties(r,!0),s},RC.render.Feature.toGeometry=Id,RC.render.VectorContext=cu,RC.render.canvas={},RC.render.canvas.Builder=rp,RC.render.canvas.BuilderGroup=gp,RC.render.canvas.Executor=Tp,RC.render.canvas.ExecutorGroup=Fp,RC.render.canvas.ExecutorGroup.ALL=Rp,RC.render.canvas.ExecutorGroup.DECLUTTER=bp,RC.render.canvas.ExecutorGroup.NON_DECLUTTER=Pp,RC.render.canvas.ExecutorGroup.getPixelIndexArray=Lp,RC.render.canvas.ImageBuilder=sp,RC.render.canvas.Immediate=uu,RC.render.canvas.Instruction={},RC.render.canvas.Instruction.beginPathInstruction=ip,RC.render.canvas.Instruction.closePathInstruction=np,RC.render.canvas.Instruction.fillInstruction=tp,RC.render.canvas.Instruction.strokeInstruction=ep,RC.render.canvas.LineStringBuilder=op,RC.render.canvas.PolygonBuilder=ap,RC.render.canvas.TextBuilder=up,RC.render.canvas.TextBuilder.TEXT_ALIGN=cp,RC.render.canvas.ZIndexContext=Gg,RC.render.canvas.checkedFonts=jh,RC.render.canvas.defaultFillStyle=Mh,RC.render.canvas.defaultFont=Fh,RC.render.canvas.defaultLineCap=Lh,RC.render.canvas.defaultLineDash=Ih,RC.render.canvas.defaultLineDashOffset=0,RC.render.canvas.defaultLineJoin=Ah,RC.render.canvas.defaultLineWidth=1,RC.render.canvas.defaultMiterLimit=Oh,RC.render.canvas.defaultPadding=Gh,RC.render.canvas.defaultStrokeStyle=Dh,RC.render.canvas.defaultTextAlign=Nh,RC.render.canvas.defaultTextBaseline=kh,RC.render.canvas.drawImageOrLabel=qh,RC.render.canvas.getTextDimensions=Hh,RC.render.canvas.hitdetect={},RC.render.canvas.hitdetect.HIT_DETECT_RESOLUTION=Ip,RC.render.canvas.hitdetect.createHitDetectionImageData=Ap,RC.render.canvas.hitdetect.hitDetect=Op,RC.render.canvas.measureAndCacheTextWidth=Kh,RC.render.canvas.measureTextHeight=Wh,RC.render.canvas.measureTextWidth=Yh,RC.render.canvas.registerFont=$h,RC.render.canvas.rotateAtOffset=function(t,e,i,n){0!==e&&(t.translate(i,n),t.rotate(e),t.translate(-i,-n))},RC.render.canvas.style={},RC.render.canvas.style.buildRuleSet=pc,RC.render.canvas.style.buildStyle=_c,RC.render.canvas.style.flatStylesToStyleFunction=fc,RC.render.canvas.style.rulesToStyleFunction=gc,RC.render.canvas.textHeights=zh,RC.render.getRenderPixel=function(t,e){return Hn(t.inversePixelTransform,e.slice(0))},RC.render.getVectorContext=yu,RC.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=qn([1,0,0,1,0,0],n,n);return new uu(t,n,s,o,0)},RC.renderer={},RC.renderer.Composite=Bc,RC.renderer.Layer=jg,RC.renderer.Map=jc,RC.renderer.canvas={},RC.renderer.canvas.ImageLayer=Xg,RC.renderer.canvas.Layer=zg,RC.renderer.canvas.Layer.canvasPool=Ug,RC.renderer.canvas.TileLayer=Kg,RC.renderer.canvas.VectorImageLayer=Np,RC.renderer.canvas.VectorLayer=Dp,RC.renderer.vector={},RC.renderer.vector.defaultOrder=gu,RC.renderer.vector.getSquaredTolerance=fu,RC.renderer.vector.getTolerance=pu,RC.renderer.vector.renderFeature=_u,RC.reproj={},RC.reproj.DataTile=ig,RC.reproj.Image=rg,RC.reproj.Tile=sd,RC.reproj.Triangulation=nd,RC.reproj.calculateSourceExtentResolution=Cu,RC.reproj.calculateSourceResolution=Eu,RC.reproj.canvasPool=vu,RC.reproj.common={},RC.reproj.common.ERROR_THRESHOLD=rd,RC.reproj.glreproj={},RC.reproj.glreproj.canvasGLPool=tg,RC.reproj.glreproj.createCanvasContextWebGL=Jd,RC.reproj.glreproj.releaseGLCanvas=Qd,RC.reproj.glreproj.render=eg,RC.reproj.render=Tu,RC.resolution={},RC.resolution.fromResolutionLike=Ru,RC.resolutionconstraint={},RC.resolutionconstraint.createMinMaxResolution=_o,RC.resolutionconstraint.createSnapToPower=po,RC.resolutionconstraint.createSnapToResolutions=fo,RC.rotationconstraint={},RC.rotationconstraint.createSnapToN=xo,RC.rotationconstraint.createSnapToZero=vo,RC.rotationconstraint.disable=mo,RC.rotationconstraint.none=yo,RC.size={},RC.size.buffer=function(t,e,i){return void 0===i&&(i=[0,0]),i[0]=t[0]+2*e,i[1]=t[1]+2*e,i},RC.size.hasArea=Ul,RC.size.scale=Bl,RC.size.toSize=zl,RC.source={},RC.source.BingMaps=class extends fd{constructor(t){const e=void 0!==t.hidpi&&t.hidpi;super({cacheSize:t.cacheSize,crossOrigin:"anonymous",interpolate:t.interpolate,projection:vn("EPSG:3857"),reprojectionErrorThreshold:t.reprojectionErrorThreshold,state:"loading",tileLoadFunction:t.tileLoadFunction,tilePixelRatio:e?2:1,wrapX:void 0===t.wrapX||t.wrapX,transition:t.transition,zDirection:t.zDirection}),this.hidpi_=e,this.culture_=void 0!==t.culture?t.culture:"en-us",this.maxZoom_=void 0!==t.maxZoom?t.maxZoom:-1,this.apiKey_=t.key,this.imagerySet_=t.imagerySet,this.placeholderTiles_=t.placeholderTiles;const i=(t.url||"https://dev.virtualearth.net/REST/v1/Imagery/Metadata/")+this.imagerySet_+"?uriScheme=https&include=ImageryProviders&key="+this.apiKey_+"&c="+this.culture_;fetch(i).then((t=>t.json())).then((t=>this.handleImageryMetadataResponse(t)))}getApiKey(){return this.apiKey_}getImagerySet(){return this.imagerySet_}handleImageryMetadataResponse(t){if(200!=t.statusCode||"OK"!=t.statusDescription||"ValidCredentials"!=t.authenticationResultCode||1!=t.resourceSets.length||1!=t.resourceSets[0].resources.length)return void this.setState("error");const e=t.resourceSets[0].resources[0],i=-1==this.maxZoom_?e.zoomMax:this.maxZoom_,n=Vu(this.getProjection()),r=this.hidpi_?2:1,s=e.imageWidth==e.imageHeight?e.imageWidth/r:[e.imageWidth/r,e.imageHeight/r],o=Bu({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=ed(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;Pu(t[0],t[1],t[2],i);const s=new URL(n.replace("{quadkey}",_d(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=Fn(vn("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(Se(Re([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")}},RC.source.BingMaps.quadKey=_d,RC.source.Cluster=class extends zd{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 It(!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)}oi(i,1/t.length);const n=de(e),r=this.interpolationRatio,s=new zr([i[0]*(1-r)+n[0]*r,i[1]*(1-r)+n[1]*r]);return this.createCustomCluster_?this.createCustomCluster_(s,t):new At({geometry:s,features:t})}},RC.source.DataTile=ng,RC.source.Google=class extends fd{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_;const n=t.url||"https://tile.googleapis.com/";this.createSessionUrl_=n+"v1/createSession",this.tileUrl_=n+"v1/2dtiles",this.attributionUrl_=n+"tile/v1/viewport",this.createSession_()}getError(){return this.error_}fetchSessionToken(t,e){return fetch(t,e)}async createSession_(){const t=this.createSessionUrl_+"?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=Bu({extent:Vu(this.getProjection()),maxZoom:22,tileSize:s});const o=n.session;this.sessionTokenValue_=o;const a=this.apiKey_,l=this.tileUrl_;this.tileUrlFunction=function(t,e,i){const n=t[0],r=t[1],s=t[2];return`${l}/${n}/${r}/${s}?session=${o}&key=${a}`};const h=1e3*parseInt(n.expiry,10),c=Math.max(h-Date.now()-6e4,1);this.sessionRefreshId_=setTimeout((()=>this.createSession_()),c),this.setAttributions(this.fetchAttributions_.bind(this)),this.setState("ready")}async fetchAttributions_(t){if(t.viewHints[oo]||t.viewHints[ao]||t.animate)return this.previousViewportAttribution_;const[e,i]=bn(ce(t.extent),t.viewState.projection),[n,r]=bn(xe(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=this.sessionTokenValue_,a=this.apiKey_,l=`${this.attributionUrl_}?session=${o}&key=${a}&${s}`;return this.previousViewportAttribution_=await fetch(l).then((t=>t.json())).then((t=>t.copyright)),this.previousViewportAttribution_}disposeInternal(){clearTimeout(this.sessionRefreshId_),super.disposeInternal()}},RC.source.Image=hg,RC.source.Image.ImageSourceEvent=lg,RC.source.Image.defaultImageLoadFunction=cg,RC.source.Image.getRequestExtent=ug,RC.source.ImageArcGISRest=class extends hg{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:cg,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=gg({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),Ds(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()}},RC.source.ImageCanvas=class extends hg{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&&Wt(r.getExtent(),t))return r;Ce(t=t.slice(),this.ratio_);const s=[ve(t)/e*i,_e(t)/e*i],o=this.canvasFunction_.call(this,t,e,i,s,n);return o&&(r=new Ns(t,e,i,o)),this.canvas_=r,this.renderedRevision_=this.getRevision(),r}},RC.source.ImageStatic=class extends hg{constructor(t){const e=void 0!==t.crossOrigin?t.crossOrigin:null,i=void 0!==t.imageLoadFunction?t.imageLoadFunction:cg;super({attributions:t.attributions,interpolate:t.interpolate,projection:vn(t.projection)}),this.url_=t.url,this.imageExtent_=t.imageExtent,this.image=null,this.image=new Ls(this.imageExtent_,void 0,1,fg({url:t.url,imageExtent:t.imageExtent,crossOrigin:e,load:(t,e)=>(this.image.setImage(t),i(this.image,e),Ds(t))})),this.image.addEventListener(n,this.handleImageChange.bind(this))}getImageExtent(){return this.imageExtent_}getImageInternal(t,e,i,n){return Se(t,this.image.getExtent())?this.image:null}getUrl(){return this.url_}},RC.source.ImageTile=Sg,RC.source.ImageWMS=class extends hg{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:cg,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=vn(i),s=this.getProjection();s&&s!==r&&(e=Eu(s,r,t,e),t=In(t,r,s));return Pg({url:this.url_,params:{...this.params_,...n},projection:s||r},t,e)}getLegendUrl(t,e){return Fg({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=bg({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),Ds(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()}},RC.source.OGCMapTile=class extends fd{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});Ng({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){He(t),this.setState("error")}},RC.source.OSM=class extends md{constructor(t){let e;e=void 0!==(t=t||{}).attributions?t.attributions:[kg];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:(e,i)=>{const n=e.getImage();!ct&&n instanceof HTMLImageElement&&(n.referrerPolicy="origin-when-cross-origin"),(t.tileLoadFunction||pd)(e,i)},transition:t.transition,url:n,wrapX:t.wrapX,zDirection:t.zDirection})}},RC.source.OSM.ATTRIBUTION=kg,RC.source.Raster=af,RC.source.Raster.Processor=nf,RC.source.Raster.RasterSourceEvent=of,RC.source.Source=od,RC.source.StadiaMaps=class extends md{constructor(t){const e=t.layer.indexOf("-"),i=-1==e?t.layer:t.layer.slice(0,e),n=df[i]||{minZoom:0,maxZoom:20,retina:!0},r=uf[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',kg];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})}},RC.source.Tile=ld,RC.source.Tile.TileSourceEvent=hd,RC.source.TileArcGISRest=class extends fd{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[De(Lu(t),o.length)]}return dg(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=zl(n.getTileSize(t[0]),this.tmpSize);1!=e&&(s=Bl(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)}},RC.source.TileDebug=class extends Sg{constructor(t){const e=(t=t||{}).template||"z:{z} x:{x} y:{y}",i=t.source,r=t.color||"grey";super({transition:0,wrapX:void 0!==t.wrapX?t.wrapX:void 0!==i?i.getWrapX():void 0});const s=()=>{this.projection=void 0!==t.projection?vn(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 ng&&(this.transformMatrix=i.transformMatrix?.slice()||null);const n=this.tileGrid;n&&this.setTileSizes(n.getResolutions().map(((t,e)=>zl(n.getTileSize(e)).map((t=>Math.max(Math.floor(t),1)))))),this.setLoader(((t,i,n,s)=>{const o=Hu(e,t,i,n,s.maxY),[a,l]=this.getTileSize(t),h=ft(a,l);return h.strokeStyle=r,h.strokeRect(.5,.5,a+.5,l+.5),h.fillStyle=r,h.strokeStyle="white",h.textAlign="center",h.textBaseline="middle",h.font="24px sans-serif",h.lineWidth=4,h.strokeText(o,a/2,l/2,a),h.fillText(o,a/2,l/2,a),Promise.resolve(h.canvas)})),this.setState("ready")};if(void 0===i||"ready"===i.getState())s();else{const t=()=>{"ready"===i.getState()&&(i.removeEventListener(n,t),s())};i.addEventListener(n,t)}}},RC.source.TileImage=fd,RC.source.TileImage.defaultTileLoadFunction=pd,RC.source.TileJSON=class extends fd{constructor(t){if(super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,interpolate:t.interpolate,projection:vn("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)su(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=vn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=Fn(e,i);n=Re(t.bounds,r)}const r=Vu(i),s=t.minzoom||0,o=Bu({extent:r,maxZoom:t.maxzoom||22,minZoom:s,tileSize:this.tileSize_});if(this.tileGrid=o,this.tileUrlFunction=td(t.tiles,o),t.attribution&&!this.getAttributions()){const e=void 0!==n?n:r;this.setAttributions((function(i){return Se(e,i.extent)?[t.attribution]:null}))}this.tileJSON_=t,this.setState("ready")}handleTileJSONError(){this.setState("error")}},RC.source.TileWMS=class extends fd{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=vn(i),s=this.getProjection()||r;let o=this.getTileGrid();o||(o=this.getTileGridForProjection(s));const a=In(t,r,s),l=Eu(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=zt(d,c*g,d));const f={QUERY_LAYERS:this.params_.LAYERS};Object.assign(f,Rg(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:wg,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),$u(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[De(Lu(t),s.length)]}return Tg(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||wg;this.v13_=Je(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=zt(s,r*o,s));const a=Object.assign({},Rg(this.params_,"GetMap"));return this.getRequestUrl_(t,s,e,i,a)}},RC.source.UTFGrid=class extends ld{constructor(t){if(super({projection:vn("EPSG:3857"),state:"loading",wrapX:void 0===t.wrapX||t.wrapX,zDirection:t.zDirection}),this.preemptive_=void 0===t.preemptive||t.preemptive,this.tileUrlFunction_=id,this.template_=void 0,this.jsonp_=t.jsonp||!1,this.tileCache_=new bu(512),t.url)if(this.jsonp_)su(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=vn("EPSG:4326"),i=this.getProjection();let n;if(void 0!==t.bounds){const r=Fn(e,i);n=Re(t.bounds,r)}const r=Vu(i),s=t.minzoom||0,o=Bu({extent:r,maxZoom:t.maxzoom||22,minZoom:s});this.tileGrid=o,this.template_=t.template;const a=t.grids;if(a){if(this.tileUrlFunction_=td(a,o),t.attribution){const e=void 0!==n?n:r;this.setAttributions((function(i){return Se(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()},${Fu(t,e,i)}`;if(this.tileCache_.containsKey(l))return this.tileCache_.get(l);this.tileCache_.expireCache();const h=new gf(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}},RC.source.UTFGrid.CustomTile=gf,RC.source.UrlTile=gd,RC.source.Vector=zd,RC.source.Vector.VectorSourceEvent=Bd,RC.source.WMTS=class extends fd{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=Ju(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=ed(n.map(this.createFromWMTSTemplate.bind(this))))}setUrls(t){this.urls=t;const e=t.join("\n");this.setTileUrlFunction(ed(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?$u(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?$u(l,a):l.replace(/\{(\w+?)\}/g,(function(t,e){return encodeURIComponent(a[e])})),l}}},RC.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=vn(i),s=vn(e.projection);return n&&s?Pn(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=vn(g)),"projection"in e){const t=vn(e.projection);t&&(d&&!Pn(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=n.BoundingBox?.find((t=>vn(t.crs)&&Pn(vn(t.crs),d))),x=28e-5*_.ScaleDenominator/d.getMetersPerUnit(),v=p?[_.TopLeftCorner[1],_.TopLeftCorner[0]]:_.TopLeftCorner,S=_.TileWidth*x,w=_.TileHeight*x;let E=y?.extent??u.BoundingBox;E&&p&&(E=[E[1],E[0],E[3],E[2]]);let C=[v[0]+S*m.MinTileCol,v[1]-w*(1+m.MaxTileRow),v[0]+S*(1+m.MaxTileCol),v[1]-w*m.MinTileRow];if(void 0!==E&&!Wt(E,C)){const t=n.WGS84BoundingBox,e=vn("EPSG:4326").getExtent();if(C=E,t)f=t[0]===e[0]&&t[2]===e[2];else{const t=An(E,u.SupportedCRS,"EPSG:4326");f=t[0]-1e-10<=e[0]&&t[2]+1e-10>=e[2]}}const T=ku(u,C,a),R=[];let b=e.requestEncoding;if(b=void 0!==b?b:"","OperationsMetadata"in t&&"GetTile"in t.OperationsMetadata){const e=t.OperationsMetadata.GetTile.DCP.HTTP.Get;for(let t=0,i=e.length;t({image:t,extent:r,pixelRatio:o})))}},RC.source.ogcTileUtil={},RC.source.ogcTileUtil.appendCollectionsQueryParam=Ig,RC.source.ogcTileUtil.getMapTileUrlTemplate=Ag,RC.source.ogcTileUtil.getTileSetInfo=Ng,RC.source.ogcTileUtil.getVectorTileUrlTemplate=Og,RC.source.sourcesFromTileGrid=function(t,e){const i=new bu(32),n=t.getExtent();return function(r,s){i.expireCache(),n&&(r=me(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}},RC.source.static={},RC.source.static.createLoader=fg,RC.source.wms={},RC.source.wms.DEFAULT_VERSION=wg,RC.source.wms.createLoader=bg,RC.source.wms.getFeatureInfoUrl=Pg,RC.source.wms.getImageSrc=Tg,RC.source.wms.getLegendUrl=Fg,RC.source.wms.getRequestParams=Rg,RC.source.wms.getRequestUrl=Cg,RC.sphere={},RC.sphere.DEFAULT_RADIUS=ze,RC.sphere.getArea=function t(e,i){const n=(i=i||{}).radius||ze,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($e(o[0],n)),l=1,h=o.length;l