mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-04-19 00:45:18 +00:00
11 lines
304 KiB
JavaScript
11 lines
304 KiB
JavaScript
import{_ as el,D as il,a as nl,c as sl,e as rl}from"./index-glbWjskj.js";class fe{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const di={PROPERTYCHANGE:"propertychange"};class Wn{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function ol(n,t,e){let i,s;e=e||ae;let r=0,o=n.length,a=!1;for(;r<o;)i=r+(o-r>>1),s=+e(n[i],t),s<0?r=i+1:(o=i,a=!s);return a?r:~r}function ae(n,t){return n>t?1:n<t?-1:0}function Bs(n,t,e){if(n[0]<=t)return 0;const i=n.length;if(t<=n[i-1])return i-1;if(typeof e=="function"){for(let s=1;s<i;++s){const r=n[s];if(r===t)return s;if(r<t)return e(t,n[s-1],r)>0?s-1:s}return i-1}if(e>0){for(let s=1;s<i;++s)if(n[s]<t)return s-1;return i-1}if(e<0){for(let s=1;s<i;++s)if(n[s]<=t)return s;return i-1}for(let s=1;s<i;++s){if(n[s]==t)return s;if(n[s]<t)return n[s-1]-t<t-n[s]?s-1:s}return i-1}function al(n,t,e){for(;t<e;){const i=n[t];n[t]=n[e],n[e]=i,++t,--e}}function Yn(n,t){const e=Array.isArray(t)?t:[t],i=e.length;for(let s=0;s<i;s++)n[n.length]=e[s]}function Ae(n,t){const e=n.length;if(e!==t.length)return!1;for(let i=0;i<e;i++)if(n[i]!==t[i])return!1;return!0}function ll(n,t,e){const i=t||ae;return n.every(function(s,r){if(r===0)return!0;const o=i(n[r-1],s);return!(o>0||o===0)})}function Wi(){return!0}function Zn(){return!1}function fi(){}function No(n){let t,e,i;return function(){const s=Array.prototype.slice.call(arguments);return(!e||this!==i||!Ae(s,e))&&(i=this,e=s,t=n.apply(this,arguments)),t}}function hl(n){function t(){let e;try{e=n()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}function nn(n){for(const t in n)delete n[t]}function gi(n){let t;for(t in n)return!1;return!t}class Kn extends Wn{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_={}),s=i[t]||(i[t]=[]);s.includes(e)||s.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,s=this.listeners_&&this.listeners_[i];if(!s)return;const r=e?new fe(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let c=0,h=s.length;c<h;++c)if("handleEvent"in s[c]?l=s[c].handleEvent(r):l=s[c].call(this,r),l===!1||r.propagationStopped){l=!1;break}if(--o[i]===0){let c=a[i];for(delete a[i];c--;)this.removeEventListener(i,fi);delete o[i]}return l}disposeInternal(){this.listeners_&&nn(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return this.listeners_?t?t in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const s=i.indexOf(e);s!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[s]=fi,++this.pendingRemovals_[t]):(i.splice(s,1),i.length===0&&delete this.listeners_[t]))}}const z={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function V(n,t,e,i,s){if(s){const o=e;e=function(){n.removeEventListener(t,e),o.apply(i??this,arguments)}}else i&&i!==n&&(e=e.bind(i));const r={target:n,type:t,listener:e};return n.addEventListener(t,e),r}function vn(n,t,e,i){return V(n,t,e,i,!0)}function tt(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),nn(n))}class sn extends Kn{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(z.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=V(this,t[r],e);return s}return V(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const s=t.length;i=new Array(s);for(let r=0;r<s;++r)i[r]=vn(this,t[r],e)}else i=vn(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)cl(i);else if(Array.isArray(t))for(let s=0,r=t.length;s<r;++s)this.removeEventListener(t[s],e);else this.removeEventListener(t,e)}}sn.prototype.on;sn.prototype.once;sn.prototype.un;function cl(n){if(Array.isArray(n))for(let t=0,e=n.length;t<e;++t)tt(n[t]);else tt(n)}function U(){throw new Error("Unimplemented abstract method.")}let ul=0;function $(n){return n.ol_uid||(n.ol_uid=String(++ul))}class kr extends fe{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}class $t extends sn{constructor(t){super(),this.on,this.once,this.un,$(this),this.values_=null,t!==void 0&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new kr(i,t,e)),i=di.PROPERTYCHANGE,this.hasListener(i)&&this.dispatchEvent(new kr(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const s=this.values_||(this.values_={});if(i)s[t]=e;else{const r=s[t];s[t]=e,r!==e&&this.notify(t,r)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],gi(this.values_)&&(this.values_=null),e||this.notify(t,i)}}}const wt={ADD:"add",REMOVE:"remove"},Nr={LENGTH:"length"};class gn extends fe{constructor(t,e,i){super(t),this.element=e,this.index=i}}class jt extends $t{constructor(t,e){if(super(),this.on,this.once,this.un,e=e||{},this.unique_=!!e.unique,this.array_=t||[],this.unique_)for(let i=0,s=this.array_.length;i<s;++i)this.assertUnique_(this.array_[i],i);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(t){for(let e=0,i=t.length;e<i;++e)this.push(t[e]);return this}forEach(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)t(e[i],i,e)}getArray(){return this.array_}item(t){return this.array_[t]}getLength(){return this.get(Nr.LENGTH)}insertAt(t,e){if(t<0||t>this.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new gn(wt.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){this.unique_&&this.assertUnique_(t);const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,s=e.length;i<s;++i)if(e[i]===t)return this.removeAt(i)}removeAt(t){if(t<0||t>=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new gn(wt.REMOVE,e,t)),e}setAt(t,e){const i=this.getLength();if(t>=i){this.insertAt(t,e);return}if(t<0)throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e,t);const s=this.array_[t];this.array_[t]=e,this.dispatchEvent(new gn(wt.REMOVE,s,t)),this.dispatchEvent(new gn(wt.ADD,e,t))}updateLength_(){this.set(Nr.LENGTH,this.array_.length)}assertUnique_(t,e){for(let i=0,s=this.array_.length;i<s;++i)if(this.array_[i]===t&&i!==e)throw new Error("Duplicate item added to a unique collection")}}const J={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};function j(n,t){if(!n)throw new Error(t)}function st(n,t,e){return Math.min(Math.max(n,t),e)}function dl(n,t,e,i,s,r){const o=s-e,a=r-i;if(o!==0||a!==0){const l=((n-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=s,i=r):l>0&&(e+=o*l,i+=a*l)}return hi(n,t,e,i)}function hi(n,t,e,i){const s=e-n,r=i-t;return s*s+r*r}function fl(n){const t=n.length;for(let i=0;i<t;i++){let s=i,r=Math.abs(n[i][i]);for(let a=i+1;a<t;a++){const l=Math.abs(n[a][i]);l>r&&(r=l,s=a)}if(r===0)return null;const o=n[s];n[s]=n[i],n[i]=o;for(let a=i+1;a<t;a++){const l=-n[a][i]/n[i][i];for(let c=i;c<t+1;c++)i==c?n[a][c]=0:n[a][c]+=l*n[i][c]}}const e=new Array(t);for(let i=t-1;i>=0;i--){e[i]=n[i][t]/n[i][i];for(let s=i-1;s>=0;s--)n[s][t]-=n[s][i]*e[i]}return e}function In(n){return n*Math.PI/180}function ci(n,t){const e=n%t;return e*t<0?e+t:e}function St(n,t,e){return n+e*(t-n)}function Vs(n,t){const e=Math.pow(10,t);return Math.round(n*e)/e}function _n(n,t){return Math.floor(Vs(n,t))}function mn(n,t){return Math.ceil(Vs(n,t))}class Go extends $t{constructor(t){super(),this.on,this.once,this.un,this.background_=t.background;const e=Object.assign({},t);typeof t.properties=="object"&&(delete e.properties,Object.assign(e,t.properties)),e[J.OPACITY]=t.opacity!==void 0?t.opacity:1,j(typeof e[J.OPACITY]=="number","Layer opacity must be a number"),e[J.VISIBLE]=t.visible!==void 0?t.visible:!0,e[J.Z_INDEX]=t.zIndex,e[J.MAX_RESOLUTION]=t.maxResolution!==void 0?t.maxResolution:1/0,e[J.MIN_RESOLUTION]=t.minResolution!==void 0?t.minResolution:0,e[J.MIN_ZOOM]=t.minZoom!==void 0?t.minZoom:-1/0,e[J.MAX_ZOOM]=t.maxZoom!==void 0?t.maxZoom:1/0,this.className_=e.className!==void 0?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:t===void 0?!0:t},i=this.getZIndex();return e.opacity=st(Math.round(this.getOpacity()*100)/100,0,1),e.visible=this.getVisible(),e.extent=this.getExtent(),e.zIndex=i===void 0&&!e.managed?1/0:i,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(J.EXTENT)}getMaxResolution(){return this.get(J.MAX_RESOLUTION)}getMinResolution(){return this.get(J.MIN_RESOLUTION)}getMinZoom(){return this.get(J.MIN_ZOOM)}getMaxZoom(){return this.get(J.MAX_ZOOM)}getOpacity(){return this.get(J.OPACITY)}getSourceState(){return U()}getVisible(){return this.get(J.VISIBLE)}getZIndex(){return this.get(J.Z_INDEX)}setBackground(t){this.background_=t,this.changed()}setExtent(t){this.set(J.EXTENT,t)}setMaxResolution(t){this.set(J.MAX_RESOLUTION,t)}setMinResolution(t){this.set(J.MIN_RESOLUTION,t)}setMaxZoom(t){this.set(J.MAX_ZOOM,t)}setMinZoom(t){this.set(J.MIN_ZOOM,t)}setOpacity(t){j(typeof t=="number","Layer opacity must be a number"),this.set(J.OPACITY,t)}setVisible(t){this.set(J.VISIBLE,t)}setZIndex(t){this.set(J.Z_INDEX,t)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}}const Ot={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},mt={ANIMATING:0,INTERACTING:1},Nt={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"},gl=42,Us=256,js={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class zo{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=t.extent!==void 0?t.extent:null,this.worldExtent_=t.worldExtent!==void 0?t.worldExtent:null,this.axisOrientation_=t.axisOrientation!==void 0?t.axisOrientation:"enu",this.global_=t.global!==void 0?t.global:!1,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_||js[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 rn=6378137,oi=Math.PI*rn,_l=[-oi,-oi,oi,oi],ml=[-180,-85,180,85],pn=rn*Math.log(Math.tan(Math.PI/2));class je extends zo{constructor(t){super({code:t,units:"m",extent:_l,global:!0,worldExtent:ml,getPointResolution:function(e,i){return e/Math.cosh(i[1]/rn)}})}}const Gr=[new je("EPSG:3857"),new je("EPSG:102100"),new je("EPSG:102113"),new je("EPSG:900913"),new je("http://www.opengis.net/def/crs/EPSG/0/3857"),new je("http://www.opengis.net/gml/srs/epsg.xml#3857")];function pl(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i){t[r]=oi*n[r]/180;let o=rn*Math.log(Math.tan(Math.PI*(+n[r+1]+90)/360));o>pn?o=pn:o<-pn&&(o=-pn),t[r+1]=o}return t}function yl(n,t,e,i){const s=n.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=n.slice():t=new Array(s));for(let r=0;r<s;r+=i)t[r]=180*n[r]/oi,t[r+1]=360*Math.atan(Math.exp(n[r+1]/rn))/Math.PI-90;return t}const El=6378137,zr=[-180,-90,180,90],xl=Math.PI*El/180;class Pe extends zo{constructor(t,e){super({code:t,units:"degrees",extent:zr,axisOrientation:e,global:!0,metersPerUnit:xl,worldExtent:zr})}}const Xr=[new Pe("CRS:84"),new Pe("EPSG:4326","neu"),new Pe("urn:ogc:def:crs:OGC:1.3:CRS84"),new Pe("urn:ogc:def:crs:OGC:2:84"),new Pe("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new Pe("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new Pe("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let bs={};function wl(n){return bs[n]||bs[n.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function Cl(n,t){bs[n]=t}let ui={};function Sn(n,t,e){const i=n.getCode(),s=t.getCode();i in ui||(ui[i]={}),ui[i][s]=e}function Rl(n,t){let e;return n in ui&&t in ui[n]&&(e=ui[n][t]),e}const ht={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Wr(n){const t=Ft();for(let e=0,i=n.length;e<i;++e)zi(t,n[e]);return t}function Hs(n,t,e){return e?(e[0]=n[0]-t,e[1]=n[1]-t,e[2]=n[2]+t,e[3]=n[3]+t,e):[n[0]-t,n[1]-t,n[2]+t,n[3]+t]}function Xo(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n.slice()}function qs(n,t,e){let i,s;return t<n[0]?i=n[0]-t:n[2]<t?i=t-n[2]:i=0,e<n[1]?s=n[1]-e:n[3]<e?s=e-n[3]:s=0,i*i+s*s}function _i(n,t){return Wo(n,t[0],t[1])}function ai(n,t){return n[0]<=t[0]&&t[2]<=n[2]&&n[1]<=t[1]&&t[3]<=n[3]}function Wo(n,t,e){return n[0]<=t&&t<=n[2]&&n[1]<=e&&e<=n[3]}function Ds(n,t){const e=n[0],i=n[1],s=n[2],r=n[3],o=t[0],a=t[1];let l=ht.UNKNOWN;return o<e?l=l|ht.LEFT:o>s&&(l=l|ht.RIGHT),a<i?l=l|ht.BELOW:a>r&&(l=l|ht.ABOVE),l===ht.UNKNOWN&&(l=ht.INTERSECTING),l}function Ft(){return[1/0,1/0,-1/0,-1/0]}function Se(n,t,e,i,s){return s?(s[0]=n,s[1]=t,s[2]=e,s[3]=i,s):[n,t,e,i]}function Bn(n){return Se(1/0,1/0,-1/0,-1/0,n)}function Yo(n,t){const e=n[0],i=n[1];return Se(e,i,e,i,t)}function $s(n,t,e,i,s){const r=Bn(s);return Zo(r,n,t,e,i)}function Yi(n,t){return n[0]==t[0]&&n[2]==t[2]&&n[1]==t[1]&&n[3]==t[3]}function Tl(n,t){return t[0]<n[0]&&(n[0]=t[0]),t[2]>n[2]&&(n[2]=t[2]),t[1]<n[1]&&(n[1]=t[1]),t[3]>n[3]&&(n[3]=t[3]),n}function zi(n,t){t[0]<n[0]&&(n[0]=t[0]),t[0]>n[2]&&(n[2]=t[0]),t[1]<n[1]&&(n[1]=t[1]),t[1]>n[3]&&(n[3]=t[1])}function Zo(n,t,e,i,s){for(;e<i;e+=s)Il(n,t[e],t[e+1]);return n}function Il(n,t,e){n[0]=Math.min(n[0],t),n[1]=Math.min(n[1],e),n[2]=Math.max(n[2],t),n[3]=Math.max(n[3],e)}function Ko(n,t){let e;return e=t(Vn(n)),e||(e=t(Un(n)),e)||(e=t(jn(n)),e)||(e=t(Ye(n)),e)?e:!1}function Zi(n){let t=0;return Hn(n)||(t=q(n)*pt(n)),t}function Vn(n){return[n[0],n[1]]}function Un(n){return[n[2],n[1]]}function Xe(n){return[(n[0]+n[2])/2,(n[1]+n[3])/2]}function vl(n,t){let e;if(t==="bottom-left")e=Vn(n);else if(t==="bottom-right")e=Un(n);else if(t==="top-left")e=Ye(n);else if(t==="top-right")e=jn(n);else throw new Error("Invalid corner");return e}function Ps(n,t,e,i,s){const[r,o,a,l,c,h,u,d]=Sl(n,t,e,i);return Se(Math.min(r,a,c,u),Math.min(o,l,h,d),Math.max(r,a,c,u),Math.max(o,l,h,d),s)}function Sl(n,t,e,i){const s=t*i[0]/2,r=t*i[1]/2,o=Math.cos(e),a=Math.sin(e),l=s*o,c=s*a,h=r*o,u=r*a,d=n[0],f=n[1];return[d-l+u,f-c-h,d-l-u,f-c+h,d+l-u,f+c+h,d+l+u,f+c-h,d-l+u,f-c-h]}function pt(n){return n[3]-n[1]}function Xt(n,t,e){const i=e||Ft();return Tt(n,t)?(n[0]>t[0]?i[0]=n[0]:i[0]=t[0],n[1]>t[1]?i[1]=n[1]:i[1]=t[1],n[2]<t[2]?i[2]=n[2]:i[2]=t[2],n[3]<t[3]?i[3]=n[3]:i[3]=t[3]):Bn(i),i}function Ye(n){return[n[0],n[3]]}function jn(n){return[n[2],n[3]]}function q(n){return n[2]-n[0]}function Tt(n,t){return n[0]<=t[2]&&n[2]>=t[0]&&n[1]<=t[3]&&n[3]>=t[1]}function Hn(n){return n[2]<n[0]||n[3]<n[1]}function Ll(n,t){return t?(t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t):n}function Al(n,t,e){let i=!1;const s=Ds(n,t),r=Ds(n,e);if(s===ht.INTERSECTING||r===ht.INTERSECTING)i=!0;else{const o=n[0],a=n[1],l=n[2],c=n[3],h=t[0],u=t[1],d=e[0],f=e[1],g=(f-u)/(d-h);let _,m;r&ht.ABOVE&&!(s&ht.ABOVE)&&(_=d-(f-c)/g,i=_>=o&&_<=l),!i&&r&ht.RIGHT&&!(s&ht.RIGHT)&&(m=f-(d-l)*g,i=m>=a&&m<=c),!i&&r&ht.BELOW&&!(s&ht.BELOW)&&(_=d-(f-a)/g,i=_>=o&&_<=l),!i&&r&ht.LEFT&&!(s&ht.LEFT)&&(m=f-(d-o)*g,i=m>=a&&m<=c)}return i}function Bo(n,t){const e=t.getExtent(),i=Xe(n);if(t.canWrapX()&&(i[0]<e[0]||i[0]>=e[2])){const s=q(e),o=Math.floor((i[0]-e[0])/s)*s;n[0]-=o,n[2]-=o}return n}function Js(n,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[i[0],n[1],i[2],n[3]]];Bo(n,t);const s=q(i);if(q(n)>s&&!e)return[[i[0],n[1],i[2],n[3]]];if(n[0]<i[0])return[[n[0]+s,n[1],i[2],n[3]],[i[0],n[1],n[2],n[3]]];if(n[2]>i[2])return[[n[0],n[1],i[2],n[3]],[i[0],n[1],n[2]-s,n[3]]]}return[n]}function Ml(n,t){return n[0]+=+t[0],n[1]+=+t[1],n}function Ln(n,t){let e=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=t[i]){e=!1;break}return e}function Qs(n,t){const e=Math.cos(t),i=Math.sin(t),s=n[0]*e-n[1]*i,r=n[1]*e+n[0]*i;return n[0]=s,n[1]=r,n}function bl(n,t){return n[0]*=t,n[1]*=t,n}function Vo(n,t){if(t.canWrapX()){const e=q(t.getExtent()),i=Dl(n,t,e);i&&(n[0]-=i*e)}return n}function Dl(n,t,e){const i=t.getExtent();let s=0;return t.canWrapX()&&(n[0]<i[0]||n[0]>i[2])&&(e=e||q(i),s=Math.floor((n[0]-i[0])/e)),s}const Pl=63710088e-1;function Yr(n,t,e){e=e||Pl;const i=In(n[1]),s=In(t[1]),r=(s-i)/2,o=In(t[0]-n[0])/2,a=Math.sin(r)*Math.sin(r)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(s);return 2*e*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Uo(...n){console.warn(...n)}let Os=!0;function jo(n){Os=!1}function tr(n,t){if(t!==void 0){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];t=t}else t=n.slice();return t}function Ho(n,t){if(t!==void 0&&n!==t){for(let e=0,i=n.length;e<i;++e)t[e]=n[e];n=t}return n}function Ol(n){Cl(n.getCode(),n),Sn(n,n,tr)}function Fl(n){n.forEach(Ol)}function kt(n){return typeof n=="string"?wl(n):n||null}function Zr(n,t,e,i){n=kt(n);let s;const r=n.getPointResolutionFunc();if(r)s=r(t,e);else{const o=n.getUnits();if(o=="degrees"&&!i||i=="degrees")s=t;else{const a=ir(n,kt("EPSG:4326"));if(a===Ho&&o!=="degrees")s=t*n.getMetersPerUnit();else{let c=[e[0]-t/2,e[1],e[0]+t/2,e[1],e[0],e[1]-t/2,e[0],e[1]+t/2];c=a(c,c,2);const h=Yr(c.slice(0,2),c.slice(2,4)),u=Yr(c.slice(4,6),c.slice(6,8));s=(h+u)/2}const l=n.getMetersPerUnit();l!==void 0&&(s/=l)}}return s}function Kr(n){Fl(n),n.forEach(function(t){n.forEach(function(e){t!==e&&Sn(t,e,tr)})})}function kl(n,t,e,i){n.forEach(function(s){t.forEach(function(r){Sn(s,r,e),Sn(r,s,i)})})}function er(n,t){return n?typeof n=="string"?kt(n):n:kt(t)}function us(n,t){return jo(),qo(n,"EPSG:4326","EPSG:3857")}function ds(n,t){if(n===t)return!0;const e=n.getUnits()===t.getUnits();return(n.getCode()===t.getCode()||ir(n,t)===tr)&&e}function ir(n,t){const e=n.getCode(),i=t.getCode();let s=Rl(e,i);return s||(s=Ho),s}function An(n,t){const e=kt(n),i=kt(t);return ir(e,i)}function qo(n,t,e){return An(t,e)(n,void 0,n.length)}function Fs(n,t){return n}function se(n,t){return Os&&!Ln(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(Os=!1,Uo("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function $o(n,t){return n}function Te(n,t){return n}function Nl(){Kr(Gr),Kr(Xr),kl(Xr,Gr,pl,yl)}Nl();function Br(n,t,e){return function(i,s,r,o,a){if(!i)return;if(!s&&!t)return i;const l=t?0:r[0]*s,c=t?0:r[1]*s,h=a?a[0]:0,u=a?a[1]:0;let d=n[0]+l/2+h,f=n[2]-l/2+h,g=n[1]+c/2+u,_=n[3]-c/2+u;d>f&&(d=(f+d)/2,f=d),g>_&&(g=(_+g)/2,_=g);let m=st(i[0],d,f),p=st(i[1],g,_);if(o&&e&&s){const y=30*s;m+=-y*Math.log(1+Math.max(0,d-i[0])/y)+y*Math.log(1+Math.max(0,i[0]-f)/y),p+=-y*Math.log(1+Math.max(0,g-i[1])/y)+y*Math.log(1+Math.max(0,i[1]-_)/y)}return[m,p]}}function Gl(n){return n}function nr(n,t,e,i){const s=q(t)/e[0],r=pt(t)/e[1];return i?Math.min(n,Math.max(s,r)):Math.min(n,Math.min(s,r))}function sr(n,t,e){let i=Math.min(n,t);const s=50;return i*=Math.log(1+s*Math.max(0,n/t-1))/s+1,e&&(i=Math.max(i,e),i/=Math.log(1+s*Math.max(0,e/n-1))/s+1),st(i,e/2,t*2)}function zl(n,t,e,i){return t=t!==void 0?t:!0,function(s,r,o,a){if(s!==void 0){const l=n[0],c=n[n.length-1],h=e?nr(l,e,o,i):l;if(a)return t?sr(s,h,c):st(s,c,h);const u=Math.min(h,s),d=Math.floor(Bs(n,u,r));return n[d]>h&&d<n.length-1?n[d+1]:n[d]}}}function Xl(n,t,e,i,s,r){return i=i!==void 0?i:!0,e=e!==void 0?e:0,function(o,a,l,c){if(o!==void 0){const h=s?nr(t,s,l,r):t;if(c)return i?sr(o,h,e):st(o,e,h);const u=1e-9,d=Math.ceil(Math.log(t/h)/Math.log(n)-u),f=-a*(.5-u)+.5,g=Math.min(h,o),_=Math.floor(Math.log(t/g)/Math.log(n)+f),m=Math.max(d,_),p=t/Math.pow(n,m);return st(p,e,h)}}}function Vr(n,t,e,i,s){return e=e!==void 0?e:!0,function(r,o,a,l){if(r!==void 0){const c=i?nr(n,i,a,s):n;return!e||!l?st(r,t,c):sr(r,c,t)}}}function rr(n){if(n!==void 0)return 0}function Ur(n){if(n!==void 0)return n}function Wl(n){const t=2*Math.PI/n;return function(e,i){if(i)return e;if(e!==void 0)return e=Math.floor(e/t+.5)*t,e}}function Yl(n){const t=In(5);return function(e,i){return i||e===void 0?e:Math.abs(e)<=t?0:e}}function Jo(n){return Math.pow(n,3)}function xi(n){return 1-Jo(1-n)}function Zl(n){return 3*n*n-2*n*n*n}function Kl(n){return n}new Array(6);function Wt(){return[1,0,0,1,0,0]}function Bl(n,t){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n}function dt(n,t){const e=t[0],i=t[1];return t[0]=n[0]*e+n[2]*i+n[4],t[1]=n[1]*e+n[3]*i+n[5],t}function de(n,t,e,i,s,r,o,a){const l=Math.sin(r),c=Math.cos(r);return n[0]=i*c,n[1]=s*l,n[2]=-i*l,n[3]=s*c,n[4]=o*i*c-a*i*l+t,n[5]=o*s*l+a*s*c+e,n}function Qo(n,t){const e=Vl(t);j(e!==0,"Transformation matrix cannot be inverted");const i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5];return n[0]=o/e,n[1]=-s/e,n[2]=-r/e,n[3]=i/e,n[4]=(r*l-o*a)/e,n[5]=-(i*l-s*a)/e,n}function Vl(n){return n[0]*n[3]-n[1]*n[2]}const jr=[1e6,1e6,1e6,1e6,2,2];function Ul(n){return"matrix("+n.map((e,i)=>Math.round(e*jr[i])/jr[i]).join(", ")+")"}function ve(n,t,e,i,s,r,o){r=r||[],o=o||2;let a=0;for(let l=t;l<e;l+=i){const c=n[l],h=n[l+1];r[a++]=s[0]*c+s[2]*h+s[4],r[a++]=s[1]*c+s[3]*h+s[5];for(let u=2;u<o;u++)r[a++]=n[l+u]}return r&&r.length!=a&&(r.length=a),r}function ta(n,t,e,i,s,r,o){o=o||[];const a=Math.cos(s),l=Math.sin(s),c=r[0],h=r[1];let u=0;for(let d=t;d<e;d+=i){const f=n[d]-c,g=n[d+1]-h;o[u++]=c+f*a-g*l,o[u++]=h+f*l+g*a;for(let _=d+2;_<d+i;++_)o[u++]=n[_]}return o&&o.length!=u&&(o.length=u),o}function jl(n,t,e,i,s,r,o,a){a=a||[];const l=o[0],c=o[1];let h=0;for(let u=t;u<e;u+=i){const d=n[u]-l,f=n[u+1]-c;a[h++]=l+s*d,a[h++]=c+r*f;for(let g=u+2;g<u+i;++g)a[h++]=n[g]}return a&&a.length!=h&&(a.length=h),a}function Hl(n,t,e,i,s,r,o){o=o||[];let a=0;for(let l=t;l<e;l+=i){o[a++]=n[l]+s,o[a++]=n[l+1]+r;for(let c=l+2;c<l+i;++c)o[a++]=n[c]}return o&&o.length!=a&&(o.length=a),o}const Hr=Wt();class ql extends $t{constructor(){super(),this.extent_=Ft(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=No((t,e,i)=>{if(!i)return this.getSimplifiedGeometry(e);const s=this.clone();return s.applyTransform(i),s.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return U()}closestPointXY(t,e,i,s){return U()}containsXY(t,e){const i=this.getClosestPoint([t,e]);return i[0]===t&&i[1]===e}getClosestPoint(t,e){return e=e||[NaN,NaN],this.closestPointXY(t[0],t[1],e,1/0),e}intersectsCoordinate(t){return this.containsXY(t[0],t[1])}computeExtent(t){return U()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Bn(e),this.extentRevision_=this.getRevision()}return Ll(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=kt(t),s=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),c=i.getWorldExtent(),h=pt(c)/pt(l);return de(Hr,c[0],c[3],h,-h,0,0,0),ve(r,0,r.length,a,Hr,o),An(i,e)(r,o,a)}:An(i,e);return this.applyTransform(s),this}}class qn extends ql{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return $s(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||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&t<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;const e=this.getSimplifiedGeometryInternal(t);return e.getFlatCoordinates().length<this.flatCoordinates.length?e:(this.simplifiedGeometryMaxMinSquaredTolerance=t,this)}getSimplifiedGeometryInternal(t){return this}getStride(){return this.stride}setFlatCoordinates(t,e){this.stride=qr(t),this.layout=t,this.flatCoordinates=e}setCoordinates(t,e){U()}setLayout(t,e,i){let s;if(t)s=qr(t);else{for(let r=0;r<i;++r){if(e.length===0){this.layout="XY",this.stride=2;return}e=e[0]}s=e.length,t=$l(s)}this.layout=t,this.stride=s}applyTransform(t){this.flatCoordinates&&(t(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();ta(i,0,i.length,s,t,e,i),this.changed()}}scale(t,e,i){e===void 0&&(e=t),i||(i=Xe(this.getExtent()));const s=this.getFlatCoordinates();if(s){const r=this.getStride();jl(s,0,s.length,r,t,e,i,s),this.changed()}}translate(t,e){const i=this.getFlatCoordinates();if(i){const s=this.getStride();Hl(i,0,i.length,s,t,e,i),this.changed()}}}function $l(n){let t;return n==2?t="XY":n==3?t="XYZ":n==4&&(t="XYZM"),t}function qr(n){let t;return n=="XY"?t=2:n=="XYZ"||n=="XYM"?t=3:n=="XYZM"&&(t=4),t}function Jl(n,t,e){const i=n.getFlatCoordinates();if(!i)return null;const s=n.getStride();return ve(i,0,i.length,s,t,e)}function $r(n,t,e,i,s,r,o){const a=n[t],l=n[t+1],c=n[e]-a,h=n[e+1]-l;let u;if(c===0&&h===0)u=t;else{const d=((s-a)*c+(r-l)*h)/(c*c+h*h);if(d>1)u=e;else if(d>0){for(let f=0;f<i;++f)o[f]=St(n[t+f],n[e+f],d);o.length=i;return}else u=t}for(let d=0;d<i;++d)o[d]=n[u+d];o.length=i}function or(n,t,e,i,s){let r=n[t],o=n[t+1];for(t+=i;t<e;t+=i){const a=n[t],l=n[t+1],c=hi(r,o,a,l);c>s&&(s=c),r=a,o=l}return s}function Ql(n,t,e,i,s){for(let r=0,o=e.length;r<o;++r){const a=e[r];s=or(n,t,a,i,s),t=a}return s}function ar(n,t,e,i,s,r,o,a,l,c,h){if(t==e)return c;let u,d;if(s===0){if(d=hi(o,a,n[t],n[t+1]),d<c){for(u=0;u<i;++u)l[u]=n[t+u];return l.length=i,d}return c}h=h||[NaN,NaN];let f=t+i;for(;f<e;)if($r(n,f-i,f,i,o,a,h),d=hi(o,a,h[0],h[1]),d<c){for(c=d,u=0;u<i;++u)l[u]=h[u];l.length=i,f+=i}else f+=i*Math.max((Math.sqrt(d)-Math.sqrt(c))/s|0,1);if(r&&($r(n,e-i,t,i,o,a,h),d=hi(o,a,h[0],h[1]),d<c)){for(c=d,u=0;u<i;++u)l[u]=h[u];l.length=i}return c}function th(n,t,e,i,s,r,o,a,l,c,h){h=h||[NaN,NaN];for(let u=0,d=e.length;u<d;++u){const f=e[u];c=ar(n,t,f,i,s,r,o,a,l,c,h),t=f}return c}function eh(n,t,e,i){for(let s=0,r=e.length;s<r;++s)n[t++]=e[s];return t}function lr(n,t,e,i){for(let s=0,r=e.length;s<r;++s){const o=e[s];for(let a=0;a<i;++a)n[t++]=o[a]}return t}function ih(n,t,e,i,s){s=s||[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=lr(n,t,e[o],i);s[r++]=l,t=l}return s.length=r,s}function $n(n,t,e,i,s,r,o){const a=(e-t)/i;if(a<3){for(;t<e;t+=i)r[o++]=n[t],r[o++]=n[t+1];return o}const l=new Array(a);l[0]=1,l[a-1]=1;const c=[t,e-i];let h=0;for(;c.length>0;){const u=c.pop(),d=c.pop();let f=0;const g=n[d],_=n[d+1],m=n[u],p=n[u+1];for(let y=d+i;y<u;y+=i){const x=n[y],E=n[y+1],w=dl(x,E,g,_,m,p);w>f&&(h=y,f=w)}f>s&&(l[(h-t)/i]=1,d+i<h&&c.push(d,h),h+i<u&&c.push(h,u))}for(let u=0;u<a;++u)l[u]&&(r[o++]=n[t+u*i],r[o++]=n[t+u*i+1]);return o}function nh(n,t,e,i,s,r,o,a){for(let l=0,c=e.length;l<c;++l){const h=e[l];o=$n(n,t,h,i,s,r,o),a.push(o),t=h}return o}function Fe(n,t){return t*Math.round(n/t)}function sh(n,t,e,i,s,r,o){if(t==e)return o;let a=Fe(n[t],s),l=Fe(n[t+1],s);t+=i,r[o++]=a,r[o++]=l;let c,h;do if(c=Fe(n[t],s),h=Fe(n[t+1],s),t+=i,t==e)return r[o++]=c,r[o++]=h,o;while(c==a&&h==l);for(;t<e;){const u=Fe(n[t],s),d=Fe(n[t+1],s);if(t+=i,u==c&&d==h)continue;const f=c-a,g=h-l,_=u-a,m=d-l;if(f*m==g*_&&(f<0&&_<f||f==_||f>0&&_>f)&&(g<0&&m<g||g==m||g>0&&m>g)){c=u,h=d;continue}r[o++]=c,r[o++]=h,a=c,l=h,c=u,h=d}return r[o++]=c,r[o++]=h,o}function ea(n,t,e,i,s,r,o,a){for(let l=0,c=e.length;l<c;++l){const h=e[l];o=sh(n,t,h,i,s,r,o),a.push(o),t=h}return o}function ke(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=t;o<e;o+=i)s[r++]=n.slice(o,o+i);return s.length=r,s}function Mn(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=ke(n,t,l,i,s[r]),t=l}return s.length=r,s}function Jr(n,t,e,i,s){s=s!==void 0?s:[];let r=0;for(let o=0,a=e.length;o<a;++o){const l=e[o];s[r++]=l.length===1&&l[0]===t?[]:Mn(n,t,l,i,s[r]),t=l[l.length-1]}return s.length=r,s}function ia(n,t,e,i){let s=0;const r=n[e-i],o=n[e-i+1];let a=0,l=0;for(;t<e;t+=i){const c=n[t]-r,h=n[t+1]-o;s+=l*c-a*h,a=c,l=h}return s/2}function rh(n,t,e,i){let s=0;for(let r=0,o=e.length;r<o;++r){const a=e[r];s+=ia(n,t,a,i),t=a}return s}class Ki extends qn{constructor(t,e){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}clone(){return new Ki(this.flatCoordinates.slice(),this.layout)}closestPointXY(t,e,i,s){return s<qs(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(or(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ar(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,t,e,i,s))}getArea(){return ia(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return ke(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(t){const e=[];return e.length=$n(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new Ki(e,"XY")}getType(){return"LinearRing"}intersectsExtent(t){return!1}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=lr(this.flatCoordinates,0,t,this.stride),this.changed()}}class Bi extends qn{constructor(t,e){super(),this.setCoordinates(t,e)}clone(){const t=new Bi(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){const r=this.flatCoordinates,o=hi(t,e,r[0],r[1]);if(o<s){const a=this.stride;for(let l=0;l<a;++l)i[l]=r[l];return i.length=a,o}return s}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(t){return Yo(this.flatCoordinates,t)}getType(){return"Point"}intersectsExtent(t){return Wo(t,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(t,e){this.setLayout(e,t,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=eh(this.flatCoordinates,0,t,this.stride),this.changed()}}function oh(n,t,e,i,s){return!Ko(s,function(o){return!Ne(n,t,e,i,o[0],o[1])})}function Ne(n,t,e,i,s,r){let o=0,a=n[e-i],l=n[e-i+1];for(;t<e;t+=i){const c=n[t],h=n[t+1];l<=r?h>r&&(c-a)*(r-l)-(s-a)*(h-l)>0&&o++:h<=r&&(c-a)*(r-l)-(s-a)*(h-l)<0&&o--,a=c,l=h}return o!==0}function na(n,t,e,i,s,r){if(e.length===0||!Ne(n,t,e[0],i,s,r))return!1;for(let o=1,a=e.length;o<a;++o)if(Ne(n,e[o-1],e[o],i,s,r))return!1;return!0}function hr(n,t,e,i,s,r,o){let a,l,c,h,u,d,f;const g=s[r+1],_=[];for(let y=0,x=e.length;y<x;++y){const E=e[y];for(h=n[E-i],d=n[E-i+1],a=t;a<E;a+=i)u=n[a],f=n[a+1],(g<=d&&f<=g||d<=g&&g<=f)&&(c=(g-d)/(f-d)*(u-h)+h,_.push(c)),h=u,d=f}let m=NaN,p=-1/0;for(_.sort(ae),h=_[0],a=1,l=_.length;a<l;++a){u=_[a];const y=Math.abs(u-h);y>p&&(c=(h+u)/2,na(n,t,e,i,c,g)&&(m=c,p=y)),h=u}return isNaN(m)&&(m=s[r]),o?(o.push(m,g,p),o):[m,g,p]}function ah(n,t,e,i,s){let r=[];for(let o=0,a=e.length;o<a;++o){const l=e[o];r=hr(n,t,l,i,s,2*o,r),t=l[l.length-1]}return r}function sa(n,t,e,i,s){let r;for(t+=i;t<e;t+=i)if(r=s(n.slice(t-i,t),n.slice(t,t+i)),r)return r;return!1}function cr(n,t,e,i,s){const r=Zo(Ft(),n,t,e,i);return Tt(s,r)?ai(s,r)||r[0]>=s[0]&&r[2]<=s[2]||r[1]>=s[1]&&r[3]<=s[3]?!0:sa(n,t,e,i,function(o,a){return Al(s,o,a)}):!1}function ra(n,t,e,i,s){return!!(cr(n,t,e,i,s)||Ne(n,t,e,i,s[0],s[1])||Ne(n,t,e,i,s[0],s[3])||Ne(n,t,e,i,s[2],s[1])||Ne(n,t,e,i,s[2],s[3]))}function lh(n,t,e,i,s){if(!ra(n,t,e[0],i,s))return!1;if(e.length===1)return!0;for(let r=1,o=e.length;r<o;++r)if(oh(n,e[r-1],e[r],i,s)&&!cr(n,e[r-1],e[r],i,s))return!1;return!0}function hh(n,t,e,i){for(;t<e-i;){for(let s=0;s<i;++s){const r=n[t+s];n[t+s]=n[e-i+s],n[e-i+s]=r}t+=i,e-=i}}function ur(n,t,e,i){let s=0,r=n[e-i],o=n[e-i+1];for(;t<e;t+=i){const a=n[t],l=n[t+1];s+=(a-r)*(l+o),r=a,o=l}return s===0?void 0:s>0}function ch(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=ur(n,t,a,i);if(r===0){if(s&&l||!s&&!l)return!1}else if(s&&!l||!s&&l)return!1;t=a}return!0}function Qr(n,t,e,i,s){s=s!==void 0?s:!1;for(let r=0,o=e.length;r<o;++r){const a=e[r],l=ur(n,t,a,i);(r===0?s&&l||!s&&!l:s&&!l||!s&&l)&&hh(n,t,a,i),t=a}return t}function uh(n,t){const e=[];let i=0,s=0,r;for(let o=0,a=t.length;o<a;++o){const l=t[o],c=ur(n,i,l,2);if(r===void 0&&(r=c),c===r)e.push(t.slice(s,o+1));else{if(e.length===0)continue;e[e.length-1].push(t[s])}s=o+1,i=l}return e}class Vi extends qn{constructor(t,e,i){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,e!==void 0&&i?(this.setFlatCoordinates(e,t),this.ends_=i):this.setCoordinates(t,e)}appendLinearRing(t){this.flatCoordinates?Yn(this.flatCoordinates,t.getFlatCoordinates()):this.flatCoordinates=t.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){const t=new Vi(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<qs(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Ql(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),th(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,t,e,i,s))}containsXY(t,e){return na(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,e)}getArea(){return rh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(t){let e;return t!==void 0?(e=this.getOrientedFlatCoordinates().slice(),Qr(e,0,this.ends_,this.stride,t)):e=this.flatCoordinates,Mn(e,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){const t=Xe(this.getExtent());this.flatInteriorPoint_=hr(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new Bi(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(t){return t<0||this.ends_.length<=t?null:new Ki(this.flatCoordinates.slice(t===0?0:this.ends_[t-1],this.ends_[t]),this.layout)}getLinearRings(){const t=this.layout,e=this.flatCoordinates,i=this.ends_,s=[];let r=0;for(let o=0,a=i.length;o<a;++o){const l=i[o],c=new Ki(e.slice(r,l),t);s.push(c),r=l}return s}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){const t=this.flatCoordinates;ch(t,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=t:(this.orientedFlatCoordinates_=t.slice(),this.orientedFlatCoordinates_.length=Qr(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(t){const e=[],i=[];return e.length=ea(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(t),e,0,i),new Vi(e,"XY",i)}getType(){return"Polygon"}intersectsExtent(t){return lh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,2),this.flatCoordinates||(this.flatCoordinates=[]);const i=ih(this.flatCoordinates,0,t,this.stride,this.ends_);this.flatCoordinates.length=i.length===0?0:i[i.length-1],this.changed()}}function to(n){if(Hn(n))throw new Error("Cannot create polygon from empty extent");const t=n[0],e=n[1],i=n[2],s=n[3],r=[t,e,t,s,i,s,i,e,t,e];return new Vi(r,"XY",[r.length])}const fs=0;class Vt extends $t{constructor(t){super(),this.on,this.once,this.un,t=Object.assign({},t),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=er(t.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,t.projection&&jo(),t.center&&(t.center=se(t.center,this.projection_)),t.extent&&(t.extent=Te(t.extent,this.projection_)),this.applyOptions_(t)}applyOptions_(t){const e=Object.assign({},t);for(const a in Nt)delete e[a];this.setProperties(e,!0);const i=fh(t);this.maxResolution_=i.maxResolution,this.minResolution_=i.minResolution,this.zoomFactor_=i.zoomFactor,this.resolutions_=t.resolutions,this.padding_=t.padding,this.minZoom_=i.minZoom;const s=dh(t),r=i.constraint,o=gh(t);this.constraints_={center:s,resolution:r,rotation:o},this.setRotation(t.rotation!==void 0?t.rotation:0),this.setCenterInternal(t.center!==void 0?t.center:null),t.resolution!==void 0?this.setResolution(t.resolution):t.zoom!==void 0&&this.setZoom(t.zoom)}get padding(){return this.padding_}set padding(t){let e=this.padding_;this.padding_=t;const i=this.getCenterInternal();if(i){const s=t||[0,0,0,0];e=e||[0,0,0,0];const r=this.getResolution(),o=r/2*(s[3]-e[3]+e[1]-s[1]),a=r/2*(s[0]-e[0]+e[2]-s[2]);this.setCenterInternal([i[0]+o,i[1]-a])}}getUpdatedOptions_(t){const e=this.getProperties();return e.resolution!==void 0?e.resolution=this.getResolution():e.zoom=this.getZoom(),e.center=this.getCenterInternal(),e.rotation=this.getRotation(),Object.assign({},e,t)}animate(t){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);const e=new Array(arguments.length);for(let i=0;i<e.length;++i){let s=arguments[i];s.center&&(s=Object.assign({},s),s.center=se(s.center,this.getProjection())),s.anchor&&(s=Object.assign({},s),s.anchor=se(s.anchor,this.getProjection())),e[i]=s}this.animateInternal.apply(this,e)}animateInternal(t){let e=arguments.length,i;e>1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let s=0;for(;s<e&&!this.isDef();++s){const h=arguments[s];h.center&&this.setCenterInternal(h.center),h.zoom!==void 0?this.setZoom(h.zoom):h.resolution&&this.setResolution(h.resolution),h.rotation!==void 0&&this.setRotation(h.rotation)}if(s===e){i&&yn(i,!0);return}let r=Date.now(),o=this.targetCenter_.slice(),a=this.targetResolution_,l=this.targetRotation_;const c=[];for(;s<e;++s){const h=arguments[s],u={start:r,complete:!1,anchor:h.anchor,duration:h.duration!==void 0?h.duration:1e3,easing:h.easing||Zl,callback:i};if(h.center&&(u.sourceCenter=o,u.targetCenter=h.center.slice(),o=u.targetCenter),h.zoom!==void 0?(u.sourceResolution=a,u.targetResolution=this.getResolutionForZoom(h.zoom),a=u.targetResolution):h.resolution&&(u.sourceResolution=a,u.targetResolution=h.resolution,a=u.targetResolution),h.rotation!==void 0){u.sourceRotation=l;const d=ci(h.rotation-l+Math.PI,2*Math.PI)-Math.PI;u.targetRotation=l+d,l=u.targetRotation}_h(u)?u.complete=!0:r+=u.duration,c.push(u)}this.animations_.push(c),this.setHint(mt.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[mt.ANIMATING]>0}getInteracting(){return this.hints_[mt.INTERACTING]>0}cancelAnimations(){this.setHint(mt.ANIMATING,-this.hints_[mt.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e<i;++e){const s=this.animations_[e];if(s[0].callback&&yn(s[0].callback,!1),!t)for(let r=0,o=s.length;r<o;++r){const a=s[r];if(!a.complete){t=a.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=t,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;const t=Date.now();let e=!1;for(let i=this.animations_.length-1;i>=0;--i){const s=this.animations_[i];let r=!0;for(let o=0,a=s.length;o<a;++o){const l=s[o];if(l.complete)continue;const c=t-l.start;let h=l.duration>0?c/l.duration:1;h>=1?(l.complete=!0,h=1):r=!1;const u=l.easing(h);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],_=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=d+u*(g-d),p=f+u*(_-f);this.targetCenter_=[m,p]}if(l.sourceResolution&&l.targetResolution){const d=u===1?l.targetResolution:l.sourceResolution+u*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=u===1?ci(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+u*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),e=!0,!l.complete)break}if(r){this.animations_[i]=null,this.setHint(mt.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=s[0].callback;o&&yn(o,!0)}}this.animations_=this.animations_.filter(Boolean),e&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(t,e){let i;const s=this.getCenterInternal();return s!==void 0&&(i=[s[0]-e[0],s[1]-e[1]],Qs(i,t-this.getRotation()),Ml(i,e)),i}calculateCenterZoom(t,e){let i;const s=this.getCenterInternal(),r=this.getResolution();if(s!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-s[0])/r,a=e[1]-t*(e[1]-s[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],s=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(s*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(s*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&&Fs(t,this.getProjection())}getCenterInternal(){return this.get(Nt.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(t){return t!==void 0?(t[0]=this.hints_[0],t[1]=this.hints_[1],t):this.hints_.slice()}calculateExtent(t){const e=this.calculateExtentInternal(t);return $o(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();j(e,"The view center is not defined");const i=this.getResolution();j(i!==void 0,"The view resolution is not defined");const s=this.getRotation();return j(s!==void 0,"The view rotation is not defined"),Ps(e,i,s,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(Nt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(Te(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=q(t)/e[0],s=pt(t)/e[1];return Math.max(i,s)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,s=Math.log(e/i)/Math.log(t);return function(r){return e/Math.pow(t,r*s)}}getRotation(){return this.get(Nt.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),s=this.minResolution_,r=Math.log(i/s)/e;return function(o){return Math.log(i/o)/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 s=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();s=gs(s,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:s.slice(0),projection:t!==void 0?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 e!==void 0&&(t=this.getZoomForResolution(e)),t}getZoomForResolution(t){let e=this.minZoom_||0,i,s;if(this.resolutions_){const r=Bs(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?s=2:s=i/this.resolutions_[r+1]}else i=this.maxResolution_,s=this.zoomFactor_;return e+Math.log(i/t)/Math.log(s)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const e=st(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,st(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(j(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){j(!Hn(t),"Cannot fit empty extent provided as `geometry`");const s=Te(t,this.getProjection());i=to(s)}else if(t.getType()==="Circle"){const s=Te(t.getExtent(),this.getProjection());i=to(s),i.rotate(this.getRotation(),Xe(s))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),s=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,c=-1/0,h=-1/0;for(let u=0,d=r.length;u<d;u+=o){const f=r[u]*i-r[u+1]*s,g=r[u]*s+r[u+1]*i;a=Math.min(a,f),l=Math.min(l,g),c=Math.max(c,f),h=Math.max(h,g)}return[a,l,c,h]}fitInternal(t,e){e=e||{};let i=e.size;i||(i=this.getViewportSizeMinusPadding_());const s=e.padding!==void 0?e.padding:[0,0,0,0],r=e.nearest!==void 0?e.nearest:!1;let o;e.minResolution!==void 0?o=e.minResolution:e.maxZoom!==void 0?o=this.getResolutionForZoom(e.maxZoom):o=0;const a=this.rotatedExtentForGeometry(t);let l=this.getResolutionForExtentInternal(a,[i[0]-s[1]-s[3],i[1]-s[0]-s[2]]);l=isNaN(l)?o:Math.max(l,o),l=this.getConstrainedResolution(l,r?0:1);const c=this.getRotation(),h=Math.sin(c),u=Math.cos(c),d=Xe(a);d[0]+=(s[1]-s[3])/2*l,d[1]+=(s[0]-s[2])/2*l;const f=d[0]*u-d[1]*h,g=d[1]*u+d[0]*h,_=this.getConstrainedCenter([f,g],l),m=e.callback?e.callback:fi;e.duration!==void 0?this.animateInternal({resolution:l,center:_,duration:e.duration,easing:e.easing},m):(this.targetResolution_=l,this.targetCenter_=_,this.applyTargetState_(!1,!0),yn(m,!0))}centerOn(t,e,i){this.centerOnInternal(se(t,this.getProjection()),e,i)}centerOnInternal(t,e,i){this.setCenterInternal(gs(t,e,i,this.getResolution(),this.getRotation()))}calculateCenterShift(t,e,i,s){let r;const o=this.padding_;if(o&&t){const a=this.getViewportSizeMinusPadding_(-i),l=gs(t,s,[a[0]/2+o[3],a[1]/2+o[0]],e,i);r=[t[0]-l[0],t[1]-l[1]]}return r}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(t){const e=Fs(this.targetCenter_,this.getProjection());this.setCenter([e[0]+t[0],e[1]+t[1]])}adjustCenterInternal(t){const e=this.targetCenter_;this.setCenterInternal([e[0]+t[0],e[1]+t[1]])}adjustResolution(t,e){e=e&&se(e,this.getProjection()),this.adjustResolutionInternal(t,e)}adjustResolutionInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.getViewportSize_(this.getRotation()),r=this.constraints_.resolution(this.targetResolution_*t,0,s,i);e&&(this.targetCenter_=this.calculateCenterZoom(r,e)),this.targetResolution_*=t,this.applyTargetState_()}adjustZoom(t,e){this.adjustResolution(Math.pow(this.zoomFactor_,-t),e)}adjustRotation(t,e){e&&(e=se(e,this.getProjection())),this.adjustRotationInternal(t,e)}adjustRotationInternal(t,e){const i=this.getAnimating()||this.getInteracting(),s=this.constraints_.rotation(this.targetRotation_+t,i);e&&(this.targetCenter_=this.calculateCenterRotate(s,e)),this.targetRotation_+=t,this.applyTargetState_()}setCenter(t){this.setCenterInternal(t&&se(t,this.getProjection()))}setCenterInternal(t){this.targetCenter_=t,this.applyTargetState_()}setHint(t,e){return this.hints_[t]+=e,this.changed(),this.hints_[t]}setResolution(t){this.targetResolution_=t,this.applyTargetState_()}setRotation(t){this.targetRotation_=t,this.applyTargetState_()}setZoom(t){this.setResolution(this.getResolutionForZoom(t))}applyTargetState_(t,e){const i=this.getAnimating()||this.getInteracting()||e,s=this.constraints_.rotation(this.targetRotation_,i),r=this.getViewportSize_(s),o=this.constraints_.resolution(this.targetResolution_,0,r,i),a=this.constraints_.center(this.targetCenter_,o,r,i,this.calculateCenterShift(this.targetCenter_,o,s,r));this.get(Nt.ROTATION)!==s&&this.set(Nt.ROTATION,s),this.get(Nt.RESOLUTION)!==o&&(this.set(Nt.RESOLUTION,o),this.set("zoom",this.getZoom(),!0)),(!a||!this.get(Nt.CENTER)||!Ln(this.get(Nt.CENTER),a))&&this.set(Nt.CENTER,a),this.getAnimating()&&!t&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(t,e,i){t=t!==void 0?t:200;const s=e||0,r=this.constraints_.rotation(this.targetRotation_),o=this.getViewportSize_(r),a=this.constraints_.resolution(this.targetResolution_,s,o),l=this.constraints_.center(this.targetCenter_,a,o,!1,this.calculateCenterShift(this.targetCenter_,a,r,o));if(t===0&&!this.cancelAnchor_){this.targetResolution_=a,this.targetRotation_=r,this.targetCenter_=l,this.applyTargetState_();return}i=i||(t===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==a||this.getRotation()!==r||!this.getCenterInternal()||!Ln(this.getCenterInternal(),l))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:r,center:l,resolution:a,duration:t,easing:xi,anchor:i}))}beginInteraction(){this.resolveConstraints(0),this.setHint(mt.INTERACTING,1)}endInteraction(t,e,i){i=i&&se(i,this.getProjection()),this.endInteractionInternal(t,e,i)}endInteractionInternal(t,e,i){this.getInteracting()&&(this.setHint(mt.INTERACTING,-1),this.resolveConstraints(t,e,i))}getConstrainedCenter(t,e){const i=this.getViewportSize_(this.getRotation());return this.constraints_.center(t,e||this.getResolution(),i)}getConstrainedZoom(t,e){const i=this.getResolutionForZoom(t);return this.getZoomForResolution(this.getConstrainedResolution(i,e))}getConstrainedResolution(t,e){e=e||0;const i=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(t,e,i)}}function yn(n,t){setTimeout(function(){n(t)},0)}function dh(n){if(n.extent!==void 0){const e=n.smoothExtentConstraint!==void 0?n.smoothExtentConstraint:!0;return Br(n.extent,n.constrainOnlyCenter,e)}const t=er(n.projection,"EPSG:3857");if(n.multiWorld!==!0&&t.isGlobal()){const e=t.getExtent().slice();return e[0]=-1/0,e[2]=1/0,Br(e,!1,!1)}return Gl}function fh(n){let t,e,i,o=n.minZoom!==void 0?n.minZoom:fs,a=n.maxZoom!==void 0?n.maxZoom:28;const l=n.zoomFactor!==void 0?n.zoomFactor:2,c=n.multiWorld!==void 0?n.multiWorld:!1,h=n.smoothResolutionConstraint!==void 0?n.smoothResolutionConstraint:!0,u=n.showFullExtent!==void 0?n.showFullExtent:!1,d=er(n.projection,"EPSG:3857"),f=d.getExtent();let g=n.constrainOnlyCenter,_=n.extent;if(!c&&!_&&d.isGlobal()&&(g=!1,_=f),n.resolutions!==void 0){const m=n.resolutions;e=m[o],i=m[a]!==void 0?m[a]:m[m.length-1],n.constrainResolution?t=zl(m,h,!g&&_,u):t=Vr(e,i,h,!g&&_,u)}else{const p=(f?Math.max(q(f),pt(f)):360*js.degrees/d.getMetersPerUnit())/Us/Math.pow(2,fs),y=p/Math.pow(2,28-fs);e=n.maxResolution,e!==void 0?o=0:e=p/Math.pow(l,o),i=n.minResolution,i===void 0&&(n.maxZoom!==void 0?n.maxResolution!==void 0?i=e/Math.pow(l,a):i=p/Math.pow(l,a):i=y),a=o+Math.floor(Math.log(e/i)/Math.log(l)),i=e/Math.pow(l,a-o),n.constrainResolution?t=Xl(l,e,i,h,!g&&_,u):t=Vr(e,i,h,!g&&_,u)}return{constraint:t,maxResolution:e,minResolution:i,minZoom:o,zoomFactor:l}}function gh(n){if(n.enableRotation!==void 0?n.enableRotation:!0){const e=n.constrainRotation;return e===void 0||e===!0?Yl():e===!1?Ur:typeof e=="number"?Wl(e):Ur}return rr}function _h(n){return!(n.sourceCenter&&n.targetCenter&&!Ln(n.sourceCenter,n.targetCenter)||n.sourceResolution!==n.targetResolution||n.sourceRotation!==n.targetRotation)}function gs(n,t,e,i,s){const r=Math.cos(-s);let o=Math.sin(-s),a=n[0]*r-n[1]*o,l=n[1]*r+n[0]*o;a+=(t[0]/2-e[0])*i,l+=(e[1]-t[1]/2)*i,o=-o;const c=a*r-l*o,h=l*r+a*o;return[c,h]}class Jn extends Go{constructor(t){const e=Object.assign({},t);delete e.source,super(e),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,t.render&&(this.render=t.render),t.map&&this.setMap(t.map),this.addChangeListener(J.SOURCE,this.handleSourcePropertyChange_);const i=t.source?t.source:null;this.setSource(i)}getLayersArray(t){return t=t||[],t.push(this),t}getLayerStatesArray(t){return t=t||[],t.push(this.getLayerState()),t}getSource(){return this.get(J.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){const t=this.getSource();return t?t.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(tt(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;const t=this.getSource();t&&(this.sourceChangeKey_=V(t,z.CHANGE,this.handleSourceChange_,this),t.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(t){return this.renderer_?this.renderer_.getFeatures(t):Promise.resolve([])}getData(t){return!this.renderer_||!this.rendered?null:this.renderer_.getData(t)}isVisible(t){let e;const i=this.getMapInternal();!t&&i&&(t=i.getView()),t instanceof Vt?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let s;e.layerStatesArray?s=e.layerStatesArray.find(o=>o.layer===this):s=this.getLayerState();const r=this.getExtent();return dr(s,e.viewState)&&(!r||Tt(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof Vt?t.getViewStateAndExtent():t;let s=e(i);return Array.isArray(s)||(s=[s]),s}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(J.MAP,t)}getMapInternal(){return this.get(J.MAP)}setMap(t){this.mapPrecomposeKey_&&(tt(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(tt(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=V(t,Ot.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=V(this,z.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);j(!e.some(s=>s.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(J.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function dr(n,t){if(!n.visible)return!1;const e=t.resolution;if(e<n.minResolution||e>=n.maxResolution)return!1;const i=t.zoom;return i>n.minZoom&&i<=n.maxZoom}function oa(n,t,e=0,i=n.length-1,s=mh){for(;i>e;){if(i-e>600){const l=i-e+1,c=t-e+1,h=Math.log(l),u=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*u*(l-u)/l)*(c-l/2<0?-1:1),f=Math.max(e,Math.floor(t-c*u/l+d)),g=Math.min(i,Math.floor(t+(l-c)*u/l+d));oa(n,t,f,g,s)}const r=n[t];let o=e,a=i;for(Ai(n,e,t),s(n[i],r)>0&&Ai(n,e,i);o<a;){for(Ai(n,o,a),o++,a--;s(n[o],r)<0;)o++;for(;s(n[a],r)>0;)a--}s(n[e],r)===0?Ai(n,e,a):(a++,Ai(n,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function Ai(n,t,e){const i=n[t];n[t]=n[e],n[e]=i}function mh(n,t){return n<t?-1:n>t?1:0}let aa=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!xn(t,e))return i;const s=this.toBBox,r=[];for(;e;){for(let o=0;o<e.children.length;o++){const a=e.children[o],l=e.leaf?s(a):a;xn(t,l)&&(e.leaf?i.push(a):ms(t,l)?this._all(a,i):r.push(a))}e=r.pop()}return i}collides(t){let e=this.data;if(!xn(t,e))return!1;const i=[];for(;e;){for(let s=0;s<e.children.length;s++){const r=e.children[s],o=e.leaf?this.toBBox(r):r;if(xn(t,o)){if(e.leaf||ms(t,o))return!0;i.push(r)}}e=i.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=e;else if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const i=this.data;this.data=e,e=i}this._insert(e,this.data.height-e.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=ii([]),this}remove(t,e){if(!t)return this;let i=this.data;const s=this.toBBox(t),r=[],o=[];let a,l,c;for(;i||r.length;){if(i||(i=r.pop(),l=r[r.length-1],a=o.pop(),c=!0),i.leaf){const h=ph(t,i.children,e);if(h!==-1)return i.children.splice(h,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&ms(i,s)?(r.push(i),o.push(a),a=0,l=i,i=i.children[0]):l?(a++,i=l.children[a],c=!1):i=null}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const i=[];for(;t;)t.leaf?e.push(...t.children):i.push(...t.children),t=i.pop();return e}_build(t,e,i,s){const r=i-e+1;let o=this._maxEntries,a;if(r<=o)return a=ii(t.slice(e,i+1)),He(a,this.toBBox),a;s||(s=Math.ceil(Math.log(r)/Math.log(o)),o=Math.ceil(r/Math.pow(o,s-1))),a=ii([]),a.leaf=!1,a.height=s;const l=Math.ceil(r/o),c=l*Math.ceil(Math.sqrt(o));eo(t,e,i,c,this.compareMinX);for(let h=e;h<=i;h+=c){const u=Math.min(h+c-1,i);eo(t,h,u,l,this.compareMinY);for(let d=h;d<=u;d+=l){const f=Math.min(d+l-1,u);a.children.push(this._build(t,d,f,s-1))}}return He(a,this.toBBox),a}_chooseSubtree(t,e,i,s){for(;s.push(e),!(e.leaf||s.length-1===i);){let r=1/0,o=1/0,a;for(let l=0;l<e.children.length;l++){const c=e.children[l],h=_s(c),u=xh(t,c)-h;u<o?(o=u,r=h<r?h:r,a=c):u===o&&h<r&&(r=h,a=c)}e=a||e.children[0]}return e}_insert(t,e,i){const s=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(s,this.data,e,r);for(o.children.push(t),Oi(o,s);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)}_split(t,e){const i=t[e],s=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,s);const o=this._chooseSplitIndex(i,r,s),a=ii(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,He(i,this.toBBox),He(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=ii([t,e]),this.data.height=t.height+1,this.data.leaf=!1,He(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let s,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=Pi(t,0,a,this.toBBox),c=Pi(t,a,i,this.toBBox),h=wh(l,c),u=_s(l)+_s(c);h<r?(r=h,s=a,o=u<o?u:o):h===r&&u<o&&(o=u,s=a)}return s||i-e}_chooseSplitAxis(t,e,i){const s=t.leaf?this.compareMinX:yh,r=t.leaf?this.compareMinY:Eh,o=this._allDistMargin(t,e,i,s),a=this._allDistMargin(t,e,i,r);o<a&&t.children.sort(s)}_allDistMargin(t,e,i,s){t.children.sort(s);const r=this.toBBox,o=Pi(t,0,e,r),a=Pi(t,i-e,i,r);let l=En(o)+En(a);for(let c=e;c<i-e;c++){const h=t.children[c];Oi(o,t.leaf?r(h):h),l+=En(o)}for(let c=i-e-1;c>=e;c--){const h=t.children[c];Oi(a,t.leaf?r(h):h),l+=En(a)}return l}_adjustParentBBoxes(t,e,i){for(let s=i;s>=0;s--)Oi(e[s],t)}_condense(t){for(let e=t.length-1,i;e>=0;e--)t[e].children.length===0?e>0?(i=t[e-1].children,i.splice(i.indexOf(t[e]),1)):this.clear():He(t[e],this.toBBox)}};function ph(n,t,e){if(!e)return t.indexOf(n);for(let i=0;i<t.length;i++)if(e(n,t[i]))return i;return-1}function He(n,t){Pi(n,0,n.children.length,t,n)}function Pi(n,t,e,i,s){s||(s=ii(null)),s.minX=1/0,s.minY=1/0,s.maxX=-1/0,s.maxY=-1/0;for(let r=t;r<e;r++){const o=n.children[r];Oi(s,n.leaf?i(o):o)}return s}function Oi(n,t){return n.minX=Math.min(n.minX,t.minX),n.minY=Math.min(n.minY,t.minY),n.maxX=Math.max(n.maxX,t.maxX),n.maxY=Math.max(n.maxY,t.maxY),n}function yh(n,t){return n.minX-t.minX}function Eh(n,t){return n.minY-t.minY}function _s(n){return(n.maxX-n.minX)*(n.maxY-n.minY)}function En(n){return n.maxX-n.minX+(n.maxY-n.minY)}function xh(n,t){return(Math.max(t.maxX,n.maxX)-Math.min(t.minX,n.minX))*(Math.max(t.maxY,n.maxY)-Math.min(t.minY,n.minY))}function wh(n,t){const e=Math.max(n.minX,t.minX),i=Math.max(n.minY,t.minY),s=Math.min(n.maxX,t.maxX),r=Math.min(n.maxY,t.maxY);return Math.max(0,s-e)*Math.max(0,r-i)}function ms(n,t){return n.minX<=t.minX&&n.minY<=t.minY&&t.maxX<=n.maxX&&t.maxY<=n.maxY}function xn(n,t){return t.minX<=n.maxX&&t.minY<=n.maxY&&t.maxX>=n.minX&&t.maxY>=n.minY}function ii(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function eo(n,t,e,i,s){const r=[t,e];for(;r.length;){if(e=r.pop(),t=r.pop(),e-t<=i)continue;const o=t+Math.ceil((e-t)/i/2)*i;oa(n,o,t,e,s),r.push(t,o,o,e)}}const Y={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};function io(n){return n[0]>0&&n[1]>0}function Ch(n,t,e){return e===void 0&&(e=[0,0]),e[0]=n[0]*t+.5|0,e[1]=n[1]*t+.5|0,e}function vt(n,t){return Array.isArray(n)?n:(t===void 0?t=[n,n]:(t[0]=n,t[1]=n),t)}class Qn{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=vt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Qn({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return U()}getImage(t){return U()}getHitDetectionImage(){return U()}getPixelRatio(t){return 1}getImageState(){return U()}getImageSize(){return U()}getOrigin(){return U()}getSize(){return U()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=vt(t)}listenImageChange(t){U()}load(){U()}unlistenImageChange(t){U()}ready(){return Promise.resolve()}}const Ui={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var ft={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"]};ft.whitepoint={2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}};ft.max=ft.whitepoint[2].D65;ft.rgb=function(n,t){t=t||ft.whitepoint[2].E;var e=n[0]/t[0],i=n[1]/t[1],s=n[2]/t[2],r,o,a;return r=e*3.240969941904521+i*-1.537383177570093+s*-.498610760293,o=e*-.96924363628087+i*1.87596750150772+s*.041555057407175,a=e*.055630079696993+i*-.20397695888897+s*1.056971514242878,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r=r*12.92,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=a*12.92,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[r*255,o*255,a*255]};Ui.xyz=function(n,t){var e=n[0]/255,i=n[1]/255,s=n[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92,s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92;var r=e*.41239079926595+i*.35758433938387+s*.18048078840183,o=e*.21263900587151+i*.71516867876775+s*.072192315360733,a=e*.019330818715591+i*.11919477979462+s*.95053215224966;return t=t||ft.whitepoint[2].E,[r*t[0],o*t[1],a*t[2]]};const fr={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(n,t,e){var i,s,r,o,a,l,c,h,u,d,f,g,_;if(r=n[0],o=n[1],a=n[2],r===0)return[0,0,0];var m=.0011070564598794539;return t=t||"D65",e=e||2,u=ft.whitepoint[e][t][0],d=ft.whitepoint[e][t][1],f=ft.whitepoint[e][t][2],g=4*u/(u+15*d+3*f),_=9*d/(u+15*d+3*f),i=o/(13*r)+g||0,s=a/(13*r)+_||0,c=r>8?d*Math.pow((r+16)/116,3):d*r*m,l=c*9*i/(4*s)||0,h=c*(12-3*i-20*s)/(4*s)||0,[l,c,h]}};ft.luv=function(n,t,e){var i,s,r,o,a,l,c,h,u,d,f,g,_,m=.008856451679035631,p=903.2962962962961;t=t||"D65",e=e||2,u=ft.whitepoint[e][t][0],d=ft.whitepoint[e][t][1],f=ft.whitepoint[e][t][2],g=4*u/(u+15*d+3*f),_=9*d/(u+15*d+3*f),l=n[0],c=n[1],h=n[2],i=4*l/(l+15*c+3*h)||0,s=9*c/(l+15*c+3*h)||0;var y=c/d;return r=y<=m?p*y:116*Math.pow(y,1/3)-16,o=13*r*(i-g),a=13*r*(s-_),[r,o,a]};var la={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(n){var t=n[0],e=n[1],i=n[2],s,r,o;return o=i/360*2*Math.PI,s=e*Math.cos(o),r=e*Math.sin(o),[t,s,r]},xyz:function(n){return fr.xyz(la.luv(n))}};fr.lchuv=function(n){var t=n[0],e=n[1],i=n[2],s=Math.sqrt(e*e+i*i),r=Math.atan2(i,e),o=r*360/2/Math.PI;return o<0&&(o+=360),[t,s,o]};ft.lchuv=function(n){return fr.lchuv(ft.luv(n))};const no={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};var so={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function Rh(n){var t,e=[],i=1,s;if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(typeof n=="number")return{space:"rgb",values:[n>>>16,(n&65280)>>>8,n&255],alpha:1};if(n=String(n).toLowerCase(),no[n])e=no[n].slice(),s="rgb";else if(n==="transparent")i=0,s="rgb",e=[0,0,0];else if(n[0]==="#"){var r=n.slice(1),o=r.length,a=o<=4;i=1,a?(e=[parseInt(r[0]+r[0],16),parseInt(r[1]+r[1],16),parseInt(r[2]+r[2],16)],o===4&&(i=parseInt(r[3]+r[3],16)/255)):(e=[parseInt(r[0]+r[1],16),parseInt(r[2]+r[3],16),parseInt(r[4]+r[5],16)],o===8&&(i=parseInt(r[6]+r[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0),s="rgb"}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(n)){var l=t[1];s=l.replace(/a$/,"");var c=s==="cmyk"?4:s==="gray"?1:3;e=t[2].trim().split(/\s*[,\/]\s*|\s+/),s==="color"&&(s=e.shift()),e=e.map(function(h,u){if(h[h.length-1]==="%")return h=parseFloat(h)/100,u===3?h:s==="rgb"?h*255:s[0]==="h"||s[0]==="l"&&!u?h*100:s==="lab"?h*125:s==="lch"?u<2?h*150:h*360:s[0]==="o"&&!u?h:s==="oklab"?h*.4:s==="oklch"?u<2?h*.4:h*360:h;if(s[u]==="h"||u===2&&s[s.length-1]==="h"){if(so[h]!==void 0)return so[h];if(h.endsWith("deg"))return parseFloat(h);if(h.endsWith("turn"))return parseFloat(h)*360;if(h.endsWith("grad"))return parseFloat(h)*360/400;if(h.endsWith("rad"))return parseFloat(h)*180/Math.PI}return h==="none"?0:parseFloat(h)}),i=e.length>c?e.pop():1}else/[0-9](?:\s|\/|,)/.test(n)&&(e=n.match(/([0-9]+)/g).map(function(h){return parseFloat(h)}),s=n.match(/([a-z])/ig)?.join("")?.toLowerCase()||"rgb");return{space:s,values:e,alpha:i}}const ps={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(n){var t=n[0]/360,e=n[1]/100,i=n[2]/100,s,r,o,a,l,c=0;if(e===0)return l=i*255,[l,l,l];for(r=i<.5?i*(1+e):i+e-i*e,s=2*i-r,a=[0,0,0];c<3;)o=t+1/3*-(c-1),o<0?o++:o>1&&o--,l=6*o<1?s+(r-s)*6*o:2*o<1?r:3*o<2?s+(r-s)*(2/3-o)*6:s,a[c++]=l*255;return a}};Ui.hsl=function(n){var t=n[0]/255,e=n[1]/255,i=n[2]/255,s=Math.min(t,e,i),r=Math.max(t,e,i),o=r-s,a,l,c;return r===s?a=0:t===r?a=(e-i)/o:e===r?a=2+(i-t)/o:i===r&&(a=4+(t-e)/o),a=Math.min(a*60,360),a<0&&(a+=360),c=(s+r)/2,r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]};function Th(n){Array.isArray(n)&&n.raw&&(n=String.raw(...arguments)),n instanceof Number&&(n=+n);var t,e=Rh(n);if(!e.space)return[];const i=e.space[0]==="h"?ps.min:Ui.min,s=e.space[0]==="h"?ps.max:Ui.max;return t=Array(3),t[0]=Math.min(Math.max(e.values[0],i[0]),s[0]),t[1]=Math.min(Math.max(e.values[1],i[1]),s[1]),t[2]=Math.min(Math.max(e.values[2],i[2]),s[2]),e.space[0]==="h"&&(t=ps.rgb(t)),t.push(Math.min(Math.max(e.alpha,0),1)),t}const gr=[NaN,NaN,NaN,0];function Ih(n){return typeof n=="string"?n:mr(n)}const vh=1024,Mi={};let ys=0;function Sh(n){if(n.length===4)return n;const t=n.slice();return t[3]=1,t}function ro(n){const t=ft.lchuv(Ui.xyz(n));return t[3]=n[3],t}function Lh(n){const t=ft.rgb(la.xyz(n));return t[3]=n[3],t}function _r(n){if(n==="none")return gr;if(Mi.hasOwnProperty(n))return Mi[n];if(ys>=vh){let e=0;for(const i in Mi)e++&3||(delete Mi[i],--ys)}const t=Th(n);if(t.length!==4)throw new Error('failed to parse "'+n+'" as color');for(const e of t)if(isNaN(e))throw new Error('failed to parse "'+n+'" as color');return ha(t),Mi[n]=t,++ys,t}function ji(n){return Array.isArray(n)?n:_r(n)}function ha(n){return n[0]=st(n[0]+.5|0,0,255),n[1]=st(n[1]+.5|0,0,255),n[2]=st(n[2]+.5|0,0,255),n[3]=st(n[3],0,1),n}function mr(n){let t=n[0];t!=(t|0)&&(t=t+.5|0);let e=n[1];e!=(e|0)&&(e=e+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const s=n[3]===void 0?1:Math.round(n[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+s+")"}const Le=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",Ah=Le.includes("firefox"),Mh=Le.includes("safari")&&!Le.includes("chrom");Mh&&(Le.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(Le));const bh=Le.includes("webkit")&&!Le.includes("edge"),ca=Le.includes("macintosh"),ua=typeof devicePixelRatio<"u"?devicePixelRatio:1,da=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,fa=typeof Image<"u"&&Image.prototype.decode,ga=function(){let n=!1;try{const t=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,t),window.removeEventListener("_",null,t)}catch{}return n}();function rt(n,t,e,i){let s;return e&&e.length?s=e.shift():da?s=new OffscreenCanvas(n||300,t||300):s=document.createElement("canvas"),n&&(s.width=n),t&&(s.height=t),s.getContext("2d",i)}let Es;function bn(){return Es||(Es=rt(1,1)),Es}function mi(n){const t=n.canvas;t.width=1,t.height=1,n.clearRect(0,0,1,1)}function oo(n,t){const e=t.parentNode;e&&e.replaceChild(n,t)}function Dh(n){for(;n.lastChild;)n.lastChild.remove()}function Ph(n,t){const e=n.childNodes;for(let i=0;;++i){const s=e[i],r=t[i];if(!s&&!r)break;if(s!==r){if(!s){n.appendChild(r);continue}if(!r){n.removeChild(s),--i;continue}n.insertBefore(r,s)}}}function Oh(n,t,e){const i=n;let s=!0,r=!1,o=!1;const a=[vn(i,z.LOAD,function(){o=!0,r||t()})];return i.src&&fa?(r=!0,i.decode().then(function(){s&&t()}).catch(function(l){s&&(o?t():e())})):a.push(vn(i,z.ERROR,e)),function(){s=!1,a.forEach(tt)}}function Fh(n,t){return new Promise((e,i)=>{function s(){o(),e(n)}function r(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",s),n.removeEventListener("error",r)}n.addEventListener("load",s),n.addEventListener("error",r)})}function kh(n,t){return t&&(n.src=t),n.src&&fa?new Promise((e,i)=>n.decode().then(()=>e(n)).catch(s=>n.complete&&n.width?e(n):i(s))):Fh(n)}class Nh{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}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];!(t++&3)&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e,i){const s=xs(t,e,i);return s in this.cache_?this.cache_[s]:null}getPattern(t,e,i){const s=xs(t,e,i);return s in this.patternCache_?this.patternCache_[s]:null}set(t,e,i,s,r){const o=xs(t,e,i),a=o in this.cache_;this.cache_[o]=s,r&&(s.getImageState()===Y.IDLE&&s.load(),s.getImageState()===Y.LOADING?s.ready().then(()=>{this.patternCache_[o]=bn().createPattern(s.getImage(1),"repeat")}):this.patternCache_[o]=bn().createPattern(s.getImage(1),"repeat")),a||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function xs(n,t,e){const i=e?ji(e):"null";return t+":"+n+":"+i}const Ht=new Nh;let bi=null;class Gh extends Kn{constructor(t,e,i,s,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i,this.canvas_={},this.color_=r,this.imageState_=s===void 0?Y.IDLE:s,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,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===Y.LOADED){bi||(bi=rt(1,1,void 0,{willReadFrequently:!0})),bi.drawImage(this.image_,0,0);try{bi.getImageData(0,0,1,1),this.tainted_=!1}catch{bi=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(z.CHANGE)}handleImageError_(){this.imageState_=Y.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Y.LOADED,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=rt(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_===Y.IDLE){this.image_||this.initializeImage_(),this.imageState_=Y.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&kh(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_!==Y.LOADED)return;const e=this.image_,i=rt(Math.ceil(e.width*t),Math.ceil(e.height*t)),s=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Ih(this.color_),i.fillRect(0,0,s.width/t,s.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=s}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===Y.LOADED||this.imageState_===Y.ERROR)t();else{const e=()=>{(this.imageState_===Y.LOADED||this.imageState_===Y.ERROR)&&(this.removeEventListener(z.CHANGE,e),t())};this.addEventListener(z.CHANGE,e)}})),this.ready_}}function pr(n,t,e,i,s,r){let o=t===void 0?void 0:Ht.get(t,e,s);return o||(o=new Gh(n,n&&"src"in n?n.src||void 0:t,e,i,s),Ht.set(t,e,s,o,r)),r&&o&&!Ht.getPattern(t,e,s)&&Ht.set(t,e,s,o,r),o}function qt(n){return n?Array.isArray(n)?mr(n):typeof n=="object"&&"src"in n?zh(n):n:null}function zh(n){if(!n.offset||!n.size)return Ht.getPattern(n.src,"anonymous",n.color);const t=n.src+":"+n.offset,e=Ht.getPattern(t,void 0,n.color);if(e)return e;const i=Ht.get(n.src,"anonymous",null);if(i.getImageState()!==Y.LOADED)return null;const s=rt(n.size[0],n.size[1]);return s.drawImage(i.getImage(1),n.offset[0],n.offset[1],n.size[0],n.size[1],0,0,n.size[0],n.size[1]),pr(s.canvas,t,void 0,Y.LOADED,n.color,!0),Ht.getPattern(t,void 0,n.color)}const wn="ol-hidden",ts="ol-unselectable",yr="ol-control",ao="ol-collapsed",Xh=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`].join(""),"i"),lo=["style","variant","weight","size","lineHeight","family"],_a=function(n){const t=n.match(Xh);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let i=0,s=lo.length;i<s;++i){const r=t[i+1];r!==void 0&&(e[lo[i]]=r)}return e.families=e.family.split(/,\s?/),e},ma="10px sans-serif",Ct="#000",pi="round",le=[],he=0,yi="round",Hi=10,qi="#000",$i="center",Dn="middle",Ge=[0,0,0,0],Ji=1,re=new $t;let ni=null,ks;const Ns={},Wh=function(){const t="32px ",e=["monospace","serif"],i=e.length,s="wmytzilWMYTZIL@#/&?$%10";let r,o;function a(c,h,u){let d=!0;for(let f=0;f<i;++f){const g=e[f];if(o=Pn(c+" "+h+" "+t+g,s),u!=g){const _=Pn(c+" "+h+" "+t+u+","+g,s);d=d&&_!=o}}return!!d}function l(){let c=!0;const h=re.getKeys();for(let u=0,d=h.length;u<d;++u){const f=h[u];if(re.get(f)<100){const[g,_,m]=f.split(`
|
||
`);a(g,_,m)?(nn(Ns),ni=null,ks=void 0,re.set(f,100)):(re.set(f,re.get(f)+1,!0),c=!1)}}c&&(clearInterval(r),r=void 0)}return function(c){const h=_a(c);if(!h)return;const u=h.families;for(let d=0,f=u.length;d<f;++d){const g=u[d],_=h.style+`
|
||
`+h.weight+`
|
||
`+g;re.get(_)===void 0&&(re.set(_,100,!0),a(h.style,h.weight,g)||(re.set(_,0,!0),r===void 0&&(r=setInterval(l,32))))}}}(),Yh=function(){let n;return function(t){let e=Ns[t];if(e==null){if(da){const i=_a(t),s=pa(t,"Žg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(s.actualBoundingBoxAscent+s.actualBoundingBoxDescent)}else n||(n=document.createElement("div"),n.innerHTML="M",n.style.minHeight="0",n.style.maxHeight="none",n.style.height="auto",n.style.padding="0",n.style.border="none",n.style.position="absolute",n.style.display="block",n.style.left="-99999px"),n.style.font=t,document.body.appendChild(n),e=n.offsetHeight,document.body.removeChild(n);Ns[t]=e}return e}}();function pa(n,t){return ni||(ni=rt(1,1)),n!=ks&&(ni.font=n,ks=ni.font),ni.measureText(t)}function Pn(n,t){return pa(n,t).width}function ho(n,t,e){if(t in e)return e[t];const i=t.split(`
|
||
`).reduce((s,r)=>Math.max(s,Pn(n,r)),0);return e[t]=i,i}function Zh(n,t){const e=[],i=[],s=[];let r=0,o=0,a=0,l=0;for(let c=0,h=t.length;c<=h;c+=2){const u=t[c];if(u===`
|
||
`||c===h){r=Math.max(r,o),s.push(o),o=0,a+=l,l=0;continue}const d=t[c+1]||n.font,f=Pn(d,u);e.push(f),o+=f;const g=Yh(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:s}}function Kh(n,t,e,i,s,r,o,a,l,c,h){n.save(),e!==1&&(n.globalAlpha===void 0?n.globalAlpha=u=>u.globalAlpha*=e:n.globalAlpha*=e),t&&n.transform.apply(n,t),i.contextInstructions?(n.translate(l,c),n.scale(h[0],h[1]),Bh(i,n)):h[0]<0||h[1]<0?(n.translate(l,c),n.scale(h[0],h[1]),n.drawImage(i,s,r,o,a,0,0,o,a)):n.drawImage(i,s,r,o,a,l,c,o*h[0],a*h[1]),n.restore()}function Bh(n,t){const e=n.contextInstructions;for(let i=0,s=e.length;i<s;i+=2)Array.isArray(e[i+1])?t[e[i]].apply(t,e[i+1]):t[e[i]]=e[i+1]}class es extends Qn{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.canvases_,this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?Y.LOADING:Y.LOADED,this.imageState_===Y.LOADING&&this.ready().then(()=>this.imageState_=Y.LOADED),this.render()}clone(){const t=this.getScale(),e=new es({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){let e=this.canvases_[t];if(!e){const i=this.renderOptions_,s=rt(i.size*t,i.size*t);this.draw_(i,s,t),e=s.canvas,this.canvases_[t]=e}return e}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(e===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return e;let s=this.radius,r=this.radius2_===void 0?s:this.radius2_;if(s<r){const v=s;s=r,r=v}const o=this.radius2_===void 0?this.points_:this.points_*2,a=2*Math.PI/o,l=r*Math.sin(a),c=Math.sqrt(r*r-l*l),h=s-c,u=Math.sqrt(l*l+h*h),d=u/l;if(t==="miter"&&d<=i)return d*e;const f=e/2/d,g=e/2*(h/u),m=Math.sqrt((s+f)*(s+f)+g*g)-s;if(this.radius2_===void 0||t==="bevel")return m*2;const p=s*Math.sin(a),y=Math.sqrt(s*s-p*p),x=r-y,w=Math.sqrt(p*p+x*x)/p;if(w<=i){const v=w*e/2-r-s;return 2*Math.max(m,v)}return m*2}createRenderOptions(){let t=pi,e=yi,i=0,s=null,r=0,o,a=0;this.stroke_&&(o=qt(this.stroke_.getColor()??qi),a=this.stroke_.getWidth()??Ji,s=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset()??0,e=this.stroke_.getLineJoin()??yi,t=this.stroke_.getLineCap()??pi,i=this.stroke_.getMiterLimit()??Hi);const l=this.calculateLineJoinSize_(e,a,i),c=Math.max(this.radius,this.radius2_||0),h=Math.ceil(2*c+l);return{strokeStyle:o,strokeWidth:a,size:h,lineCap:t,lineDash:s,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.canvases_={},this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let s=this.fill_.getColor();s===null&&(s=Ct),e.fillStyle=qt(s),e.fill()}t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineCap=t.lineCap,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){let e;if(this.fill_){let i=this.fill_.getColor(),s=0;typeof i=="string"&&(i=ji(i)),i===null?s=1:Array.isArray(i)&&(s=i.length===4?i[3]:1),s===0&&(e=rt(t.size,t.size),this.drawHitDetectionCanvas_(t,e))}return e?e.canvas:this.getImage(1)}createPath_(t){let e=this.points_;const i=this.radius;if(e===1/0)t.arc(0,0,i,0,2*Math.PI);else{const s=this.radius2_===void 0?i:this.radius2_;this.radius2_!==void 0&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let a=0;a<e;a++){const l=r+a*o,c=a%2===0?i:s;t.lineTo(c*Math.cos(l),c*Math.sin(l))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=Ct,e.fill(),t.strokeStyle&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}}class on extends es{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new on({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius=t,this.render()}}class wi{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){const t=this.getColor();return new wi({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){const e=pr(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));e.ready().then(()=>{this.patternImage_=null}),e.getImageState()===Y.IDLE&&e.load(),e.getImageState()===Y.LOADING&&(this.patternImage_=e)}this.color_=t}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}class Ei{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?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 Ei({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 ce{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=co,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new ce({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){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(e){return e.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=co,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function Vh(n){let t;if(typeof n=="function")t=n;else{let e;Array.isArray(n)?e=n:(j(typeof n.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[n]),t=function(){return e}}return t}let ws=null;function ya(n,t){if(!ws){const e=new wi({color:"rgba(255,255,255,0.4)"}),i=new Ei({color:"#3399CC",width:1.25});ws=[new ce({image:new on({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return ws}function co(n){return n.getGeometry()}function uo(n,t,e,i){return e!==void 0&&i!==void 0?[e/n,i/t]:e!==void 0?e/n:i!==void 0?i/t:1}class is extends Qn{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,s=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:s,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:r,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;const o=t.img!==void 0?t.img:null;let a=t.src;j(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||$(o)),j(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),j(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(t.src!==void 0?l=Y.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?Y.LOADED:Y.IDLE:l=Y.LOADING:l=Y.LOADED),this.color_=t.color!==void 0?ji(t.color):null,this.iconImage_=pr(o,a,this.crossOrigin_,l,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let c,h;if(t.size)[c,h]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)c=u.width,h=u.height;else if(u instanceof HTMLImageElement){this.initialOptions_=t;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(uo(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}c!==void 0&&this.setScale(uo(c,h,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 is({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:this.size_!==null?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 s=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!s)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=s[0]),this.anchorYUnits_=="fraction"&&(t[1]*=s[1])}if(this.anchorOrigin_!="top-left"){if(!s)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+s[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+s[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(this.offsetOrigin_!="top-left"){const e=this.getSize(),i=this.iconImage_.getSize();if(!e||!i)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=i[0]-e[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=i[1]-e[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==Y.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){const t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==Y.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(z.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(z.CHANGE,t)}ready(){return this.iconImage_.ready()}}const Uh="#333";class Er{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.scale_=t.scale,this.scaleArray_=vt(t.scale!==void 0?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_=t.fill!==void 0?t.fill:new wi({color:Uh}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new Er({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,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_}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}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=vt(t!==void 0?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}}let Ze=0;const Et=1<<Ze++,B=1<<Ze++,Rt=1<<Ze++,zt=1<<Ze++,We=1<<Ze++,Fi=1<<Ze++,Cn=Math.pow(2,Ze)-1,xr={[Et]:"boolean",[B]:"number",[Rt]:"string",[zt]:"color",[We]:"number[]",[Fi]:"size"},jh=Object.keys(xr).map(Number).sort(ae);function Hh(n){return n in xr}function ki(n){const t=[];for(const e of jh)Ni(n,e)&&t.push(xr[e]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function Ni(n,t){return(n&t)===t}function me(n,t){return n===t}class ot{constructor(t,e){if(!Hh(t))throw new Error(`literal expressions must have a specific type, got ${ki(t)}`);this.type=t,this.value=e}}class qh{constructor(t,e,...i){this.type=t,this.operator=e,this.args=i}}function Ea(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1}}function gt(n,t,e){switch(typeof n){case"boolean":{if(me(t,Rt))return new ot(Rt,n?"true":"false");if(!Ni(t,Et))throw new Error(`got a boolean, but expected ${ki(t)}`);return new ot(Et,n)}case"number":{if(me(t,Fi))return new ot(Fi,vt(n));if(me(t,Et))return new ot(Et,!!n);if(me(t,Rt))return new ot(Rt,n.toString());if(!Ni(t,B))throw new Error(`got a number, but expected ${ki(t)}`);return new ot(B,n)}case"string":{if(me(t,zt))return new ot(zt,_r(n));if(me(t,Et))return new ot(Et,!!n);if(!Ni(t,Rt))throw new Error(`got a string, but expected ${ki(t)}`);return new ot(Rt,n)}}if(!Array.isArray(n))throw new Error("expression must be an array or a primitive value");if(n.length===0)throw new Error("empty expression");if(typeof n[0]=="string")return ac(n,t,e);for(const i of n)if(typeof i!="number")throw new Error("expected an array of numbers");if(me(t,Fi)){if(n.length!==2)throw new Error(`expected an array of two values for a size, got ${n.length}`);return new ot(Fi,n)}if(me(t,zt)){if(n.length===3)return new ot(zt,[...n,1]);if(n.length===4)return new ot(zt,n);throw new Error(`expected an array of 3 or 4 values for a color, got ${n.length}`)}if(!Ni(t,We))throw new Error(`got an array of numbers, but expected ${ki(t)}`);return new ot(We,n)}const C={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",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"},$h={[C.Get]:N(W(1,1/0),fo),[C.Var]:N(W(1,1),Jh),[C.Has]:N(W(1,1/0),fo),[C.Id]:N(Qh,qe),[C.Concat]:N(W(2,1/0),H(Rt)),[C.GeometryType]:N(tc,qe),[C.LineMetric]:N(qe),[C.Resolution]:N(qe),[C.Zoom]:N(qe),[C.Time]:N(qe),[C.Any]:N(W(2,1/0),H(Et)),[C.All]:N(W(2,1/0),H(Et)),[C.Not]:N(W(1,1),H(Et)),[C.Equal]:N(W(2,2),H(Cn)),[C.NotEqual]:N(W(2,2),H(Cn)),[C.GreaterThan]:N(W(2,2),H(B)),[C.GreaterThanOrEqualTo]:N(W(2,2),H(B)),[C.LessThan]:N(W(2,2),H(B)),[C.LessThanOrEqualTo]:N(W(2,2),H(B)),[C.Multiply]:N(W(2,1/0),go),[C.Coalesce]:N(W(2,1/0),go),[C.Divide]:N(W(2,2),H(B)),[C.Add]:N(W(2,1/0),H(B)),[C.Subtract]:N(W(2,2),H(B)),[C.Clamp]:N(W(3,3),H(B)),[C.Mod]:N(W(2,2),H(B)),[C.Pow]:N(W(2,2),H(B)),[C.Abs]:N(W(1,1),H(B)),[C.Floor]:N(W(1,1),H(B)),[C.Ceil]:N(W(1,1),H(B)),[C.Round]:N(W(1,1),H(B)),[C.Sin]:N(W(1,1),H(B)),[C.Cos]:N(W(1,1),H(B)),[C.Atan]:N(W(1,2),H(B)),[C.Sqrt]:N(W(1,1),H(B)),[C.Match]:N(W(4,1/0),_o,ic),[C.Between]:N(W(3,3),H(B)),[C.Interpolate]:N(W(6,1/0),_o,nc),[C.Case]:N(W(3,1/0),ec,sc),[C.In]:N(W(2,2),rc),[C.Number]:N(W(1,1/0),H(Cn)),[C.String]:N(W(1,1/0),H(Cn)),[C.Array]:N(W(1,1/0),H(B)),[C.Color]:N(W(1,4),H(B)),[C.Band]:N(W(1,3),H(B)),[C.Palette]:N(W(2,2),oc),[C.ToString]:N(W(1,1),H(Et|B|Rt|zt))};function fo(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=n[r+1];switch(typeof o){case"number":{s[r]=new ot(B,o);break}case"string":{s[r]=new ot(Rt,o);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${o}`)}r===0&&e.properties.add(String(o))}return s}function Jh(n,t,e){const i=n[1];if(typeof i!="string")throw new Error("expected a string argument for var operation");return e.variables.add(i),[new ot(Rt,i)]}function Qh(n,t,e){e.featureId=!0}function tc(n,t,e){e.geometryType=!0}function qe(n,t,e){const i=n[0];if(n.length!==1)throw new Error(`expected no arguments for ${i} operation`);return[]}function W(n,t){return function(e,i,s){const r=e[0],o=e.length-1;if(n===t){if(o!==n){const a=n===1?"":"s";throw new Error(`expected ${n} argument${a} for ${r}, got ${o}`)}}else if(o<n||o>t){const a=t===1/0?`${n} or more`:`${n} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function go(n,t,e){const i=n.length-1,s=new Array(i);for(let r=0;r<i;++r){const o=gt(n[r+1],t,e);s[r]=o}return s}function H(n){return function(t,e,i){const s=t.length-1,r=new Array(s);for(let o=0;o<s;++o){const a=gt(t[o+1],n,i);r[o]=a}return r}}function ec(n,t,e){const i=n[0],s=n.length-1;if(s%2===0)throw new Error(`expected an odd number of arguments for ${i}, got ${s} instead`)}function _o(n,t,e){const i=n[0],s=n.length-1;if(s%2===1)throw new Error(`expected an even number of arguments for operation ${i}, got ${s} instead`)}function ic(n,t,e){const i=n.length-1,s=Rt|B|Et,r=gt(n[1],s,e),o=gt(n[n.length-1],t,e),a=new Array(i-2);for(let l=0;l<i-2;l+=2){try{const c=gt(n[l+2],r.type,e);a[l]=c}catch(c){throw new Error(`failed to parse argument ${l+1} of match expression: ${c.message}`)}try{const c=gt(n[l+3],o.type,e);a[l+1]=c}catch(c){throw new Error(`failed to parse argument ${l+2} of match expression: ${c.message}`)}}return[r,...a,o]}function nc(n,t,e){const i=n[1];let s;switch(i[0]){case"linear":s=1;break;case"exponential":const l=i[1];if(typeof l!="number"||l<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(l)} instead`);s=l;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(i)}`)}const r=new ot(B,s);let o;try{o=gt(n[2],B,e)}catch(l){throw new Error(`failed to parse argument 1 in interpolate expression: ${l.message}`)}const a=new Array(n.length-3);for(let l=0;l<a.length;l+=2){try{const c=gt(n[l+3],B,e);a[l]=c}catch(c){throw new Error(`failed to parse argument ${l+2} for interpolate expression: ${c.message}`)}try{const c=gt(n[l+4],t,e);a[l+1]=c}catch(c){throw new Error(`failed to parse argument ${l+3} for interpolate expression: ${c.message}`)}}return[r,o,...a]}function sc(n,t,e){const i=gt(n[n.length-1],t,e),s=new Array(n.length-1);for(let r=0;r<s.length-1;r+=2){try{const o=gt(n[r+1],Et,e);s[r]=o}catch(o){throw new Error(`failed to parse argument ${r} of case expression: ${o.message}`)}try{const o=gt(n[r+2],i.type,e);s[r+1]=o}catch(o){throw new Error(`failed to parse argument ${r+1} of case expression: ${o.message}`)}}return s[s.length-1]=i,s}function rc(n,t,e){let i=n[2];if(!Array.isArray(i))throw new Error('the second argument for the "in" operator must be an array');let s;if(typeof i[0]=="string"){if(i[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(i[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');i=i[1],s=Rt}else s=B;const r=new Array(i.length);for(let a=0;a<r.length;a++)try{const l=gt(i[a],s,e);r[a]=l}catch(l){throw new Error(`failed to parse haystack item ${a} for "in" expression: ${l.message}`)}return[gt(n[1],s,e),...r]}function oc(n,t,e){let i;try{i=gt(n[1],B,e)}catch(o){throw new Error(`failed to parse first argument in palette expression: ${o.message}`)}const s=n[2];if(!Array.isArray(s))throw new Error("the second argument of palette must be an array");const r=new Array(s.length);for(let o=0;o<r.length;o++){let a;try{a=gt(s[o],zt,e)}catch(l){throw new Error(`failed to parse color at index ${o} in palette expression: ${l.message}`)}if(!(a instanceof ot))throw new Error(`the palette color at index ${o} must be a literal value`);r[o]=a}return[i,...r]}function N(...n){return function(t,e,i){const s=t[0];let r;for(let o=0;o<n.length;o++){const a=n[o](t,e,i);if(o==n.length-1){if(!a)throw new Error("expected last argument validator to return the parsed args");r=a}}return new qh(e,s,...r)}}function ac(n,t,e){const i=n[0],s=$h[i];if(!s)throw new Error(`unknown operator: ${i}`);return s(n,t,e)}function xa(n){if(!n)return"";const t=n.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return xa(n.getGeometries()[0]);default:return""}}function wa(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function ge(n,t,e){const i=gt(n,t,e);return Yt(i)}function Yt(n,t){if(n instanceof ot){if(n.type===zt&&typeof n.value=="string"){const i=_r(n.value);return function(){return i}}return function(){return n.value}}const e=n.operator;switch(e){case C.Number:case C.String:case C.Coalesce:return lc(n);case C.Get:case C.Var:case C.Has:return hc(n);case C.Id:return i=>i.featureId;case C.GeometryType:return i=>i.geometryType;case C.Concat:{const i=n.args.map(s=>Yt(s));return s=>"".concat(...i.map(r=>r(s).toString()))}case C.Resolution:return i=>i.resolution;case C.Any:case C.All:case C.Between:case C.In:case C.Not:return uc(n);case C.Equal:case C.NotEqual:case C.LessThan:case C.LessThanOrEqualTo:case C.GreaterThan:case C.GreaterThanOrEqualTo:return cc(n);case C.Multiply:case C.Divide:case C.Add:case C.Subtract:case C.Clamp:case C.Mod:case C.Pow:case C.Abs:case C.Floor:case C.Ceil:case C.Round:case C.Sin:case C.Cos:case C.Atan:case C.Sqrt:return dc(n);case C.Case:return fc(n);case C.Match:return gc(n);case C.Interpolate:return _c(n);case C.ToString:return mc(n);default:throw new Error(`Unsupported operator ${e}`)}}function lc(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Yt(n.args[r]);switch(e){case C.Coalesce:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a<"u"&&a!==null)return a}throw new Error("Expected one of the values to be non-null")};case C.Number:case C.String:return r=>{for(let o=0;o<i;++o){const a=s[o](r);if(typeof a===e)return a}throw new Error(`Expected one of the values to be a ${e}`)};default:throw new Error(`Unsupported assertion operator ${e}`)}}function hc(n,t){const i=n.args[0].value;switch(n.operator){case C.Get:return s=>{const r=n.args;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const h=r[a].value;o=o[h]}return o};case C.Var:return s=>s.variables[i];case C.Has:return s=>{const r=n.args;if(!(i in s.properties))return!1;let o=s.properties[i];for(let a=1,l=r.length;a<l;++a){const h=r[a].value;if(!o||!Object.hasOwn(o,h))return!1;o=o[h]}return!0};default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function cc(n,t){const e=n.operator,i=Yt(n.args[0]),s=Yt(n.args[1]);switch(e){case C.Equal:return r=>i(r)===s(r);case C.NotEqual:return r=>i(r)!==s(r);case C.LessThan:return r=>i(r)<s(r);case C.LessThanOrEqualTo:return r=>i(r)<=s(r);case C.GreaterThan:return r=>i(r)>s(r);case C.GreaterThanOrEqualTo:return r=>i(r)>=s(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function uc(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Yt(n.args[r]);switch(e){case C.Any:return r=>{for(let o=0;o<i;++o)if(s[o](r))return!0;return!1};case C.All:return r=>{for(let o=0;o<i;++o)if(!s[o](r))return!1;return!0};case C.Between:return r=>{const o=s[0](r),a=s[1](r),l=s[2](r);return o>=a&&o<=l};case C.In:return r=>{const o=s[0](r);for(let a=1;a<i;++a)if(o===s[a](r))return!0;return!1};case C.Not:return r=>!s[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function dc(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Yt(n.args[r]);switch(e){case C.Multiply:return r=>{let o=1;for(let a=0;a<i;++a)o*=s[a](r);return o};case C.Divide:return r=>s[0](r)/s[1](r);case C.Add:return r=>{let o=0;for(let a=0;a<i;++a)o+=s[a](r);return o};case C.Subtract:return r=>s[0](r)-s[1](r);case C.Clamp:return r=>{const o=s[0](r),a=s[1](r);if(o<a)return a;const l=s[2](r);return o>l?l:o};case C.Mod:return r=>s[0](r)%s[1](r);case C.Pow:return r=>Math.pow(s[0](r),s[1](r));case C.Abs:return r=>Math.abs(s[0](r));case C.Floor:return r=>Math.floor(s[0](r));case C.Ceil:return r=>Math.ceil(s[0](r));case C.Round:return r=>Math.round(s[0](r));case C.Sin:return r=>Math.sin(s[0](r));case C.Cos:return r=>Math.cos(s[0](r));case C.Atan:return i===2?r=>Math.atan2(s[0](r),s[1](r)):r=>Math.atan(s[0](r));case C.Sqrt:return r=>Math.sqrt(s[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function fc(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Yt(n.args[s]);return s=>{for(let r=0;r<e-1;r+=2)if(i[r](s))return i[r+1](s);return i[e-1](s)}}function gc(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Yt(n.args[s]);return s=>{const r=i[0](s);for(let o=1;o<e;o+=2)if(r===i[o](s))return i[o+1](s);return i[e-1](s)}}function _c(n,t){const e=n.args.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=Yt(n.args[s]);return s=>{const r=i[0](s),o=i[1](s);let a,l;for(let c=2;c<e;c+=2){const h=i[c](s);let u=i[c+1](s);const d=Array.isArray(u);if(d&&(u=Sh(u)),h>=o)return c===2?u:d?pc(r,o,a,l,h,u):Gi(r,o,a,l,h,u);a=h,l=u}return l}}function mc(n,t){const e=n.operator,i=n.args.length,s=new Array(i);for(let r=0;r<i;++r)s[r]=Yt(n.args[r]);switch(e){case C.ToString:return r=>{const o=s[0](r);return n.args[0].type===zt?mr(o):o.toString()};default:throw new Error(`Unsupported convert operator ${e}`)}}function Gi(n,t,e,i,s,r){const o=s-e;if(o===0)return i;const a=t-e,l=n===1?a/o:(Math.pow(n,a)-1)/(Math.pow(n,o)-1);return i+l*(r-i)}function pc(n,t,e,i,s,r){if(s-e===0)return i;const a=ro(i),l=ro(r);let c=l[2]-a[2];c>180?c-=360:c<-180&&(c+=360);const h=[Gi(n,t,e,a[0],s,l[0]),Gi(n,t,e,a[1],s,l[1]),a[2]+Gi(n,t,e,0,s,c),Gi(n,t,e,i[3],s,r[3])];return ha(Lh(h))}function yc(n){return!0}function Ec(n){const t=Ea(),e=xc(n,t),i=wa();return function(s,r){if(i.properties=s.getPropertiesInternal(),i.resolution=r,t.featureId){const o=s.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=xa(s.getGeometry())),e(i)}}function mo(n){const t=Ea(),e=n.length,i=new Array(e);for(let o=0;o<e;++o)i[o]=Gs(n[o],t);const s=wa(),r=new Array(e);return function(o,a){if(s.properties=o.getPropertiesInternal(),s.resolution=a,t.featureId){const c=o.getId();c!==void 0?s.featureId=c:s.featureId=null}let l=0;for(let c=0;c<e;++c){const h=i[c](s);h&&(r[l]=h,l+=1)}return r.length=l,r}}function xc(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s){const r=n[s],o="filter"in r?ge(r.filter,Et,t):yc;let a;if(Array.isArray(r.style)){const l=r.style.length;a=new Array(l);for(let c=0;c<l;++c)a[c]=Gs(r.style[c],t)}else a=[Gs(r.style,t)];i[s]={filter:o,styles:a}}return function(s){const r=[];let o=!1;for(let a=0;a<e;++a){const l=i[a].filter;if(l(s)&&!(n[a].else&&o)){o=!0;for(const c of i[a].styles){const h=c(s);h&&r.push(h)}}}return r}}function Gs(n,t){const e=Qi(n,"",t),i=tn(n,"",t),s=wc(n,t),r=Cc(n,t),o=It(n,"z-index",t);if(!e&&!i&&!s&&!r&&!gi(n))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(n));const a=new ce;return function(l){let c=!0;if(e){const h=e(l);h&&(c=!1),a.setFill(h)}if(i){const h=i(l);h&&(c=!1),a.setStroke(h)}if(s){const h=s(l);h&&(c=!1),a.setText(h)}if(r){const h=r(l);h&&(c=!1),a.setImage(h)}return o&&a.setZIndex(o(l)),c?null:a}}function Qi(n,t,e){let i;if(t+"fill-pattern-src"in n)i=vc(n,t+"fill-",e);else{if(n[t+"fill-color"]==="none")return r=>null;i=wr(n,t+"fill-color",e)}if(!i)return null;const s=new wi;return function(r){const o=i(r);return o===gr?null:(s.setColor(o),s)}}function tn(n,t,e){const i=It(n,t+"stroke-width",e),s=wr(n,t+"stroke-color",e);if(!i&&!s)return null;const r=oe(n,t+"stroke-line-cap",e),o=oe(n,t+"stroke-line-join",e),a=Ca(n,t+"stroke-line-dash",e),l=It(n,t+"stroke-line-dash-offset",e),c=It(n,t+"stroke-miter-limit",e),h=new Ei;return function(u){if(s){const d=s(u);if(d===gr)return null;h.setColor(d)}if(i&&h.setWidth(i(u)),r){const d=r(u);if(d!=="butt"&&d!=="round"&&d!=="square")throw new Error("Expected butt, round, or square line cap");h.setLineCap(d)}if(o){const d=o(u);if(d!=="bevel"&&d!=="round"&&d!=="miter")throw new Error("Expected bevel, round, or miter line join");h.setLineJoin(d)}return a&&h.setLineDash(a(u)),l&&h.setLineDashOffset(l(u)),c&&h.setMiterLimit(c(u)),h}}function wc(n,t){const e="text-",i=oe(n,e+"value",t);if(!i)return null;const s=Qi(n,e,t),r=Qi(n,e+"background-",t),o=tn(n,e,t),a=tn(n,e+"background-",t),l=oe(n,e+"font",t),c=It(n,e+"max-angle",t),h=It(n,e+"offset-x",t),u=It(n,e+"offset-y",t),d=en(n,e+"overflow",t),f=oe(n,e+"placement",t),g=It(n,e+"repeat",t),_=ns(n,e+"scale",t),m=en(n,e+"rotate-with-view",t),p=It(n,e+"rotation",t),y=oe(n,e+"align",t),x=oe(n,e+"justify",t),E=oe(n,e+"baseline",t),w=Ca(n,e+"padding",t),v=ss(n,e+"declutter-mode"),T=new Er({declutterMode:v});return function(R){if(T.setText(i(R)),s&&T.setFill(s(R)),r&&T.setBackgroundFill(r(R)),o&&T.setStroke(o(R)),a&&T.setBackgroundStroke(a(R)),l&&T.setFont(l(R)),c&&T.setMaxAngle(c(R)),h&&T.setOffsetX(h(R)),u&&T.setOffsetY(u(R)),d&&T.setOverflow(d(R)),f){const I=f(R);if(I!=="point"&&I!=="line")throw new Error("Expected point or line for text-placement");T.setPlacement(I)}if(g&&T.setRepeat(g(R)),_&&T.setScale(_(R)),m&&T.setRotateWithView(m(R)),p&&T.setRotation(p(R)),y){const I=y(R);if(I!=="left"&&I!=="center"&&I!=="right"&&I!=="end"&&I!=="start")throw new Error("Expected left, right, center, start, or end for text-align");T.setTextAlign(I)}if(x){const I=x(R);if(I!=="left"&&I!=="right"&&I!=="center")throw new Error("Expected left, right, or center for text-justify");T.setJustify(I)}if(E){const I=E(R);if(I!=="bottom"&&I!=="top"&&I!=="middle"&&I!=="alphabetic"&&I!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");T.setTextBaseline(I)}return w&&T.setPadding(w(R)),T}}function Cc(n,t){return"icon-src"in n?Rc(n,t):"shape-points"in n?Tc(n,t):"circle-radius"in n?Ic(n,t):null}function Rc(n,t){const e="icon-",i=e+"src",s=Ra(n[i],i),r=On(n,e+"anchor",t),o=ns(n,e+"scale",t),a=It(n,e+"opacity",t),l=On(n,e+"displacement",t),c=It(n,e+"rotation",t),h=en(n,e+"rotate-with-view",t),u=yo(n,e+"anchor-origin"),d=Eo(n,e+"anchor-x-units"),f=Eo(n,e+"anchor-y-units"),g=Mc(n,e+"color"),_=Lc(n,e+"cross-origin"),m=Ac(n,e+"offset"),p=yo(n,e+"offset-origin"),y=Fn(n,e+"width"),x=Fn(n,e+"height"),E=Sc(n,e+"size"),w=ss(n,e+"declutter-mode"),v=new is({src:s,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,color:g,crossOrigin:_,offset:m,offsetOrigin:p,height:x,width:y,size:E,declutterMode:w});return function(T){return a&&v.setOpacity(a(T)),l&&v.setDisplacement(l(T)),c&&v.setRotation(c(T)),h&&v.setRotateWithView(h(T)),o&&v.setScale(o(T)),r&&v.setAnchor(r(T)),v}}function Tc(n,t){const e="shape-",i=e+"points",s=e+"radius",r=zs(n[i],i),o=zs(n[s],s),a=Qi(n,e,t),l=tn(n,e,t),c=ns(n,e+"scale",t),h=On(n,e+"displacement",t),u=It(n,e+"rotation",t),d=en(n,e+"rotate-with-view",t),f=Fn(n,e+"radius2"),g=Fn(n,e+"angle"),_=ss(n,e+"declutter-mode"),m=new es({points:r,radius:o,radius2:f,angle:g,declutterMode:_});return function(p){return a&&m.setFill(a(p)),l&&m.setStroke(l(p)),h&&m.setDisplacement(h(p)),u&&m.setRotation(u(p)),d&&m.setRotateWithView(d(p)),c&&m.setScale(c(p)),m}}function Ic(n,t){const e="circle-",i=Qi(n,e,t),s=tn(n,e,t),r=It(n,e+"radius",t),o=ns(n,e+"scale",t),a=On(n,e+"displacement",t),l=It(n,e+"rotation",t),c=en(n,e+"rotate-with-view",t),h=ss(n,e+"declutter-mode"),u=new on({radius:5,declutterMode:h});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),s&&u.setStroke(s(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),c&&u.setRotateWithView(c(d)),o&&u.setScale(o(d)),u}}function It(n,t,e){if(!(t in n))return;const i=ge(n[t],B,e);return function(s){return zs(i(s),t)}}function oe(n,t,e){if(!(t in n))return null;const i=ge(n[t],Rt,e);return function(s){return Ra(i(s),t)}}function vc(n,t,e){const i=oe(n,t+"pattern-src",e),s=po(n,t+"pattern-offset",e),r=po(n,t+"pattern-size",e),o=wr(n,t+"color",e);return function(a){return{src:i(a),offset:s&&s(a),size:r&&r(a),color:o&&o(a)}}}function en(n,t,e){if(!(t in n))return null;const i=ge(n[t],Et,e);return function(s){const r=i(s);if(typeof r!="boolean")throw new Error(`Expected a boolean for ${t}`);return r}}function wr(n,t,e){if(!(t in n))return null;const i=ge(n[t],zt,e);return function(s){return Ta(i(s),t)}}function Ca(n,t,e){if(!(t in n))return null;const i=ge(n[t],We,e);return function(s){return an(i(s),t)}}function On(n,t,e){if(!(t in n))return null;const i=ge(n[t],We,e);return function(s){const r=an(i(s),t);if(r.length!==2)throw new Error(`Expected two numbers for ${t}`);return r}}function po(n,t,e){if(!(t in n))return null;const i=ge(n[t],We,e);return function(s){return Ia(i(s),t)}}function ns(n,t,e){if(!(t in n))return null;const i=ge(n[t],We|B,e);return function(s){return bc(i(s),t)}}function Fn(n,t){const e=n[t];if(e!==void 0){if(typeof e!="number")throw new Error(`Expected a number for ${t}`);return e}}function Sc(n,t){const e=n[t];if(e!==void 0){if(typeof e=="number")return vt(e);if(!Array.isArray(e))throw new Error(`Expected a number or size array for ${t}`);if(e.length!==2||typeof e[0]!="number"||typeof e[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return e}}function Lc(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);return e}}function yo(n,t){const e=n[t];if(e!==void 0){if(e!=="bottom-left"&&e!=="bottom-right"&&e!=="top-left"&&e!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return e}}function Eo(n,t){const e=n[t];if(e!==void 0){if(e!=="pixels"&&e!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return e}}function Ac(n,t){const e=n[t];if(e!==void 0)return an(e,t)}function ss(n,t){const e=n[t];if(e!==void 0){if(typeof e!="string")throw new Error(`Expected a string for ${t}`);if(e!=="declutter"&&e!=="obstacle"&&e!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return e}}function Mc(n,t){const e=n[t];if(e!==void 0)return Ta(e,t)}function an(n,t){if(!Array.isArray(n))throw new Error(`Expected an array for ${t}`);const e=n.length;for(let i=0;i<e;++i)if(typeof n[i]!="number")throw new Error(`Expected an array of numbers for ${t}`);return n}function Ra(n,t){if(typeof n!="string")throw new Error(`Expected a string for ${t}`);return n}function zs(n,t){if(typeof n!="number")throw new Error(`Expected a number for ${t}`);return n}function Ta(n,t){if(typeof n=="string")return n;const e=an(n,t),i=e.length;if(i<3||i>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function Ia(n,t){const e=an(n,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function bc(n,t){return typeof n=="number"?n:Ia(n,t)}const xo={RENDER_ORDER:"renderOrder"};class va extends Jn{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_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(xo.RENDER_ORDER)}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||(t.declutter[i]=new aa(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(xo.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?ya:t;const e=Dc(t);this.styleFunction_=t===null?void 0:Vh(e),this.changed()}}function Dc(n){if(n===void 0)return ya;if(!n)return null;if(typeof n=="function"||n instanceof ce)return n;if(!Array.isArray(n))return mo([n]);if(n.length===0)return[];const t=n.length,e=n[0];if(e instanceof ce){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!(o instanceof ce))throw new Error("Expected a list of style instances");s[r]=o}return s}if("style"in e){const s=new Array(t);for(let r=0;r<t;++r){const o=n[r];if(!("style"in o))throw new Error("Expected a list of rules with a style property");s[r]=o}return Ec(s)}return mo(n)}class Pc extends Wn{constructor(t){super(),this.map_=t}dispatchRenderEvent(t,e){U()}calculateMatrices2D(t){const e=t.viewState,i=t.coordinateToPixelTransform,s=t.pixelToCoordinateTransform;de(i,t.size[0]/2,t.size[1]/2,1/e.resolution,-1/e.resolution,-e.rotation,-e.center[0],-e.center[1]),Qo(s,i)}forEachFeatureAtCoordinate(t,e,i,s,r,o,a,l){let c;const h=e.viewState;function u(E,w,v,T){return r.call(o,w,E?v:null,T)}const d=h.projection,f=Vo(t.slice(),d),g=[[0,0]];if(d.canWrapX()&&s){const E=d.getExtent(),w=q(E);g.push([-w,0],[w,0])}const _=e.layerStatesArray,m=_.length,p=[],y=[];for(let E=0;E<g.length;E++)for(let w=m-1;w>=0;--w){const v=_[w],T=v.layer;if(T.hasRenderer()&&dr(v,h)&&a.call(l,T)){const R=T.getRenderer(),I=T.getSource();if(R&&I){const G=I.getWrapX()?f:t,D=u.bind(null,v.managed);y[0]=G[0]+g[E][0],y[1]=G[1]+g[E][1],c=R.forEachFeatureAtCoordinate(y,e,i,D,p)}if(c)return c}}if(p.length===0)return;const x=1/p.length;return p.forEach((E,w)=>E.distanceSq+=w*x),p.sort((E,w)=>E.distanceSq-w.distanceSq),p.some(E=>c=E.callback(E.feature,E.layer,E.geometry)),c}hasFeatureAtCoordinate(t,e,i,s,r,o){return this.forEachFeatureAtCoordinate(t,e,i,s,Wi,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){U()}scheduleExpireIconCache(t){Ht.canExpireCache()&&t.postRenderFunctions.push(Oc)}}function Oc(n,t){Ht.expire()}class Sa extends fe{constructor(t,e,i,s){super(t),this.inversePixelTransform=e,this.frameState=i,this.context=s}}class Fc extends Pc{constructor(t){super(t),this.fontChangeListenerKey_=V(re,di.PROPERTYCHANGE,t.redrawText,t),this.element_=document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=ts+" ol-layers";const i=t.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const s=new Sa(t,void 0,e);i.dispatchEvent(s)}}disposeInternal(){tt(this.fontChangeListenerKey_),this.element_.remove(),super.disposeInternal()}renderFrame(t){if(!t){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(t),this.dispatchRenderEvent(Ot.PRECOMPOSE,t);const e=t.layerStatesArray.sort((a,l)=>a.zIndex-l.zIndex);e.some(a=>a.layer instanceof va&&a.layer.getDeclutter())&&(t.declutter={});const s=t.viewState;this.children_.length=0;const r=[];let o=null;for(let a=0,l=e.length;a<l;++a){const c=e[a];t.layerIndex=a;const h=c.layer,u=h.getSourceState();if(!dr(c,s)||u!="ready"&&u!="undefined"){h.unrender();continue}const d=h.render(t,o);d&&(d!==o&&(this.children_.push(d),o=d),r.push(c))}this.declutter(t,r),Ph(this.element_,this.children_),this.dispatchRenderEvent(Ot.POSTCOMPOSE,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 s=e[i],r=s.layer;r.getDeclutter()&&r.renderDeclutter(t,s)}e.forEach(i=>i.layer.renderDeferred(t))}}}class Re extends fe{constructor(t,e){super(t),this.layer=e}}const Cs={LAYERS:"layers"};class Ci extends Go{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(Cs.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new jt(i.slice(),{unique:!0}):j(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new jt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(tt),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push(V(t,wt.ADD,this.handleLayersAdd_,this),V(t,wt.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(tt);nn(this.listenerKeys_);const e=t.getArray();for(let i=0,s=e.length;i<s;i++){const r=e[i];this.registerLayerListeners_(r),this.dispatchEvent(new Re("addlayer",r))}this.changed()}registerLayerListeners_(t){const e=[V(t,di.PROPERTYCHANGE,this.handleLayerChange_,this),V(t,z.CHANGE,this.handleLayerChange_,this)];t instanceof Ci&&e.push(V(t,"addlayer",this.handleLayerGroupAdd_,this),V(t,"removelayer",this.handleLayerGroupRemove_,this)),this.listenerKeys_[$(t)]=e}handleLayerGroupAdd_(t){this.dispatchEvent(new Re("addlayer",t.layer))}handleLayerGroupRemove_(t){this.dispatchEvent(new Re("removelayer",t.layer))}handleLayersAdd_(t){const e=t.element;this.registerLayerListeners_(e),this.dispatchEvent(new Re("addlayer",e)),this.changed()}handleLayersRemove_(t){const e=t.element,i=$(e);this.listenerKeys_[i].forEach(tt),delete this.listenerKeys_[i],this.dispatchEvent(new Re("removelayer",e)),this.changed()}getLayers(){return this.get(Cs.LAYERS)}setLayers(t){const e=this.getLayers();if(e){const i=e.getArray();for(let s=0,r=i.length;s<r;++s)this.dispatchEvent(new Re("removelayer",i[s]))}this.set(Cs.LAYERS,t)}getLayersArray(t){return t=t!==void 0?t:[],this.getLayers().forEach(function(e){e.getLayersArray(t)}),t}getLayerStatesArray(t){const e=t!==void 0?t:[],i=e.length;this.getLayers().forEach(function(o){o.getLayerStatesArray(e)});const s=this.getLayerState();let r=s.zIndex;!t&&s.zIndex===void 0&&(r=0);for(let o=i,a=e.length;o<a;o++){const l=e[o];l.opacity*=s.opacity,l.visible=l.visible&&s.visible,l.maxResolution=Math.min(l.maxResolution,s.maxResolution),l.minResolution=Math.max(l.minResolution,s.minResolution),l.minZoom=Math.max(l.minZoom,s.minZoom),l.maxZoom=Math.min(l.maxZoom,s.maxZoom),s.extent!==void 0&&(l.extent!==void 0?l.extent=Xt(l.extent,s.extent):l.extent=s.extent),l.zIndex===void 0&&(l.zIndex=r)}return e}getSourceState(){return"ready"}}class si extends fe{constructor(t,e,i){super(t),this.map=e,this.frameState=i!==void 0?i:null}}class we extends si{constructor(t,e,i,s,r,o){super(t,e,r),this.originalEvent=i,this.pixel_=null,this.coordinate_=null,this.dragging=s!==void 0?s:!1,this.activePointers=o}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()}}const nt={SINGLECLICK:"singleclick",CLICK:z.CLICK,DBLCLICK:z.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"},Xs={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};class kc extends Kn{constructor(t,e){super(t),this.map_=t,this.clickTimeoutId_,this.emulateClicks_=!1,this.dragging_=!1,this.dragListenerKeys_=[],this.moveTolerance_=e===void 0?1:e,this.down_=null;const i=this.map_.getViewport();this.activePointers_=[],this.trackedTouches_={},this.element_=i,this.pointerdownListenerKey_=V(i,Xs.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=V(i,Xs.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(z.TOUCHMOVE,this.boundHandleTouchMove_,ga?{passive:!1}:!1)}emulateClick_(t){let e=new we(nt.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new we(nt.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new we(nt.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==nt.POINTERUP||e.type==nt.POINTERCANCEL){delete this.trackedTouches_[i];for(const s in this.trackedTouches_)if(this.trackedTouches_[s].target!==e.target){delete this.trackedTouches_[s];break}}else(e.type==nt.POINTERDOWN||e.type==nt.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new we(nt.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_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(tt),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(t){return t.button===0}handlePointerDown_(t){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(t);const e=new we(nt.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}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(V(i,nt.POINTERMOVE,this.handlePointerMove_,this),V(i,nt.POINTERUP,this.handlePointerUp_,this),V(this.element_,nt.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(V(this.element_.getRootNode(),nt.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new we(nt.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 we(nt.POINTERMOVE,this.map_,t,e))}handleTouchMove_(t){const e=this.originalPointerMoveEvent_;(!e||e.defaultPrevented)&&(typeof t.cancelable!="boolean"||t.cancelable===!0)&&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_&&(tt(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(z.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(tt(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(tt),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Ce={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},_t={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},kn=1/0;class Nc{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,nn(this.queuedElements_)}dequeue(){const t=this.elements_,e=this.priorities_,i=t[0];t.length==1?(t.length=0,e.length=0):(t[0]=t.pop(),e[0]=e.pop(),this.siftUp_(0));const s=this.keyFunction_(i);return delete this.queuedElements_[s],i}enqueue(t){j(!(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!=kn?(this.elements_.push(t),this.priorities_.push(e),this.queuedElements_[this.keyFunction_(t)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(t){return t*2+1}getRightChildIndex_(t){return t*2+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 this.elements_.length===0}isKeyQueued(t){return t in this.queuedElements_}isQueued(t){return this.isKeyQueued(this.keyFunction_(t))}siftUp_(t){const e=this.elements_,i=this.priorities_,s=e.length,r=e[t],o=i[t],a=t;for(;t<s>>1;){const l=this.getLeftChildIndex_(t),c=this.getRightChildIndex_(t),h=c<s&&i[c]<i[l]?c:l;e[t]=e[h],i[t]=i[h],t=h}e[t]=r,i[t]=o,this.siftDown_(a,t)}siftDown_(t,e){const i=this.elements_,s=this.priorities_,r=i[e],o=s[e];for(;e>t;){const a=this.getParentIndex_(e);if(s[a]>o)i[e]=i[a],s[e]=s[a],e=a;else break}i[e]=r,s[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let s=0;const r=e.length;let o,a,l;for(a=0;a<r;++a)o=e[a],l=t(o),l==kn?delete this.queuedElements_[this.keyFunction_(o)]:(i[s]=l,e[s++]=o);e.length=s,i.length=s,this.heapify_()}}const M={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};class Gc extends Nc{constructor(t,e){super(function(i){return t.apply(null,i)},function(i){return i[0].getKey()}),this.boundHandleTileChange_=this.handleTileChange.bind(this),this.tileChangeCallback_=e,this.tilesLoading_=0,this.tilesLoadingKeys_={}}enqueue(t){const e=super.enqueue(t);return e&&t[0].addEventListener(z.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===M.LOADED||i===M.ERROR||i===M.EMPTY){i!==M.ERROR&&e.removeEventListener(z.CHANGE,this.boundHandleTileChange_);const s=e.getKey();s in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[s],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_<t&&i<e&&this.getCount()>0;){const s=this.dequeue()[0],r=s.getKey();s.getState()===M.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,s.load())}}}function zc(n,t,e,i,s){if(!n||!(e in n.wantedTiles)||!n.wantedTiles[e][t.getKey()])return kn;const r=n.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(s)+Math.sqrt(o*o+a*a)/s}class Cr extends $t{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 e=0,i=this.listenerKeys.length;e<i;++e)tt(this.listenerKeys[e]);this.listenerKeys.length=0,this.map_=t,t&&((this.target_??t.getOverlayContainerStopEvent()).appendChild(this.element),this.render!==fi&&this.listenerKeys.push(V(t,Ce.POSTRENDER,this.render,this)),t.render())}render(t){}setTarget(t){this.target_=typeof t=="string"?document.getElementById(t):t}}class Xc extends Cr{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target}),this.ulElement_=document.createElement("ul"),this.collapsed_=t.collapsed!==void 0?t.collapsed:!0,this.userCollapsed_=this.collapsed_,this.overrideCollapsible_=t.collapsible!==void 0,this.collapsible_=t.collapsible!==void 0?t.collapsible:!0,this.collapsible_||(this.collapsed_=!1),this.attributions_=t.attributions;const e=t.className!==void 0?t.className:"ol-attribution",i=t.tipLabel!==void 0?t.tipLabel:"Attributions",s=t.expandClassName!==void 0?t.expandClassName:e+"-expand",r=t.collapseLabel!==void 0?t.collapseLabel:"›",o=t.collapseClassName!==void 0?t.collapseClassName:e+"-collapse";typeof r=="string"?(this.collapseLabel_=document.createElement("span"),this.collapseLabel_.textContent=r,this.collapseLabel_.className=o):this.collapseLabel_=r;const a=t.label!==void 0?t.label:"i";typeof a=="string"?(this.label_=document.createElement("span"),this.label_.textContent=a,this.label_.className=s):this.label_=a;const l=this.collapsible_&&!this.collapsed_?this.collapseLabel_:this.label_;this.toggleButton_=document.createElement("button"),this.toggleButton_.setAttribute("type","button"),this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_)),this.toggleButton_.title=i,this.toggleButton_.appendChild(l),this.toggleButton_.addEventListener(z.CLICK,this.handleClick_.bind(this),!1);const c=e+" "+ts+" "+yr+(this.collapsed_&&this.collapsible_?" "+ao:"")+(this.collapsible_?"":" ol-uncollapsible"),h=this.element;h.className=c,h.appendChild(this.toggleButton_),h.appendChild(this.ulElement_),this.renderedAttributions_=[],this.renderedVisible_=!0}collectSourceAttributions_(t){const e=this.getMap().getAllLayers(),i=new Set(e.flatMap(s=>s.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(s=>i.add(s)):i.add(this.attributions_)),!this.overrideCollapsible_){const s=!e.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(s)}return Array.from(i)}async updateElement_(t){if(!t){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const e=await Promise.all(this.collectSourceAttributions_(t).map(s=>hl(()=>s))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Ae(e,this.renderedAttributions_)){Dh(this.ulElement_);for(let s=0,r=e.length;s<r;++s){const o=document.createElement("li");o.innerHTML=e[s],this.ulElement_.appendChild(o)}this.renderedAttributions_=e}}handleClick_(t){t.preventDefault(),this.handleToggle_(),this.userCollapsed_=this.collapsed_}handleToggle_(){this.element.classList.toggle(ao),this.collapsed_?oo(this.collapseLabel_,this.label_):oo(this.label_,this.collapseLabel_),this.collapsed_=!this.collapsed_,this.toggleButton_.setAttribute("aria-expanded",String(!this.collapsed_))}getCollapsible(){return this.collapsible_}setCollapsible(t){this.collapsible_!==t&&(this.collapsible_=t,this.element.classList.toggle("ol-uncollapsible"),this.userCollapsed_&&this.handleToggle_())}setCollapsed(t){this.userCollapsed_=t,!(!this.collapsible_||this.collapsed_===t)&&this.handleToggle_()}getCollapsed(){return this.collapsed_}render(t){this.updateElement_(t.frameState)}}class Wc extends Cr{constructor(t){t=t||{},super({element:document.createElement("div"),render:t.render,target:t.target});const e=t.className!==void 0?t.className:"ol-rotate",i=t.label!==void 0?t.label:"⇧",s=t.compassClassName!==void 0?t.compassClassName:"ol-compass";this.label_=null,typeof i=="string"?(this.label_=document.createElement("span"),this.label_.className=s,this.label_.textContent=i):(this.label_=i,this.label_.classList.add(s));const r=t.tipLabel?t.tipLabel:"Reset rotation",o=document.createElement("button");o.className=e+"-reset",o.setAttribute("type","button"),o.title=r,o.appendChild(this.label_),o.addEventListener(z.CLICK,this.handleClick_.bind(this),!1);const a=e+" "+ts+" "+yr,l=this.element;l.className=a,l.appendChild(o),this.callResetNorth_=t.resetNorth?t.resetNorth:void 0,this.duration_=t.duration!==void 0?t.duration:250,this.autoHide_=t.autoHide!==void 0?t.autoHide:!0,this.rotation_=void 0,this.autoHide_&&this.element.classList.add(wn)}handleClick_(t){t.preventDefault(),this.callResetNorth_!==void 0?this.callResetNorth_():this.resetNorth_()}resetNorth_(){const e=this.getMap().getView();if(!e)return;const i=e.getRotation();i!==void 0&&(this.duration_>0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:xi}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const s="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(wn);!r&&i===0?this.element.classList.add(wn):r&&i!==0&&this.element.classList.remove(wn)}this.label_.style.transform=s}this.rotation_=i}}class Yc extends Cr{constructor(t){t=t||{},super({element:document.createElement("div"),target:t.target});const e=t.className!==void 0?t.className:"ol-zoom",i=t.delta!==void 0?t.delta:1,s=t.zoomInClassName!==void 0?t.zoomInClassName:e+"-in",r=t.zoomOutClassName!==void 0?t.zoomOutClassName:e+"-out",o=t.zoomInLabel!==void 0?t.zoomInLabel:"+",a=t.zoomOutLabel!==void 0?t.zoomOutLabel:"–",l=t.zoomInTipLabel!==void 0?t.zoomInTipLabel:"Zoom in",c=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=s,h.setAttribute("type","button"),h.title=l,h.appendChild(typeof o=="string"?document.createTextNode(o):o),h.addEventListener(z.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=c,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(z.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+ts+" "+yr,f=this.element;f.className=d,f.appendChild(h),f.appendChild(u),this.duration_=t.duration!==void 0?t.duration:250}handleClick_(t,e){e.preventDefault(),this.zoomByDelta_(t)}zoomByDelta_(t){const i=this.getMap().getView();if(!i)return;const s=i.getZoom();if(s!==void 0){const r=i.getConstrainedZoom(s+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:xi})):i.setZoom(r)}}}function Zc(n){n=n||{};const t=new jt;return(n.zoom!==void 0?n.zoom:!0)&&t.push(new Yc(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&t.push(new Wc(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&t.push(new Xc(n.attributionOptions)),t}const wo={ACTIVE:"active"};class ln extends $t{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(wo.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(wo.ACTIVE,t)}setMap(t){this.map_=t}}function Kc(n,t,e){const i=n.getCenterInternal();if(i){const s=[i[0]+t[0],i[1]+t[1]];n.animateInternal({duration:e!==void 0?e:250,easing:Kl,center:n.getConstrainedCenter(s)})}}function Rr(n,t,e,i){const s=n.getZoom();if(s===void 0)return;const r=n.getConstrainedZoom(s+t),o=n.getResolutionForZoom(r);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:e,duration:i!==void 0?i:250,easing:xi})}class Bc extends ln{constructor(t){super(),t=t||{},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:250}handleEvent(t){let e=!1;if(t.type==nt.DBLCLICK){const i=t.originalEvent,s=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=s.getView();Rr(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}class hn extends ln{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let e=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==nt.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==nt.POINTERUP){const i=this.handleUpEvent(t);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(t.type==nt.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==nt.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 Tr(n){const t=n.length;let e=0,i=0;for(let s=0;s<t;s++)e+=n[s].clientX,i+=n[s].clientY;return{clientX:e/t,clientY:i/t}}function Ws(n){const t=arguments;return function(e){let i=!0;for(let s=0,r=t.length;s<r&&(i=i&&t[s](e),!!i);++s);return i}}const Vc=function(n){const t=n.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},Uc=function(n){const t=n.map.getTargetElement(),e=t.getRootNode(),i=n.map.getOwnerDocument().activeElement;return e instanceof ShadowRoot?e.host.contains(i):t.contains(i)},La=function(n){const t=n.map.getTargetElement(),e=t.getRootNode();return(e instanceof ShadowRoot?e.host:t).hasAttribute("tabindex")?Uc(n):!0},jc=Wi,Aa=function(n){const t=n.originalEvent;return t.button==0&&!(bh&&ca&&t.ctrlKey)},Ma=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey},Hc=function(n){const t=n.originalEvent;return ca?t.metaKey:t.ctrlKey},qc=function(n){const t=n.originalEvent;return!t.altKey&&!(t.metaKey||t.ctrlKey)&&t.shiftKey},ba=function(n){const t=n.originalEvent,e=t.target.tagName;return e!=="INPUT"&&e!=="SELECT"&&e!=="TEXTAREA"&&!t.target.isContentEditable},Rs=function(n){const t=n.originalEvent;return j(t!==void 0,"mapBrowserEvent must originate from a pointer event"),t.pointerType=="mouse"},$c=function(n){const t=n.originalEvent;return j(t!==void 0,"mapBrowserEvent must originate from a pointer event"),t.isPrimary&&t.button===0};class Jc extends hn{constructor(t){super({stopDown:Zn}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:Ws(Ma,$c);this.condition_=t.onFocusOnly?Ws(La,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,s=e.getEventPixel(Tr(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(s[0],s[1]),this.lastCentroid){const r=[this.lastCentroid[0]-s[0],s[1]-this.lastCentroid[1]],a=t.map.getView();bl(r,a.getResolution()),Qs(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=s,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const s=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-s*Math.cos(r),a[1]-s*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:xi})}return this.panning_&&(this.panning_=!1,i.endInteraction()),!1}return this.kinetic_&&this.kinetic_.begin(),this.lastCentroid=null,!0}handleDownEvent(t){if(this.targetPointers.length>0&&this.condition_(t)){const i=t.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}class Qc extends hn{constructor(t){t=t||{},super({stopDown:Zn}),this.condition_=t.condition?t.condition:Vc,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!Rs(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===rr)return;const s=e.getSize(),r=t.pixel,o=Math.atan2(s[1]/2-r[1],r[0]-s[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return Rs(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return Rs(t)&&Aa(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class tu extends Wn{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",s=this.element_.style;s.left=Math.min(t[0],e[0])+i,s.top=Math.min(t[1],e[1])+i,s.width=Math.abs(e[0]-t[0])+i,s.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const e=this.element_.style;e.left="inherit",e.top="inherit",e.width="inherit",e.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_,s=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);s[4]=s[0].slice(),this.geometry_?this.geometry_.setCoordinates([s]):this.geometry_=new Vi([s])}getGeometry(){return this.geometry_}}const $e={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Di extends fe{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class eu extends hn{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new tu(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Aa,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const s=i[0]-e[0],r=i[1]-e[1];return s*s+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new Di($e.BOXDRAG,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 Di(e?$e.BOXEND:$e.BOXCANCEL,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 Di($e.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Di($e.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new Di($e.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class iu extends eu{constructor(t){t=t||{};const e=t.condition?t.condition:qc;super({condition:e,className:t.className||"ol-dragzoom",minArea:t.minArea}),this.duration_=t.duration!==void 0?t.duration:200,this.out_=t.out!==void 0?t.out:!1}onBoxEnd(t){const i=this.getMap().getView();let s=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(s),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;s=s.clone(),s.scale(a*a)}i.fitInternal(s,{duration:this.duration_,easing:xi})}}const Oe={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class nu extends ln{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return Ma(e)&&ba(e)},this.condition_=t.condition!==void 0?t.condition:this.defaultCondition_,this.duration_=t.duration!==void 0?t.duration:100,this.pixelDelta_=t.pixelDelta!==void 0?t.pixelDelta:128}handleEvent(t){let e=!1;if(t.type==z.KEYDOWN){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==Oe.DOWN||s==Oe.LEFT||s==Oe.RIGHT||s==Oe.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,c=0;s==Oe.DOWN?c=-a:s==Oe.LEFT?l=-a:s==Oe.RIGHT?l=a:c=a;const h=[l,c];Qs(h,o.getRotation()),Kc(o,h,this.duration_),i.preventDefault(),e=!0}}return!e}}class su extends ln{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!Hc(e)&&ba(e)},this.delta_=t.delta?t.delta:1,this.duration_=t.duration!==void 0?t.duration:100}handleEvent(t){let e=!1;if(t.type==z.KEYDOWN||t.type==z.KEYPRESS){const i=t.originalEvent,s=i.key;if(this.condition_(t)&&(s==="+"||s==="-")){const r=t.map,o=s==="+"?this.delta_:-this.delta_,a=r.getView();Rr(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}class ru{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]<t)return!1;let i=e-3;for(;i>0&&this.points_[i+2]>t;)i-=3;const s=this.points_[e+2]-this.points_[i+2];if(s<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/s,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class ou extends ln{constructor(t){t=t||{},super(t),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=t.maxDelta!==void 0?t.maxDelta:1,this.duration_=t.duration!==void 0?t.duration:250,this.timeout_=t.timeout!==void 0?t.timeout:80,this.useAnchor_=t.useAnchor!==void 0?t.useAnchor:!0,this.constrainResolution_=t.constrainResolution!==void 0?t.constrainResolution:!1;const e=t.condition?t.condition:jc;this.condition_=t.onFocusOnly?Ws(La,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)||t.type!==z.WHEEL)return!0;const i=t.map,s=t.originalEvent;s.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r;if(t.type==z.WHEEL&&(r=s.deltaY,Ah&&s.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(r/=ua),s.deltaMode===WheelEvent.DOM_DELTA_LINE&&(r*=40)),r===0)return!1;this.lastDelta_=r;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(r)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-r/this.deltaPerZoom_,this.lastAnchor_?i.getCoordinateFromPixel(this.lastAnchor_):null),this.startTime_=o,!1;this.totalDelta_+=r;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(t){const e=t.getView();e.getAnimating()&&e.cancelAnimations();let i=-st(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Rr(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 au extends hn{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Zn),super(e),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=t.threshold!==void 0?t.threshold:.3,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){let e=0;const i=this.targetPointers[0],s=this.targetPointers[1],r=Math.atan2(s.clientY-i.clientY,s.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=r-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),e=l}this.lastAngle_=r;const o=t.map,a=o.getView();a.getConstraints().rotation!==rr&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(Tr(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(e,this.anchor_)))}handleUpEvent(t){return this.targetPointers.length<2?(t.map.getView().endInteraction(this.duration_),!1):!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 lu extends hn{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Zn),super(e),this.anchor_=null,this.duration_=t.duration!==void 0?t.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(t){let e=1;const i=this.targetPointers[0],s=this.targetPointers[1],r=i.clientX-s.clientX,o=i.clientY-s.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,c=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(Tr(this.targetPointers))),l.render(),c.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),s=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,s),!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 hu(n){n=n||{};const t=new jt,e=new ru(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&t.push(new Qc),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&t.push(new Bc({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&t.push(new Jc({onFocusOnly:n.onFocusOnly,kinetic:e})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&t.push(new au),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&t.push(new lu({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(t.push(new nu),t.push(new su({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&t.push(new ou({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&t.push(new iu({duration:n.zoomDuration})),t}function Da(n){if(n instanceof Jn){n.setMapInternal(null);return}n instanceof Ci&&n.getLayers().forEach(Da)}function Pa(n,t){if(n instanceof Jn){n.setMapInternal(t);return}if(n instanceof Ci){const e=n.getLayers().getArray();for(let i=0,s=e.length;i<s;++i)Pa(e[i],t)}}class cu extends $t{constructor(t){super(),t=t||{},this.on,this.once,this.un;const e=uu(t);this.renderComplete_=!1,this.loaded_=!0,this.boundHandleBrowserEvent_=this.handleBrowserEvent.bind(this),this.maxTilesLoading_=t.maxTilesLoading!==void 0?t.maxTilesLoading:16,this.pixelRatio_=t.pixelRatio!==void 0?t.pixelRatio:ua,this.postRenderTimeoutHandle_,this.animationDelayKey_,this.animationDelay_=this.animationDelay_.bind(this),this.coordinateToPixelTransform_=Wt(),this.pixelToCoordinateTransform_=Wt(),this.frameIndex_=0,this.frameState_=null,this.previousExtent_=null,this.viewPropertyListenerKey_=null,this.viewChangeListenerKey_=null,this.layerGroupPropertyListenerKeys_=null,this.viewport_=document.createElement("div"),this.viewport_.className="ol-viewport"+("ontouchstart"in window?" ol-touch":""),this.viewport_.style.position="relative",this.viewport_.style.overflow="hidden",this.viewport_.style.width="100%",this.viewport_.style.height="100%",this.overlayContainer_=document.createElement("div"),this.overlayContainer_.style.position="absolute",this.overlayContainer_.style.zIndex="0",this.overlayContainer_.style.width="100%",this.overlayContainer_.style.height="100%",this.overlayContainer_.style.pointerEvents="none",this.overlayContainer_.className="ol-overlaycontainer",this.viewport_.appendChild(this.overlayContainer_),this.overlayContainerStopEvent_=document.createElement("div"),this.overlayContainerStopEvent_.style.position="absolute",this.overlayContainerStopEvent_.style.zIndex="0",this.overlayContainerStopEvent_.style.width="100%",this.overlayContainerStopEvent_.style.height="100%",this.overlayContainerStopEvent_.style.pointerEvents="none",this.overlayContainerStopEvent_.className="ol-overlaycontainer-stopevent",this.viewport_.appendChild(this.overlayContainerStopEvent_),this.mapBrowserEventHandler_=null,this.moveTolerance_=t.moveTolerance,this.keyboardEventTarget_=e.keyboardEventTarget,this.targetChangeHandlerKeys_=null,this.targetElement_=null,this.resizeObserver_=new ResizeObserver(()=>this.updateSize()),this.controls=e.controls||Zc(),this.interactions=e.interactions||hu({onFocusOnly:!0}),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Gc(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(_t.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(_t.VIEW,this.handleViewChanged_),this.addChangeListener(_t.SIZE,this.handleSizeChanged_),this.addChangeListener(_t.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof Vt)&&t.view.then(function(s){i.setView(new Vt(s))}),this.controls.addEventListener(wt.ADD,s=>{s.element.setMap(this)}),this.controls.addEventListener(wt.REMOVE,s=>{s.element.setMap(null)}),this.interactions.addEventListener(wt.ADD,s=>{s.element.setMap(this)}),this.interactions.addEventListener(wt.REMOVE,s=>{s.element.setMap(null)}),this.overlays_.addEventListener(wt.ADD,s=>{this.addOverlayInternal_(s.element)}),this.overlays_.addEventListener(wt.REMOVE,s=>{const r=s.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],s.element.setMap(null)}),this.controls.forEach(s=>{s.setMap(this)}),this.interactions.forEach(s=>{s.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){Pa(t.layer,this)}addOverlay(t){this.getOverlays().push(t)}addOverlayInternal_(t){const e=t.getId();e!==void 0&&(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 s=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Wi,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(s,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(s){i.push(s)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(s){s instanceof Ci?e(s.getLayers()):t.push(s)})}return e(this.getLayers()),t}hasFeatureAtPixel(t,e){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(t);e=e!==void 0?e:{};const s=e.layerFilter!==void 0?e.layerFilter:Wi,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,s,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),s=this.getSize(),r=i.width/s[0],o=i.height/s[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(_t.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return Fs(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?dt(e.pixelToCoordinateTransform,t.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(t){const e=this.overlayIdIndex_[t.toString()];return e!==void 0?e:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(_t.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof jt){e.setLayers(t);return}const i=e.getLayers();i.clear(),i.extend(t)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const s=t[e];if(!s.visible)continue;const r=s.layer.getRenderer();if(r&&!r.ready)return!0;const o=s.layer.getSource();if(o&&o.loading)return!0}return!1}getPixelFromCoordinate(t){const e=se(t,this.getView().getProjection());return this.getPixelFromCoordinateInternal(e)}getPixelFromCoordinateInternal(t){const e=this.frameState_;return e?dt(e.coordinateToPixelTransform,t.slice(0,2)):null}getRenderer(){return this.renderer_}getSize(){return this.get(_t.SIZE)}getView(){return this.get(_t.VIEW)}getViewport(){return this.viewport_}getOverlayContainer(){return this.overlayContainer_}getOverlayContainerStopEvent(){return this.overlayContainerStopEvent_}getOwnerDocument(){const t=this.getTargetElement();return t?t.ownerDocument:document}getTilePriority(t,e,i,s){return zc(this.frameState_,t,e,i,s)}handleBrowserEvent(t,e){e=e||t.type;const i=new we(e,this,t);this.handleMapBrowserEvent(i)}handleMapBrowserEvent(t){if(!this.frameState_)return;const e=t.originalEvent,i=e.type;if(i===Xs.POINTERDOWN||i===z.WHEEL||i===z.KEYDOWN){const s=this.getOwnerDocument(),r=this.viewport_.getRootNode?this.viewport_.getRootNode():s,o=e.target,a=r instanceof ShadowRoot?r.host===o?r.host.ownerDocument:r:r===s?s.documentElement:r;if(this.overlayContainerStopEvent_.contains(o)||!a.contains(o))return}if(t.frameState=this.frameState_,this.dispatchEvent(t)!==!1){const s=this.getInteractions().getArray().slice();for(let r=s.length-1;r>=0;r--){const o=s[r];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(t)||t.propagationStopped)break}}}handlePostRender(){const t=this.frameState_,e=this.tileQueue_;if(!e.isEmpty()){let s=this.maxTilesLoading_,r=s;if(t){const o=t.viewHints;if(o[mt.ANIMATING]||o[mt.INTERACTING]){const a=Date.now()-t.time>8;s=a?0:8,r=a?0:2}}e.getTilesLoading()<s&&(e.reprioritize(),e.loadMoreTiles(s,r))}t&&this.renderer_&&!t.animate&&(this.renderComplete_?(this.hasListener(Ot.RENDERCOMPLETE)&&this.renderer_.dispatchRenderEvent(Ot.RENDERCOMPLETE,t),this.loaded_===!1&&(this.loaded_=!0,this.dispatchEvent(new si(Ce.LOADEND,this,t)))):this.loaded_===!0&&(this.loaded_=!1,this.dispatchEvent(new si(Ce.LOADSTART,this,t))));const i=this.postRenderFunctions_;for(let s=0,r=i.length;s<r;++s)i[s](this,t);i.length=0}handleSizeChanged_(){this.getView()&&!this.getView().getAnimating()&&this.getView().resolveConstraints(0),this.render()}handleTargetChanged_(){if(this.mapBrowserEventHandler_){for(let i=0,s=this.targetChangeHandlerKeys_.length;i<s;++i)tt(this.targetChangeHandlerKeys_[i]);this.targetChangeHandlerKeys_=null,this.viewport_.removeEventListener(z.CONTEXTMENU,this.boundHandleBrowserEvent_),this.viewport_.removeEventListener(z.WHEEL,this.boundHandleBrowserEvent_),this.mapBrowserEventHandler_.dispose(),this.mapBrowserEventHandler_=null,this.viewport_.remove()}if(this.targetElement_){this.resizeObserver_.unobserve(this.targetElement_);const i=this.targetElement_.getRootNode();i instanceof ShadowRoot&&this.resizeObserver_.unobserve(i.host),this.setSize(void 0)}const t=this.getTarget(),e=typeof t=="string"?document.getElementById(t):t;if(this.targetElement_=e,!e)this.renderer_&&(clearTimeout(this.postRenderTimeoutHandle_),this.postRenderTimeoutHandle_=void 0,this.postRenderFunctions_.length=0,this.renderer_.dispose(),this.renderer_=null),this.animationDelayKey_&&(cancelAnimationFrame(this.animationDelayKey_),this.animationDelayKey_=void 0);else{e.appendChild(this.viewport_),this.renderer_||(this.renderer_=new Fc(this)),this.mapBrowserEventHandler_=new kc(this,this.moveTolerance_);for(const r in nt)this.mapBrowserEventHandler_.addEventListener(nt[r],this.handleMapBrowserEvent.bind(this));this.viewport_.addEventListener(z.CONTEXTMENU,this.boundHandleBrowserEvent_,!1),this.viewport_.addEventListener(z.WHEEL,this.boundHandleBrowserEvent_,ga?{passive:!1}:!1);let i;if(this.keyboardEventTarget_)i=this.keyboardEventTarget_;else{const r=e.getRootNode();i=r instanceof ShadowRoot?r.host:e}this.targetChangeHandlerKeys_=[V(i,z.KEYDOWN,this.handleBrowserEvent,this),V(i,z.KEYPRESS,this.handleBrowserEvent,this)];const s=e.getRootNode();s instanceof ShadowRoot&&this.resizeObserver_.observe(s.host),this.resizeObserver_.observe(e)}this.updateSize()}handleTileChange_(){this.render()}handleViewPropertyChanged_(){this.render()}handleViewChanged_(){this.viewPropertyListenerKey_&&(tt(this.viewPropertyListenerKey_),this.viewPropertyListenerKey_=null),this.viewChangeListenerKey_&&(tt(this.viewChangeListenerKey_),this.viewChangeListenerKey_=null);const t=this.getView();t&&(this.updateViewportSize_(this.getSize()),this.viewPropertyListenerKey_=V(t,di.PROPERTYCHANGE,this.handleViewPropertyChanged_,this),this.viewChangeListenerKey_=V(t,z.CHANGE,this.handleViewPropertyChanged_,this),t.resolveConstraints(0)),this.render()}handleLayerGroupChanged_(){this.layerGroupPropertyListenerKeys_&&(this.layerGroupPropertyListenerKeys_.forEach(tt),this.layerGroupPropertyListenerKeys_=null);const t=this.getLayerGroup();t&&(this.handleLayerAdd_(new Re("addlayer",t)),this.layerGroupPropertyListenerKeys_=[V(t,di.PROPERTYCHANGE,this.render,this),V(t,z.CHANGE,this.render,this),V(t,"addlayer",this.handleLayerAdd_,this),V(t,"removelayer",this.handleLayerRemove_,this)]),this.render()}isRendered(){return!!this.frameState_}animationDelay_(){this.animationDelayKey_=void 0,this.renderFrame_(Date.now())}renderSync(){this.animationDelayKey_&&cancelAnimationFrame(this.animationDelayKey_),this.animationDelay_()}redrawText(){const t=this.getLayerGroup().getLayerStatesArray();for(let e=0,i=t.length;e<i;++e){const s=t[e].layer;s.hasRenderer()&&s.getRenderer().handleFontsChanged()}}render(){this.renderer_&&this.animationDelayKey_===void 0&&(this.animationDelayKey_=requestAnimationFrame(this.animationDelay_))}removeControl(t){return this.getControls().remove(t)}removeInteraction(t){return this.getInteractions().remove(t)}removeLayer(t){return this.getLayerGroup().getLayers().remove(t)}handleLayerRemove_(t){Da(t.layer)}removeOverlay(t){return this.getOverlays().remove(t)}renderFrame_(t){const e=this.getSize(),i=this.getView(),s=this.frameState_;let r=null;if(e!==void 0&&io(e)&&i&&i.isDef()){const o=i.getHints(this.frameState_?this.frameState_.viewHints:void 0),a=i.getState();if(r={animate:!1,coordinateToPixelTransform:this.coordinateToPixelTransform_,declutter:null,extent:Ps(a.center,a.resolution,a.rotation,e),index:this.frameIndex_++,layerIndex:0,layerStatesArray:this.getLayerGroup().getLayerStatesArray(),pixelRatio:this.pixelRatio_,pixelToCoordinateTransform:this.pixelToCoordinateTransform_,postRenderFunctions:[],size:e,tileQueue:this.tileQueue_,time:t,usedTiles:{},viewState:a,viewHints:o,wantedTiles:{},mapId:$(this),renderTargets:{}},a.nextCenter&&a.nextResolution){const l=isNaN(a.nextRotation)?a.rotation:a.nextRotation;r.nextExtent=Ps(a.nextCenter,a.nextResolution,l,e)}}this.frameState_=r,this.renderer_.renderFrame(r),r&&(r.animate&&this.render(),Array.prototype.push.apply(this.postRenderFunctions_,r.postRenderFunctions),s&&(!this.previousExtent_||!Hn(this.previousExtent_)&&!Yi(r.extent,this.previousExtent_))&&(this.dispatchEvent(new si(Ce.MOVESTART,this,s)),this.previousExtent_=Bn(this.previousExtent_)),this.previousExtent_&&!r.viewHints[mt.ANIMATING]&&!r.viewHints[mt.INTERACTING]&&!Yi(r.extent,this.previousExtent_)&&(this.dispatchEvent(new si(Ce.MOVEEND,this,r)),Xo(r.extent,this.previousExtent_))),this.dispatchEvent(new si(Ce.POSTRENDER,this,r)),this.renderComplete_=(this.hasListener(Ce.LOADSTART)||this.hasListener(Ce.LOADEND)||this.hasListener(Ot.RENDERCOMPLETE))&&!this.tileQueue_.getTilesLoading()&&!this.tileQueue_.getCount()&&!this.getLoadingOrNotReady(),this.postRenderTimeoutHandle_||(this.postRenderTimeoutHandle_=setTimeout(()=>{this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Re("removelayer",e)),this.set(_t.LAYERGROUP,t)}setSize(t){this.set(_t.SIZE,t)}setTarget(t){this.set(_t.TARGET,t)}setView(t){if(!t||t instanceof Vt){this.set(_t.VIEW,t);return}this.set(_t.VIEW,new Vt);const e=this;t.then(function(i){e.setView(new Vt(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){const s=getComputedStyle(t),r=t.offsetWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.paddingLeft)-parseFloat(s.paddingRight)-parseFloat(s.borderRightWidth),o=t.offsetHeight-parseFloat(s.borderTopWidth)-parseFloat(s.paddingTop)-parseFloat(s.paddingBottom)-parseFloat(s.borderBottomWidth);!isNaN(r)&&!isNaN(o)&&(e=[Math.max(0,r),Math.max(0,o)],!io(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Uo("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!Ae(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}}function uu(n){let t=null;n.keyboardEventTarget!==void 0&&(t=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const e={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new Ci({layers:n.layers});e[_t.LAYERGROUP]=i,e[_t.TARGET]=n.target,e[_t.VIEW]=n.view instanceof Vt?n.view:new Vt;let s;n.controls!==void 0&&(Array.isArray(n.controls)?s=new jt(n.controls.slice()):(j(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),s=n.controls));let r;n.interactions!==void 0&&(Array.isArray(n.interactions)?r=new jt(n.interactions.slice()):(j(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new jt(n.overlays.slice()):(j(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new jt,{controls:s,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}class Ir extends Kn{constructor(t,e,i){super(),i=i||{},this.tileCoord=t,this.state=e,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(z.CHANGE)}release(){this.state===M.ERROR&&this.setState(M.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==M.ERROR&&this.state>t)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)i=e,this.transitionStarts_[t]=i;else if(i===-1)return 1;const s=e-i+1e3/60;return s>=this.transition_?1:Jo(s/this.transition_)}inTransition(t){return this.transition_?this.transitionStarts_[t]!==-1:!1}endTransition(t){this.transition_&&(this.transitionStarts_[t]=-1)}disposeInternal(){this.release(),super.disposeInternal()}}class Oa extends Ir{constructor(t,e,i,s,r,o){super(t,e,o),this.crossOrigin_=s,this.src_=i,this.key=i,this.image_=new Image,s!==null&&(this.image_.crossOrigin=s),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=M.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=M.ERROR,this.unlistenImage_(),this.image_=du(),this.changed()}handleImageLoad_(){const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=M.LOADED:this.state=M.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==M.ERROR&&(this.state=M.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==M.IDLE&&(this.state=M.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=Oh(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()}}function du(){const n=rt(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}const Fa=.5,fu=10,Co=.25;class ka{constructor(t,e,i,s,r,o){this.sourceProj_=t,this.targetProj_=e;let a={};const l=An(this.targetProj_,this.sourceProj_);this.transformInv_=function(y){const x=y[0]+"/"+y[1];return a[x]||(a[x]=l(y)),a[x]},this.maxSourceExtent_=s,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!s&&!!this.sourceProj_.getExtent()&&q(s)>=q(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?q(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?q(this.targetProj_.getExtent()):null;const c=Ye(i),h=jn(i),u=Un(i),d=Vn(i),f=this.transformInv_(c),g=this.transformInv_(h),_=this.transformInv_(u),m=this.transformInv_(d),p=fu+(o?Math.max(0,Math.ceil(Math.log2(Zi(i)/(o*o*256*256)))):0);if(this.addQuad_(c,h,u,d,f,g,_,m,p),this.wrapsXInSource_){let y=1/0;this.triangles_.forEach(function(x,E,w){y=Math.min(y,x.source[0][0],x.source[1][0],x.source[2][0])}),this.triangles_.forEach(x=>{if(Math.max(x.source[0][0],x.source[1][0],x.source[2][0])-y>this.sourceWorldWidth_/2){const E=[[x.source[0][0],x.source[0][1]],[x.source[1][0],x.source[1][1]],[x.source[2][0],x.source[2][1]]];E[0][0]-y>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-y>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-y>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);const w=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-w<this.sourceWorldWidth_/2&&(x.source=E)}})}a={}}addTriangle_(t,e,i,s,r,o){this.triangles_.push({source:[s,r,o],target:[t,e,i]})}addQuad_(t,e,i,s,r,o,a,l,c){const h=Wr([r,o,a,l]),u=this.sourceWorldWidth_?q(h)/this.sourceWorldWidth_:null,d=this.sourceWorldWidth_,f=this.sourceProj_.canWrapX()&&u>.5&&u<1;let g=!1;if(c>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const m=Wr([t,e,i,s]);g=q(m)/this.targetWorldWidth_>Co||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>Co||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Tt(h,this.maxSourceExtent_))return;let _=0;if(!g&&(!isFinite(r[0])||!isFinite(r[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(c>0)g=!0;else if(_=(!isFinite(r[0])||!isFinite(r[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),_!=1&&_!=2&&_!=4&&_!=8)return}if(c>0){if(!g){const m=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(m);let y;f?y=(ci(r[0],d)+ci(a[0],d))/2-ci(p[0],d):y=(r[0]+a[0])/2-p[0];const x=(r[1]+a[1])/2-p[1];g=y*y+x*x>this.errorThresholdSquared_}if(g){if(Math.abs(t[0]-i[0])<=Math.abs(t[1]-i[1])){const m=[(e[0]+i[0])/2,(e[1]+i[1])/2],p=this.transformInv_(m),y=[(s[0]+t[0])/2,(s[1]+t[1])/2],x=this.transformInv_(y);this.addQuad_(t,e,m,y,r,o,p,x,c-1),this.addQuad_(y,m,i,s,x,p,a,l,c-1)}else{const m=[(t[0]+e[0])/2,(t[1]+e[1])/2],p=this.transformInv_(m),y=[(i[0]+s[0])/2,(i[1]+s[1])/2],x=this.transformInv_(y);this.addQuad_(t,m,y,s,r,p,x,l,c-1),this.addQuad_(m,e,i,y,p,o,a,x,c-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}_&11||this.addTriangle_(t,i,s,r,a,l),_&14||this.addTriangle_(t,i,e,r,a,o),_&&(_&13||this.addTriangle_(e,s,t,o,l,r),_&7||this.addTriangle_(e,s,i,o,l,a))}calculateSourceExtent(){const t=Ft();return this.triangles_.forEach(function(e,i,s){const r=e.source;zi(t,r[0]),zi(t,r[1]),zi(t,r[2])}),t}getTriangles(){return this.triangles_}}let Ts;const ue=[];function Ro(n,t,e,i,s){n.beginPath(),n.moveTo(0,0),n.lineTo(t,e),n.lineTo(i,s),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(t,i)+1,Math.max(e,s)),n.restore()}function Is(n,t){return Math.abs(n[t*4]-210)>2||Math.abs(n[t*4+3]-.75*255)>2}function gu(){if(Ts===void 0){const n=rt(6,6,ue);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",Ro(n,4,5,4,0),Ro(n,4,5,0,5);const t=n.getImageData(0,0,3,3).data;Ts=Is(t,0)||Is(t,4)||Is(t,8),mi(n),ue.push(n.canvas)}return Ts}function To(n,t,e,i){const s=qo(e,t,n);let r=Zr(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=n.getMetersPerUnit();a!==void 0&&(r/=a);const l=n.getExtent();if(!l||_i(l,s)){const c=Zr(n,r,s)/r;isFinite(c)&&c>0&&(r/=c)}return r}function Na(n,t,e,i){const s=Xe(e);let r=To(n,t,s,i);return(!isFinite(r)||r<=0)&&Ko(e,function(o){return r=To(n,t,o,i),isFinite(r)&&r>0}),r}function Ga(n,t,e,i,s,r,o,a,l,c,h,u,d,f){const g=rt(Math.round(e*n),Math.round(e*t),ue);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function _(w){return Math.round(w*e)/e}g.globalCompositeOperation="lighter";const m=Ft();l.forEach(function(w,v,T){Tl(m,w.extent)});let p;const y=e/i,x=(u?1:1+Math.pow(2,-24))/y;if(!d||l.length!==1||c!==0){if(p=rt(Math.round(q(m)*y),Math.round(pt(m)*y),ue),u||(p.imageSmoothingEnabled=!1),s&&f){const w=(s[0]-m[0])*y,v=-(s[3]-m[3])*y,T=q(s)*y,R=pt(s)*y;p.rect(w,v,T,R),p.clip()}l.forEach(function(w,v,T){if(w.image.width>0&&w.image.height>0){if(w.clipExtent){p.save();const b=(w.clipExtent[0]-m[0])*y,O=-(w.clipExtent[3]-m[3])*y,A=q(w.clipExtent)*y,F=pt(w.clipExtent)*y;p.rect(u?b:Math.round(b),u?O:Math.round(O),u?A:Math.round(b+A)-Math.round(b),u?F:Math.round(O+F)-Math.round(O)),p.clip()}const R=(w.extent[0]-m[0])*y,I=-(w.extent[3]-m[3])*y,G=q(w.extent)*y,D=pt(w.extent)*y;p.drawImage(w.image,c,c,w.image.width-2*c,w.image.height-2*c,u?R:Math.round(R),u?I:Math.round(I),u?G:Math.round(R+G)-Math.round(R),u?D:Math.round(I+D)-Math.round(I)),w.clipExtent&&p.restore()}})}const E=Ye(o);return a.getTriangles().forEach(function(w,v,T){const R=w.source,I=w.target;let G=R[0][0],D=R[0][1],b=R[1][0],O=R[1][1],A=R[2][0],F=R[2][1];const L=_((I[0][0]-E[0])/r),Z=_(-(I[0][1]-E[1])/r),K=_((I[1][0]-E[0])/r),et=_(-(I[1][1]-E[1])/r),k=_((I[2][0]-E[0])/r),X=_(-(I[2][1]-E[1])/r),Q=G,ct=D;G=0,D=0,b-=Q,O-=ct,A-=Q,F-=ct;const S=[[b,O,0,0,K-L],[A,F,0,0,k-L],[0,0,b,O,et-Z],[0,0,A,F,X-Z]],xt=fl(S);if(!xt)return;if(g.save(),g.beginPath(),gu()||!u){g.moveTo(K,et);const at=4,Zt=L-K,Jt=Z-et;for(let Lt=0;Lt<at;Lt++)g.lineTo(K+_((Lt+1)*Zt/at),et+_(Lt*Jt/(at-1))),Lt!=at-1&&g.lineTo(K+_((Lt+1)*Zt/at),et+_((Lt+1)*Jt/(at-1)));g.lineTo(k,X)}else g.moveTo(K,et),g.lineTo(L,Z),g.lineTo(k,X);g.clip(),g.transform(xt[0],xt[2],xt[1],xt[3],L,Z),g.translate(m[0]-Q,m[3]-ct);let ut;if(p)ut=p.canvas,g.scale(x,-x);else{const at=l[0],Zt=at.extent;ut=at.image,g.scale(q(Zt)/ut.width,-pt(Zt)/ut.height)}g.drawImage(ut,0,0),g.restore()}),p&&(mi(p),ue.push(p.canvas)),h&&(g.save(),g.globalCompositeOperation="source-over",g.strokeStyle="black",g.lineWidth=1,a.getTriangles().forEach(function(w,v,T){const R=w.target,I=(R[0][0]-E[0])/r,G=-(R[0][1]-E[1])/r,D=(R[1][0]-E[0])/r,b=-(R[1][1]-E[1])/r,O=(R[2][0]-E[0])/r,A=-(R[2][1]-E[1])/r;g.beginPath(),g.moveTo(D,b),g.lineTo(I,G),g.lineTo(O,A),g.closePath(),g.stroke()}),g.restore()),g.canvas}class Ys extends Ir{constructor(t,e,i,s,r,o,a,l,c,h,u,d){super(r,M.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=s,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const f=s.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let _=this.sourceTileGrid_.getExtent();const m=g?Xt(f,g):f;if(Zi(m)===0){this.state=M.EMPTY;return}const p=t.getExtent();p&&(_?_=Xt(_,p):_=p);const y=s.getResolution(this.wrappedTileCoord_[0]),x=Na(t,i,m,y);if(!isFinite(x)||x<=0){this.state=M.EMPTY;return}const E=h!==void 0?h:Fa;if(this.triangulation_=new ka(t,i,m,_,x*E,y),this.triangulation_.getTriangles().length===0){this.state=M.EMPTY;return}this.sourceZ_=e.getZForResolution(x);let w=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(w[1]=st(w[1],_[1],_[3]),w[3]=st(w[3],_[1],_[3])):w=Xt(w,_)),!Zi(w))this.state=M.EMPTY;else{let v=0,T=0;t.canWrapX()&&(v=q(p),T=Math.floor((w[0]-p[0])/v)),Js(w.slice(),t,!0).forEach(I=>{const G=e.getTileRangeForExtentAndZ(I,this.sourceZ_);for(let D=G.minX;D<=G.maxX;D++)for(let b=G.minY;b<=G.maxY;b++){const O=c(this.sourceZ_,D,b,a);if(O){const A=T*v;this.sourceTiles_.push({tile:O,offset:A})}}++T}),this.sourceTiles_.length===0&&(this.state=M.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==M.LOADED){const s=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);s[0]+=e.offset,s[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:s,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=M.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),s=typeof i=="number"?i:i[0],r=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(e),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=Ga(s,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=M.LOADED}this.changed()}load(){if(this.state==M.IDLE){this.state=M.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==M.IDLE||i==M.LOADING){t++;const s=V(e,z.CHANGE,r=>{const o=e.getState();(o==M.LOADED||o==M.ERROR||o==M.EMPTY)&&(tt(s),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,s){e.getState()==M.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(tt),this.sourcesListenerKeys_=null}release(){this.canvas_&&(mi(this.canvas_.getContext("2d")),ue.push(this.canvas_),this.canvas_=null),super.release()}}const vs={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class za extends $t{constructor(t){super(),this.projection=kt(t.projection),this.attributions_=Io(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;const e=this;this.viewPromise_=new Promise(function(i,s){e.viewResolver=i,e.viewRejector=s})}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_=Io(t),this.changed()}setState(t){this.state_=t,this.changed()}}function Io(n){return n?typeof n=="function"?n:(Array.isArray(n)||(n=[n]),t=>n):null}class vr{constructor(t,e,i,s){this.minX=t,this.maxX=e,this.minY=i,this.maxY=s}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minX<this.minX&&(this.minX=t.minX),t.maxX>this.maxX&&(this.maxX=t.maxX),t.minY<this.minY&&(this.minY=t.minY),t.maxY>this.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function Je(n,t,e,i,s){return s!==void 0?(s.minX=n,s.maxX=t,s.minY=e,s.maxY=i,s):new vr(n,t,e,i)}function Nn(n,t,e,i){return i!==void 0?(i[0]=n,i[1]=t,i[2]=e,i):[n,t,e]}function _u(n,t,e){return n+"/"+t+"/"+e}function mu(n){return pu(n[0],n[1],n[2])}function pu(n,t,e){return(t<<n)+e}function yu(n,t){const e=n[0],i=n[1],s=n[2];if(t.getMinZoom()>e||e>t.getMaxZoom())return!1;const r=t.getFullTileRange(e);return r?r.containsXY(i,s):!0}const Qe=[0,0,0],pe=5;class Xa{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,j(ll(this.resolutions_,(s,r)=>r-s),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let s=0,r=this.resolutions_.length-1;s<r;++s)if(!e)e=this.resolutions_[s]/this.resolutions_[s+1];else if(this.resolutions_[s]/this.resolutions_[s+1]!==e){e=void 0;break}}this.zoomFactor_=e,this.maxZoom=this.resolutions_.length-1,this.origin_=t.origin!==void 0?t.origin:null,this.origins_=null,t.origins!==void 0&&(this.origins_=t.origins,j(this.origins_.length==this.resolutions_.length,"Number of `origins` and `resolutions` must be equal"));const i=t.extent;i!==void 0&&!this.origin_&&!this.origins_&&(this.origin_=Ye(i)),j(!this.origin_&&this.origins_||this.origin_&&!this.origins_,"Either `origin` or `origins` must be configured, never both"),this.tileSizes_=null,t.tileSizes!==void 0&&(this.tileSizes_=t.tileSizes,j(this.tileSizes_.length==this.resolutions_.length,"Number of `tileSizes` and `resolutions` must be equal")),this.tileSize_=t.tileSize!==void 0?t.tileSize:this.tileSizes_?null:Us,j(!this.tileSize_&&this.tileSizes_||this.tileSize_&&!this.tileSizes_,"Either `tileSize` or `tileSizes` must be configured, never both"),this.extent_=i!==void 0?i:null,this.fullTileRanges_=null,this.tmpSize_=[0,0],this.tmpExtent_=[0,0,0,0],t.sizes!==void 0?this.fullTileRanges_=t.sizes.map((s,r)=>{const o=new vr(Math.min(0,s[0]),Math.max(s[0]-1,-1),Math.min(0,s[1]),Math.max(s[1]-1,-1));if(i){const a=this.getTileRangeForExtentAndZ(i,r);o.minX=Math.max(a.minX,o.minX),o.maxX=Math.min(a.maxX,o.maxX),o.minY=Math.max(a.minY,o.minY),o.maxY=Math.min(a.maxY,o.maxY)}return o}):i&&this.calculateTileRanges_(i)}forEachTileCoord(t,e,i){const s=this.getTileRangeForExtentAndZ(t,e);for(let r=s.minX,o=s.maxX;r<=o;++r)for(let a=s.minY,l=s.maxY;a<=l;++a)i([e,r,a])}forEachTileCoordParentTileRange(t,e,i,s){let r,o,a,l=null,c=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,s);c>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=Je(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,c,i),e(c,r))return!0;--c}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]<this.maxZoom){if(this.zoomFactor_===2){const r=t[1]*2,o=t[2]*2;return Je(r,r+1,o,o+1,e)}const s=this.getTileCoordExtent(t,i||this.tmpExtent_);return this.getTileRangeForExtentAndZ(s,t[0]+1,e)}return null}getTileRangeForTileCoordAndZ(t,e,i){if(e>this.maxZoom||e<this.minZoom)return null;const s=t[0],r=t[1],o=t[2];if(e===s)return Je(r,o,r,o,i);if(this.zoomFactor_){const l=Math.pow(this.zoomFactor_,e-s),c=Math.floor(r*l),h=Math.floor(o*l);if(e<s)return Je(c,c,h,h,i);const u=Math.floor(l*(r+1))-1,d=Math.floor(l*(o+1))-1;return Je(c,u,h,d,i)}const a=this.getTileCoordExtent(t,this.tmpExtent_);return this.getTileRangeForExtentAndZ(a,e,i)}getTileRangeForExtentAndZ(t,e,i){this.getTileCoordForXYAndZ_(t[0],t[3],e,!1,Qe);const s=Qe[1],r=Qe[2];this.getTileCoordForXYAndZ_(t[2],t[1],e,!0,Qe);const o=Qe[1],a=Qe[2];return Je(s,o,r,a,i)}getTileCoordCenter(t){const e=this.getOrigin(t[0]),i=this.getResolution(t[0]),s=vt(this.getTileSize(t[0]),this.tmpSize_);return[e[0]+(t[1]+.5)*s[0]*i,e[1]-(t[2]+.5)*s[1]*i]}getTileCoordExtent(t,e){const i=this.getOrigin(t[0]),s=this.getResolution(t[0]),r=vt(this.getTileSize(t[0]),this.tmpSize_),o=i[0]+t[1]*r[0]*s,a=i[1]-(t[2]+1)*r[1]*s,l=o+r[0]*s,c=a+r[1]*s;return Se(o,a,l,c,e)}getTileCoordForCoordAndResolution(t,e,i){return this.getTileCoordForXYAndResolution_(t[0],t[1],e,!1,i)}getTileCoordForXYAndResolution_(t,e,i,s,r){const o=this.getZForResolution(i),a=i/this.getResolution(o),l=this.getOrigin(o),c=vt(this.getTileSize(o),this.tmpSize_);let h=a*(t-l[0])/i/c[0],u=a*(l[1]-e)/i/c[1];return s?(h=mn(h,pe)-1,u=mn(u,pe)-1):(h=_n(h,pe),u=_n(u,pe)),Nn(o,h,u,r)}getTileCoordForXYAndZ_(t,e,i,s,r){const o=this.getOrigin(i),a=this.getResolution(i),l=vt(this.getTileSize(i),this.tmpSize_);let c=(t-o[0])/a/l[0],h=(o[1]-e)/a/l[1];return s?(c=mn(c,pe)-1,h=mn(h,pe)-1):(c=_n(c,pe),h=_n(h,pe)),Nn(i,c,h,r)}getTileCoordForCoordAndZ(t,e,i){return this.getTileCoordForXYAndZ_(t[0],t[1],e,!1,i)}getTileCoordResolution(t){return this.resolutions_[t[0]]}getTileSize(t){return this.tileSize_?this.tileSize_:this.tileSizes_[t]}getFullTileRange(t){return this.fullTileRanges_?this.fullTileRanges_[t]:this.extent_?this.getTileRangeForExtentAndZ(this.extent_,t):null}getZForResolution(t,e){const i=Bs(this.resolutions_,t,e||0);return st(i,this.minZoom,this.maxZoom)}tileCoordIntersectsViewport(t,e){return ra(e,0,e.length,2,this.getTileCoordExtent(t))}calculateTileRanges_(t){const e=this.resolutions_.length,i=new Array(e);for(let s=this.minZoom;s<e;++s)i[s]=this.getTileRangeForExtentAndZ(t,s);this.fullTileRanges_=i}}function Wa(n){let t=n.getDefaultTileGrid();return t||(t=Cu(n),n.setDefaultTileGrid(t)),t}function Eu(n,t,e){const i=t[0],s=n.getTileCoordCenter(t),r=Sr(e);if(!_i(r,s)){const o=q(r),a=Math.ceil((r[0]-s[0])/o);return s[0]+=o*a,n.getTileCoordForCoordAndZ(s,i)}return t}function xu(n,t,e,i){i=i!==void 0?i:"top-left";const s=Ya(n,t,e);return new Xa({extent:n,origin:vl(n,i),resolutions:s,tileSize:e})}function wu(n){const t=n||{},e=t.extent||kt("EPSG:3857").getExtent(),i={extent:e,minZoom:t.minZoom,tileSize:t.tileSize,resolutions:Ya(e,t.maxZoom,t.tileSize,t.maxResolution)};return new Xa(i)}function Ya(n,t,e,i){t=t!==void 0?t:gl,e=vt(e!==void 0?e:Us);const s=pt(n),r=q(n);i=i>0?i:Math.max(r/e[0],s/e[1]);const o=t+1,a=new Array(o);for(let l=0;l<o;++l)a[l]=i/Math.pow(2,l);return a}function Cu(n,t,e,i){const s=Sr(n);return xu(s,t,e,i)}function Sr(n){n=kt(n);let t=n.getExtent();if(!t){const e=180*js.degrees/n.getMetersPerUnit();t=Se(-e,-e,e,e)}return t}class Ru extends za{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_=t.tilePixelRatio!==void 0?t.tilePixelRatio:1,this.tileGrid=t.tileGrid!==void 0?t.tileGrid:null;const e=[256,256];this.tileGrid&&vt(this.tileGrid.getTileSize(this.tileGrid.getMinZoom()),e),this.tmpSize=[0,0],this.key_=t.key||$(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,s,r){return U()}getTileGrid(){return this.tileGrid}getTileGridForProjection(t){return this.tileGrid?this.tileGrid:Wa(t)}getTilePixelRatio(t){return this.tilePixelRatio_}getTilePixelSize(t,e,i){const s=this.getTileGridForProjection(i),r=this.getTilePixelRatio(e),o=vt(s.getTileSize(t),this.tmpSize);return r==1?o:Ch(o,r,this.tmpSize)}getTileCoordForTileUrlFunction(t,e){e=e!==void 0?e:this.getProjection();const i=this.getTileGridForProjection(e);return this.getWrapX()&&e.isGlobal()&&(t=Eu(i,t,e)),yu(t,i)?t:null}clear(){}refresh(){this.clear(),super.refresh()}}class Tu extends fe{constructor(t,e){super(t),this.tile=e}}const Iu=/\{z\}/g,vu=/\{x\}/g,Su=/\{y\}/g,Lu=/\{-y\}/g;function Au(n,t,e,i,s){return n.replace(Iu,t.toString()).replace(vu,e.toString()).replace(Su,i.toString()).replace(Lu,function(){if(s===void 0)throw new Error("If the URL template has a {-y} placeholder, the grid extent must be known");return(s-i).toString()})}function Mu(n){const t=[];let e=/\{([a-z])-([a-z])\}/.exec(n);if(e){const i=e[1].charCodeAt(0),s=e[2].charCodeAt(0);let r;for(r=i;r<=s;++r)t.push(n.replace(e[0],String.fromCharCode(r)));return t}if(e=/\{(\d+)-(\d+)\}/.exec(n),e){const i=parseInt(e[2],10);for(let s=parseInt(e[1],10);s<=i;s++)t.push(n.replace(e[0],s.toString()));return t}return t.push(n),t}function bu(n,t){return function(e,i,s){if(!e)return;let r;const o=e[0];if(t){const a=t.getFullTileRange(o);a&&(r=a.getHeight()-1)}return Au(n,o,e[1],e[2],r)}}function Du(n,t){const e=n.length,i=new Array(e);for(let s=0;s<e;++s)i[s]=bu(n[s],t);return Pu(i)}function Pu(n){return n.length===1?n[0]:function(t,e,i){if(!t)return;const s=mu(t),r=ci(s,n.length);return n[r](t,e,i)}}class Lr extends Ru{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===Lr.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=$(e),s=e.getState();let r;s==M.LOADING?(this.tileLoadingKeys_[i]=!0,r=vs.TILELOADSTART):i in this.tileLoadingKeys_&&(delete this.tileLoadingKeys_[i],r=s==M.ERROR?vs.TILELOADERROR:s==M.LOADED?vs.TILELOADEND:void 0),r!=null&&this.dispatchEvent(new Tu(r,e))}setTileLoadFunction(t){this.tileLoadFunction=t,this.changed()}setTileUrlFunction(t,e){this.tileUrlFunction=t,typeof e<"u"?this.setKey(e):this.changed()}setUrl(t){const e=Mu(t);this.urls=e,this.setUrls(e)}setUrls(t){this.urls=t;const e=t.join(`
|
||
`);this.generateTileUrlFunction_?this.setTileUrlFunction(Du(t,this.tileGrid),e):this.setKey(e)}tileUrlFunction(t,e,i){}}class Ou extends Lr{constructor(t){super({attributions:t.attributions,cacheSize:t.cacheSize,projection:t.projection,state:t.state,tileGrid:t.tileGrid,tileLoadFunction:t.tileLoadFunction?t.tileLoadFunction:Fu,tilePixelRatio:t.tilePixelRatio,tileUrlFunction:t.tileUrlFunction,url:t.url,urls:t.urls,wrapX:t.wrapX,transition:t.transition,interpolate:t.interpolate!==void 0?t.interpolate:!0,key:t.key,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.crossOrigin=t.crossOrigin!==void 0?t.crossOrigin:null,this.tileClass=t.tileClass!==void 0?t.tileClass:Oa,this.tileGridForProjection={},this.reprojectionErrorThreshold_=t.reprojectionErrorThreshold,this.renderReprojectionEdges_=!1}getGutterForProjection(t){return this.getProjection()&&t&&!ds(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||ds(e,t)))return this.tileGrid;const i=$(t);return i in this.tileGridForProjection||(this.tileGridForProjection[i]=Wa(t)),this.tileGridForProjection[i]}createTile_(t,e,i,s,r,o){const a=[t,e,i],l=this.getTileCoordForTileUrlFunction(a,r),c=l?this.tileUrlFunction(l,s,r):void 0,h=new this.tileClass(a,c!==void 0?M.IDLE:M.EMPTY,c!==void 0?c:"",this.crossOrigin,this.tileLoadFunction,this.tileOptions);return h.key=o,h.addEventListener(z.CHANGE,this.handleTileChange.bind(this)),h}getTile(t,e,i,s,r){const o=this.getProjection();if(!o||!r||ds(o,r))return this.getTileInternal(t,e,i,s,o||r);const a=[t,e,i],l=this.getKey(),c=this.getTileGridForProjection(o),h=this.getTileGridForProjection(r),u=this.getTileCoordForTileUrlFunction(a,r),d=new Ys(o,c,r,h,a,u,this.getTilePixelRatio(s),this.getGutter(),(f,g,_,m)=>this.getTileInternal(f,g,_,m,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return d.key=l,d}getTileInternal(t,e,i,s,r){const o=this.getKey();return this.createTile_(t,e,i,s,r,o)}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=kt(t);if(i){const s=$(i);s in this.tileGridForProjection||(this.tileGridForProjection[s]=e)}}}function Fu(n,t){n.getImage().src=t}class ku extends Ou{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:wu({extent:Sr(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:t.wrapX!==void 0?t.wrapX:!0,transition:t.transition,attributionsCollapsible:t.attributionsCollapsible,zDirection:t.zDirection}),this.gutter_=t.gutter!==void 0?t.gutter:0}getGutter(){return this.gutter_}}const Nu='© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.';class Gu extends ku{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[Nu];const i=t.crossOrigin!==void 0?t.crossOrigin:"anonymous",s=t.url!==void 0?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:i,interpolate:t.interpolate,maxZoom:t.maxZoom!==void 0?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:s,wrapX:t.wrapX,zDirection:t.zDirection})}}const Rn={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class zu extends Jn{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(t.preload!==void 0?t.preload:0),this.setUseInterimTilesOnError(t.useInterimTilesOnError!==void 0?t.useInterimTilesOnError:!0)}getCacheSize(){return this.cacheSize_}getPreload(){return this.get(Rn.PRELOAD)}setPreload(t){this.set(Rn.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(Rn.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(Rn.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}const Xu=5;class Wu extends sn{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=Xu}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.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,s,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===Y.LOADED||e.getState()===Y.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=Y.LOADED&&e!=Y.ERROR&&t.addEventListener(z.CHANGE,this.boundHandleImageChange_),e==Y.IDLE&&(t.load(),e=t.getState()),e==Y.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}class Za{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(bn(),{get:(t,e)=>{if(typeof bn()[e]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e),this.pushMethodArgs_},set:(t,e,i)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(e,i),!0)})}pushMethodArgs_=(...t)=>(this.instructions_[this.zIndex+this.offset_].push(t),this);pushFunction(t){this.instructions_[this.zIndex+this.offset_].push(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,s=e.length;i<s;++i){const r=e[i];if(typeof r=="function"){r(t);continue}const o=e[++i];if(typeof t[r]=="function")t[r](...o);else{if(typeof o=="function"){t[r]=o(t);continue}t[r]=o}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}}const vo=[];let ri=null;function Yu(){ri=rt(1,1,void 0,{willReadFrequently:!0})}class Ka extends Wu{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=Wt(),this.pixelTransform=Wt(),this.inversePixelTransform=Wt(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){ri||Yu(),ri.clearRect(0,0,1,1);let s;try{ri.drawImage(t,e,i,1,1,0,0,1,1),s=ri.getImageData(0,0,1,1).data}catch{return ri=null,null}return s}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const s=this.getLayer().getClassName();let r,o;if(t&&t.className===s&&(!i||t&&t.style.backgroundColor&&Ae(ji(t.style.backgroundColor),ji(i)))){const a=t.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&o.canvas.style.transform===e?(this.container=t,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){r=document.createElement("div"),r.className=s;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=rt();const l=o.canvas;r.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=r,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(t,e,i){const s=Ye(i),r=jn(i),o=Un(i),a=Vn(i);dt(e.coordinateToPixelTransform,s),dt(e.coordinateToPixelTransform,r),dt(e.coordinateToPixelTransform,o),dt(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;dt(l,s),dt(l,r),dt(l,o),dt(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(s[0]),Math.round(s[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(o[0]),Math.round(o[1])),t.lineTo(Math.round(a[0]),Math.round(a[1])),t.clip()}prepareContainer(t,e){const i=t.extent,s=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(q(i)/s*o),l=Math.round(pt(i)/s*o);de(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),Qo(this.inversePixelTransform,this.pixelTransform);const c=Ul(this.pixelTransform);if(this.useContainer(e,c,this.getBackground(t)),!this.containerReused){const h=this.context.canvas;h.width!=a||h.height!=l?(h.width=a,h.height=l):this.context.clearRect(0,0,a,l),c!==h.style.transform&&(h.style.transform=c)}}dispatchRenderEvent_(t,e,i){const s=this.getLayer();if(s.hasListener(t)){const r=new Sa(t,this.inversePixelTransform,i,e);s.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Ot.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ot.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new Za),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Ot.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ot.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,s,r,o,a){const l=r/2,c=o/2,h=s/e,u=-h,d=-t[0]+a,f=-t[1];return de(this.tempTransform,l,c,h,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}function Gn(n){return n instanceof Image||n instanceof HTMLCanvasElement||n instanceof HTMLVideoElement||n instanceof ImageBitmap?n:null}function Zu(n){return n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Float32Array||n instanceof DataView?n:null}const Ku=new Error("disposed");let ti=null;function Bu(n){ti||(ti=rt(n.width,n.height,void 0,{willReadFrequently:!0}));const t=ti.canvas,e=n.width;t.width!==e&&(t.width=e);const i=n.height;return t.height!==i&&(t.height=i),ti.clearRect(0,0,e,i),ti.drawImage(n,0,0),ti.getImageData(0,0,e,i).data}const Vu=[256,256];class Zs extends Ir{constructor(t){const e=M.IDLE;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=Gn(this.data_);return t?[t.width,t.height]:Vu}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==M.IDLE&&this.state!==M.ERROR)return;this.state=M.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=M.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=M.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(Ku),this.controller_=null),super.disposeInternal()}}class Uu{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();){const e=this.pop();e instanceof Wn&&e.dispose()}}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return j(i!==void 0,"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 j(e!==void 0,"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=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.key_;return t}getValues(){const t=new Array(this.count_);let e=0,i;for(i=this.newest_;i;i=i.older)t[e++]=i.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){j(!(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}}class ju extends Zs{constructor(t){super({tileCoord:t.tileCoord,loader:()=>Promise.resolve(new Uint8ClampedArray(4)),interpolate:t.interpolate,transition:t.transition}),this.pixelRatio_=t.pixelRatio,this.gutter_=t.gutter,this.reprojData_=null,this.reprojError_=null,this.reprojSize_=void 0,this.sourceTileGrid_=t.sourceTileGrid,this.targetTileGrid_=t.targetTileGrid,this.wrappedTileCoord_=t.wrappedTileCoord||t.tileCoord,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0;const e=t.sourceProj,i=e.getExtent(),s=t.sourceTileGrid.getExtent();this.clipExtent_=e.canWrapX()?s?Xt(i,s):i:s;const r=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_),o=this.targetTileGrid_.getExtent();let a=this.sourceTileGrid_.getExtent();const l=o?Xt(r,o):r;if(Zi(l)===0){this.state=M.EMPTY;return}i&&(a?a=Xt(a,i):a=i);const c=this.targetTileGrid_.getResolution(this.wrappedTileCoord_[0]),h=t.targetProj,u=Na(e,h,l,c);if(!isFinite(u)||u<=0){this.state=M.EMPTY;return}const d=t.errorThreshold!==void 0?t.errorThreshold:Fa;if(this.triangulation_=new ka(e,h,l,a,u*d,c),this.triangulation_.getTriangles().length===0){this.state=M.EMPTY;return}this.sourceZ_=this.sourceTileGrid_.getZForResolution(u);let f=this.triangulation_.calculateSourceExtent();if(a&&(e.canWrapX()?(f[1]=st(f[1],a[1],a[3]),f[3]=st(f[3],a[1],a[3])):f=Xt(f,a)),!Zi(f))this.state=M.EMPTY;else{let g=0,_=0;e.canWrapX()&&(g=q(i),_=Math.floor((f[0]-i[0])/g)),Js(f.slice(),e,!0).forEach(p=>{const y=this.sourceTileGrid_.getTileRangeForExtentAndZ(p,this.sourceZ_),x=t.getTileFunction;for(let E=y.minX;E<=y.maxX;E++)for(let w=y.minY;w<=y.maxY;w++){const v=x(this.sourceZ_,E,w,this.pixelRatio_);if(v){const T=_*g;this.sourceTiles_.push({tile:v,offset:T})}}++_}),this.sourceTiles_.length===0&&(this.state=M.EMPTY)}}getSize(){return this.reprojSize_}getData(){return this.reprojData_}getError(){return this.reprojError_}reproject_(){const t=[];let e=!1;if(this.sourceTiles_.forEach(g=>{const _=g.tile;if(!_||_.getState()!==M.LOADED)return;const m=_.getSize(),p=this.gutter_;let y;const x=Zu(_.getData());x?y=x:(e=!0,y=Bu(Gn(_.getData())));const E=[m[0]+2*p,m[1]+2*p],w=y instanceof Float32Array,v=E[0]*E[1],T=w?Float32Array:Uint8ClampedArray,R=new T(y.buffer),I=T.BYTES_PER_ELEMENT,G=I*R.length/v,D=R.byteLength/E[1],b=Math.floor(D/I/E[0]),O=v*b;let A=R;if(R.length!==O){A=new T(O);let Z=0,K=0;const et=E[0]*b;for(let k=0;k<E[1];++k){for(let X=0;X<et;++X)A[Z++]=R[K+X];K+=D/I}}const F=this.sourceTileGrid_.getTileCoordExtent(_.tileCoord);F[0]+=g.offset,F[2]+=g.offset;const L=this.clipExtent_?.slice();L&&(L[0]+=g.offset,L[2]+=g.offset),t.push({extent:F,clipExtent:L,data:new Uint8ClampedArray(A.buffer),dataType:T,bytesPerPixel:G,pixelSize:E})}),this.sourceTiles_.length=0,t.length===0){this.state=M.ERROR,this.changed();return}const i=this.wrappedTileCoord_[0],s=this.targetTileGrid_.getTileSize(i),r=typeof s=="number"?s:s[0],o=typeof s=="number"?s:s[1],a=this.targetTileGrid_.getResolution(i),l=this.sourceTileGrid_.getResolution(this.sourceZ_),c=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);let h,u;const d=t[0].bytesPerPixel,f=Math.ceil(d/3);for(let g=f-1;g>=0;--g){const _=[];for(let w=0,v=t.length;w<v;++w){const T=t[w],R=T.data,I=T.pixelSize,G=I[0],D=I[1],b=rt(G,D,ue),O=b.createImageData(G,D),A=O.data;let F=g*3;for(let L=0,Z=A.length;L<Z;L+=4)A[L]=R[F],A[L+1]=R[F+1],A[L+2]=R[F+2],A[L+3]=255,F+=d;b.putImageData(O,0,0),_.push({extent:T.extent,clipExtent:T.clipExtent,image:b.canvas})}const m=Ga(r,o,this.pixelRatio_,l,this.sourceTileGrid_.getExtent(),a,c,this.triangulation_,_,this.gutter_,!1,!1,!1);for(let w=0,v=_.length;w<v;++w){const R=_[w].image.getContext("2d");mi(R),ue.push(R.canvas)}const p=m.getContext("2d"),y=p.getImageData(0,0,m.width,m.height);mi(p),ue.push(m),h||(u=new Uint8ClampedArray(d*y.width*y.height),h=new t[0].dataType(u.buffer));const x=y.data;let E=g*3;for(let w=0,v=x.length;w<v;w+=4)x[w+3]===255?(u[E]=x[w],u[E+1]=x[w+1],u[E+2]=x[w+2]):(u[E]=0,u[E+1]=0,u[E+2]=0),E+=d}if(e){const g=rt(r,o),_=new ImageData(h,r);g.putImageData(_,0,0),this.reprojData_=g.canvas}else this.reprojData_=h;this.reprojSize_=[Math.round(r*this.pixelRatio_),Math.round(o*this.pixelRatio_)],this.state=M.LOADED,this.changed()}load(){if(this.state!==M.IDLE&&this.state!==M.ERROR)return;this.state=M.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i!==M.IDLE&&i!==M.LOADING)return;t++;const s=V(e,z.CHANGE,()=>{const r=e.getState();(r==M.LOADED||r==M.ERROR||r==M.EMPTY)&&(tt(s),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(s)}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e}){e.getState()==M.IDLE&&e.load()})}unlistenSources_(){this.sourcesListenerKeys_.forEach(tt),this.sourcesListenerKeys_=null}}function Ss(n,t,e,i){return`${n},${_u(t,e,i)}`}function Ls(n,t,e){if(!(e in n))return n[e]=new Set([t]),!0;const i=n[e],s=i.has(t);return s||i.add(t),!s}function Hu(n,t,e){const i=n[e];return i?i.delete(t):!1}function So(n,t){const e=n.layerStatesArray[n.layerIndex];e.extent&&(t=Xt(t,Te(e.extent,n.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const s=i.getTileGridForProjection(n.viewState.projection).getExtent();s&&(t=Xt(t,s))}return t}class qu extends Ka{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Ft(),this.tempTileRange_=new vr(0,0,0,0),this.tempTileCoord_=Nn(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new Uu(i),this.renderedProjection_=void 0,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getOrCreateTile(t,e,i,s){const r=this.tileCache_,a=this.getLayer().getSource(),l=Ss(a.getKey(),t,e,i);let c;if(r.containsKey(l))c=r.get(l);else{if(c=a.getTile(t,e,i,s.pixelRatio,s.viewState.projection),!c)return null;r.set(l,c)}return c}getTile(t,e,i,s){const r=this.getOrCreateTile(t,e,i,s);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),s=dt(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!_i(r,s))return null;const o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),c=a.getTilePixelRatio(e.pixelRatio);for(let h=l.getZForResolution(o.resolution);h>=l.getMinZoom();--h){const u=l.getTileCoordForCoordAndZ(s,h),d=this.getTile(h,u[1],u[2],e);if(!d||d.getState()!==M.LOADED)continue;const f=l.getOrigin(h),g=vt(l.getTileSize(h)),_=l.getResolution(h);let m;if(d instanceof Oa||d instanceof Ys)m=d.getImage();else if(d instanceof Zs){if(m=Gn(d.getData()),!m)continue}else continue;const p=Math.floor(c*((s[0]-f[0])/_-u[1]*g[0])),y=Math.floor(c*((f[1]-s[1])/_-u[2]*g[1])),x=Math.round(c*a.getGutterForProjection(o.projection));return this.getImageData(m,p+x,y+x)}return null}prepareFrame(t){this.renderedProjection_?t.viewState.projection!==this.renderedProjection_&&(this.tileCache_.clear(),this.renderedProjection_=t.viewState.projection):this.renderedProjection_=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedRevision_?this.renderedRevision_!==i&&(this.renderedRevision_=i,this.renderedSourceKey_===e.getKey()&&this.tileCache_.clear()):this.renderedRevision_=i,!0}enqueueTiles(t,e,i,s,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),c=l.getTileGridForProjection(o.projection),h=$(l);h in t.wantedTiles||(t.wantedTiles[h]={});const u=t.wantedTiles[h],d=a.getMapInternal(),f=Math.max(i-r,c.getMinZoom(),c.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):c.getResolution(0)),l.zDirection));for(let g=i;g>=f;--g){const _=c.getTileRangeForExtentAndZ(e,g,this.tempTileRange_),m=c.getResolution(g);for(let p=_.minX;p<=_.maxX;++p)for(let y=_.minY;y<=_.maxY;++y){const x=this.getTile(g,p,y,t);if(!x||!Ls(s,x,g))continue;const w=x.getKey();if(u[w]=!0,x.getState()===M.IDLE&&!t.tileQueue.isKeyQueued(w)){const v=Nn(g,p,y,this.tempTileCoord_);t.tileQueue.enqueue([x,h,c.getTileCoordCenter(v),m])}}}}findStaleTile_(t,e){const i=this.tileCache_,s=t[0],r=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l<a.length;++l){const c=Ss(a[l],s,r,o);if(i.containsKey(c)){const h=i.get(c);if(h.getState()===M.LOADED)return h.endTransition($(this)),Ls(e,h,s),!0}}return!1}findAltTiles_(t,e,i,s){const r=t.getTileRangeForTileCoordAndZ(e,i,this.tempTileRange_);if(!r)return!1;let o=!0;const a=this.tileCache_,c=this.getLayer().getRenderSource().getKey();for(let h=r.minX;h<=r.maxX;++h)for(let u=r.minY;u<=r.maxY;++u){const d=Ss(c,i,h,u);let f=!1;if(a.containsKey(d)){const g=a.get(d);g.getState()===M.LOADED&&(Ls(s,g,i),f=!0)}f||(o=!1)}return o}renderFrame(t,e){this.renderComplete=!0;const i=t.layerStatesArray[t.layerIndex],s=t.viewState,r=s.projection,o=s.resolution,a=s.center,l=t.pixelRatio,c=this.getLayer(),h=c.getSource(),u=h.getRevision(),d=h.getTileGridForProjection(r),f=d.getZForResolution(o,h.zDirection),g=d.getResolution(f),_=h.getKey();this.renderedSourceKey_?this.renderedSourceKey_!==_&&(this.prependStaleKey(this.renderedSourceKey_),this.renderedSourceKey_=_):this.renderedSourceKey_=_;let m=t.extent;const p=h.getTilePixelRatio(l);this.prepareContainer(t,e);const y=this.context.canvas.width,x=this.context.canvas.height,E=i.extent&&Te(i.extent);E&&(m=Xt(m,Te(i.extent)));const w=g*y/2/p,v=g*x/2/p,T=[a[0]-w,a[1]-v,a[0]+w,a[1]+v],R={};this.renderedTiles.length=0;const I=c.getPreload();if(t.nextExtent){const k=d.getZForResolution(s.nextResolution,h.zDirection),X=So(t,t.nextExtent);this.enqueueTiles(t,X,k,R,I)}const G=So(t,m);if(this.enqueueTiles(t,G,f,R,0),I>0&&setTimeout(()=>{this.enqueueTiles(t,G,f-1,R,I-1)},0),!(f in R))return this.container;const D=$(this),b=t.time;for(const k of R[f]){const X=k.getState();if((k instanceof Ys||k instanceof ju)&&X===M.EMPTY)continue;const Q=k.tileCoord;if(X===M.LOADED&&k.getAlpha(D,b)===1){k.endTransition(D);continue}if(this.renderComplete=!1,this.findStaleTile_(Q,R)){Hu(R,k,f),t.animate=!0;continue}if(this.findAltTiles_(d,Q,f+1,R))continue;const xt=d.getMinZoom();for(let ut=f-1;ut>=xt&&!this.findAltTiles_(d,Q,ut,R);--ut);}const O=g/o*l/p,A=this.getRenderContext(t);de(this.tempTransform,y/2,x/2,O,O,0,-y/2,-x/2),i.extent&&this.clipUnrotated(A,t,E),h.getInterpolate()||(A.imageSmoothingEnabled=!1),this.preRender(A,t);const F=Object.keys(R).map(Number);F.sort(ae);let L;const Z=[],K=[];for(let k=F.length-1;k>=0;--k){const X=F[k],Q=h.getTilePixelSize(X,l,r),S=d.getResolution(X)/g,xt=Q[0]*S*O,ut=Q[1]*S*O,at=d.getTileCoordForCoordAndZ(Ye(T),X),Zt=d.getTileCoordExtent(at),Jt=dt(this.tempTransform,[p*(Zt[0]-T[0])/g,p*(T[3]-Zt[3])/g]),Lt=p*h.getGutterForProjection(r);for(const _e of R[X]){if(_e.getState()!==M.LOADED)continue;const Ri=_e.tileCoord,un=at[1]-Ri[1],rs=Math.round(Jt[0]-(un-1)*xt),Ti=at[2]-Ri[2],Me=Math.round(Jt[1]-(Ti-1)*ut),At=Math.round(Jt[0]-un*xt),Kt=Math.round(Jt[1]-Ti*ut),Ke=rs-At,Be=Me-Kt,Ii=F.length===1;let be=!1;L=[At,Kt,At+Ke,Kt,At+Ke,Kt+Be,At,Kt+Be];for(let Ve=0,Ue=Z.length;Ve<Ue;++Ve)if(!Ii&&X<K[Ve]){const lt=Z[Ve];Tt([At,Kt,At+Ke,Kt+Be],[lt[0],lt[3],lt[4],lt[7]])&&(be||(A.save(),be=!0),A.beginPath(),A.moveTo(L[0],L[1]),A.lineTo(L[2],L[3]),A.lineTo(L[4],L[5]),A.lineTo(L[6],L[7]),A.moveTo(lt[6],lt[7]),A.lineTo(lt[4],lt[5]),A.lineTo(lt[2],lt[3]),A.lineTo(lt[0],lt[1]),A.clip())}Z.push(L),K.push(X),this.drawTile(_e,t,At,Kt,Ke,Be,Lt,Ii),be&&A.restore(),this.renderedTiles.unshift(_e),this.updateUsedTiles(t.usedTiles,h,_e)}}this.renderedRevision=u,this.renderedResolution=g,this.extentChanged=!this.renderedExtent_||!Yi(this.renderedExtent_,T),this.renderedExtent_=T,this.renderedPixelRatio=l,this.renderedProjection=r,this.postRender(this.context,t),i.extent&&A.restore(),A.imageSmoothingEnabled=!0;const et=(k,X)=>{const Q=$(h),ct=X.wantedTiles[Q],S=ct?Object.keys(ct).length:0;this.updateCacheSize(S),this.tileCache_.expireCache()};return t.postRenderFunctions.push(et),this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,s,r,o,a,l){let c;if(t instanceof Zs){if(c=Gn(t.getData()),!c)throw new Error("Rendering array data is not yet supported")}else c=this.getTileImage(t);if(!c)return;const h=this.getRenderContext(e),u=$(this),d=e.layerStatesArray[e.layerIndex],f=d.opacity*(l?t.getAlpha(u,e.time):1),g=f!==h.globalAlpha;g&&(h.save(),h.globalAlpha=f),h.drawImage(c,a,a,c.width-2*a,c.height-2*a,i,s,r,o),g&&h.restore(),f!==d.opacity?e.animate=!0:l&&t.endTransition(u)}getImage(){const t=this.context;return t?t.canvas:null}getTileImage(t){return t.getImage()}updateUsedTiles(t,e,i){const s=$(e);s in t||(t[s]={}),t[s][i.getKey()]=!0}}class $u extends zu{constructor(t){super(t)}createRenderer(){return new qu(this,{cacheSize:this.getCacheSize()})}}class Xi extends $t{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(typeof t.getSimplifiedGeometry=="function"){const e=t;this.setGeometry(e)}else{const e=t;this.setProperties(e)}}clone(){const t=new Xi(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_&&(tt(this.geometryChangeKey_),this.geometryChangeKey_=null);const t=this.getGeometry();t&&(this.geometryChangeKey_=V(t,z.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(t){this.set(this.geometryName_,t)}setStyle(t){this.style_=t,this.styleFunction_=t?Ju(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 Ju(n){if(typeof n=="function")return n;let t;return Array.isArray(n)?t=n:(j(typeof n.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),t=[n]),function(){return t}}function Ks(n,t,e,i,s,r,o){let a,l;const c=(e-t)/i;if(c===1)a=t;else if(c===2)a=t,l=s;else if(c!==0){let h=n[t],u=n[t+1],d=0;const f=[0];for(let m=t+i;m<e;m+=i){const p=n[m],y=n[m+1];d+=Math.sqrt((p-h)*(p-h)+(y-u)*(y-u)),f.push(d),h=p,u=y}const g=s*d,_=ol(f,g);_<0?(l=(g-f[-_-2])/(f[-_-1]-f[-_-2]),a=t+(-_-2)*i):a=t+_*i}o=o>1?o:2,r=r||new Array(o);for(let h=0;h<o;++h)r[h]=a===void 0?NaN:l===void 0?n[a+h]:St(n[a+h],n[a+i+h],l);return r}function Qu(n,t,e,i,s,r){if(e==t)return null;let o;if(s<n[t+i-1])return r?(o=n.slice(t,t+i),o[i-1]=s,o):null;if(n[e-1]<s)return r?(o=n.slice(e-i,e),o[i-1]=s,o):null;if(s==n[t+i-1])return n.slice(t,t+i);let a=t/i,l=e/i;for(;a<l;){const d=a+l>>1;s<n[(d+1)*i-1]?l=d:a=d+1}const c=n[a*i-1];if(s==c)return n.slice((a-1)*i,(a-1)*i+i);const h=n[(a+1)*i-1],u=(s-c)/(h-c);o=[];for(let d=0;d<i-1;++d)o.push(St(n[(a-1)*i+d],n[a*i+d],u));return o.push(s),o}function Ba(n,t,e,i){let s=n[t],r=n[t+1],o=0;for(let a=t+i;a<e;a+=i){const l=n[a],c=n[a+1];o+=Math.sqrt((l-s)*(l-s)+(c-r)*(c-r)),s=l,r=c}return o}class zn extends qn{constructor(t,e){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,e!==void 0&&!Array.isArray(t[0])?this.setFlatCoordinates(e,t):this.setCoordinates(t,e)}appendCoordinate(t){Yn(this.flatCoordinates,t),this.changed()}clone(){const t=new zn(this.flatCoordinates.slice(),this.layout);return t.applyProperties(this),t}closestPointXY(t,e,i,s){return s<qs(this.getExtent(),t,e)?s:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(or(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),ar(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,t,e,i,s))}forEachSegment(t){return sa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinateAtM(t,e){return this.layout!="XYM"&&this.layout!="XYZM"?null:(e=e!==void 0?e:!1,Qu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e))}getCoordinates(){return ke(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(t,e){return Ks(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,this.stride)}getLength(){return Ba(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(t){const e=[];return e.length=$n(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t,e,0),new zn(e,"XY")}getType(){return"LineString"}intersectsExtent(t){return cr(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}setCoordinates(t,e){this.setLayout(e,t,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=lr(this.flatCoordinates,0,t,this.stride),this.changed()}}const P={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Tn=[P.FILL],Ie=[P.STROKE],ze=[P.BEGIN_PATH],Lo=[P.CLOSE_PATH];class Va{drawCustom(t,e,i,s,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 cn extends Va{constructor(t,e,i,s){super(),this.tolerance=t,this.maxExtent=e,this.pixelRatio=s,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){const e=this.pixelRatio;return e==1?t:t.map(function(i){return i*e})}appendFlatPointCoordinates(t,e){const i=this.getBufferedMaxExtent(),s=this.tmpCoordinate_,r=this.coordinates;let o=r.length;for(let a=0,l=t.length;a<l;a+=e)s[0]=t[a],s[1]=t[a+1],_i(i,s)&&(r[o++]=s[0],r[o++]=s[1]);return o}appendFlatLineCoordinates(t,e,i,s,r,o){const a=this.coordinates;let l=a.length;const c=this.getBufferedMaxExtent();o&&(e+=s);let h=t[e],u=t[e+1];const d=this.tmpCoordinate_;let f=!0,g,_,m;for(g=e+s;g<i;g+=s)d[0]=t[g],d[1]=t[g+1],m=Ds(c,d),m!==_?(f&&(a[l++]=h,a[l++]=u,f=!1),a[l++]=d[0],a[l++]=d[1]):m===ht.INTERSECTING?(a[l++]=d[0],a[l++]=d[1],f=!1):f=!0,h=d[0],u=d[1],_=m;return(r&&f||g===e+s)&&(a[l++]=h,a[l++]=u),l}drawCustomCoordinates_(t,e,i,s,r){for(let o=0,a=i.length;o<a;++o){const l=i[o],c=this.appendFlatLineCoordinates(t,e,l,s,!1,!1);r.push(c),e=l}return e}drawCustom(t,e,i,s,r){this.beginGeometry(t,e,r);const o=t.getType(),a=t.getStride(),l=this.coordinates.length;let c,h,u,d,f;switch(o){case"MultiPolygon":c=t.getOrientedFlatCoordinates(),d=[];const g=t.getEndss();f=0;for(let _=0,m=g.length;_<m;++_){const p=[];f=this.drawCustomCoordinates_(c,f,g[_],a,p),d.push(p)}this.instructions.push([P.CUSTOM,l,d,t,i,Jr,r]),this.hitDetectionInstructions.push([P.CUSTOM,l,d,t,s||i,Jr,r]);break;case"Polygon":case"MultiLineString":u=[],c=o=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),f=this.drawCustomCoordinates_(c,0,t.getEnds(),a,u),this.instructions.push([P.CUSTOM,l,u,t,i,Mn,r]),this.hitDetectionInstructions.push([P.CUSTOM,l,u,t,s||i,Mn,r]);break;case"LineString":case"Circle":c=t.getFlatCoordinates(),h=this.appendFlatLineCoordinates(c,0,c.length,a,!1,!1),this.instructions.push([P.CUSTOM,l,h,t,i,ke,r]),this.hitDetectionInstructions.push([P.CUSTOM,l,h,t,s||i,ke,r]);break;case"MultiPoint":c=t.getFlatCoordinates(),h=this.appendFlatPointCoordinates(c,a),h>l&&(this.instructions.push([P.CUSTOM,l,h,t,i,ke,r]),this.hitDetectionInstructions.push([P.CUSTOM,l,h,t,s||i,ke,r]));break;case"Point":c=t.getFlatCoordinates(),this.coordinates.push(c[0],c[1]),h=this.coordinates.length,this.instructions.push([P.CUSTOM,l,h,t,i,void 0,r]),this.hitDetectionInstructions.push([P.CUSTOM,l,h,t,s||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[P.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[P.BEGIN_GEOMETRY,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;t.reverse();let e;const i=t.length;let s,r,o=-1;for(e=0;e<i;++e)s=t[e],r=s[0],r==P.END_GEOMETRY?o=e:r==P.BEGIN_GEOMETRY&&(s[2]=e,al(this.hitDetectionInstructions,o,e),o=-1)}setFillStrokeStyle(t,e){const i=this.state;if(t){const s=t.getColor();i.fillPatternScale=s&&typeof s=="object"&&"src"in s?this.pixelRatio:1,i.fillStyle=qt(s||Ct)}else i.fillStyle=void 0;if(e){const s=e.getColor();i.strokeStyle=qt(s||qi);const r=e.getLineCap();i.lineCap=r!==void 0?r:pi;const o=e.getLineDash();i.lineDash=o?o.slice():le;const a=e.getLineDashOffset();i.lineDashOffset=a||he;const l=e.getLineJoin();i.lineJoin=l!==void 0?l:yi;const c=e.getWidth();i.lineWidth=c!==void 0?c:Ji;const h=e.getMiterLimit();i.miterLimit=h!==void 0?h:Hi,i.lineWidth>this.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(t){const e=t.fillStyle,i=[P.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[P.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,this.applyPixelRatio(t.lineDash),t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(i!==void 0&&this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,s=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,c=t.miterLimit;(t.currentStrokeStyle!=i||t.currentLineCap!=s||r!=t.currentLineDash&&!Ae(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=c)&&(i!==void 0&&e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=s,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[P.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Xo(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;Hs(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class td extends cn{constructor(t,e,i,s){super(t,e,i,s),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&&!_i(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const s=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(s,r);this.instructions.push([P.DRAW_IMAGE,o,a,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([P.DRAW_IMAGE,o,a,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 s=t.getFlatCoordinates(),r=[];for(let l=0,c=s.length;l<c;l+=t.getStride())(!this.maxExtent||_i(this.maxExtent,s.slice(l,l+2)))&&r.push(s[l],s[l+1]);const o=this.coordinates.length,a=this.appendFlatPointCoordinates(r,2);this.instructions.push([P.DRAW_IMAGE,o,a,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([P.DRAW_IMAGE,o,a,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(e)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,e){const i=t.getAnchor(),s=t.getSize(),r=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=s[1],this.opacity_=t.getOpacity(),this.originX_=r[0],this.originY_=r[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=s[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}class ed extends cn{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinates_(t,e,i,s){const r=this.coordinates.length,o=this.appendFlatLineCoordinates(t,e,i,s,!1,!1),a=[P.MOVE_TO_LINE_TO,r,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([P.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,le,he],ze);const a=t.getFlatCoordinates(),l=t.getStride();this.drawFlatCoordinates_(a,0,a.length,l),this.hitDetectionInstructions.push(Ie),this.endGeometry(e)}drawMultiLineString(t,e,i){const s=this.state,r=s.strokeStyle,o=s.lineWidth;if(r===void 0||o===void 0)return;this.updateStrokeStyle(s,this.applyStroke),this.beginGeometry(t,e,i),this.hitDetectionInstructions.push([P.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,le,he],ze);const a=t.getEnds(),l=t.getFlatCoordinates(),c=t.getStride();let h=0;for(let u=0,d=a.length;u<d;++u)h=this.drawFlatCoordinates_(l,h,a[u],c);this.hitDetectionInstructions.push(Ie),this.endGeometry(e)}finish(){const t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Ie),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Ie),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(ze)}}class Ao extends cn{constructor(t,e,i,s){super(t,e,i,s)}drawFlatCoordinatess_(t,e,i,s){const r=this.state,o=r.fillStyle!==void 0,a=r.strokeStyle!==void 0,l=i.length;this.instructions.push(ze),this.hitDetectionInstructions.push(ze);for(let c=0;c<l;++c){const h=i[c],u=this.coordinates.length,d=this.appendFlatLineCoordinates(t,e,h,s,!0,!a),f=[P.MOVE_TO_LINE_TO,u,d];this.instructions.push(f),this.hitDetectionInstructions.push(f),a&&(this.instructions.push(Lo),this.hitDetectionInstructions.push(Lo)),e=h}return o&&(this.instructions.push(Tn),this.hitDetectionInstructions.push(Tn)),a&&(this.instructions.push(Ie),this.hitDetectionInstructions.push(Ie)),e}drawCircle(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([P.SET_FILL_STYLE,Ct]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([P.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,le,he]);const a=t.getFlatCoordinates(),l=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(a,0,a.length,l,!1,!1);const h=[P.CIRCLE,c];this.instructions.push(ze,h),this.hitDetectionInstructions.push(ze,h),s.fillStyle!==void 0&&(this.instructions.push(Tn),this.hitDetectionInstructions.push(Tn)),s.strokeStyle!==void 0&&(this.instructions.push(Ie),this.hitDetectionInstructions.push(Ie)),this.endGeometry(e)}drawPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([P.SET_FILL_STYLE,Ct]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([P.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,le,he]);const a=t.getEnds(),l=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(l,0,a,c),this.endGeometry(e)}drawMultiPolygon(t,e,i){const s=this.state,r=s.fillStyle,o=s.strokeStyle;if(r===void 0&&o===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),s.fillStyle!==void 0&&this.hitDetectionInstructions.push([P.SET_FILL_STYLE,Ct]),s.strokeStyle!==void 0&&this.hitDetectionInstructions.push([P.SET_STROKE_STYLE,s.strokeStyle,s.lineWidth,s.lineCap,s.lineJoin,s.miterLimit,le,he]);const a=t.getEndss(),l=t.getOrientedFlatCoordinates(),c=t.getStride();let h=0;for(let u=0,d=a.length;u<d;++u)h=this.drawFlatCoordinatess_(l,h,a[u],c);this.endGeometry(e)}finish(){this.reverseHitDetectionInstructions(),this.state=null;const t=this.tolerance;if(t!==0){const e=this.coordinates;for(let i=0,s=e.length;i<s;++i)e[i]=Fe(e[i],t)}return super.finish()}setFillStrokeStyles_(){const t=this.state;t.fillStyle!==void 0&&this.updateFillStyle(t,this.createFill),t.strokeStyle!==void 0&&this.updateStrokeStyle(t,this.applyStroke)}}function id(n,t,e,i,s){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a<n&&o+s<i;){const[c,h]=l.slice(-2),u=t[o+s],d=t[o+s+1],f=Math.sqrt((u-c)*(u-c)+(d-h)*(d-h));if(a+=f,a>=n){const g=(n-a+f)/f,_=St(c,u,g),m=St(h,d,g);l.push(_,m),r.push(l),l=[_,m],a==n&&(o+=s),a=0}else if(a<n)l.push(t[o+s],t[o+s+1]),o+=s;else{const g=f-a,_=St(c,u,g/f),m=St(h,d,g/f);l.push(_,m),r.push(l),l=[_,m],a=0,o+=s}}return a>0&&r.push(l),r}function nd(n,t,e,i,s){let r=e,o=e,a=0,l=0,c=e,h,u,d,f,g,_,m,p,y,x;for(u=e;u<i;u+=s){const E=t[u],w=t[u+1];g!==void 0&&(y=E-g,x=w-_,f=Math.sqrt(y*y+x*x),m!==void 0&&(l+=d,h=Math.acos((m*y+p*x)/(d*f)),h>n&&(l>a&&(a=l,r=c,o=u),l=0,c=u-s)),d=f,m=y,p=x),g=E,_=w}return l+=f,l>a?[c,u]:[r,o]}const Xn={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class sd extends cn{constructor(t,e,i,s){super(t,e,i,s),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Ct]={fillStyle:Ct},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 s=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!s&&!r)return;const a=this.coordinates;let l=a.length;const c=t.getType();let h=null,u=t.getStride();if(o.placement==="line"&&(c=="LineString"||c=="MultiLineString"||c=="Polygon"||c=="MultiPolygon")){if(!Tt(this.maxExtent,t.getExtent()))return;let d;if(h=t.getFlatCoordinates(),c=="LineString")d=[h.length];else if(c=="MultiLineString")d=t.getEnds();else if(c=="Polygon")d=t.getEnds().slice(0,1);else if(c=="MultiPolygon"){const m=t.getEndss();d=[];for(let p=0,y=m.length;p<y;++p)d.push(m[p][0])}this.beginGeometry(t,e,i);const f=o.repeat,g=f?void 0:o.textAlign;let _=0;for(let m=0,p=d.length;m<p;++m){let y;f?y=id(f*this.resolution,h,_,d[m],u):y=[h.slice(_,d[m])];for(let x=0,E=y.length;x<E;++x){const w=y[x];let v=0,T=w.length;if(g==null){const I=nd(o.maxAngle,w,0,w.length,2);v=I[0],T=I[1]}for(let I=v;I<T;I+=u)a.push(w[I],w[I+1]);const R=a.length;_=d[m],this.drawChars_(l,R),l=R}}this.endGeometry(e)}else{let d=o.overflow?null:[];switch(c){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(),u=2;break;case"Polygon":h=t.getFlatInteriorPoint(),o.overflow||d.push(h[2]/this.resolution),u=3;break;case"MultiPolygon":const y=t.getFlatInteriorPoints();h=[];for(let x=0,E=y.length;x<E;x+=3)o.overflow||d.push(y[x+2]/this.resolution),h.push(y[x],y[x+1]);if(h.length===0)return;u=2;break}const f=this.appendFlatPointCoordinates(h,u);if(f===l)return;if(d&&(f-l)/2!==h.length/u){let y=l/2;d=d.filter((x,E)=>{const w=a[(y+E)*2]===h[E*u]&&a[(y+E)*2+1]===h[E*u+1];return w||--y,w})}this.saveTextStates_(),(o.backgroundFill||o.backgroundStroke)&&(this.setFillStrokeStyle(o.backgroundFill,o.backgroundStroke),o.backgroundFill&&this.updateFillStyle(this.state,this.createFill),o.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(t,e,i);let g=o.padding;if(g!=Ge&&(o.scale[0]<0||o.scale[1]<0)){let y=o.padding[0],x=o.padding[1],E=o.padding[2],w=o.padding[3];o.scale[0]<0&&(x=-x,w=-w),o.scale[1]<0&&(y=-y,E=-E),g=[y,x,E,w]}const _=this.pixelRatio;this.instructions.push([P.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,g==Ge?Ge:g.map(function(y){return y*_}),!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const m=1/_,p=this.state.fillStyle;o.backgroundFill&&(this.state.fillStyle=Ct,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([P.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[m,m],NaN,this.declutterMode_,this.declutterImageWithText_,g,!!o.backgroundFill,!!o.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Ct:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),o.backgroundFill&&(this.state.fillStyle=p,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,s=this.strokeKey_;t&&(s in this.strokeStates||(this.strokeStates[s]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||$i,justify:e.justify,textBaseline:e.textBaseline||Dn,scale:e.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(t,e){const i=this.textStrokeState_,s=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,c=Xn[s.textBaseline],h=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(s.scale[0])/2:0;this.instructions.push([P.DRAW_CHARS,t,e,c,s.overflow,a,s.maxAngle,l,h,r,d*l,u,o,1,this.declutterMode_]),this.hitDetectionInstructions.push([P.DRAW_CHARS,t,e,c,s.overflow,a&&Ct,s.maxAngle,l,h,r,d*l,u,o,1/l,this.declutterMode_])}setTextStyle(t,e){let i,s,r;if(!t)this.text_="";else{const o=t.getFill();o?(s=this.textFillState_,s||(s={},this.textFillState_=s),s.fillStyle=qt(o.getColor()||Ct)):(s=null,this.textFillState_=s);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const g=a.getLineDash(),_=a.getLineDashOffset(),m=a.getWidth(),p=a.getMiterLimit();r.lineCap=a.getLineCap()||pi,r.lineDash=g?g.slice():le,r.lineDashOffset=_===void 0?he:_,r.lineJoin=a.getLineJoin()||yi,r.lineWidth=m===void 0?Ji:m,r.miterLimit=p===void 0?Hi:p,r.strokeStyle=qt(a.getColor()||qi)}i=this.textState_;const l=t.getFont()||ma;Wh(l);const c=t.getScaleArray();i.overflow=t.getOverflow(),i.font=l,i.maxAngle=t.getMaxAngle(),i.placement=t.getPlacement(),i.textAlign=t.getTextAlign(),i.repeat=t.getRepeat(),i.justify=t.getJustify(),i.textBaseline=t.getTextBaseline()||Dn,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||Ge,i.scale=c===void 0?[1,1]:c;const h=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textRotation_=f===void 0?0:f,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:$(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=s&&s.fillStyle?typeof s.fillStyle=="string"?s.fillStyle:"|"+$(s.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const rd={Circle:Ao,Default:cn,Image:td,LineString:ed,Polygon:Ao,Text:sd};class od{constructor(t,e,i,s){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=s,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const s in i){const r=i[s].finish();t[e][s]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let s=this.buildersByZIndex_[i];s===void 0&&(s={},this.buildersByZIndex_[i]=s);let r=s[e];if(r===void 0){const o=rd[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),s[e]=r}return r}}function ad(n,t,e,i,s,r,o,a,l,c,h,u){let d=n[t],f=n[t+1],g=0,_=0,m=0,p=0;function y(){g=d,_=f,t+=i,d=n[t],f=n[t+1],p+=m,m=Math.sqrt((d-g)*(d-g)+(f-_)*(f-_))}do y();while(t<e-i&&p+m<r);let x=m===0?0:(r-p)/m;const E=St(g,d,x),w=St(_,f,x),v=t-i,T=p,R=r+a*l(c,s,h);for(;t<e-i&&p+m<R;)y();x=m===0?0:(R-p)/m;const I=St(g,d,x),G=St(_,f,x);let D;if(u){const L=[E,w,I,G];ta(L,0,4,2,u,L,L),D=L[0]>L[2]}else D=E>I;const b=Math.PI,O=[],A=v+i===t;t=v,m=0,p=T,d=n[t],f=n[t+1];let F;if(A){y(),F=Math.atan2(f-_,d-g),D&&(F+=F>0?-b:b);const L=(I+E)/2,Z=(G+w)/2;return O[0]=[L,Z,(R-r)/2,F,s],O}s=s.replace(/\n/g," ");for(let L=0,Z=s.length;L<Z;){y();let K=Math.atan2(f-_,d-g);if(D&&(K+=K>0?-b:b),F!==void 0){let S=K-F;if(S+=S>b?-2*b:S<-b?2*b:0,Math.abs(S)>o)return null}F=K;const et=L;let k=0;for(;L<Z;++L){const S=D?Z-L-1:L,xt=a*l(c,s[S],h);if(t+i<e&&p+m<r+k+xt/2)break;k+=xt}if(L===et)continue;const X=D?s.substring(Z-et,Z-L):s.substring(et,L);x=m===0?0:(r+k/2-p)/m;const Q=St(g,d,x),ct=St(_,f,x);O.push([Q,ct,k/2,K,X]),r+=k}return O}const ei=Ft(),ye=[],ie=[],ne=[],Ee=[];function Mo(n){return n[3].declutterBox}const bo=new RegExp("[֑-ࣿיִ-﷿ﹰ-ﻼࠀ--]");function As(n,t){return t==="start"?t=bo.test(n)?"right":"left":t==="end"&&(t=bo.test(n)?"left":"right"),Xn[t]}function ld(n,t,e){return e>0&&n.push(`
|
||
`,""),n.push(t,""),n}class hd{constructor(t,e,i,s,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=s.instructions,this.coordinates=s.coordinates,this.coordinateCache_={},this.renderedTransform_=Wt(),this.hitDetectionInstructions=s.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=s.fillStates||{},this.strokeStates=s.strokeStates||{},this.textStates=s.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new Za:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,s){const r=t+e+i+s;if(this.labels_[r])return this.labels_[r];const o=s?this.strokeStates[s]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],c=this.pixelRatio,h=[l.scale[0]*c,l.scale[1]*c],u=l.justify?Xn[l.justify]:As(Array.isArray(t)?t[0]:t,l.textAlign||$i),d=s&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(`
|
||
`).reduce(ld,[]),{width:g,height:_,widths:m,heights:p,lineWidths:y}=Zh(l,f),x=g+d,E=[],w=(x+2)*h[0],v=(_+d)*h[1],T={width:w<0?Math.floor(w):Math.ceil(w),height:v<0?Math.floor(v):Math.ceil(v),contextInstructions:E};(h[0]!=1||h[1]!=1)&&E.push("scale",h),s&&(E.push("strokeStyle",o.strokeStyle),E.push("lineWidth",d),E.push("lineCap",o.lineCap),E.push("lineJoin",o.lineJoin),E.push("miterLimit",o.miterLimit),E.push("setLineDash",[o.lineDash]),E.push("lineDashOffset",o.lineDashOffset)),i&&E.push("fillStyle",a.fillStyle),E.push("textBaseline","middle"),E.push("textAlign","center");const R=.5-u;let I=u*x+R*d;const G=[],D=[];let b=0,O=0,A=0,F=0,L;for(let Z=0,K=f.length;Z<K;Z+=2){const et=f[Z];if(et===`
|
||
`){O+=b,b=0,I=u*x+R*d,++F;continue}const k=f[Z+1]||l.font;k!==L&&(s&&G.push("font",k),i&&D.push("font",k),L=k),b=Math.max(b,p[A]);const X=[et,I+R*m[A]+u*(m[A]-y[F]),.5*(d+b)+O];I+=m[A],s&&G.push("strokeText",X),i&&D.push("fillText",X),++A}return Array.prototype.push.apply(E,G),Array.prototype.push.apply(E,D),this.labels_[r]=T,T}replayTextBackground_(t,e,i,s,r,o,a){t.beginPath(),t.moveTo.apply(t,e),t.lineTo.apply(t,i),t.lineTo.apply(t,s),t.lineTo.apply(t,r),t.lineTo.apply(t,e),o&&(this.alignAndScaleFill_=o[2],this.fill_(t)),a&&(this.setStrokeStyle_(t,a),t.stroke())}calculateImageOrLabelDimensions_(t,e,i,s,r,o,a,l,c,h,u,d,f,g,_,m){a*=d[0],l*=d[1];let p=i-a,y=s-l;const x=r+c>t?t-c:r,E=o+h>e?e-h:o,w=g[3]+x*d[0]+g[1],v=g[0]+E*d[1]+g[2],T=p-g[3],R=y-g[0];(_||u!==0)&&(ye[0]=T,Ee[0]=T,ye[1]=R,ie[1]=R,ie[0]=T+w,ne[0]=ie[0],ne[1]=R+v,Ee[1]=ne[1]);let I;return u!==0?(I=de(Wt(),i,s,1,1,u,-i,-s),dt(I,ye),dt(I,ie),dt(I,ne),dt(I,Ee),Se(Math.min(ye[0],ie[0],ne[0],Ee[0]),Math.min(ye[1],ie[1],ne[1],Ee[1]),Math.max(ye[0],ie[0],ne[0],Ee[0]),Math.max(ye[1],ie[1],ne[1],Ee[1]),ei)):Se(Math.min(T,T+w),Math.min(R,R+v),Math.max(T,T+w),Math.max(R,R+v),ei),f&&(p=Math.round(p),y=Math.round(y)),{drawImageX:p,drawImageY:y,drawImageW:x,drawImageH:E,originX:c,originY:h,declutterBox:{minX:ei[0],minY:ei[1],maxX:ei[2],maxY:ei[3],value:m},canvasTransform:I,scale:d}}replayImageOrLabel_(t,e,i,s,r,o,a){const l=!!(o||a),c=s.declutterBox,h=a?a[2]*s.scale[0]/2:0;return c.minX-h<=e[0]&&c.maxX+h>=0&&c.minY-h<=e[1]&&c.maxY+h>=0&&(l&&this.replayTextBackground_(t,ye,ie,ne,Ee,o,a),Kh(t,s.canvasTransform,r,i,s.originX,s.originY,s.drawImageW,s.drawImageH,s.drawImageX,s.drawImageY,s.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=dt(this.renderedTransform_,[0,0]),s=512*this.pixelRatio;t.save(),t.translate(i[0]%s,i[1]%s),e!==1&&t.scale(e,e),t.rotate(this.viewRotation_)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6])}drawLabelWithPointPlacement_(t,e,i,s){const r=this.textStates[e],o=this.createLabel(t,e,s,i),a=this.strokeStates[i],l=this.pixelRatio,c=As(Array.isArray(t)?t[0]:t,r.textAlign||$i),h=Xn[r.textBaseline||Dn],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=c*d+2*(.5-c)*u,g=h*o.height/l+2*(.5-h)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,s,r,o,a,l){const c=this.zIndexContext_;let h;this.pixelCoordinates_&&Ae(i,this.renderedTransform_)?h=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),h=ve(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Bl(this.renderedTransform_,i));let u=0;const d=s.length;let f=0,g,_,m,p,y,x,E,w,v,T,R,I,G,D=0,b=0,O=null,A=null;const F=this.coordinateCache_,L=this.viewRotation_,Z=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,K={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:L},et=this.instructions!=s||this.overlaps?0:200;let k,X,Q,ct;for(;u<d;){const S=s[u];switch(S[0]){case P.BEGIN_GEOMETRY:k=S[1],ct=S[3],k.getGeometry()?a!==void 0&&!Tt(a,ct.getExtent())?u=S[2]+1:++u:u=S[2],c&&(c.zIndex=S[4]);break;case P.BEGIN_PATH:D>et&&(this.fill_(t),D=0),b>et&&(t.stroke(),b=0),!D&&!b&&(t.beginPath(),y=NaN,x=NaN),++u;break;case P.CIRCLE:f=S[1];const ut=h[f],at=h[f+1],Zt=h[f+2],Jt=h[f+3],Lt=Zt-ut,_e=Jt-at,Ri=Math.sqrt(Lt*Lt+_e*_e);t.moveTo(ut+Ri,at),t.arc(ut,at,Ri,0,2*Math.PI,!0),++u;break;case P.CLOSE_PATH:t.closePath(),++u;break;case P.CUSTOM:f=S[1],g=S[2];const un=S[3],rs=S[4],Ti=S[5];K.geometry=un,K.feature=k,u in F||(F[u]=[]);const Me=F[u];Ti?Ti(h,f,g,2,Me):(Me[0]=h[f],Me[1]=h[f+1],Me.length=2),c&&(c.zIndex=S[6]),rs(Me,K),++u;break;case P.DRAW_IMAGE:f=S[1],g=S[2],v=S[3],_=S[4],m=S[5];let At=S[6];const Kt=S[7],Ke=S[8],Be=S[9],Ii=S[10];let be=S[11];const Ve=S[12];let Ue=S[13];p=S[14]||"declutter";const lt=S[15];if(!v&&S.length>=20){T=S[19],R=S[20],I=S[21],G=S[22];const Mt=this.drawLabelWithPointPlacement_(T,R,I,G);v=Mt.label,S[3]=v;const De=S[23];_=(Mt.anchorX-De)*this.pixelRatio,S[4]=_;const bt=S[24];m=(Mt.anchorY-bt)*this.pixelRatio,S[5]=m,At=v.height,S[6]=At,Ue=v.width,S[13]=Ue}let os;S.length>25&&(os=S[25]);let as,dn,fn;S.length>17?(as=S[16],dn=S[17],fn=S[18]):(as=Ge,dn=!1,fn=!1),Ii&&Z?be+=L:!Ii&&!Z&&(be-=L);let $a=0;for(;f<g;f+=2){if(os&&os[$a++]<Ue/this.pixelRatio)continue;const Mt=this.calculateImageOrLabelDimensions_(v.width,v.height,h[f],h[f+1],Ue,At,_,m,Ke,Be,be,Ve,r,as,dn||fn,k),De=[t,e,v,Mt,Kt,dn?O:null,fn?A:null];if(l){let bt,Bt,Dt;if(lt){const it=g-f;if(!lt[it]){lt[it]={args:De,declutterMode:p};continue}const yt=lt[it];bt=yt.args,Bt=yt.declutterMode,delete lt[it],Dt=Mo(bt)}let Qt,te;if(bt&&(Bt!=="declutter"||!l.collides(Dt))&&(Qt=!0),(p!=="declutter"||!l.collides(Mt.declutterBox))&&(te=!0),Bt==="declutter"&&p==="declutter"){const it=Qt&&te;Qt=it,te=it}Qt&&(Bt!=="none"&&l.insert(Dt),this.replayImageOrLabel_.apply(this,bt)),te&&(p!=="none"&&l.insert(Mt.declutterBox),this.replayImageOrLabel_.apply(this,De))}else this.replayImageOrLabel_.apply(this,De)}++u;break;case P.DRAW_CHARS:const Ar=S[1],Mr=S[2],ls=S[3],Ja=S[4];G=S[5];const Qa=S[6],br=S[7],Dr=S[8];I=S[9];const hs=S[10];T=S[11],R=S[12];const Pr=[S[13],S[13]];p=S[14]||"declutter";const cs=this.textStates[R],vi=cs.font,Si=[cs.scale[0]*br,cs.scale[1]*br];let Li;vi in this.widths_?Li=this.widths_[vi]:(Li={},this.widths_[vi]=Li);const Or=Ba(h,Ar,Mr,2),Fr=Math.abs(Si[0])*ho(vi,T,Li);if(Ja||Fr<=Or){const Mt=this.textStates[R].textAlign,De=(Or-Fr)*As(T,Mt),bt=ad(h,Ar,Mr,2,T,De,Qa,Math.abs(Si[0]),ho,vi,Li,Z?0:this.viewRotation_);t:if(bt){const Bt=[];let Dt,Qt,te,it,yt;if(I)for(Dt=0,Qt=bt.length;Dt<Qt;++Dt){yt=bt[Dt],te=yt[4],it=this.createLabel(te,R,"",I),_=yt[2]+(Si[0]<0?-hs:hs),m=ls*it.height+(.5-ls)*2*hs*Si[1]/Si[0]-Dr;const ee=this.calculateImageOrLabelDimensions_(it.width,it.height,yt[0],yt[1],it.width,it.height,_,m,0,0,yt[3],Pr,!1,Ge,!1,k);if(l&&p==="declutter"&&l.collides(ee.declutterBox))break t;Bt.push([t,e,it,ee,1,null,null])}if(G)for(Dt=0,Qt=bt.length;Dt<Qt;++Dt){yt=bt[Dt],te=yt[4],it=this.createLabel(te,R,G,""),_=yt[2],m=ls*it.height-Dr;const ee=this.calculateImageOrLabelDimensions_(it.width,it.height,yt[0],yt[1],it.width,it.height,_,m,0,0,yt[3],Pr,!1,Ge,!1,k);if(l&&p==="declutter"&&l.collides(ee.declutterBox))break t;Bt.push([t,e,it,ee,1,null,null])}l&&p!=="none"&&l.load(Bt.map(Mo));for(let ee=0,tl=Bt.length;ee<tl;++ee)this.replayImageOrLabel_.apply(this,Bt[ee])}}++u;break;case P.END_GEOMETRY:if(o!==void 0){k=S[1];const Mt=o(k,ct,p);if(Mt)return Mt}++u;break;case P.FILL:et?D++:this.fill_(t),++u;break;case P.MOVE_TO_LINE_TO:for(f=S[1],g=S[2],X=h[f],Q=h[f+1],t.moveTo(X,Q),y=X+.5|0,x=Q+.5|0,f+=2;f<g;f+=2)X=h[f],Q=h[f+1],E=X+.5|0,w=Q+.5|0,(f==g-2||E!==y||w!==x)&&(t.lineTo(X,Q),y=E,x=w);++u;break;case P.SET_FILL_STYLE:O=S,this.alignAndScaleFill_=S[2],D&&(this.fill_(t),D=0,b&&(t.stroke(),b=0)),t.fillStyle=S[1],++u;break;case P.SET_STROKE_STYLE:A=S,b&&(t.stroke(),b=0),this.setStrokeStyle_(t,S),++u;break;case P.STROKE:et?b++:t.stroke(),++u;break;default:++u;break}}D&&this.fill_(t),b&&t.stroke()}execute(t,e,i,s,r,o){this.viewRotation_=s,this.execute_(t,e,i,this.instructions,r,void 0,void 0,o)}executeHitDetection(t,e,i,s,r){return this.viewRotation_=i,this.execute_(t,[t.canvas.width,t.canvas.height],e,this.hitDetectionInstructions,!0,s,r)}}const li=["Polygon","Circle","LineString","Image","Text","Default"],Ua=["Image","Text"],cd=li.filter(n=>!Ua.includes(n));class ud{constructor(t,e,i,s,r,o,a){this.maxExtent_=t,this.overlaps_=s,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=Wt(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(r,a)}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 s=this.executorsByZIndex_[i];s===void 0&&(s={},this.executorsByZIndex_[i]=s);const r=t[i];for(const o in r){const a=r[o];s[o]=new hd(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let s=0,r=t.length;s<r;++s)if(t[s]in i)return!0}return!1}forEachFeatureAtCoordinate(t,e,i,s,r,o){s=Math.round(s);const a=s*2+1,l=de(this.hitDetectionTransform_,s+.5,s+.5,1/e,-1/e,-i,-t[0],-t[1]),c=!this.hitDetectionContext_;c&&(this.hitDetectionContext_=rt(a,a,void 0,{willReadFrequently:!0}));const h=this.hitDetectionContext_;h.canvas.width!==a||h.canvas.height!==a?(h.canvas.width=a,h.canvas.height=a):c||h.clearRect(0,0,a,a);let u;this.renderBuffer_!==void 0&&(u=Ft(),zi(u,t),Hs(u,e*(this.renderBuffer_+s),u));const d=dd(s);let f;function g(w,v,T){const R=h.getImageData(0,0,a,a).data;for(let I=0,G=d.length;I<G;I++)if(R[d[I]]>0){if(!o||T==="none"||f!=="Image"&&f!=="Text"||o.includes(w)){const D=(d[I]-3)/4,b=s-D%a,O=s-(D/a|0),A=r(w,v,b*b+O*O);if(A)return A}h.clearRect(0,0,a,a);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(ae);let m,p,y,x,E;for(m=_.length-1;m>=0;--m){const w=_[m].toString();for(y=this.executorsByZIndex_[w],p=li.length-1;p>=0;--p)if(f=li[p],x=y[f],x!==void 0&&(E=x.executeHitDetection(h,l,i,g,u),E))return E}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],s=e[1],r=e[2],o=e[3],a=[i,s,i,o,r,o,r,s];return ve(a,0,8,2,t,a),a}isEmpty(){return gi(this.executorsByZIndex_)}execute(t,e,i,s,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(ae),o=o||li;const c=li.length;let h,u,d,f,g;for(a&&l.reverse(),h=0,u=l.length;h<u;++h){const _=l[h].toString();for(g=this.executorsByZIndex_[_],d=0,f=o.length;d<f;++d){const m=o[d],p=g[m];if(p!==void 0){const y=a===null?void 0:p.getZIndexContext(),x=y?y.getContext():t,E=this.maxExtent_&&m!=="Image"&&m!=="Text";if(E&&(x.save(),this.clip(x,i)),!y||m==="Text"||m==="Image"?p.execute(x,e,i,s,r,a):y.pushFunction(w=>p.execute(w,e,i,s,r,a)),E&&x.restore(),y){y.offset();const w=l[h]*c+d;this.deferredZIndexContexts_[w]||(this.deferredZIndexContexts_[w]=[]),this.deferredZIndexContexts_[w].push(y)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(ae);for(let i=0,s=e.length;i<s;++i)t[e[i]].forEach(r=>{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const Ms={};function dd(n){if(Ms[n]!==void 0)return Ms[n];const t=n*2+1,e=n*n,i=new Array(e+1);for(let r=0;r<=n;++r)for(let o=0;o<=n;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+r)*t+(n+o))*4+3),r>0&&l.push(((n-r)*t+(n+o))*4+3),o>0&&(l.push(((n+r)*t+(n-o))*4+3),r>0&&l.push(((n-r)*t+(n-o))*4+3))}const s=[];for(let r=0,o=i.length;r<o;++r)i[r]&&s.push(...i[r]);return Ms[n]=s,s}class fd extends Va{constructor(t,e,i,s,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=s,this.transformRotation_=s?Vs(Math.atan2(s[1],s[0]),10):0,this.viewRotation_=r,this.squaredTolerance_=o,this.userTransform_=a,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_=Wt()}drawImages_(t,e,i,s){if(!this.image_)return;const r=ve(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let c=this.imageRotation_;this.transformRotation_===0&&(c-=this.viewRotation_),this.imageRotateWithView_&&(c+=this.viewRotation_);for(let h=0,u=r.length;h<u;h+=2){const d=r[h]-this.imageAnchorX_,f=r[h+1]-this.imageAnchorY_;if(c!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){const g=d+this.imageAnchorX_,_=f+this.imageAnchorY_;de(a,g,_,1,1,c,-g,-_),o.save(),o.transform.apply(o,a),o.translate(g,_),o.scale(this.imageScale_[0],this.imageScale_[1]),o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),o.restore()}else o.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,d,f,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(o.globalAlpha=l)}drawText_(t,e,i,s){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);const r=ve(t,e,i,s,this.transform_,this.pixelCoordinates_),o=this.context_;let a=this.textRotation_;for(this.transformRotation_===0&&(a-=this.viewRotation_),this.textRotateWithView_&&(a+=this.viewRotation_);e<i;e+=s){const l=r[e]+this.textOffsetX_,c=r[e+1]+this.textOffsetY_;a!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(o.save(),o.translate(l-this.textOffsetX_,c-this.textOffsetY_),o.rotate(a),o.translate(this.textOffsetX_,this.textOffsetY_),o.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&o.strokeText(this.text_,0,0),this.textFillState_&&o.fillText(this.text_,0,0),o.restore()):(this.textStrokeState_&&o.strokeText(this.text_,l,c),this.textFillState_&&o.fillText(this.text_,l,c))}}moveToLineTo_(t,e,i,s,r){const o=this.context_,a=ve(t,e,i,s,this.transform_,this.pixelCoordinates_);o.moveTo(a[0],a[1]);let l=a.length;r&&(l-=2);for(let c=2;c<l;c+=2)o.lineTo(a[c],a[c+1]);return r&&o.closePath(),i}drawRings_(t,e,i,s){for(let r=0,o=i.length;r<o;++r)e=this.moveToLineTo_(t,e,i[r],s,!0);return e}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Tt(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=Jl(t,this.transform_,this.pixelCoordinates_),i=e[2]-e[0],s=e[3]-e[1],r=Math.sqrt(i*i+s*s),o=this.context_;o.beginPath(),o.arc(e[0],e[1],r,0,2*Math.PI),this.fillState_&&o.fill(),this.strokeState_&&o.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break}}drawFeature(t,e){const i=e.getGeometryFunction()(t);i&&(this.setStyle(e),this.drawGeometry(i))}drawGeometryCollection(t){const e=t.getGeometriesArray();for(let i=0,s=e.length;i<s;++i)this.drawGeometry(e[i])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getFlatCoordinates(),i=t.getStride();this.image_&&this.drawImages_(e,0,e.length,i),this.text_!==""&&this.drawText_(e,0,e.length,i)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Tt(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getFlatCoordinates();e.beginPath(),this.moveToLineTo_(i,0,i.length,t.getStride(),!1),e.stroke()}if(this.text_!==""){const e=t.getFlatMidpoint();this.drawText_(e,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));const e=t.getExtent();if(Tt(this.extent_,e)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);const i=this.context_,s=t.getFlatCoordinates();let r=0;const o=t.getEnds(),a=t.getStride();i.beginPath();for(let l=0,c=o.length;l<c;++l)r=this.moveToLineTo_(s,r,o[l],a,!1);i.stroke()}if(this.text_!==""){const i=t.getFlatMidpoints();this.drawText_(i,0,i.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Tt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_;e.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoint();this.drawText_(e,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Tt(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);const e=this.context_,i=t.getOrientedFlatCoordinates();let s=0;const r=t.getEndss(),o=t.getStride();e.beginPath();for(let a=0,l=r.length;a<l;++a){const c=r[a];s=this.drawRings_(i,s,c,o)}this.fillState_&&e.fill(),this.strokeState_&&e.stroke()}if(this.text_!==""){const e=t.getFlatInteriorPoints();this.drawText_(e,0,e.length,2)}}}setContextFillState_(t){const e=this.context_,i=this.contextFillState_;i?i.fillStyle!=t.fillStyle&&(i.fillStyle=t.fillStyle,e.fillStyle=t.fillStyle):(e.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){const e=this.context_,i=this.contextStrokeState_;i?(i.lineCap!=t.lineCap&&(i.lineCap=t.lineCap,e.lineCap=t.lineCap),Ae(i.lineDash,t.lineDash)||e.setLineDash(i.lineDash=t.lineDash),i.lineDashOffset!=t.lineDashOffset&&(i.lineDashOffset=t.lineDashOffset,e.lineDashOffset=t.lineDashOffset),i.lineJoin!=t.lineJoin&&(i.lineJoin=t.lineJoin,e.lineJoin=t.lineJoin),i.lineWidth!=t.lineWidth&&(i.lineWidth=t.lineWidth,e.lineWidth=t.lineWidth),i.miterLimit!=t.miterLimit&&(i.miterLimit=t.miterLimit,e.miterLimit=t.miterLimit),i.strokeStyle!=t.strokeStyle&&(i.strokeStyle=t.strokeStyle,e.strokeStyle=t.strokeStyle)):(e.lineCap=t.lineCap,e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset,e.lineJoin=t.lineJoin,e.lineWidth=t.lineWidth,e.miterLimit=t.miterLimit,e.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){const e=this.context_,i=this.contextTextState_,s=t.textAlign?t.textAlign:$i;i?(i.font!=t.font&&(i.font=t.font,e.font=t.font),i.textAlign!=s&&(i.textAlign=s,e.textAlign=s),i.textBaseline!=t.textBaseline&&(i.textBaseline=t.textBaseline,e.textBaseline=t.textBaseline)):(e.font=t.font,e.textAlign=s,e.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:s,textBaseline:t.textBaseline})}setFillStrokeStyle(t,e){if(!t)this.fillState_=null;else{const i=t.getColor();this.fillState_={fillStyle:qt(i||Ct)}}if(!e)this.strokeState_=null;else{const i=e.getColor(),s=e.getLineCap(),r=e.getLineDash(),o=e.getLineDashOffset(),a=e.getLineJoin(),l=e.getWidth(),c=e.getMiterLimit(),h=r||le;this.strokeState_={lineCap:s!==void 0?s:pi,lineDash:this.pixelRatio_===1?h:h.map(u=>u*this.pixelRatio_),lineDashOffset:(o||he)*this.pixelRatio_,lineJoin:a!==void 0?a:yi,lineWidth:(l!==void 0?l:Ji)*this.pixelRatio_,miterLimit:c!==void 0?c:Hi,strokeStyle:qt(i||qi)}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),s=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=s[0]*i,this.imageAnchorY_=s[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 o=t.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=e[0]*i}setTextStyle(t){if(!t)this.text_="";else{const e=t.getFill();if(!e)this.textFillState_=null;else{const f=e.getColor();this.textFillState_={fillStyle:qt(f||Ct)}}const i=t.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),_=i.getLineDash(),m=i.getLineDashOffset(),p=i.getLineJoin(),y=i.getWidth(),x=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:pi,lineDash:_||le,lineDashOffset:m||he,lineJoin:p!==void 0?p:yi,lineWidth:y!==void 0?y:Ji,miterLimit:x!==void 0?x:Hi,strokeStyle:qt(f||qi)}}const s=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),c=t.getScaleArray(),h=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:s!==void 0?s:ma,textAlign:u!==void 0?u:$i,textBaseline:d!==void 0?d:Dn},this.text_=h!==void 0?Array.isArray(h)?h.reduce((f,g,_)=>f+=_%2?" ":g,""):h:"",this.textOffsetX_=r!==void 0?this.pixelRatio_*r:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*c[0],this.pixelRatio_*c[1]]}}}const Ut=.5;function gd(n,t,e,i,s,r,o,a,l){const c=s,h=n[0]*Ut,u=n[1]*Ut,d=rt(h,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new fd(d,Ut,s,null,o,a,null),_=e.length,m=Math.floor((256*256*256-1)/_),p={};for(let x=1;x<=_;++x){const E=e[x-1],w=E.getStyleFunction()||i;if(!w)continue;let v=w(E,r);if(!v)continue;Array.isArray(v)||(v=[v]);const R=(x*m).toString(16).padStart(7,"#00000");for(let I=0,G=v.length;I<G;++I){const D=v[I],b=D.getGeometryFunction()(E);if(!b||!Tt(c,b.getExtent()))continue;const O=D.clone(),A=O.getFill();A&&A.setColor(R);const F=O.getStroke();F&&(F.setColor(R),F.setLineDash(null)),O.setText(void 0);const L=D.getImage();if(L){const k=L.getImageSize();if(!k)continue;const X=rt(k[0],k[1],void 0,{alpha:!1}),Q=X.canvas;X.fillStyle=R,X.fillRect(0,0,Q.width,Q.height),O.setImage(new is({img:Q,anchor:L.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:L.getOrigin(),opacity:1,size:L.getSize(),scale:L.getScale(),rotation:L.getRotation(),rotateWithView:L.getRotateWithView()}))}const Z=O.getZIndex()||0;let K=p[Z];K||(K={},p[Z]=K,K.Polygon=[],K.Circle=[],K.LineString=[],K.Point=[]);const et=b.getType();if(et==="GeometryCollection"){const k=b.getGeometriesArrayRecursive();for(let X=0,Q=k.length;X<Q;++X){const ct=k[X];K[ct.getType().replace("Multi","")].push(ct,O)}}else K[et.replace("Multi","")].push(b,O)}}const y=Object.keys(p).map(Number).sort(ae);for(let x=0,E=y.length;x<E;++x){const w=p[y[x]];for(const v in w){const T=w[v];for(let R=0,I=T.length;R<I;R+=2){g.setStyle(T[R+1]);for(let G=0,D=t.length;G<D;++G)g.setTransform(t[G]),g.drawGeometry(T[R])}}}return d.getImageData(0,0,f.width,f.height)}function _d(n,t,e){const i=[];if(e){const s=Math.floor(Math.round(n[0])*Ut),r=Math.floor(Math.round(n[1])*Ut),o=(st(s,0,e.width-1)+st(r,0,e.height-1)*e.width)*4,a=e.data[o],l=e.data[o+1],h=e.data[o+2]+256*(l+256*a),u=Math.floor((256*256*256-1)/t.length);h&&h%u===0&&i.push(t[h/u-1])}return i}const md=.5,ja={Point:Td,LineString:wd,Polygon:vd,MultiPoint:Id,MultiLineString:Cd,MultiPolygon:Rd,GeometryCollection:xd,Circle:yd};function pd(n,t){return parseInt($(n),10)-parseInt($(t),10)}function Do(n,t){const e=Ha(n,t);return e*e}function Ha(n,t){return md*n/t}function yd(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Circle");l.setFillStrokeStyle(r,o),l.drawCircle(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i)}}function Po(n,t,e,i,s,r,o,a){const l=[],c=e.getImage();if(c){let d=!0;const f=c.getImageState();f==Y.LOADED||f==Y.ERROR?d=!1:f==Y.IDLE&&c.load(),d&&l.push(c.ready())}const h=e.getFill();h&&h.loading()&&l.push(h.ready());const u=l.length>0;return u&&Promise.all(l).then(()=>s(null)),Ed(n,t,e,i,r,o,a),u}function Ed(n,t,e,i,s,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,s);if(e.getRenderer())qa(n,l,e,t,o);else{const h=ja[l.getType()];h(n,l,e,t,o,r)}}function qa(n,t,e,i,s){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;a<l;++a)qa(n,o[a],e,i,s);return}n.getBuilder(e.getZIndex(),"Default").drawCustom(t,i,e.getRenderer(),e.getHitDetectionRenderer(),s)}function xd(n,t,e,i,s,r){const o=t.getGeometriesArray();let a,l;for(a=0,l=o.length;a<l;++a){const c=ja[o[a].getType()];c(n,o[a],e,i,s,r)}}function wd(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Cd(n,t,e,i,s){const r=e.getStroke();if(r){const a=n.getBuilder(e.getZIndex(),"LineString");a.setFillStrokeStyle(null,r),a.drawMultiLineString(t,i,s)}const o=e.getText();if(o&&o.getText()){const a=n.getBuilder(e.getZIndex(),"Text");a.setTextStyle(o),a.drawText(t,i,s)}}function Rd(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(o||r){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawMultiPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}function Td(n,t,e,i,s,r){const o=e.getImage(),a=e.getText(),l=a&&a.getText(),c=r&&o&&l?{}:void 0;if(o){if(o.getImageState()!=Y.LOADED)return;const h=n.getBuilder(e.getZIndex(),"Image");h.setImageStyle(o,c),h.drawPoint(t,i,s)}if(l){const h=n.getBuilder(e.getZIndex(),"Text");h.setTextStyle(a,c),h.drawText(t,i,s)}}function Id(n,t,e,i,s,r){const o=e.getImage(),a=o&&o.getOpacity()!==0,l=e.getText(),c=l&&l.getText(),h=r&&a&&c?{}:void 0;if(a){if(o.getImageState()!=Y.LOADED)return;const u=n.getBuilder(e.getZIndex(),"Image");u.setImageStyle(o,h),u.drawMultiPoint(t,i,s)}if(c){const u=n.getBuilder(e.getZIndex(),"Text");u.setTextStyle(l,h),u.drawText(t,i,s)}}function vd(n,t,e,i,s){const r=e.getFill(),o=e.getStroke();if(r||o){const l=n.getBuilder(e.getZIndex(),"Polygon");l.setFillStrokeStyle(r,o),l.drawPolygon(t,i,s)}const a=e.getText();if(a&&a.getText()){const l=n.getBuilder(e.getZIndex(),"Text");l.setTextStyle(a),l.drawText(t,i,s)}}class Sd extends Ka{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Ft(),this.wrappedRenderedExtent_=Ft(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,e,i){const s=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,c=r.rotation,h=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,_=!(g[mt.ANIMATING]||g[mt.INTERACTING]),m=this.context,p=Math.round(q(s)/a*f),y=Math.round(pt(s)/a*f),x=u.getWrapX()&&l.canWrapX(),E=x?q(h):null,w=x?Math.ceil((s[2]-h[2])/E)+1:1;let v=x?Math.floor((s[0]-h[0])/E):0;do{let T=this.getRenderTransform(o,a,0,f,p,y,v*E);e.declutter&&(T=T.slice(0)),t.execute(m,[m.canvas.width,m.canvas.height],T,c,_,i===void 0?li:i?Ua:cd,i?d&&e.declutter[d]:void 0)}while(++v<w)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=rt(this.context.canvas.width,this.context.canvas.height,vo))}resetDrawContext_(){if(this.opacity_!==1){const t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,mi(this.context),vo.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,e){const i=t.layerStatesArray[t.layerIndex];this.opacity_=i.opacity;const s=t.viewState;this.prepareContainer(t,e);const r=this.context,o=this.replayGroup_;let a=o&&!o.isEmpty();if(!a&&!(this.getLayer().hasListener(Ot.PRERENDER)||this.getLayer().hasListener(Ot.POSTRENDER)))return null;if(this.setDrawContext_(),this.preRender(r,t),s.projection,this.clipped_=!1,a&&i.extent&&this.clipping){const l=Te(i.extent);a=Tt(l,t.extent),this.clipped_=a&&!ai(l,t.extent),this.clipped_&&this.clipUnrotated(r,t,l)}return a&&this.renderWorlds(o,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&r.restore(),this.postRender(r,t),this.renderedRotation_!==s.rotation&&(this.renderedRotation_=s.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(e=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),s=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,c=this.getLayer(),h=[],u=i[0]*Ut,d=i[1]*Ut;h.push(this.getRenderTransform(s,r,o,Ut,u,d,0).slice());const f=c.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!ai(g,l)){let _=l[0];const m=q(g);let p=0,y;for(;_<g[0];)--p,y=m*p,h.push(this.getRenderTransform(s,r,o,Ut,u,d,y).slice()),_+=m;for(p=0,_=l[2];_>g[2];)++p,y=m*p,h.push(this.getRenderTransform(s,r,o,Ut,u,d,y).slice()),_-=m}this.hitDetectionImageData_=gd(i,h,this.renderedFeatures_,c.getStyleFunction(),l,r,o,Do(r,this.renderedPixelRatio_))}e(_d(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,s,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),c={},h=function(g,_,m){const p=$(g),y=c[p];if(y){if(y!==!0&&m<y.distanceSq){if(m===0)return c[p]=!0,r.splice(r.lastIndexOf(y),1),s(g,l,_);y.geometry=_,y.distanceSq=m}}else{if(m===0)return c[p]=!0,s(g,l,_);r.push(c[p]={feature:g,layer:l,geometry:_,distanceSq:m,callback:s})}};let u;const d=[this.replayGroup_],f=this.getLayer().getDeclutter();return d.some(g=>u=g.forEachFeatureAtCoordinate(t,o,a,i,h,f&&e.declutter[f]?e.declutter[f].all().map(_=>_.value):null)),u}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 s=t.viewHints[mt.ANIMATING],r=t.viewHints[mt.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&s||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,c=t.viewState,h=c.projection,u=c.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let _=e.getRenderOrder();_===void 0&&(_=pd);const m=c.center.slice(),p=Hs(l,g*u),y=p.slice(),x=[p.slice()],E=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!ai(E,t.extent)){const A=q(E),F=Math.max(q(p)/2,A);p[0]=E[0]-F,p[2]=E[2]+F,Vo(m,h);const L=Bo(x[0],h);L[0]<E[0]&&L[2]<E[2]?x.push([L[0]+A,L[1],L[2]+A,L[3]]):L[0]>E[0]&&L[2]>E[2]&&x.push([L[0]-A,L[1],L[2]-A,L[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedRevision_==f&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&ai(this.wrappedRenderedExtent_,p))return Ae(this.renderedExtent_,y)||(this.hitDetectionImageData_=null,this.renderedExtent_=y),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const w=new od(Ha(u,d),p,u,d);let v;for(let A=0,F=x.length;A<F;++A)i.loadFeatures(x[A],u,h);const T=Do(u,d);let R=!0;const I=(A,F)=>{let L;const Z=A.getStyleFunction()||e.getStyleFunction();if(Z&&(L=Z(A,u)),L){const K=this.renderFeature(A,T,L,w,v,this.getLayer().getDeclutter(),F);R=R&&!K}},G=$o(p),D=i.getFeaturesInExtent(G);_&&D.sort(_);for(let A=0,F=D.length;A<F;++A)I(D[A],A);this.renderedFeatures_=D,this.ready=R;const b=w.finish(),O=new ud(p,u,d,i.getOverlaps(),b,e.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=u,this.renderedRevision_=f,this.renderedRenderOrder_=_,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=y,this.wrappedRenderedExtent_=p,this.renderedCenter_=m,this.renderedProjection_=h,this.renderedPixelRatio_=d,this.replayGroup_=O,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,e,i,s,r,o,a){if(!i)return!1;let l=!1;if(Array.isArray(i))for(let c=0,h=i.length;c<h;++c)l=Po(s,t,i[c],e,this.boundHandleStyleImageChange_,r,o,a)||l;else l=Po(s,t,i,e,this.boundHandleStyleImageChange_,r,o,a);return l}}class Ld extends va{constructor(t){super(t)}createRenderer(){return new Sd(this)}}class Oo{constructor(t){this.rbush_=new aa(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_[$(e)]=i}load(t,e){const i=new Array(e.length);for(let s=0,r=e.length;s<r;s++){const o=t[s],a=e[s],l={minX:o[0],minY:o[1],maxX:o[2],maxY:o[3],value:a};i[s]=l,this.items_[$(a)]=l}this.rbush_.load(i)}remove(t){const e=$(t),i=this.items_[e];return delete this.items_[e],this.rbush_.remove(i)!==null}update(t,e){const i=this.items_[$(e)],s=[i.minX,i.minY,i.maxX,i.maxY];Yi(s,t)||(this.remove(e),this.insert(t,e))}getAll(){return this.rbush_.all().map(function(e){return e.value})}getInExtent(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(e).map(function(s){return s.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,e){return this.forEach_(this.getInExtent(t),e)}forEach_(t,e){let i;for(let s=0,r=t.length;s<r;s++)if(i=e(t[s]),i)return i;return i}isEmpty(){return gi(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){const e=this.rbush_.toJSON();return Se(e.minX,e.minY,e.maxX,e.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(const e in t.items_)this.items_[e]=t.items_[e]}}function Ad(n,t,e,i){const s=[];let r=Ft();for(let o=0,a=e.length;o<a;++o){const l=e[o];r=$s(n,t,l[0],i),s.push((r[0]+r[2])/2,(r[1]+r[3])/2),t=l[l.length-1]}return s}const Fo=Wt();class Gt{constructor(t,e,i,s,r,o){this.styleFunction,this.extent_,this.id_=o,this.type_=t,this.flatCoordinates_=e,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=i||null,this.properties_=r,this.squaredTolerance_,this.stride_=s,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Yo(this.flatCoordinates_):$s(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Xe(this.getExtent());this.flatInteriorPoints_=hr(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=uh(this.flatCoordinates_,this.ends_),e=Ad(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=ah(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Ks(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let s=0,r=i.length;s<r;++s){const o=i[s],a=Ks(t,e,o,2,.5);Yn(this.flatMidpoints_,a),e=o}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,e){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=kt(t);const e=t.getExtent(),i=t.getWorldExtent();if(e&&i){const s=pt(i)/pt(e);de(Fo,i[0],i[3],s,-s,0,0,0),ve(this.flatCoordinates_,0,this.flatCoordinates_.length,2,Fo,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new Gt(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=No((t,e)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let s;switch(this.type_){case"LineString":i.length=$n(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),s=[i.length];break;case"MultiLineString":s=[],i.length=nh(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,s);break;case"Polygon":s=[],i.length=ea(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,s);break}return s&&(this.simplifiedGeometry_=new Gt(this.type_,i,s,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Gt.prototype.getFlatCoordinates=Gt.prototype.getOrientedFlatCoordinates;const Pt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function Md(n,t){return[[-1/0,-1/0,1/0,1/0]]}let bd=!1;function Dd(n,t,e,i,s,r,o){const a=new XMLHttpRequest;a.open("GET",typeof n=="function"?n(e,i,s):n,!0),t.getType()=="arraybuffer"&&(a.responseType="arraybuffer"),a.withCredentials=bd,a.onload=function(l){if(!a.status||a.status>=200&&a.status<300){const c=t.getType();try{let h;c=="text"||c=="json"?h=a.responseText:c=="xml"?h=a.responseXML||a.responseText:c=="arraybuffer"&&(h=a.response),h?r(t.readFeatures(h,{extent:e,featureProjection:s}),t.readProjection(h)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function ko(n,t){return function(e,i,s,r,o){const a=this;Dd(n,t,e,i,s,function(l,c){a.addFeatures(l),r!==void 0&&r(l)},o||fi)}}class xe extends fe{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class Pd extends za{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=fi,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(j(this.format_,"`format` must be set when `url` is set"),this.loader_=ko(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:Md;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new Oo:null,this.loadedExtentsRtree_=new Oo,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,s;Array.isArray(t.features)?s=t.features:t.features&&(i=t.features,s=i.getArray()),!e&&i===void 0&&(i=new jt(s)),s!==void 0&&this.addFeaturesInternal(s),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=$(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const s=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(s,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new xe(Pt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Gt||(this.featureChangeKeys_[t]=[V(e,z.CHANGE,this.handleFeatureChange_,this),V(e,di.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const s=String(e.getId());if(!(s in this.idIndex_))this.idIndex_[s]=e;else if(e instanceof Gt){const r=this.idIndex_[s];r instanceof Gt?Array.isArray(r)?r.push(e):this.idIndex_[s]=[r,e]:i=!1}else i=!1}return i&&(j(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=e),i}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){const e=[],i=[],s=[];for(let r=0,o=t.length;r<o;r++){const a=t[r],l=$(a);this.addToIndex_(l,a)&&i.push(a)}for(let r=0,o=i.length;r<o;r++){const a=i[r],l=$(a);this.setupChangeEvents_(l,a);const c=a.getGeometry();if(c){const h=c.getExtent();e.push(h),s.push(a)}else this.nullGeometryFeatures_[l]=a}if(this.featuresRtree_&&this.featuresRtree_.load(e,s),this.hasListener(Pt.ADDFEATURE))for(let r=0,o=i.length;r<o;r++)this.dispatchEvent(new xe(Pt.ADDFEATURE,i[r]))}bindFeaturesCollection_(t){let e=!1;this.addEventListener(Pt.ADDFEATURE,function(i){e||(e=!0,t.push(i.feature),e=!1)}),this.addEventListener(Pt.REMOVEFEATURE,function(i){e||(e=!0,t.remove(i.feature),e=!1)}),t.addEventListener(wt.ADD,i=>{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(wt.REMOVE,i=>{e||(e=!0,this.removeFeature(i.element),e=!1)}),this.featuresCollection_=t}clear(t){if(t){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(tt);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const i=s=>{this.removeFeatureInternal(s)};this.featuresRtree_.forEach(i);for(const s in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[s])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new xe(Pt.CLEAR);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(s){const r=s.getGeometry();if(r instanceof Gt||r.intersectsCoordinate(t))return e(s)})}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 s=i.getGeometry();if(s instanceof Gt||s.intersectsExtent(t)){const r=e(i);if(r)return r}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),gi(this.nullGeometryFeatures_)||Yn(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){const e=[];return this.forEachFeatureAtCoordinateDirect(t,function(i){e.push(i)}),e}getFeaturesInExtent(t,e){if(this.featuresRtree_){if(!(e&&e.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);const s=Js(t,e);return[].concat(...s.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],s=t[1];let r=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return e=e||Wi,this.featuresRtree_.forEachInExtent(l,function(c){if(e(c)){const h=c.getGeometry(),u=a;if(a=h instanceof Gt?0:h.closestPointXY(i,s,o,a),a<u){r=c;const d=Math.sqrt(a);l[0]=i-d,l[1]=s-d,l[2]=i+d,l[3]=s+d}}}),r}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){const e=this.idIndex_[t.toString()];return e!==void 0?e:null}getFeatureByUid(t){const e=this.uidIndex_[t];return e!==void 0?e:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){const e=t.target,i=$(e),s=e.getGeometry();if(!s)i in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(e),this.nullGeometryFeatures_[i]=e);else{const o=s.getExtent();i in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[i],this.featuresRtree_&&this.featuresRtree_.insert(o,e)):this.featuresRtree_&&this.featuresRtree_.update(o,e)}const r=e.getId();if(r!==void 0){const o=r.toString();this.idIndex_[o]!==e&&(this.removeFromIdIndex_(e),this.idIndex_[o]=e)}else this.removeFromIdIndex_(e),this.uidIndex_[i]=e;this.changed(),this.dispatchEvent(new xe(Pt.CHANGEFEATURE,e))}hasFeature(t){const e=t.getId();return e!==void 0?e in this.idIndex_:$(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&gi(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,e,i){const s=this.loadedExtentsRtree_,r=this.strategy_(t,e,i);for(let o=0,a=r.length;o<a;++o){const l=r[o];s.forEachInExtent(l,function(h){return ai(h.extent,l)})||(++this.loadingExtentsCount_,this.dispatchEvent(new xe(Pt.FEATURESLOADSTART)),this.loader_.call(this,l,e,i,h=>{--this.loadingExtentsCount_,this.dispatchEvent(new xe(Pt.FEATURESLOADEND,void 0,h))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new xe(Pt.FEATURESLOADERROR))}),s.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){const e=this.loadedExtentsRtree_;let i;e.forEachInExtent(t,function(s){if(Yi(s.extent,t))return i=s,!0}),i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,s=t.length;i<s;++i)e=this.removeFeatureInternal(t[i])||e;e&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){const e=$(t);if(!(e in this.uidIndex_))return!1;e in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[e]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[e]?.forEach(tt),delete this.featureChangeKeys_[e];const s=t.getId();if(s!==void 0){const r=s.toString(),o=this.idIndex_[r];o===t?delete this.idIndex_[r]:Array.isArray(o)&&(o.splice(o.indexOf(t),1),o.length===1&&(this.idIndex_[r]=o[0]))}return delete this.uidIndex_[e],this.hasListener(Pt.REMOVEFEATURE)&&this.dispatchEvent(new xe(Pt.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(const e in this.idIndex_)if(this.idIndex_[e]===t){delete this.idIndex_[e];break}}setLoader(t){this.loader_=t}setUrl(t){j(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(ko(t,this.format_))}}const Od={name:"osmap",props:{type:"",d:Object||Array},data(){return{osmAvailable:!0}},setup(){return{store:il()}},methods:{getLastLonLat(){if(this.type==="traceroute"){const n=this.d.findLast(t=>t.geo&&t.geo.lat&&t.geo.lon);return n?[n.geo.lon,n.geo.lat]:[0,0]}return[this.d.geo.lon,this.d.geo.lat]}},async mounted(){await fetch("https://tile.openstreetmap.org/",{signal:AbortSignal.timeout(1500)}).then(n=>{const t=new cu({target:"map",layers:[new $u({source:new Gu})],view:new Vt({center:us(this.getLastLonLat()),zoom:this.type==="traceroute"?3:10})}),e=[],i=new Pd;if(this.type==="traceroute")console.log(this.getLastLonLat()),this.d.forEach(a=>{if(a.geo&&a.geo.lat&&a.geo.lon){const l=us([a.geo.lon,a.geo.lat]);e.push(l);const c=this.getLastLonLat();console.log(a.geo.lon,a.geo.lat),console.log(a.geo.lon===c[0]&&a.geo.lat===c[1]);const h=new Xi({geometry:new Bi(l),last:a.geo.lon===c[0]&&a.geo.lat===c[1]});i.addFeature(h)}});else{const a=us([this.d.geo.lon,this.d.geo.lat]);e.push(a);const l=new Xi({geometry:new Bi(a)});i.addFeature(l)}const s=new zn(e),r=new Xi({geometry:s});i.addFeature(r);const o=new Ld({source:i,style:function(a){if(a.getGeometry().getType()==="Point")return new ce({image:new on({radius:10,fill:new wi({color:a.get("last")?"#dc3545":"#0d6efd"}),stroke:new Ei({color:"white",width:5})})});if(a.getGeometry().getType()==="LineString")return new ce({stroke:new Ei({color:"#0d6efd",width:2})})}});t.addLayer(o),this.store.Configuration.Server.dashboard_theme==="dark"&&t.on("postcompose",function(a){document.querySelector("#map").style.filter="grayscale(80%) invert(100%) "})}).catch(n=>{this.osmAvailable=!1})}},Fd={key:0,id:"map",class:"w-100 rounded-3"};function kd(n,t,e,i,s,r){return this.osmAvailable?(nl(),sl("div",Fd)):rl("",!0)}const zd=el(Od,[["render",kd]]);export{zd as O};
|