import{c as bt,r as G,j as C,S as ac,a as yl,D as lc,d as hc,R as cc,X as xl,N as uc,b as dc,F as El,O as Cl}from"./index-mUEXKEer.js";import{T as ua,C as da,S as fc}from"./NielsenHeuristics-d7HCIgJi.js";import{S as gc}from"./search-wZFAvndP.js";import{M as wl}from"./map-pin-BhJz-uKs.js";import{E as vl}from"./eye-QHwXAkqY.js";import{E as Rl}from"./eye-off-Dznbbs9G.js";import{U as _c}from"./user-H-bTlvBe.js";const mc=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],pc=bt("activity",mc);const yc=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xc=bt("chevron-up",yc);const Ec=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],Cc=bt("hand",Ec);const wc=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],vc=bt("layers",wc);const Rc=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],fa=bt("loader-circle",Rc);const Sc=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Tc=bt("maximize-2",Sc);const Ic=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],bc=bt("navigation",Ic);const Mc=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],Pc=bt("package",Mc);const Lc=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ac=bt("pencil",Lc);const Oc=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],kc=bt("rotate-ccw",Oc);const Fc=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],Dc=bt("ruler",Fc);const Nc=[["path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z",key:"xwnzip"}],["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h2",key:"1qve2z"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v2",key:"p14lih"}],["path",{d:"M3 14v1",key:"vnatye"}]],Gc=bt("square-dashed-mouse-pointer",Nc);const jc=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],zc=bt("tag",jc);const Xc=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Wc=bt("zoom-in",Xc);const Yc=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Uc=bt("zoom-out",Yc);function Sl(...s){console.warn(...s)}const gt={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Wr(s){const t=Vt();for(let e=0,i=s.length;en&&(l=l|gt.RIGHT),ar&&(l=l|gt.ABOVE),l===gt.UNKNOWN&&(l=gt.INTERSECTING),l}function Vt(){return[1/0,1/0,-1/0,-1/0]}function be(s,t,e,i,n){return n?(n[0]=s,n[1]=t,n[2]=e,n[3]=i,n):[s,t,e,i]}function Ln(s){return be(1/0,1/0,-1/0,-1/0,s)}function Il(s,t){const e=s[0],i=s[1];return be(e,i,e,i,t)}function _o(s,t,e,i,n){const r=Ln(n);return Ml(r,s,t,e,i)}function pn(s,t){return s[0]==t[0]&&s[2]==t[2]&&s[1]==t[1]&&s[3]==t[3]}function bl(s,t){return t[0]s[2]&&(s[2]=t[2]),t[1]s[3]&&(s[3]=t[3]),s}function fn(s,t){t[0]s[2]&&(s[2]=t[0]),t[1]s[3]&&(s[3]=t[1])}function Ml(s,t,e,i,n){for(;et[0]?i[0]=s[0]:i[0]=t[0],s[1]>t[1]?i[1]=s[1]:i[1]=t[1],s[2]=t[0]&&s[1]<=t[3]&&s[3]>=t[1]}function An(s){return s[2]=o&&_<=l),!i&&r>.RIGHT&&!(n>.RIGHT)&&(m=f-(d-l)*g,i=m>=a&&m<=h),!i&&r>.BELOW&&!(n>.BELOW)&&(_=d-(f-a)/g,i=_>=o&&_<=l),!i&&r>.LEFT&&!(n>.LEFT)&&(m=f-(d-o)*g,i=m>=a&&m<=h)}return i}function Ll(s,t){const e=t.getExtent(),i=Ue(s);if(t.canWrapX()&&(i[0]=e[2])){const n=st(e),o=Math.floor((i[0]-e[0])/n)*n;s[0]-=o,s[2]-=o}return s}function Al(s,t,e){if(t.canWrapX()){const i=t.getExtent();if(!isFinite(s[0])||!isFinite(s[2]))return[[i[0],s[1],i[2],s[3]]];Ll(s,t);const n=st(i);if(st(s)>n&&!e)return[[i[0],s[1],i[2],s[3]]];if(s[0]i[2])return[[s[0],s[1],i[2],s[3]],[i[0],s[1],s[2]-n,s[3]]]}return[s]}function at(s,t,e){return Math.min(Math.max(s,t),e)}function Hc(s,t,e,i,n,r){const o=n-e,a=r-i;if(o!==0||a!==0){const l=((s-e)*o+(t-i)*a)/(o*o+a*a);l>1?(e=n,i=r):l>0&&(e+=o*l,i+=a*l)}return ve(s,t,e,i)}function ve(s,t,e,i){const n=e-s,r=i-t;return n*n+r*r}function $c(s){const t=s.length;for(let i=0;ir&&(r=l,n=a)}if(r===0)return null;const o=s[n];s[n]=s[i],s[i]=o;for(let a=i+1;a=0;i--){e[i]=s[i][t]/s[i][i];for(let n=i-1;n>=0;n--)s[n][t]-=s[n][i]*e[i]}return e}function ga(s){return s*180/Math.PI}function Qt(s){return s*Math.PI/180}function ni(s,t){const e=s%t;return e*t<0?e+t:e}function Nt(s,t,e){return s+e*(t-s)}function On(s,t){const e=Math.pow(10,t);return Math.round(s*e)/e}function qn(s,t){return Math.floor(On(s,t))}function Jn(s,t){return Math.ceil(On(s,t))}function Zr(s,t,e){if(s>=t&&s=0;--i)if(s[i]!=t[i]){e=!1;break}return e}function po(s,t){const e=Math.cos(t),i=Math.sin(t),n=s[0]*e-s[1]*i,r=s[1]*e+s[0]*i;return s[0]=n,s[1]=r,s}function tu(s,t){return s[0]*=t,s[1]*=t,s}function Ol(s,t){const e=s[0]-t[0],i=s[1]-t[1];return e*e+i*i}function kl(s,t){return Math.sqrt(Ol(s,t))}function eu(s,t){return Qc(s,"{x}, {y}",t)}function yo(s,t){if(t.canWrapX()){const e=st(t.getExtent()),i=iu(s,t,e);i&&(s[0]-=i*e)}return s}function iu(s,t,e){const i=t.getExtent();let n=0;return t.canWrapX()&&(s[0]i[2])&&(e=e||st(i),n=Math.floor((s[0]-i[0])/e)),n}function nu(s,t,e){const i=Math.sqrt((t[0]-s[0])*(t[0]-s[0])+(t[1]-s[1])*(t[1]-s[1])),n=[(t[0]-s[0])/i,(t[1]-s[1])/i],r=[-n[1],n[0]],o=Math.sqrt((e[0]-s[0])*(e[0]-s[0])+(e[1]-s[1])*(e[1]-s[1])),a=[(e[0]-s[0])/o,(e[1]-s[1])/o];let l=i===0||o===0?0:Math.acos(at(a[0]*n[0]+a[1]*n[1],-1,1));return l=Math.max(l,1e-5),a[0]*r[0]+a[1]*r[1]>0?l:Math.PI*2-l}const Oi={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class xo{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_||Oi[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 kn=6378137,Ti=Math.PI*kn,su=[-Ti,-Ti,Ti,Ti],ru=[-180,-85,180,85],Qn=kn*Math.log(Math.tan(Math.PI/2));class gi extends xo{constructor(t){super({code:t,units:"m",extent:su,global:!0,worldExtent:ru,getPointResolution:function(e,i){return e/Math.cosh(i[1]/kn)}})}}const _a=[new gi("EPSG:3857"),new gi("EPSG:102100"),new gi("EPSG:102113"),new gi("EPSG:900913"),new gi("http://www.opengis.net/def/crs/EPSG/0/3857"),new gi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function ou(s,t,e,i){const n=s.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;rQn?o=Qn:o<-Qn&&(o=-Qn),t[r+1]=o}return t}function au(s,t,e,i){const n=s.length;e=e>1?e:2,i=i??e,t===void 0&&(e>2?t=s.slice():t=new Array(n));for(let r=0;rEa&&(t=Ea);const i=Qt(t),n=Math.sin(i),r=Math.cos(i),o=n/r,a=o*o,l=a*a,h=Qt(s),c=Gl(e.number),u=Qt(c),d=vs/Math.sqrt(1-Kt*n**2),f=Je*r**2,g=r*Zr(h-u,-Math.PI,Math.PI),_=g*g,m=_*g,p=m*g,x=p*g,w=x*g,y=vs*(Nl*i-du*Math.sin(2*i)+fu*Math.sin(4*i)-gu*Math.sin(6*i)),E=ws*d*(g+m/6*(1-a+f)+x/120*(5-18*a+l+72*f-58*Je))+5e5;let T=ws*(y+d*o*(_/2+p/24*(5-a+9*f+4*f**2)+w/720*(61-58*a+l+600*f-330*Je)));return e.north||(T+=1e7),[E,T]}function Gl(s){return(s-1)*6-180+3}const vu=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function jl(s){let t=0;for(const n of vu){const r=s.match(n);if(r){t=parseInt(r[1]);break}}if(!t)return null;let e=0,i=!1;return t>32700&&t<32761?e=t-32700:t>32600&&t<32661&&(i=!0,e=t-32600),e?{number:e,north:i}:null}function Ca(s,t){return function(e,i,n,r){const o=e.length;n=n>1?n:2,r=r??n,i||(n>2?i=e.slice():i=new Array(o));for(let a=0;a=l?t[o+h]:a[h]}return e})}function Xs(s,t){return Wl(),Ys(s,"EPSG:4326","EPSG:3857")}function va(s,t){const e=Ys(s,"EPSG:3857","EPSG:4326"),i=e[0];return(i<-180||i>180)&&(e[0]=ni(i+180,360)-180),e}function gn(s,t){if(s===t)return!0;const e=s.getUnits()===t.getUnits();return(s.getCode()===t.getCode()||Ws(s,t)===vo)&&e}function Ws(s,t){const e=s.getCode(),i=t.getCode();let n=ur(e,i);if(n)return n;let r=null,o=null;for(const l of Tu)r||(r=l(s)),o||(o=l(t));if(!r&&!o)return null;const a="EPSG:4326";if(o)if(r)n=fr(r.inverse,o.forward);else{const l=ur(e,a);l&&(n=fr(l,o.forward))}else{const l=ur(a,i);l&&(n=fr(r.inverse,l))}return n&&($r(s),$r(t),yn(s,t,n)),n}function fr(s,t){return function(e,i,n,r){return i=s(e,i,n,r),t(i,i,n,r)}}function xn(s,t){const e=ht(s),i=ht(t);return Ws(e,i)}function Ys(s,t,e){const i=xn(t,e);if(!i){const n=ht(t).getCode(),r=ht(e).getCode();throw new Error(`No transform available between ${n} and ${r}`)}return i(s,void 0,s.length)}function qr(s,t){return s}function qt(s,t){return Hr&&!Cs(s,[0,0])&&s[0]>=-180&&s[0]<=180&&s[1]>=-90&&s[1]<=90&&(Hr=!1,Sl("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),s}function Yl(s,t){return s}function je(s,t){return s}function Au(){wa(_a),wa(pa),Pu(pa,_a,ou,au)}Au();const Fi={PROPERTYCHANGE:"propertychange"},U={CHANGE:"change",ERROR:"error",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",TOUCHMOVE:"touchmove",WHEEL:"wheel"};class Us{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Ou(s,t,e){let i,n;e=e||Re;let r=0,o=s.length,a=!1;for(;r>1),n=+e(s[i],t),n<0?r=i+1:(o=i,a=!n);return a?r:~r}function Re(s,t){return s>t?1:st?-1:0}function So(s,t,e){if(s[0]<=t)return 0;const i=s.length;if(t<=s[i-1])return i-1;if(typeof e=="function"){for(let n=1;n0?n-1:n}return i-1}if(e>0){for(let n=1;n0||o===0)})}function Di(){return!0}function Xi(){return!1}function En(){}function Ul(s){let t,e,i;return function(){const n=Array.prototype.slice.call(arguments);return(!e||this!==i||!Be(n,e))&&(i=this,e=n,t=s.apply(this,arguments)),t}}function Nu(s){function t(){let e;try{e=s()}catch(i){return Promise.reject(i)}return e instanceof Promise?e:Promise.resolve(e)}return t()}class fe{constructor(t){this.propagationStopped,this.defaultPrevented,this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}class Bs extends Us{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(t){const e=typeof t=="string",i=e?t:t.type,n=this.listeners_&&this.listeners_[i];if(!n)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 h=0,c=n.length;h0:!1}removeEventListener(t,e){if(!this.listeners_)return;const i=this.listeners_[t];if(!i)return;const n=i.indexOf(e);n!==-1&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=En,++this.pendingRemovals_[t]):(i.splice(n,1),i.length===0&&delete this.listeners_[t]))}}function $(s,t,e,i,n){if(n){const o=e;e=function(a){return s.removeEventListener(t,e),o.call(i??this,a)}}else i&&i!==s&&(e=e.bind(i));const r={target:s,type:t,listener:e};return s.addEventListener(t,e),r}function Ss(s,t,e,i){return $(s,t,e,i,!0)}function ot(s){s&&s.target&&(s.target.removeEventListener(s.type,s.listener),Fn(s))}class Dn extends Bs{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(U.CHANGE)}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r{if(!i)return this.getSimplifiedGeometry(e);const n=this.clone();return n.applyTransform(i),n.getSimplifiedGeometry(e)})}simplifyTransformed(t,e){return this.simplifyTransformedInternal(this.getRevision(),t,e)}clone(){return X()}closestPointXY(t,e,i,n){return X()}containsXY(t,e){return this.closestPointXY(t,e,id,Number.MIN_VALUE)===0}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 X()}getExtent(t){if(this.extentRevision_!=this.getRevision()){const e=this.computeExtent(this.extent_);(isNaN(e[0])||isNaN(e[1]))&&Ln(e),this.extentRevision_=this.getRevision()}return Kc(this.extent_,t)}rotate(t,e){X()}scale(t,e,i){X()}simplify(t){return this.getSimplifiedGeometry(t*t)}getSimplifiedGeometry(t){return X()}getType(){return X()}applyTransform(t){X()}intersectsExtent(t){return X()}translate(t,e){X()}transform(t,e){const i=ht(t),n=i.getUnits()=="tile-pixels"?function(r,o,a){const l=i.getExtent(),h=i.getWorldExtent(),c=Tt(h)/Tt(l);Me(Sa,h[0],h[3],c,-c,0,0,0);const u=Ye(r,0,r.length,a,Sa,o),d=xn(i,e);return d?d(u,u,a):u}:xn(i,e);return this.applyTransform(n),this}}class Ze extends Jl{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(t){return _o(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,t)}getCoordinates(){return X()}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=i[0]||t[1]<=i[1]&&t[3]>=i[1]?!0:mo(t,this.intersectsCoordinate.bind(this))}return!1}setCenter(t){const e=this.stride,i=this.flatCoordinates[e]-this.flatCoordinates[0],n=t.slice();n[e]=n[0]+i;for(let r=1;r1)u=e;else if(d>0){for(let f=0;fn&&(n=h),r=a,o=l}return n}function Mo(s,t,e,i,n){for(let r=0,o=e.length;r1?o:2,r=r||new Array(o);for(let c=0;c>1;nr&&(h-a)*(r-l)-(n-a)*(c-l)>0&&o++:c<=r&&(h-a)*(r-l)-(n-a)*(c-l)<0&&o--,a=h,l=c}return o!==0}function Ao(s,t,e,i,n,r){if(e.length===0||!Qe(s,t,e[0],i,n,r))return!1;for(let o=1,a=e.length;o=n[0]&&r[2]<=n[2]||r[1]>=n[1]&&r[3]<=n[3]?!0:eh(s,t,e,i,function(o,a){return Vc(n,o,a)}):!1}function hd(s,t,e,i,n){for(let r=0,o=e.length;r0;){const u=h.pop(),d=h.pop();let f=0;const g=s[d],_=s[d+1],m=s[u],p=s[u+1];for(let x=d+i;xf&&(c=x,f=E)}f>n&&(l[(c-t)/i]=1,d+i0&&_>f)&&(g<0&&m0&&m>g)){h=u,c=d;continue}r[o++]=h,r[o++]=c,a=h,l=c,h=u,c=d}return r[o++]=h,r[o++]=c,o}function ko(s,t,e,i,n,r,o,a){for(let l=0,h=e.length;lp&&(h=(c+u)/2,Ao(s,t,e,i,h,g)&&(m=h,p=x)),c=u}return isNaN(m)&&(m=n[r]),o?(o.push(m,g,p),o):[m,g,p]}function ah(s,t,e,i,n){let r=[];for(let o=0,a=e.length;o0}function No(s,t,e,i,n){n=n!==void 0?n:!1;for(let r=0,o=e.length;r0?t.childNodes[0]:null:Reflect.get(t,e,i)}})}function Xe(s){return typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas}const Ut={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"},B={IDLE:0,LOADING:1,LOADED:2,ERROR:3},Go=[NaN,NaN,NaN,0];let mr;function xd(){return mr||(mr=dt(1,1,void 0,{willReadFrequently:!0,desynchronized:!0})),mr}const Ed=/^rgba?\(\s*(\d+%?)\s+(\d+%?)\s+(\d+%?)(?:\s*\/\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,Cd=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,wd=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(\d+%|\d*\.\d+|[01]))?\s*\)$/i,vd=/^#([\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i;function es(s,t){return s.endsWith("%")?Number(s.substring(0,s.length-1))/t:Number(s)}function _n(s){throw new Error('failed to parse "'+s+'" as color')}function dh(s){if(s.toLowerCase().startsWith("rgb")){const r=s.match(Cd)||s.match(Ed)||s.match(wd);if(r){const o=r[4],a=100/255;return[at(es(r[1],a)+.5|0,0,255),at(es(r[2],a)+.5|0,0,255),at(es(r[3],a)+.5|0,0,255),o!==void 0?at(es(o,100),0,1):1]}_n(s)}if(s.startsWith("#")){if(vd.test(s)){const r=s.substring(1),o=r.length<=4?1:2,a=[0,0,0,255];for(let l=0,h=r.length;l.0031308?Math.pow(s,1/2.4)*269.025-14.025:s*3294.6}function xr(s){return s>.2068965?Math.pow(s,3):(s-4/29)*(108/841)}function Er(s){return s>10.314724?Math.pow((s+14.025)/269.025,2.4):s/3294.6}function Cr(s){return s>.0088564?Math.pow(s,1/3):s/(108/841)+4/29}function Ma(s){const t=Er(s[0]),e=Er(s[1]),i=Er(s[2]),n=Cr(t*.222488403+e*.716873169+i*.06060791),r=500*(Cr(t*.452247074+e*.399439023+i*.148375274)-n),o=200*(n-Cr(t*.016863605+e*.117638439+i*.865350722)),a=Math.atan2(o,r)*(180/Math.PI);return[116*n-16,Math.sqrt(r*r+o*o),a<0?a+360:a,s[3]]}function Id(s){const t=(s[0]+16)/116,e=s[1],i=s[2]*Math.PI/180,n=xr(t),r=xr(t+e/500*Math.cos(i)),o=xr(t-e/200*Math.sin(i)),a=yr(r*3.021973625-n*1.617392459-o*.404875592),l=yr(r*-.943766287+n*1.916279586+o*.027607165),h=yr(r*.069407491-n*.22898585+o*1.159737864);return[at(a+.5|0,0,255),at(l+.5|0,0,255),at(h+.5|0,0,255),s[3]]}function jo(s){if(s==="none")return Go;if(Ji.hasOwnProperty(s))return Ji[s];if(pr>=Sd){let e=0;for(const i in Ji)(e++&3)===0&&(delete Ji[i],--pr)}const t=dh(s);t.length!==4&&_n(s);for(const e of t)isNaN(e)&&_n(s);return Ji[s]=t,++pr,t}function oi(s){return Array.isArray(s)?s:jo(s)}function zo(s){let t=s[0];t!=(t|0)&&(t=t+.5|0);let e=s[1];e!=(e|0)&&(e=e+.5|0);let i=s[2];i!=(i|0)&&(i=i+.5|0);const n=s[3]===void 0?1:Math.round(s[3]*1e3)/1e3;return"rgba("+t+","+e+","+i+","+n+")"}function bd(s,t,e){const i=s;let n=!0,r=!1,o=!1;const a=[Ss(i,U.LOAD,function(){o=!0,r||t()})];return i.src&&Zl?(r=!0,i.decode().then(function(){n&&t()}).catch(function(l){n&&(o?t():e())})):a.push(Ss(i,U.ERROR,e)),function(){n=!1,a.forEach(ot)}}function Md(s,t){return new Promise((e,i)=>{function n(){o(),e(s)}function r(){o(),i(new Error("Image load error"))}function o(){s.removeEventListener("load",n),s.removeEventListener("error",r)}s.addEventListener("load",n),s.addEventListener("error",r)})}function Pd(s,t){return t&&(s.src=t),s.src&&Zl?new Promise((e,i)=>s.decode().then(()=>e(s)).catch(n=>s.complete&&s.width?e(s):i(n))):Md(s)}class Ld{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let t=0;for(const e in this.cache_){const i=this.cache_[e];(t++&3)===0&&!i.hasListener()&&(delete this.cache_[e],delete this.patternCache_[e],--this.cacheSize_)}}}get(t,e){const i=wr(t,e);return i in this.cache_?this.cache_[i]:null}getPattern(t,e){const i=wr(t,e);return i in this.patternCache_?this.patternCache_[i]:null}set(t,e,i,n){const r=wr(t,e),o=r in this.cache_;this.cache_[r]=i,n&&(i.getImageState()===B.IDLE&&i.load(),i.getImageState()===B.LOADING?i.ready().then(()=>{this.patternCache_[r]=Ms().createPattern(i.getImage(1),"repeat")}):this.patternCache_[r]=Ms().createPattern(i.getImage(1),"repeat")),o||++this.cacheSize_}setSize(t){this.maxCacheSize_=t,this.expire()}}function wr(s,t){const e=t?oi(t):"null";return s+":"+e}const Bt=new Ld;let Qi=null;class fh extends Bs{constructor(t,e,i,n,r){super(),this.hitDetectionImage_=null,this.image_=t,this.crossOrigin_=i?.crossOrigin,this.referrerPolicy_=i?.referrerPolicy,this.canvas_={},this.color_=r,this.imageState_=n===void 0?B.IDLE:n,this.size_=t&&t.width&&t.height?[t.width,t.height]:null,this.src_=e,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===B.LOADED){Qi||(Qi=dt(1,1,void 0,{willReadFrequently:!0})),Qi.drawImage(this.image_,0,0);try{Qi.getImageData(0,0,1,1),this.tainted_=!1}catch{Qi=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(U.CHANGE)}handleImageError_(){this.imageState_=B.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=B.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_}setImage(t){this.image_=t}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=dt(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_===B.IDLE){this.image_||this.initializeImage_(),this.imageState_=B.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Pd(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_!==B.LOADED)return;const e=this.image_,i=dt(Math.ceil(e.width*t),Math.ceil(e.height*t)),n=i.canvas;i.scale(t,t),i.drawImage(e,0,0),i.globalCompositeOperation="multiply",i.fillStyle=Rd(this.color_),i.fillRect(0,0,n.width/t,n.height/t),i.globalCompositeOperation="destination-in",i.drawImage(e,0,0),this.canvas_[t]=n}ready(){return this.ready_||(this.ready_=new Promise(t=>{if(this.imageState_===B.LOADED||this.imageState_===B.ERROR)t();else{const e=()=>{(this.imageState_===B.LOADED||this.imageState_===B.ERROR)&&(this.removeEventListener(U.CHANGE,e),t())};this.addEventListener(U.CHANGE,e)}})),this.ready_}}function mn(s,t,e,i,n,r){let o=t===void 0?void 0:Bt.get(t,n);return o||(o=new fh(s,s&&"src"in s?s.src||void 0:t,e,i,n),Bt.set(t,n,o,r)),r&&o&&!Bt.getPattern(t,n)&&Bt.set(t,n,o,r),o}function le(s){return s?Array.isArray(s)?zo(s):typeof s=="object"&&"src"in s?Ad(s):s:null}function Ad(s){if(!s.offset||!s.size)return Bt.getPattern(s.src,s.color);const t=s.src+":"+s.offset,e=Bt.getPattern(t,s.color);if(e)return e;const i=Bt.get(s.src,null);if(i.getImageState()!==B.LOADED)return null;const n=dt(s.size[0],s.size[1]);return n.drawImage(i.getImage(1),s.offset[0],s.offset[1],s.size[0],s.size[1],0,0,s.size[0],s.size[1]),mn(n.canvas,t,void 0,B.LOADED,s.color,!0),Bt.getPattern(t,s.color)}class gh{drawCustom(t,e,i,n,r){}drawGeometry(t){}setStyle(t){}drawCircle(t,e,i){}drawFeature(t,e,i){}drawGeometryCollection(t,e,i){}drawLineString(t,e,i){}drawMultiLineString(t,e,i){}drawMultiPoint(t,e,i){}drawMultiPolygon(t,e,i){}drawPoint(t,e,i){}drawPolygon(t,e,i){}drawText(t,e,i){}setFillStrokeStyle(t,e){}setImageStyle(t,e){}setTextStyle(t,e){}}const is="ol-hidden",Od="ol-selectable",jn="ol-unselectable",Xo="ol-control",Pa="ol-collapsed",kd=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-z0-9]+?)\\s*$`].join(""),"i"),La=["style","variant","weight","size","lineHeight","family"],so={normal:400,bold:700},ro=function(s){const t=s.match(kd);if(!t)return null;const e={lineHeight:"normal",size:"1.2em",style:"normal",weight:"400",variant:"normal"};for(let i=0,n=La.length;ii.trim().replace(/^['"]|['"]$/g,"")),e},_h="10px sans-serif",Lt="#000",ji="round",Te=[],Ie=0,zi="round",vn=10,Fd=0,Rn="#000",Sn="center",Ps="middle",ti=[0,0,0,0],Tn=1,wi=new ie;let tn=null,Aa;const oo={},Dd=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"]);function Nd(s,t,e){return`${s} ${t} 16px "${e}"`}const Gd=(function(){let t,e;async function i(r){await e.ready;const o=await e.load(r);if(o.length===0)return!1;const a=ro(r),l=a.families[0].toLowerCase(),h=a.weight;return o.some(c=>{const u=c.family.replace(/^['"]|['"]$/g,"").toLowerCase(),d=so[c.weight]||c.weight;return u===l&&c.style===a.style&&d==h})}async function n(){await e.ready;let r=!0;const o=wi.getProperties(),a=Object.keys(o).filter(l=>o[l]<100);for(let l=a.length-1;l>=0;--l){const h=a[l];let c=o[h];c<100&&(await i(h)?(Fn(oo),wi.set(h,100)):(c+=10,wi.set(h,c,!0),c<100&&(r=!1)))}t=void 0,r||(t=setTimeout(n,100))}return async function(r){e||(e=Yt?self.fonts:document.fonts);const o=ro(r);if(!o)return;const a=o.families;let l=!1;for(const h of a){if(Dd.has(h))continue;const c=Nd(o.style,o.weight,h);wi.get(c)===void 0&&(wi.set(c,0,!0),l=!0)}l&&(clearTimeout(t),t=setTimeout(n,100))}})(),jd=(function(){let s;return function(t){let e=oo[t];if(e==null){if(Yt){const i=ro(t),n=mh(t,"Žg");e=(isNaN(Number(i.lineHeight))?1.2:Number(i.lineHeight))*(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent)}else s||(s=document.createElement("div"),s.innerHTML="M",s.style.minHeight="0",s.style.maxHeight="none",s.style.height="auto",s.style.padding="0",s.style.border="none",s.style.position="absolute",s.style.display="block",s.style.left="-99999px"),s.style.font=t,document.body.appendChild(s),e=s.offsetHeight,document.body.removeChild(s);oo[t]=e}return e}})();function mh(s,t){return tn||(tn=dt(1,1)),s!=Aa&&(tn.font=s,Aa=tn.font),tn.measureText(t)}function ph(s,t){return mh(s,t).width}function Oa(s,t,e){if(t in e)return e[t];const i=t.split(` `).reduce((n,r)=>Math.max(n,ph(s,r)),0);return e[t]=i,i}function zd(s,t){const e=[],i=[],n=[];let r=0,o=0,a=0,l=0;for(let h=0,c=t.length;h<=c;h+=2){const u=t[h];if(u===` `||h===c){r=Math.max(r,o),n.push(o),o=0,a+=l,l=0;continue}const d=t[h+1]||s.font,f=ph(d,u);e.push(f),o+=f;const g=jd(d);i.push(g),l=Math.max(l,g)}return{width:r,height:a,widths:e,heights:i,lineWidths:n}}function Xd(s,t,e,i,n,r,o,a,l,h,c){s.save(),e!==1&&(s.globalAlpha===void 0?s.globalAlpha=u=>u.globalAlpha*=e:s.globalAlpha*=e),t&&s.transform.apply(s,t),i.contextInstructions?(s.translate(l,h),s.scale(c[0],c[1]),Wd(i,s)):c[0]<0||c[1]<0?(s.translate(l,h),s.scale(c[0],c[1]),s.drawImage(i,n,r,o,a,0,0,o,a)):s.drawImage(i,n,r,o,a,l,h,o*c[0],a*c[1]),s.restore()}function Wd(s,t){const e=s.contextInstructions;for(let i=0,n=e.length;il&&(this.instructions.push([k.CUSTOM,l,c,t,i,ze,r]),this.hitDetectionInstructions.push([k.CUSTOM,l,c,t,n||i,ze,r]));break;case"Point":h=t.getFlatCoordinates(),this.coordinates.push(h[0],h[1]),c=this.coordinates.length,this.instructions.push([k.CUSTOM,l,c,t,i,void 0,r]),this.hitDetectionInstructions.push([k.CUSTOM,l,c,t,n||i,void 0,r]);break}this.endGeometry(e)}beginGeometry(t,e,i){this.beginGeometryInstruction1_=[k.BEGIN_GEOMETRY,e,0,t,i],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[k.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 n,r,o=-1;for(e=0;ethis.maxLineWidth&&(this.maxLineWidth=e.lineWidth,this.bufferedMaxExtent_=null)}else e.strokeStyle=void 0,e.lineCap=void 0,e.lineDash=null,e.lineDashOffset=void 0,e.lineJoin=void 0,e.lineWidth=void 0,e.miterLimit=void 0,e.strokeOffset=void 0;return e}setFillStrokeStyle(t,e){const i=this.state;this.fillStyleToState(t,i),this.strokeStyleToState(e,i)}createFill(t){const e=t.fillStyle,i=[k.SET_FILL_STYLE,e];return typeof e!="string"&&i.push(t.fillPatternScale),i}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[k.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,e){const i=t.fillStyle;(typeof i!="string"||t.currentFillStyle!=i)&&(this.instructions.push(e.call(this,t)),t.currentFillStyle=i)}updateStrokeStyle(t,e){const i=t.strokeStyle,n=t.lineCap,r=t.lineDash,o=t.lineDashOffset,a=t.lineJoin,l=t.lineWidth,h=t.miterLimit,c=t.strokeOffset;(t.currentStrokeStyle!=i||t.currentLineCap!=n||r!=t.currentLineDash&&!Be(t.currentLineDash,r)||t.currentLineDashOffset!=o||t.currentLineJoin!=a||t.currentLineWidth!=l||t.currentMiterLimit!=h||t.currentStrokeOffset!=c)&&(e.call(this,t),t.currentStrokeStyle=i,t.currentLineCap=n,t.currentLineDash=r,t.currentLineDashOffset=o,t.currentLineJoin=a,t.currentLineWidth=l,t.currentMiterLimit=h,t.currentStrokeOffset=c)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const e=[k.END_GEOMETRY,t];this.instructions.push(e),this.hitDetectionInstructions.push(e)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Tl(this.maxExtent),this.maxLineWidth>0)){const t=this.resolution*(this.maxLineWidth+1)/2;fo(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Yd extends zn{constructor(t,e,i,n){super(t,e,i,n),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,e,i){if(!this.image_||this.maxExtent&&!Ai(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,e,i);const n=t.getFlatCoordinates(),r=t.getStride(),o=this.coordinates.length,a=this.appendFlatPointCoordinates(n,r);this.instructions.push([k.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([k.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 n=t.getFlatCoordinates(),r=[];for(let l=0,h=n.length;lthis.drawCircle(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_FILL_STYLE,Lt]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Te,Ie]);const l=t.getFlatCoordinates(),h=t.getStride(),c=this.coordinates.length;this.appendFlatLineCoordinates(l,0,l.length,h,!1,!1);const u=[k.CIRCLE,c,a];this.instructions.push(ei,u),this.hitDetectionInstructions.push(ei,u),n.fillStyle!==void 0&&(this.instructions.push(ns),this.hitDetectionInstructions.push(ns)),n.strokeStyle!==void 0&&(this.instructions.push(We),this.hitDetectionInstructions.push(We)),this.endGeometry(e)}drawPolygon(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(r===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_FILL_STYLE,Lt]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Te,Ie]);const l=t.getEnds(),h=t.getOrientedFlatCoordinates(),c=t.getStride();this.drawFlatCoordinatess_(h,0,l,c,a),this.endGeometry(e)}drawMultiPolygon(t,e,i){const n=this.state,r=n.fillStyle,o=n.strokeStyle,a=n.strokeOffset;if(r===void 0&&o===void 0||this.handleStrokeOffset_(()=>this.drawMultiPolygon(t,e,i)))return;this.setFillStrokeStyles_(),this.beginGeometry(t,e,i),n.fillStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_FILL_STYLE,Lt]),n.strokeStyle!==void 0&&this.hitDetectionInstructions.push([k.SET_STROKE_STYLE,n.strokeStyle,n.lineWidth,n.lineCap,n.lineJoin,n.miterLimit,Te,Ie]);const l=t.getEndss(),h=t.getOrientedFlatCoordinates(),c=t.getStride();let u=0;for(let d=0,f=l.length;d0&&i!==void 0&&n!==void 0?(e.strokeStyle=void 0,e.strokeOffset=0,t(),e.fillStyle=void 0,e.strokeStyle=n,e.strokeOffset=r,t(),e.fillStyle=i,!0):!1}}function Bd(s,t,e,i,n){const r=[];let o=e,a=0,l=t.slice(e,2);for(;a=s){const g=(s-a+f)/f,_=Nt(h,u,g),m=Nt(c,d,g);l.push(_,m),r.push(l),l=[_,m],a==s&&(o+=n),a=0}else if(a0&&r.push(l),r}function Zd(s,t,e,i,n){let r=e,o=e,a=0,l=0,h=e,c,u,d,f,g,_,m,p,x,w;for(u=e;us&&(l>a&&(a=l,r=h,o=u),l=0,h=u-n)),d=f,m=x,p=w),g=y,_=E}return l+=f,l>a?[h,u]:[r,o]}const Ls={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Kd extends zn{constructor(t,e,i,n){super(t,e,i,n),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Lt]={fillStyle:Lt},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){const t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,e,i){const n=this.textFillState_,r=this.textStrokeState_,o=this.textState_;if(this.text_===""||!o||!n&&!r)return;const a=this.coordinates;let l=a.length;const h=t.getType();let c=null,u=t.getStride();if(o.placement==="line"&&(h=="LineString"||h=="MultiLineString"||h=="Polygon"||h=="MultiPolygon")){if(!St(this.maxExtent,t.getExtent()))return;let d;if(c=t.getFlatCoordinates(),h=="LineString")d=[c.length];else if(h=="MultiLineString")d=t.getEnds();else if(h=="Polygon")d=t.getEnds().slice(0,1);else if(h=="MultiPolygon"){const m=t.getEndss();d=[];for(let p=0,x=m.length;p{const M=a[(y+T)*2]===c[T*u]&&a[(y+T)*2+1]===c[T*u+1];return M||--y,M})}this.saveTextStates_();const g=o.backgroundFill?this.createFill(this.fillStyleToState(o.backgroundFill)):null,_=o.backgroundStroke?this.createStroke(this.strokeStyleToState(o.backgroundStroke)):null;this.beginGeometry(t,e,i);let m=o.padding;if(m!=ti&&(o.scale[0]<0||o.scale[1]<0)){let y=o.padding[0],E=o.padding[1],T=o.padding[2],M=o.padding[3];o.scale[0]<0&&(E=-E,M=-M),o.scale[1]<0&&(y=-y,T=-T),m=[y,E,T,M]}const p=this.pixelRatio;this.instructions.push([k.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,m==ti?ti:m.map(function(y){return y*p}),g,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]);const x=1/p,w=g?g.slice(0):null;w&&(w[1]=Lt),this.hitDetectionInstructions.push([k.DRAW_IMAGE,l,f,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[x,x],NaN,this.declutterMode_,this.declutterImageWithText_,m,w,_,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Lt:this.fillKey_,this.textOffsetX_,this.textOffsetY_,d]),this.endGeometry(e)}}saveTextStates_(){const t=this.textStrokeState_,e=this.textState_,i=this.textFillState_,n=this.strokeKey_;t&&(n in this.strokeStates||(this.strokeStates[n]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));const r=this.textKey_;r in this.textStates||(this.textStates[r]={font:e.font,textAlign:e.textAlign||Sn,justify:e.justify,textBaseline:e.textBaseline||Ps,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_,n=this.textState_,r=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,h=Ls[n.textBaseline],c=this.textOffsetY_*l,u=this.text_,d=i?i.lineWidth*Math.abs(n.scale[0])/2:0;this.instructions.push([k.DRAW_CHARS,t,e,h,n.overflow,a,n.maxAngle,l,c,r,d*l,u,o,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([k.DRAW_CHARS,t,e,h,n.overflow,a&&Lt,n.maxAngle,l,c,r,d*l,u,o,1/l,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,e){let i,n,r;if(!t)this.text_="";else{const o=t.getFill();o?(n=this.textFillState_,n||(n={},this.textFillState_=n),n.fillStyle=le(o.getColor()||Lt)):(n=null,this.textFillState_=n);const a=t.getStroke();if(!a)r=null,this.textStrokeState_=r;else{r=this.textStrokeState_,r||(r={},this.textStrokeState_=r);const _=a.getLineDash(),m=a.getLineDashOffset(),p=a.getWidth(),x=a.getMiterLimit();r.lineCap=a.getLineCap()||ji,r.lineDash=_?_.slice():Te,r.lineDashOffset=m===void 0?Ie:m,r.lineJoin=a.getLineJoin()||zi,r.lineWidth=p===void 0?Tn:p,r.miterLimit=x===void 0?vn:x,r.strokeStyle=le(a.getColor()||Rn)}i=this.textState_;const l=t.getFont()||_h;Gd(l);const h=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()||Ps,i.backgroundFill=t.getBackgroundFill(),i.backgroundStroke=t.getBackgroundStroke(),i.padding=t.getPadding()||ti,i.scale=h===void 0?[1,1]:h;const c=t.getOffsetX(),u=t.getOffsetY(),d=t.getRotateWithView(),f=t.getKeepUpright(),g=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=c===void 0?0:c,this.textOffsetY_=u===void 0?0:u,this.textRotateWithView_=d===void 0?!1:d,this.textKeepUpright_=f===void 0?!0:f,this.textRotation_=g===void 0?0:g,this.strokeKey_=r?(typeof r.strokeStyle=="string"?r.strokeStyle:Q(r.strokeStyle))+r.lineCap+r.lineDashOffset+"|"+r.lineWidth+r.lineJoin+r.miterLimit+"["+r.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=n&&n.fillStyle?typeof n.fillStyle=="string"?n.fillStyle:"|"+Q(n.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=e}}const Vd={Circle:Fa,Default:zn,Image:Yd,LineString:Ud,Polygon:Fa,Text:Kd};class Hd{constructor(t,e,i,n){this.tolerance_=t,this.maxExtent_=e,this.pixelRatio_=n,this.resolution_=i,this.buildersByZIndex_={}}finish(){const t={};for(const e in this.buildersByZIndex_){t[e]=t[e]||{};const i=this.buildersByZIndex_[e];for(const n in i){const r=i[n].finish();t[e][n]=r}}return t}getBuilder(t,e){const i=t!==void 0?t.toString():"0";let n=this.buildersByZIndex_[i];n===void 0&&(n={},this.buildersByZIndex_[i]=n);let r=n[e];if(r===void 0){const o=Vd[e];r=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),n[e]=r}return r}}function $d(s,t,e,i,n,r){n=n??[],r=r??t;const o=s[0],a=s[1],l=s[s.length-4],h=s[s.length-3];let c,u,d,f,g,_,m,p,x=0;for(let w=0;w.998)return[s+c*o,t+u*o];const f=Math.cos(d/2),g=Math.sin(d/2),_=g*a+f*l,m=-f*a+g*l,p=_*(1/g),x=m*(1/g);return[s+p*o,t+x*o]}function qd(s,t,e,i,n,r,o,a,l,h,c,u,d=!0){let f=s[t],g=s[t+1],_=0,m=0,p=0,x=0;function w(){_=f,m=g,t+=i,f=s[t],g=s[t+1],x+=p,p=Math.sqrt((f-_)*(f-_)+(g-m)*(g-m))}do w();while(tj[2]}else O=E>S;const L=Math.PI,W=[],P=M+i===t;t=M,p=0,x=b,f=s[t],g=s[t+1];let Y;if(P){w(),Y=Math.atan2(g-m,f-_),O&&(Y+=Y>0?-L:L);const j=(S+E)/2,F=(A+T)/2;return W[0]=[j,F,(R-r)/2,Y,n],W}n=n.replace(/\n/g," ");for(let j=0,F=n.length;j0?-L:L),Y!==void 0){let I=D-Y;if(I+=I>L?-2*L:I<-L?2*L:0,Math.abs(I)>o)return null}Y=D;const V=j;let q=0;for(;j{if(typeof Ms()[e]=="function")return this.push_(e),this.pushMethodArgs_},set:(t,e,i)=>(this.push_(e,i),!0)})}push_(...t){const e=this.instructions_,i=this.zIndex+this.offset_;e[i]||(e[i]=[]),e[i].push(...t)}pushMethodArgs_=(...t)=>(this.push_(t),this);pushFunction(t){this.push_(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(e=>{for(let i=0,n=e.length;i0&&s.push(` `,""),s.push(t,""),s}function Qd(s,t,e){return e%2===0&&(s+=t),s}class tf{constructor(t,e,i,n,r){this.overlaps=i,this.pixelRatio=e,this.resolution=t,this.alignAndScaleFill_,this.instructions=n.instructions,this.coordinates=n.coordinates,this.coordinateCache_={},this.renderedTransform_=te(),this.hitDetectionInstructions=n.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=n.fillStates||{},this.strokeStates=n.strokeStates||{},this.textStates=n.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=r?new yh:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,e,i,n){const r=t+e+i+n;if(this.labels_[r])return this.labels_[r];const o=n?this.strokeStates[n]:null,a=i?this.fillStates[i]:null,l=this.textStates[e],h=this.pixelRatio,c=[l.scale[0]*h,l.scale[1]*h],u=l.justify?Ls[l.justify]:vr(Array.isArray(t)?t[0]:t,l.textAlign||Sn),d=n&&o.lineWidth?o.lineWidth:0,f=Array.isArray(t)?t:String(t).split(` `).reduce(Jd,[]),{width:g,height:_,widths:m,heights:p,lineWidths:x}=zd(l,f),w=g+d,y=[],E=(w+2)*c[0],T=(_+d)*c[1],M={width:E<0?Math.floor(E):Math.ceil(E),height:T<0?Math.floor(T):Math.ceil(T),contextInstructions:y};(c[0]!=1||c[1]!=1)&&y.push("scale",c),n&&(y.push("strokeStyle",o.strokeStyle),y.push("lineWidth",d),y.push("lineCap",o.lineCap),y.push("lineJoin",o.lineJoin),y.push("miterLimit",o.miterLimit),y.push("setLineDash",[o.lineDash]),y.push("lineDashOffset",o.lineDashOffset)),i&&y.push("fillStyle",a.fillStyle),y.push("textBaseline","middle"),y.push("textAlign","center");const b=.5-u;let R=u*w+b*d;const S=[],A=[];let O=0,L=0,W=0,P=0,Y;for(let j=0,F=f.length;jt?t-h:r,y=o+c>e?e-c:o,E=g[3]+w*d[0]+g[1],T=g[0]+y*d[1]+g[2],M=p-g[3],b=x-g[0];(_||u!==0)&&(Ae[0]=M,Oe[0]=M,Ae[1]=b,pe[1]=b,pe[0]=M+E,ye[0]=pe[0],ye[1]=b+T,Oe[1]=ye[1]);let R;return u!==0?(R=Me(te(),i,n,1,1,u,-i,-n),_t(R,Ae),_t(R,pe),_t(R,ye),_t(R,Oe),be(Math.min(Ae[0],pe[0],ye[0],Oe[0]),Math.min(Ae[1],pe[1],ye[1],Oe[1]),Math.max(Ae[0],pe[0],ye[0],Oe[0]),Math.max(Ae[1],pe[1],ye[1],Oe[1]),_i)):be(Math.min(M,M+E),Math.min(b,b+T),Math.max(M,M+E),Math.max(b,b+T),_i),f&&(p=Math.round(p),x=Math.round(x)),{drawImageX:p,drawImageY:x,drawImageW:w,drawImageH:y,originX:h,originY:c,declutterBox:{minX:_i[0],minY:_i[1],maxX:_i[2],maxY:_i[3],value:m},canvasTransform:R,scale:d}}replayImageOrLabel_(t,e,i,n,r,o,a){const l=!!(o||a),h=n.declutterBox,c=a?a[2]*n.scale[0]/2:0;return h.minX-c<=e[0]&&h.maxX+c>=0&&h.minY-c<=e[1]&&h.maxY+c>=0&&(l&&this.replayTextBackground_(t,Ae,pe,ye,Oe,o,a),Xd(t,n.canvasTransform,r,i,n.originX,n.originY,n.drawImageW,n.drawImageH,n.drawImageX,n.drawImageY,n.scale)),!0}fill_(t){const e=this.alignAndScaleFill_;if(e){const i=_t(this.renderedTransform_,[0,0]),n=512*this.pixelRatio;t.save(),t.translate(i[0]%n,i[1]%n),e!==1&&t.scale(e,e)}t.fill(),e&&t.restore()}setStrokeStyle_(t,e){t.strokeStyle=e[1],e[1]&&(t.lineWidth=e[2],t.lineCap=e[3],t.lineJoin=e[4],t.miterLimit=e[5],t.lineDashOffset=e[7],t.setLineDash(e[6]))}drawLabelWithPointPlacement_(t,e,i,n){const r=this.textStates[e],o=this.createLabel(t,e,n,i),a=this.strokeStates[i],l=this.pixelRatio,h=vr(Array.isArray(t)?t[0]:t,r.textAlign||Sn),c=Ls[r.textBaseline||Ps],u=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*r.scale[0],f=h*d+2*(.5-h)*u,g=c*o.height/l+2*(.5-c)*u;return{label:o,anchorX:f,anchorY:g}}execute_(t,e,i,n,r,o,a,l){const h=this.zIndexContext_;let c;this.pixelCoordinates_&&Be(i,this.renderedTransform_)?c=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),c=Ye(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Hu(this.renderedTransform_,i));let u=0;const d=n.length;let f=0,g,_,m,p,x,w,y,E,T,M,b,R,S,A,O,L,W=0,P=0;const Y=this.coordinateCache_,j=this.viewRotation_,F=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,D={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:j},V=this.instructions!=n||this.overlaps?0:200;let q,J,K,lt;for(;uV&&(this.fill_(t),W=0),P>V&&(t.stroke(),P=0),!W&&!P&&(t.beginPath(),E=NaN,T=NaN),++u;break;case k.CIRCLE:f=I[1],p=I[2]??0;const rt=c[f],Mt=c[f+1],Pt=c[f+2]-p,Dt=c[f+3]-p,Bi=Pt-rt,Bn=Dt-Mt,Zi=Math.sqrt(Bi*Bi+Bn*Bn);t.moveTo(rt+Zi,Mt),t.arc(rt,Mt,Zi,0,2*Math.PI,!0),++u;break;case k.CLOSE_PATH:t.closePath(),++u;break;case k.CUSTOM:f=I[1],g=I[2];const rr=I[3],ne=I[4],Ht=I[5];D.geometry=rr,D.feature=q,u in Y||(Y[u]=[]);const se=Y[u];Ht?Ht(c,f,g,2,se):(se[0]=c[f],se[1]=c[f+1],se.length=2),h&&(h.zIndex=I[6]),ne(se,D),++u;break;case k.DRAW_IMAGE:f=I[1],g=I[2],R=I[3],_=I[4],m=I[5];let Le=I[6];const Zn=I[7],Ki=I[8],fi=I[9],Kn=I[10];let yt=I[11];const ec=I[12];let Vn=I[13];y=I[14]||"declutter";const Vi=I[15];if(!R&&I.length>=20){S=I[19],A=I[20],O=I[21],L=I[22];const jt=this.drawLabelWithPointPlacement_(S,A,O,L);R=jt.label,I[3]=R;const Ke=I[23];_=(jt.anchorX-Ke)*this.pixelRatio,I[4]=_;const zt=I[24];m=(jt.anchorY-zt)*this.pixelRatio,I[5]=m,Le=R.height,I[6]=Le,Vn=R.width,I[13]=Vn}let or;I.length>25&&(or=I[25]);let ar,Hn,$n;I.length>17?(ar=I[16],Hn=I[17],$n=I[18]):(ar=ti,Hn=null,$n=null),Kn&&F?yt+=j:!Kn&&!F&&(yt-=j);let ic=0;for(;f!xh.includes(s));let Eh=!1,Ch=!1;function nf(){let s=0;const t=i=>{const n=dt(1,1,null,{willReadFrequently:i});let r=0;const o=performance.now();for(;performance.now()-o<50;++r)n.fillStyle=`rgba(255,0,${r%256},1)`,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1);return s=r>s?r:s,r};Eh={[t(!0)]:!0,[t(!1)]:!1,[t(void 0)]:void 0}[s],Ch=!0}class sf{constructor(t,e,i,n,r,o,a){this.maxExtent_=t,this.overlaps_=n,this.pixelRatio_=i,this.resolution_=e,this.renderBuffer_=o,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=te(),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 n=this.executorsByZIndex_[i];n===void 0&&(n={},this.executorsByZIndex_[i]=n);const r=t[i];for(const o in r){const a=r[o];n[o]=new tf(this.resolution_,this.pixelRatio_,this.overlaps_,a,e)}}}hasExecutors(t){for(const e in this.executorsByZIndex_){const i=this.executorsByZIndex_[e];for(let n=0,r=t.length;n0){if(!o||M==="none"||f!=="Image"&&f!=="Text"||o.includes(E)){const A=(d[R]-3)/4,O=n-A%a,L=n-(A/a|0),W=r(E,T,O*O+L*L);if(W)return W}c.clearRect(0,0,a,a);break}}const _=Object.keys(this.executorsByZIndex_).map(Number);_.sort(Re);let m,p,x,w,y;for(m=_.length-1;m>=0;--m){const E=_[m].toString();for(x=this.executorsByZIndex_[E],p=qe.length-1;p>=0;--p)if(f=qe[p],w=x[f],w!==void 0&&(y=w.executeHitDetection(c,l,i,g,u),y))return y}}getClipCoords(t){const e=this.maxExtent_;if(!e)return null;const i=e[0],n=e[1],r=e[2],o=e[3],a=[i,n,i,o,r,o,r,n];return Ye(a,0,8,2,t,a),a}isEmpty(){return si(this.executorsByZIndex_)}execute(t,e,i,n,r,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(a?ku:Re),o=o||qe;const h=qe.length;for(let c=0,u=l.length;cp.execute(E,e,i,n,r,a)),y&&w.restore(),x){x.offset();const E=l[c]*h+qe.indexOf(m);this.deferredZIndexContexts_[E]||(this.deferredZIndexContexts_[E]=[]),this.deferredZIndexContexts_[E].push(x)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){const t=this.deferredZIndexContexts_,e=Object.keys(t).map(Number).sort(Re);for(let i=0,n=e.length;i{r.draw(this.renderedContext_),r.clear()}),t[e[i]].length=0}}const Rr={};function rf(s){if(Rr[s]!==void 0)return Rr[s];const t=s*2+1,e=s*s,i=new Array(e+1);for(let r=0;r<=s;++r)for(let o=0;o<=s;++o){const a=r*r+o*o;if(a>e)break;let l=i[a];l||(l=[],i[a]=l),l.push(((s+r)*t+(s+o))*4+3),r>0&&l.push(((s-r)*t+(s+o))*4+3),o>0&&(l.push(((s+r)*t+(s-o))*4+3),r>0&&l.push(((s-r)*t+(s-o))*4+3))}const n=[];for(let r=0,o=i.length;r0&&s[1]>0}function of(s,t,e){return e===void 0&&(e=[0,0]),e[0]=s[0]*t+.5|0,e[1]=s[1]*t+.5|0,e}function kt(s,t){return Array.isArray(s)?s:(t===void 0?t=[s,s]:(t[0]=s,t[1]=s),t)}class qs{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=kt(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new qs({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 X()}getImage(t){return X()}getHitDetectionImage(){return X()}getPixelRatio(t){return 1}getImageState(){return X()}getImageSize(){return X()}getOrigin(){return X()}getSize(){return X()}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_=kt(t)}listenImageChange(t){X()}load(){X()}unlistenImageChange(t){X()}ready(){return Promise.resolve()}}class Js extends qs{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.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()?B.LOADING:B.LOADED,this.imageState_===B.LOADING&&this.ready().then(()=>this.imageState_=B.LOADED),this.render()}clone(){const t=this.getScale(),e=new Js({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_,e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){const e=this.fill_?.getKey(),i=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${e}`+Object.values(this.renderOptions_).join(",");let n=Bt.get(i,null)?.getImage(1);if(!n){const r=this.renderOptions_,o=Math.ceil(r.size*t),a=dt(o,o);this.draw_(r,a,t),n=a.canvas;const l=new fh(n,void 0,null,B.LOADED,null);Bt.set(i,null,l),createImageBitmap(n).then(h=>{l.setImage(h)})}return n}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}setRadius(t){this.radius!==t&&(this.radius=t,this.render())}getRadius2(){return this.radius2_}setRadius2(t){this.radius2_!==t&&(this.radius2_=t,this.render())}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 n=this.radius,r=this.radius2_===void 0?n:this.radius2_;if(n{this.patternImage_=null}),e.getImageState()===B.IDLE&&e.load(),e.getImageState()===B.LOADING&&(this.patternImage_=e)}this.color_=t}getKey(){const t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?Q(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:oi(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}}function ja(s,t,e,i){return e!==void 0&&i!==void 0?[e/s,i/t]:e!==void 0?e/s:i!==void 0?i/t:1}class Qs extends qs{constructor(t){t=t||{};const e=t.opacity!==void 0?t.opacity:1,i=t.rotation!==void 0?t.rotation:0,n=t.scale!==void 0?t.scale:1,r=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:e,rotation:i,scale:n,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,this.referrerPolicy_=t.referrerPolicy;const o=t.img!==void 0?t.img:null;let a=t.src;it(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||Q(o)),it(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),it(!((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=B.IDLE:o!==void 0&&("complete"in o?o.complete?l=o.src?B.LOADED:B.IDLE:l=B.LOADING:l=B.LOADED),this.color_=t.color!==void 0?oi(t.color):null,this.iconImage_=mn(o,a,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},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 h,c;if(t.size)[h,c]=t.size;else{const u=this.getImage(1);if(u.width&&u.height)h=u.width,c=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(ja(f[0],f[1],t.width,t.height))};this.listenImageChange(d);return}}h!==void 0&&this.setScale(ja(h,c,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 Qs({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_,referrerPolicy:this.referrerPolicy_,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 n=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!n)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=n[0]),this.anchorYUnits_=="fraction"&&(t[1]*=n[1])}if(this.anchorOrigin_!="top-left"){if(!n)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+n[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+n[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_}setColor(t){const e=t?oi(t):null;if(this.color_===e||this.color_&&e&&this.color_.length===e.length&&this.color_.every((o,a)=>o===e[a]))return;this.color_=e;const i=this.getSrc(),n=i!==void 0?null:this.getHitDetectionImage(),r=i!==void 0?B.IDLE:this.iconImage_.getImageState();this.iconImage_=mn(n,i,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},r,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()}setSrc(t){this.iconImage_=mn(null,t,{crossOrigin:this.crossOrigin_,referrerPolicy:this.referrerPolicy_},B.IDLE,this.color_)}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()==B.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()==B.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(U.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(U.CHANGE,t)}ready(){return this.iconImage_.ready()}}class Ft{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.offset_=t.offset,this.width_=t.width}clone(){const t=this.getColor();return new Ft({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(),offset:this.getOffset(),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_}getOffset(){return this.offset_}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}setOffset(t){this.offset_=t}setWidth(t){this.width_=t}}class wt{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=za,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 wt({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_=za,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function af(s){let t;if(typeof s=="function")t=s;else{let e;Array.isArray(s)?e=s:(it(typeof s.getZIndex=="function","Expected an `Style` or an array of `Style`"),e=[s]),t=function(){return e}}return t}let Sr=null;function wh(s,t){if(!Sr){const e=new It({color:"rgba(255,255,255,0.4)"}),i=new Ft({color:"#3399CC",width:1.25});Sr=[new wt({image:new ui({fill:e,stroke:i,radius:5}),fill:e,stroke:i})]}return Sr}function lf(){const s={},t=[255,255,255,1],e=[0,153,255,1],i=3;return s.Polygon=[new wt({fill:new It({color:[255,255,255,.5]})})],s.MultiPolygon=s.Polygon,s.LineString=[new wt({stroke:new Ft({color:t,width:i+2})}),new wt({stroke:new Ft({color:e,width:i})})],s.MultiLineString=s.LineString,s.Circle=s.Polygon.concat(s.LineString),s.Point=[new wt({image:new ui({radius:i*2,fill:new It({color:e}),stroke:new Ft({color:t,width:i/2})}),zIndex:1/0})],s.MultiPoint=s.Point,s.GeometryCollection=s.Polygon.concat(s.LineString,s.Point),s}function za(s){return s.getGeometry()}const hf="#333";class tr{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=kt(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 It({color:hf}),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 tr({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()instanceof It?this.getFill().clone():this.getFill(),stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=kt(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}}class cf extends gh{constructor(t,e,i,n,r,o,a){super(),this.context_=t,this.pixelRatio_=e,this.extent_=i,this.transform_=n,this.transformRotation_=n?On(Math.atan2(n[1],n[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_=te()}drawImages_(t,e,i,n){if(!this.image_)return;const r=Ye(t,e,i,n,this.transform_,this.pixelCoordinates_),o=this.context_,a=this.tmpLocalTransform_,l=o.globalAlpha;this.imageOpacity_!=1&&(o.globalAlpha=l*this.imageOpacity_);let h=this.imageRotation_;this.transformRotation_===0&&(h-=this.viewRotation_),this.imageRotateWithView_&&(h+=this.viewRotation_);for(let c=0,u=r.length;c0&&(l=$d(l,n,o,r,l)),a.moveTo(l[0],l[1]);let h=l.length;r&&(h-=2);for(let c=2;cd*this.pixelRatio_),lineDashOffset:(o||Ie)*this.pixelRatio_,lineJoin:a!==void 0?a:zi,lineWidth:(l!==void 0?l:Tn)*this.pixelRatio_,miterLimit:h!==void 0?h:vn,strokeStyle:le(i||Rn),strokeOffset:(u??0)*this.pixelRatio_}}}setImageStyle(t){let e;if(!t||!(e=t.getSize())){this.image_=null;return}const i=t.getPixelRatio(this.pixelRatio_),n=t.getAnchor(),r=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=n[0]*i,this.imageAnchorY_=n[1]*i,this.imageHeight_=e[1]*i,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=r[0],this.imageOriginY_=r[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();const 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:le(f||Lt)}}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(),x=i.getWidth(),w=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:ji,lineDash:_||Te,lineDashOffset:m||Ie,lineJoin:p!==void 0?p:zi,lineWidth:x!==void 0?x:Tn,miterLimit:w!==void 0?w:vn,strokeStyle:le(f||Rn)}}const n=t.getFont(),r=t.getOffsetX(),o=t.getOffsetY(),a=t.getRotateWithView(),l=t.getRotation(),h=t.getScaleArray(),c=t.getText(),u=t.getTextAlign(),d=t.getTextBaseline();this.textState_={font:n!==void 0?n:_h,textAlign:u!==void 0?u:Sn,textBaseline:d!==void 0?d:Ps},this.text_=c!==void 0?Array.isArray(c)?c.reduce((f,g,_)=>f+=_%2?" ":g,""):c:"",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_*h[0],this.pixelRatio_*h[1]]}}}const oe=.5;function uf(s,t,e,i,n,r,o,a,l){const h=n,c=s[0]*oe,u=s[1]*oe,d=dt(c,u);d.imageSmoothingEnabled=!1;const f=d.canvas,g=new cf(d,oe,n,null,o,a,null),_=e.length,m=Math.floor((256*256*256-1)/_),p={};for(let w=1;w<=_;++w){const y=e[w-1],E=y.getStyleFunction()||i;if(!E)continue;let T=E(y,r);if(!T)continue;Array.isArray(T)||(T=[T]);const b=(w*m).toString(16).padStart(7,"#00000");for(let R=0,S=T.length;R0;return u&&Promise.all(l).then(()=>n(null)),mf(s,t,e,i,r,o,a),u}function mf(s,t,e,i,n,r,o){const a=e.getGeometryFunction()(t);if(!a)return;const l=a.simplifyTransformed(i,n);if(e.getRenderer())Sh(s,l,e,t,o);else{const c=vh[l.getType()];c(s,l,e,t,o,r)}}function Sh(s,t,e,i,n){if(t.getType()=="GeometryCollection"){const o=t.getGeometries();for(let a=0,l=o.length;athis.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return X()}getData(t){return null}prepareFrame(t){return X()}renderFrame(t,e){return X()}forEachFeatureAtCoordinate(t,e,i,n,r){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){const e=t.target;(e.getState()===B.LOADED||e.getState()===B.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let e=t.getState();return e!=B.LOADED&&e!=B.ERROR&&t.addEventListener(U.CHANGE,this.boundHandleImageChange_),e==B.IDLE&&(t.load(),e=t.getState()),e==B.LOADED}renderIfReadyAndVisible(){const t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Ya=[];let vi=null;function Tf(){vi=dt(1,1,void 0,{willReadFrequently:!0})}class Ih extends Sf{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=te(),this.pixelTransform=te(),this.inversePixelTransform=te(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,e,i){vi||Tf(),vi.clearRect(0,0,1,1);let n;try{vi.drawImage(t,e,i,1,1,0,0,1,1),n=vi.getImageData(0,0,1,1).data}catch{return vi=null,null}return n}getBackground(t){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(t.viewState.resolution)),i||void 0}useContainer(t,e,i){const n=this.getLayer().getClassName();let r,o;if(t&&t.className===n&&(!i||t&&t.style.backgroundColor&&Be(oi(t.style.backgroundColor),oi(i)))){const a=t.firstElementChild;Xe(a)&&(o=a.getContext("2d"))}if(o&&Qu(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=Yt?uh():document.createElement("div"),r.className=n;let a=r.style;a.position="absolute",a.width="100%",a.height="100%",o=dt();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 n=hi(i),r=Gs(i),o=Ns(i),a=Ds(i);_t(e.coordinateToPixelTransform,n),_t(e.coordinateToPixelTransform,r),_t(e.coordinateToPixelTransform,o),_t(e.coordinateToPixelTransform,a);const l=this.inversePixelTransform;_t(l,n),_t(l,r),_t(l,o),_t(l,a),t.save(),t.beginPath(),t.moveTo(Math.round(n[0]),Math.round(n[1])),t.lineTo(Math.round(r[0]),Math.round(r[1])),t.lineTo(Math.round(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,n=t.viewState.resolution,r=t.viewState.rotation,o=t.pixelRatio,a=Math.round(st(i)/n*o),l=Math.round(Tt(i)/n*o);Me(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/o,1/o,r,-a/2,-l/2),ql(this.inversePixelTransform,this.pixelTransform);const h=Ju(this.pixelTransform);if(this.useContainer(e,h,this.getBackground(t)),!this.containerReused){const c=this.context.canvas;c.width!=a||c.height!=l?(c.width=a,c.height=l):this.context.clearRect(0,0,a,l),h!==c.style.transform&&(c.style.transform=h)}}dispatchRenderEvent_(t,e,i){const n=this.getLayer();if(n.hasListener(t)){const r=new Th(t,this.inversePixelTransform,i,e);n.dispatchEvent(r)}}preRender(t,e){this.frameState=e,!e.declutter&&this.dispatchRenderEvent_(Ut.PRERENDER,t,e)}postRender(t,e){e.declutter||this.dispatchRenderEvent_(Ut.POSTRENDER,t,e)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new yh),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(Ut.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(Ut.POSTRENDER,this.context,t))}getRenderTransform(t,e,i,n,r,o,a){const l=r/2,h=o/2,c=n/e,u=-c,d=-t[0]+a,f=-t[1];return Me(this.tempTransform,l,h,c,u,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class If extends Ih{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipExtent_=null,this.extendX_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Vt(),this.wrappedRenderedExtent_=Vt(),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 n=e.extent,r=e.viewState,o=r.center,a=r.resolution,l=r.projection,h=r.rotation,c=l.getExtent(),u=this.getLayer().getSource(),d=this.getLayer().getDeclutter(),f=e.pixelRatio,g=e.viewHints,_=!(g[Ct.ANIMATING]||g[Ct.INTERACTING]),m=this.context,p=Math.round(st(n)/a*f),x=Math.round(Tt(n)/a*f),w=u.getWrapX()&&l.canWrapX(),y=w?st(c):null,E=w?Math.ceil((n[2]-c[2])/y)+(this.extendX_?2:1):1;let T=w?Math.floor((n[0]-c[0])/y)-(this.extendX_?1:0):0;do{let M=this.getRenderTransform(o,a,0,f,p,x,T*y);e.declutter&&(M=M.slice(0)),t.execute(m,[m.canvas.width,m.canvas.height],M,h,_,i===void 0?qe:i?xh:ef,i?d&&e.declutter[d]:void 0)}while(++T{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=this.frameState.size.slice(),n=this.renderedCenter_,r=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,h=this.getLayer(),c=[],u=i[0]*oe,d=i[1]*oe;c.push(this.getRenderTransform(n,r,o,oe,u,d,0).slice());const f=h.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Si(g,l)){let _=l[0];const m=st(g);let p=0,x;for(;_g[2];)++p,x=m*p,c.push(this.getRenderTransform(n,r,o,oe,u,d,x).slice()),_-=m}this.hitDetectionImageData_=uf(i,c,this.renderedFeatures_,h.getStyleFunction(),l,r,o,Xa(r,this.renderedPixelRatio_))}e(df(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,e,i,n,r){if(!this.replayGroup_)return;const o=e.viewState.resolution,a=e.viewState.rotation,l=this.getLayer(),h={},c=function(d,f,g){const _=Q(d),m=h[_];if(m){if(m!==!0&&gd.value):null)}handleFontsChanged(){const t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){const e=this.getLayer(),i=e.getSource();if(!i)return!1;const n=t.viewHints[Ct.ANIMATING],r=t.viewHints[Ct.INTERACTING],o=e.getUpdateWhileAnimating(),a=e.getUpdateWhileInteracting();if(this.ready&&!o&&n||!a&&r)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=t.extent,h=t.viewState,c=h.projection,u=h.resolution,d=t.pixelRatio,f=e.getRevision(),g=e.getRenderBuffer();let _=e.getRenderOrder();_===void 0&&(_=gf);const m=h.center.slice(),p=fo(l,g*u),x=p.slice(),w=[p.slice()],y=c.getExtent(),E=i.getWrapX()&&c.canWrapX();if(this.extendX_=!1,E){const P=i.getExtent();P&&!An(P)&&(this.extendX_=P[0]y[2])}if(E&&(!Si(y,t.extent)||this.extendX_)){const P=st(y),Y=Math.max(st(p)/2,P);let j=y[0],F=y[2];this.extendX_&&(j-=P,F+=P),p[0]=j-Y,p[2]=F+Y,yo(m,c);const D=Ll(w[0],c);D[0]y[0]&&D[2]>y[2]&&w.push([D[0]-P,D[1],D[2]-P,D[3]])}if(this.ready&&this.renderedResolution_==u&&this.renderedPixelRatio_===d&&this.renderedRevision_==f&&this.renderedRenderOrder_==_&&this.renderedFrameDeclutter_===!!t.declutter&&Si(this.wrappedRenderedExtent_,p))return Be(this.renderedExtent_,x)||(this.hitDetectionImageData_=null,this.renderedExtent_=x),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const T=new Hd(Rh(u,d),p,u,d);let M;for(let P=0,Y=w.length;P{let j;const F=P.getStyleFunction()||e.getStyleFunction();if(F&&(j=F(P,u)),j){const D=this.renderFeature(P,b,j,T,M,this.getLayer().getDeclutter(),Y);R=R&&!D}},A=Yl(p),O=i.getFeaturesInExtent(A);_&&O.sort(_);for(let P=0,Y=O.length;Pe;){if(i-e>600){const l=i-e+1,h=t-e+1,c=Math.log(l),u=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*u*(l-u)/l)*(h-l/2<0?-1:1),f=Math.max(e,Math.floor(t-h*u/l+d)),g=Math.min(i,Math.floor(t+(l-h)*u/l+d));bh(s,t,f,g,n)}const r=s[t];let o=e,a=i;for(en(s,e,t),n(s[i],r)>0&&en(s,e,i);o0;)a--}n(s[e],r)===0?en(s,e,a):(a++,en(s,a,i)),a<=t&&(e=a+1),t<=a&&(i=a-1)}}function en(s,t,e){const i=s[t];s[t]=s[e],s[e]=i}function bf(s,t){return st?1:0}let Mh=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(!rs(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let o=0;o=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const o=this._chooseSplitIndex(i,r,n),a=Ri(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,mi(i,this.toBBox),mi(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=Ri([t,e]),this.data.height=t.height+1,this.data.leaf=!1,mi(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,o=1/0;for(let a=e;a<=i-e;a++){const l=rn(t,0,a,this.toBBox),h=rn(t,a,i,this.toBBox),c=Of(l,h),u=Tr(l)+Tr(h);c=e;h--){const c=t.children[h];on(a,t.leaf?r(c):c),l+=ss(a)}return l}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)on(e[n],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():mi(t[e],this.toBBox)}};function Mf(s,t,e){if(!e)return t.indexOf(s);for(let i=0;i=s.minX&&t.maxY>=s.minY}function Ri(s){return{children:s,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ua(s,t,e,i,n){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;bh(s,o,t,e,n),r.push(t,o,o,e)}}let di=0;const Rt=1<",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},Nf={[v.Get]:z(Z(1,1/0),Ba),[v.Var]:z(Z(1,1),Gf),[v.Has]:z(Z(1,1/0),Ba),[v.Id]:z(jf,pi),[v.Concat]:z(Z(2,1/0),tt(At)),[v.GeometryType]:z(zf,pi),[v.LineMetric]:z(pi),[v.Resolution]:z(br,pi),[v.Zoom]:z(br,pi),[v.Time]:z(br,pi),[v.Any]:z(Z(2,1/0),tt(Rt)),[v.All]:z(Z(2,1/0),tt(Rt)),[v.Not]:z(Z(1,1),tt(Rt)),[v.Equal]:z(Z(2,2),tt(os)),[v.NotEqual]:z(Z(2,2),tt(os)),[v.GreaterThan]:z(Z(2,2),tt(H)),[v.GreaterThanOrEqualTo]:z(Z(2,2),tt(H)),[v.LessThan]:z(Z(2,2),tt(H)),[v.LessThanOrEqualTo]:z(Z(2,2),tt(H)),[v.Multiply]:z(Z(2,1/0),Za),[v.Coalesce]:z(Z(2,1/0),Za),[v.Divide]:z(Z(2,2),tt(H)),[v.Add]:z(Z(2,1/0),tt(H)),[v.Subtract]:z(Z(2,2),tt(H)),[v.Clamp]:z(Z(3,3),tt(H)),[v.Mod]:z(Z(2,2),tt(H)),[v.Pow]:z(Z(2,2),tt(H)),[v.Abs]:z(Z(1,1),tt(H)),[v.Floor]:z(Z(1,1),tt(H)),[v.Ceil]:z(Z(1,1),tt(H)),[v.Round]:z(Z(1,1),tt(H)),[v.Sin]:z(Z(1,1),tt(H)),[v.Cos]:z(Z(1,1),tt(H)),[v.Atan]:z(Z(1,2),tt(H)),[v.Sqrt]:z(Z(1,1),tt(H)),[v.Match]:z(Z(4,1/0),Ka,Wf),[v.Between]:z(Z(3,3),tt(H)),[v.Interpolate]:z(Z(6,1/0),Ka,Yf),[v.Case]:z(Z(3,1/0),Xf,Uf),[v.In]:z(Z(2,2),Bf),[v.Number]:z(Z(1,1/0),tt(os)),[v.String]:z(Z(1,1/0),tt(os)),[v.Array]:z(Z(1,1/0),tt(H)),[v.Color]:z(Z(1,4),tt(H)),[v.Band]:z(Z(1,3),tt(H)),[v.Palette]:z(Z(2,2),Zf),[v.ToString]:z(Z(1,1),tt(Rt|H|At|Jt))};function Ba(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;rt){const a=t===1/0?`${s} or more`:`${s} to ${t}`;throw new Error(`expected ${a} arguments for ${r}, got ${o}`)}}}function Za(s,t,e){const i=s.length-1,n=new Array(i);for(let r=0;ri.featureId;case v.GeometryType:return i=>i.geometryType;case v.Concat:{const i=s.args.map(n=>ee(n));return n=>"".concat(...i.map(r=>r(n).toString()))}case v.Resolution:return i=>i.resolution;case v.Any:case v.All:case v.Between:case v.In:case v.Not:return qf(s);case v.Equal:case v.NotEqual:case v.LessThan:case v.LessThanOrEqualTo:case v.GreaterThan:case v.GreaterThanOrEqualTo:return $f(s);case v.Multiply:case v.Divide:case v.Add:case v.Subtract:case v.Clamp:case v.Mod:case v.Pow:case v.Abs:case v.Floor:case v.Ceil:case v.Round:case v.Sin:case v.Cos:case v.Atan:case v.Sqrt:return Jf(s);case v.Case:return Qf(s);case v.Match:return tg(s);case v.Interpolate:return eg(s);case v.ToString:return ig(s);default:throw new Error(`Unsupported operator ${e}`)}}function Vf(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;o{const r=s.args;let o=n.properties[i];for(let a=1,l=r.length;an.variables[i];case v.Has:return n=>{const r=s.args;if(!(i in n.properties))return!1;let o=n.properties[i];for(let a=1,l=r.length;ai(r)===n(r);case v.NotEqual:return r=>i(r)!==n(r);case v.LessThan:return r=>i(r)i(r)<=n(r);case v.GreaterThan:return r=>i(r)>n(r);case v.GreaterThanOrEqualTo:return r=>i(r)>=n(r);default:throw new Error(`Unsupported comparison operator ${e}`)}}function qf(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r{for(let o=0;o{for(let o=0;o{const o=n[0](r),a=n[1](r),l=n[2](r);return o>=a&&o<=l};case v.In:return r=>{const o=n[0](r);for(let a=1;a!n[0](r);default:throw new Error(`Unsupported logical operator ${e}`)}}function Jf(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r{let o=1;for(let a=0;an[0](r)/n[1](r);case v.Add:return r=>{let o=0;for(let a=0;an[0](r)-n[1](r);case v.Clamp:return r=>{const o=n[0](r),a=n[1](r);if(ol?l:o};case v.Mod:return r=>n[0](r)%n[1](r);case v.Pow:return r=>Math.pow(n[0](r),n[1](r));case v.Abs:return r=>Math.abs(n[0](r));case v.Floor:return r=>Math.floor(n[0](r));case v.Ceil:return r=>Math.ceil(n[0](r));case v.Round:return r=>Math.round(n[0](r));case v.Sin:return r=>Math.sin(n[0](r));case v.Cos:return r=>Math.cos(n[0](r));case v.Atan:return i===2?r=>Math.atan2(n[0](r),n[1](r)):r=>Math.atan(n[0](r));case v.Sqrt:return r=>Math.sqrt(n[0](r));default:throw new Error(`Unsupported numeric operator ${e}`)}}function Qf(s,t){const e=s.args.length,i=new Array(e);for(let n=0;n{for(let r=0;r{const r=i[0](n);for(let o=1;o{const r=i[0](n),o=i[1](n);let a,l;for(let h=2;h=o)return h===2?u:d?ng(r,o,a,l,c,u):cn(r,o,a,l,c,u);a=c,l=u}return l}}function ig(s,t){const e=s.operator,i=s.args.length,n=new Array(i);for(let r=0;r{const o=n[0](r);return s.args[0].type===Jt?zo(o):o.toString()};throw new Error(`Unsupported convert operator ${e}`)}function cn(s,t,e,i,n,r){const o=n-e;if(o===0)return i;const a=t-e,l=s===1?a/o:(Math.pow(s,a)-1)/(Math.pow(s,o)-1);return i+l*(r-i)}function ng(s,t,e,i,n,r){if(n-e===0)return i;const a=Ma(i),l=Ma(r);let h=l[2]-a[2];h>180?h-=360:h<-180&&(h+=360);const c=[cn(s,t,e,a[0],n,l[0]),cn(s,t,e,a[1],n,l[1]),a[2]+cn(s,t,e,0,n,h),cn(s,t,e,i[3],n,r[3])];return Id(c)}function sg(s){return!0}function rg(s){const t=Ph(),e=og(s,t),i=Ah();return function(n,r){if(i.properties=n.getPropertiesInternal(),i.resolution=r,t.featureId){const o=n.getId();o!==void 0?i.featureId=o:i.featureId=null}return t.geometryType&&(i.geometryType=Lh(n.getGeometry())),e(i)}}function Va(s){const t=Ph(),e=s.length,i=new Array(e);for(let o=0;onull;i=er(s,t+"fill-color",e)}if(!i)return null;const n=new It;return function(r){const o=i(r);return o===Go?null:(n.setColor(o),n)}}function bn(s,t,e){const i=mt(s,t+"stroke-width",e),n=er(s,t+"stroke-color",e);if(!i&&!n)return null;const r=Ce(s,t+"stroke-line-cap",e),o=Ce(s,t+"stroke-line-join",e),a=Oh(s,t+"stroke-line-dash",e),l=mt(s,t+"stroke-line-dash-offset",e),h=mt(s,t+"stroke-miter-limit",e),c=mt(s,t+"stroke-offset",e),u=new Ft;return function(d){if(n){const f=n(d);if(f===Go)return null;u.setColor(f)}if(i&&u.setWidth(i(d)),r){const f=r(d);if(f!=="butt"&&f!=="round"&&f!=="square")throw new Error("Expected butt, round, or square line cap");u.setLineCap(f)}if(o){const f=o(d);if(f!=="bevel"&&f!=="round"&&f!=="miter")throw new Error("Expected bevel, round, or miter line join");u.setLineJoin(f)}return a&&u.setLineDash(a(d)),l&&u.setLineDashOffset(l(d)),h&&u.setMiterLimit(h(d)),c&&u.setOffset(c(d)),u}}function ag(s,t){const e="text-",i=Ce(s,e+"value",t);if(!i)return null;const n=In(s,e,t),r=In(s,e+"background-",t),o=bn(s,e,t),a=bn(s,e+"background-",t),l=Ce(s,e+"font",t),h=mt(s,e+"max-angle",t),c=mt(s,e+"offset-x",t),u=mt(s,e+"offset-y",t),d=Pi(s,e+"overflow",t),f=Ce(s,e+"placement",t),g=mt(s,e+"repeat",t),_=ir(s,e+"scale",t),m=Pi(s,e+"rotate-with-view",t),p=mt(s,e+"rotation",t),x=Ce(s,e+"align",t),w=Ce(s,e+"justify",t),y=Ce(s,e+"baseline",t),E=Pi(s,e+"keep-upright",t),T=Oh(s,e+"padding",t),M=nr(s,e+"declutter-mode"),b=new tr({declutterMode:M});return function(R){if(b.setText(i(R)),n&&b.setFill(n(R)),r&&b.setBackgroundFill(r(R)),o&&b.setStroke(o(R)),a&&b.setBackgroundStroke(a(R)),l&&b.setFont(l(R)),h&&b.setMaxAngle(h(R)),c&&b.setOffsetX(c(R)),u&&b.setOffsetY(u(R)),d&&b.setOverflow(d(R)),f){const S=f(R);if(S!=="point"&&S!=="line")throw new Error("Expected point or line for text-placement");b.setPlacement(S)}if(g&&b.setRepeat(g(R)),_&&b.setScale(_(R)),m&&b.setRotateWithView(m(R)),p&&b.setRotation(p(R)),x){const S=x(R);if(S!=="left"&&S!=="center"&&S!=="right"&&S!=="end"&&S!=="start")throw new Error("Expected left, right, center, start, or end for text-align");b.setTextAlign(S)}if(w){const S=w(R);if(S!=="left"&&S!=="right"&&S!=="center")throw new Error("Expected left, right, or center for text-justify");b.setJustify(S)}if(y){const S=y(R);if(S!=="bottom"&&S!=="top"&&S!=="middle"&&S!=="alphabetic"&&S!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");b.setTextBaseline(S)}return T&&b.setPadding(T(R)),E&&b.setKeepUpright(E(R)),b}}function lg(s,t){return"icon-src"in s?hg(s,t):"shape-points"in s?cg(s,t):"circle-radius"in s?ug(s,t):null}function hg(s,t){const e="icon-",i=e+"src",n=kh(s[i],i),r=As(s,e+"anchor",t),o=ir(s,e+"scale",t),a=mt(s,e+"opacity",t),l=As(s,e+"displacement",t),h=mt(s,e+"rotation",t),c=Pi(s,e+"rotate-with-view",t),u=$a(s,e+"anchor-origin"),d=qa(s,e+"anchor-x-units"),f=qa(s,e+"anchor-y-units"),g=Pe(s,e+"color");let _,m=null;g!==void 0&&(Array.isArray(g)&&g.length>0&&typeof g[0]=="string"?m=er(s,e+"color",t):_=Fh(g,e+"color"));const p=gg(s,e+"cross-origin"),x=_g(s,e+"offset"),w=$a(s,e+"offset-origin"),y=lo(s,e+"width"),E=lo(s,e+"height"),T=fg(s,e+"size"),M=nr(s,e+"declutter-mode"),b={src:n,anchorOrigin:u,anchorXUnits:d,anchorYUnits:f,crossOrigin:p,offset:x,offsetOrigin:w,height:E,width:y,size:T,declutterMode:M};let R=null;return function(S){if(R)m&&R.setColor(m(S));else{const A=m?m(S):_;R=new Qs(A!==void 0?Object.assign({},b,{color:A}):Object.assign({},b))}return a&&R.setOpacity(a(S)),l&&R.setDisplacement(l(S)),h&&R.setRotation(h(S)),c&&R.setRotateWithView(c(S)),o&&R.setScale(o(S)),r&&R.setAnchor(r(S)),R}}function cg(s,t){const e="shape-",i=e+"points",n=e+"radius",r=Yo(s[i],i);if(!(n in s))throw new Error(`Expected a number for ${n}`);const o=mt(s,n,t),a=typeof s[n]=="number"?s[n]:5,l=e+"radius2",h=mt(s,l,t),c=typeof s[l]=="number"?s[l]:void 0,u=In(s,e,t),d=bn(s,e,t),f=ir(s,e+"scale",t),g=As(s,e+"displacement",t),_=mt(s,e+"rotation",t),m=Pi(s,e+"rotate-with-view",t),p=lo(s,e+"angle"),x=nr(s,e+"declutter-mode"),w=new Js({points:r,radius:a,radius2:c,angle:p,declutterMode:x});return function(y){return o&&w.setRadius(o(y)),h&&w.setRadius2(h(y)),u&&w.setFill(u(y)),d&&w.setStroke(d(y)),g&&w.setDisplacement(g(y)),_&&w.setRotation(_(y)),m&&w.setRotateWithView(m(y)),f&&w.setScale(f(y)),w}}function ug(s,t){const e="circle-",i=In(s,e,t),n=bn(s,e,t),r=mt(s,e+"radius",t),o=ir(s,e+"scale",t),a=As(s,e+"displacement",t),l=mt(s,e+"rotation",t),h=Pi(s,e+"rotate-with-view",t),c=nr(s,e+"declutter-mode"),u=new ui({radius:5,declutterMode:c});return function(d){return r&&u.setRadius(r(d)),i&&u.setFill(i(d)),n&&u.setStroke(n(d)),a&&u.setDisplacement(a(d)),l&&u.setRotation(l(d)),h&&u.setRotateWithView(h(d)),o&&u.setScale(o(d)),u}}function Pe(s,t){if(!(t in s))return;const e=s[t];return e===void 0?void 0:e}function mt(s,t,e){const i=Pe(s,t);if(i===void 0)return;const n=de(i,H,e);return function(r){return Yo(n(r),t)}}function Ce(s,t,e){const i=Pe(s,t);if(i===void 0)return null;const n=de(i,At,e);return function(r){return kh(n(r),t)}}function dg(s,t,e){const i=Ce(s,t+"pattern-src",e),n=Ha(s,t+"pattern-offset",e),r=Ha(s,t+"pattern-size",e),o=er(s,t+"color",e);return function(a){return{src:i(a),offset:n&&n(a),size:r&&r(a),color:o&&o(a)}}}function Pi(s,t,e){const i=Pe(s,t);if(i===void 0)return null;const n=de(i,Rt,e);return function(r){const o=n(r);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${t}`);return o}}function er(s,t,e){const i=Pe(s,t);if(i===void 0)return null;const n=de(i,Jt,e);return function(r){return Fh(n(r),t)}}function Oh(s,t,e){const i=Pe(s,t);if(i===void 0)return null;if(Array.isArray(i)&&(i.length===0||typeof i[0]!="string")){const r=i.map((o,a)=>{if(typeof o=="number")return()=>o;const l=de(o,H,e);return function(h){return Yo(l(h),`${t}[${a}]`)}});return function(o){const a=new Array(r.length);for(let l=0;l4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return e}function Dh(s,t){const e=Xn(s,t);if(e.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return e}function mg(s,t){return typeof s=="number"?s:Dh(s,t)}const $t={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Ja(s,t,e){return(function(i,n,r,o,a){if(!i)return;if(!n&&!t)return i;const l=t?0:r[0]*n,h=t?0:r[1]*n,c=a?a[0]:0,u=a?a[1]:0;let d=s[0]+l/2+c,f=s[2]-l/2+c,g=s[1]+h/2+u,_=s[3]-h/2+u;d>f&&(d=(f+d)/2,f=d),g>_&&(g=(_+g)/2,_=g);let m=at(i[0],d,f),p=at(i[1],g,_);if(o&&e&&n){const x=30*n;m+=-x*Math.log(1+Math.max(0,d-i[0])/x)+x*Math.log(1+Math.max(0,i[0]-f)/x),p+=-x*Math.log(1+Math.max(0,g-i[1])/x)+x*Math.log(1+Math.max(0,i[1]-_)/x)}return[m,p]})}function pg(s){return s}function Nh(s){return Math.pow(s,3)}function Wi(s){return 1-Nh(1-s)}function yg(s){return 3*s*s-2*s*s*s}function xg(s){return s}function Uo(s,t,e,i){const n=st(t)/e[0],r=Tt(t)/e[1];return i?Math.min(s,Math.max(n,r)):Math.min(s,Math.min(n,r))}function Bo(s,t,e){let i=Math.min(s,t);const n=50;return i*=Math.log(1+n*Math.max(0,s/t-1))/n+1,e&&(i=Math.max(i,e),i/=Math.log(1+n*Math.max(0,e/s-1))/n+1),at(i,e/2,t*2)}function Eg(s,t,e,i){return t=t!==void 0?t:!0,(function(n,r,o,a){if(n!==void 0){const l=s[0],h=s[s.length-1],c=e?Uo(l,e,o,i):l;if(a)return t?Bo(n,c,h):at(n,h,c);const u=Math.min(c,n),d=Math.floor(So(s,u,r));return s[d]>c&&d1&&typeof arguments[e-1]=="function"&&(i=arguments[e-1],--e);let n=0;for(;n0}getInteracting(){return this.hints_[Ct.INTERACTING]>0}cancelAnimations(){this.setHint(Ct.ANIMATING,-this.hints_[Ct.ANIMATING]);let t;for(let e=0,i=this.animations_.length;e=0;--i){const n=this.animations_[i];let r=!0;for(let o=0,a=n.length;o0?h/l.duration:1;c>=1?(l.complete=!0,c=1):r=!1;const u=l.easing(c);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?ni(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(Ct.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=n[0].callback;o&&as(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 n=this.getCenterInternal();return n!==void 0&&(i=[n[0]-e[0],n[1]-e[1]],po(i,t-this.getRotation()),qc(i,e)),i}calculateCenterZoom(t,e){let i;const n=this.getCenterInternal(),r=this.getResolution();if(n!==void 0&&r!==void 0){const o=e[0]-t*(e[0]-n[0])/r,a=e[1]-t*(e[1]-n[1])/r;i=[o,a]}return i}getViewportSize_(t){const e=this.viewportSize_;if(t){const i=e[0],n=e[1];return[Math.abs(i*Math.cos(t))+Math.abs(n*Math.sin(t)),Math.abs(i*Math.sin(t))+Math.abs(n*Math.cos(t))]}return e}setViewportSize(t){this.viewportSize_=Array.isArray(t)?t.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const t=this.getCenterInternal();return t&&qr(t,this.getProjection())}getCenterInternal(){return this.get($t.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 Yl(e,this.getProjection())}calculateExtentInternal(t){t=t||this.getViewportSizeMinusPadding_();const e=this.getCenterInternal();it(e,"The view center is not defined");const i=this.getResolution();it(i!==void 0,"The view resolution is not defined");const n=this.getRotation();return it(n!==void 0,"The view rotation is not defined"),Br(e,i,n,t)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(t){this.applyOptions_(this.getUpdatedOptions_({maxZoom:t}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(t){this.applyOptions_(this.getUpdatedOptions_({minZoom:t}))}setConstrainResolution(t){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:t}))}getProjection(){return this.projection_}getResolution(){return this.get($t.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(t,e){return this.getResolutionForExtentInternal(je(t,this.getProjection()),e)}getResolutionForExtentInternal(t,e){e=e||this.getViewportSizeMinusPadding_();const i=st(t)/e[0],n=Tt(t)/e[1];return Math.max(i,n)}getResolutionForValueFunction(t){t=t||2;const e=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,n=Math.log(e/i)/Math.log(t);return(function(r){return e/Math.pow(t,r*n)})}getRotation(){return this.get($t.ROTATION)}getValueForResolutionFunction(t){const e=Math.log(t||2),i=this.getConstrainedResolution(this.maxResolution_),n=this.minResolution_,r=Math.log(i/n)/e;return(function(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 n=this.getCenterInternal();const r=this.padding_;if(r){const o=this.getViewportSizeMinusPadding_();n=Pr(n,this.getViewportSize_(),[o[0]/2+r[3],o[1]/2+r[0]],e,i)}return{center:n.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,n;if(this.resolutions_){const r=So(this.resolutions_,t,1);e=r,i=this.resolutions_[r],r==this.resolutions_.length-1?n=2:n=i/this.resolutions_[r+1]}else i=this.maxResolution_,n=this.zoomFactor_;return e+Math.log(i/t)/Math.log(n)}getResolutionForZoom(t){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];const e=at(Math.floor(t),0,this.resolutions_.length-2),i=this.resolutions_[e]/this.resolutions_[e+1];return this.resolutions_[e]/Math.pow(i,at(t-e,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,t-this.minZoom_)}fit(t,e){let i;if(it(Array.isArray(t)||typeof t.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(t)){it(!An(t),"Cannot fit empty extent provided as `geometry`");const n=je(t,this.getProjection());i=Ia(n)}else if(t.getType()==="Circle"){const n=je(t.getExtent(),this.getProjection());i=Ia(n),i.rotate(this.getRotation(),Ue(n))}else i=t;this.fitInternal(i,e)}rotatedExtentForGeometry(t){const e=this.getRotation(),i=Math.cos(e),n=Math.sin(-e),r=t.getFlatCoordinates(),o=t.getStride();let a=1/0,l=1/0,h=-1/0,c=-1/0;for(let u=0,d=r.length;u{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 ae?e={viewState:t.getState(),extent:t.calculateExtent()}:e=t,!e.layerStatesArray&&i&&(e.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let n;if(e.layerStatesArray){if(n=e.layerStatesArray.find(o=>o.layer===this),!n)return!1}else n=this.getLayerState();const r=this.getExtent();return Vo(n,e.viewState)&&(!r||St(r,e.extent))}getAttributions(t){if(!this.isVisible(t))return[];const e=this.getSource()?.getAttributions();if(!e)return[];const i=t instanceof ae?t.getViewStateAndExtent():t;let n=e(i);return Array.isArray(n)||(n=[n]),n}render(t,e){const i=this.getRenderer();return i.prepareFrame(t)?(this.rendered=!0,i.renderFrame(t,e)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(t,e){}renderDeferred(t){const e=this.getRenderer();e&&e.renderDeferred(t)}setMapInternal(t){t||this.unrender(),this.set(nt.MAP,t)}getMapInternal(){return this.get(nt.MAP)}setMap(t){this.mapPrecomposeKey_&&(ot(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),t||this.changed(),this.mapRenderKey_&&(ot(this.mapRenderKey_),this.mapRenderKey_=null),t&&(this.mapPrecomposeKey_=$(t,Ut.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=$(this,U.CHANGE,t.render,t),this.changed())}handlePrecompose_(t){const e=t.frameState.layerStatesArray,i=this.getLayerState(!1);it(!e.some(n=>n.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(nt.SOURCE,t)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}}function Vo(s,t){if(!s.visible)return!1;const e=t.resolution;if(e=s.maxResolution)return!1;const i=t.zoom;return i>s.minZoom&&i<=s.maxZoom}const el={RENDER_ORDER:"renderOrder"};class jh extends sr{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(el.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 Mh(9)),this.getRenderer().renderDeclutter(t,e)}setRenderOrder(t){this.set(el.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?wh:t;const e=Mg(t);this.styleFunction_=t===null?void 0:af(e),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}}function Mg(s){if(s===void 0)return wh;if(!s)return null;if(typeof s=="function"||s instanceof wt)return s;if(!Array.isArray(s))return Va([s]);if(s.length===0)return[];const t=s.length,e=s[0];if(e instanceof wt){const n=new Array(t);for(let r=0;r0;)this.pop()}extend(t){for(let e=0,i=t.length;ethis.getLength())throw new Error("Index out of bounds: "+t);this.unique_&&this.assertUnique_(e),this.array_.splice(t,0,e),this.updateLength_(),this.dispatchEvent(new ls(Ot.ADD,e,t))}pop(){return this.removeAt(this.getLength()-1)}push(t){const e=this.getLength();return this.insertAt(e,t),this.getLength()}remove(t){const e=this.array_;for(let i=0,n=e.length;i=this.getLength())return;const e=this.array_[t];return this.array_.splice(t,1),this.updateLength_(),this.dispatchEvent(new ls(Ot.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 n=this.array_[t];this.array_[t]=e,this.dispatchEvent(new ls(Ot.REMOVE,n,t)),this.dispatchEvent(new ls(Ot.ADD,e,t))}updateLength_(){this.set(il.LENGTH,this.array_.length)}assertUnique_(t,e){const i=this.array_;for(let n=0,r=i.length;n=200&&a.status<300){const h=t.getType();try{let c;h=="text"||h=="json"?c=a.responseText:h=="xml"?c=a.responseXML||a.responseText:h=="arraybuffer"&&(c=a.response),c?r(t.readFeatures(c,{extent:e,featureProjection:n}),t.readProjection(c)):o()}catch{o()}}else o()},a.onerror=o,a.send()}function nl(s,t){return function(e,i,n,r,o){Lg(s,t,e,i,n,(a,l)=>{this.addFeatures(a),r!==void 0&&r(a)},()=>{this.changed(),o!==void 0&&o()})}}function Ag(s,t){return[[-1/0,-1/0,1/0,1/0]]}class Mn extends Jl{constructor(t){super(),this.geometries_=t,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(ot),this.changeEventsKeys_.length=0}listenGeometriesChange_(){const t=this.geometries_;for(let e=0,i=t.length;et.clone())}const sl=te();class Gt{constructor(t,e,i,n,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_=n,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Il(this.flatCoordinates_):_o(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){const t=Ue(this.getExtent());this.flatInteriorPoints_=Fo(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){const t=_d(this.flatCoordinates_,this.ends_),e=hh(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=ah(this.flatCoordinates_,0,t,2,e)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Is(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];const t=this.flatCoordinates_;let e=0;const i=this.ends_;for(let n=0,r=i.length;n{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),e&&this.simplifiedGeometry_.applyTransform(e);const i=this.simplifiedGeometry_.getFlatCoordinates();let n;switch(this.type_){case"LineString":i.length=Hs(i,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,i,0),n=[i.length];break;case"MultiLineString":n=[],i.length=sh(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,i,0,n);break;case"Polygon":n=[],i.length=ko(i,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),i,0,n);break}return n&&(this.simplifiedGeometry_=new Gt(this.type_,i,n,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}}Gt.prototype.getFlatCoordinates=Gt.prototype.getOrientedFlatCoordinates;class rl{constructor(t){this.rbush_=new Mh(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_[Q(e)]=i}load(t,e){const i=new Array(e.length);for(let n=0,r=e.length;ns):null}const Wt={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};class Fe extends fe{constructor(t,e,i){super(t),this.feature=e,this.features=i}}class dn extends zh{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_=En,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&&(it(this.format_,"`format` must be set when `url` is set"),this.loader_=nl(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:Ag;const e=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=e?new rl:null,this.loadedExtentsRtree_=new rl,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,n;Array.isArray(t.features)?n=t.features:t.features&&(i=t.features,n=i.getArray()),!e&&i===void 0&&(i=new Zt(n)),n!==void 0&&this.addFeaturesInternal(n),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){const e=Q(t);if(!this.addToIndex_(e,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(e,t);const i=t.getGeometry();if(i){const n=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(n,t)}else this.nullGeometryFeatures_[e]=t;this.dispatchEvent(new Fe(Wt.ADDFEATURE,t))}setupChangeEvents_(t,e){e instanceof Gt||(this.featureChangeKeys_[t]=[$(e,U.CHANGE,this.handleFeatureChange_,this),$(e,Fi.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,e){let i=!0;if(e.getId()!==void 0){const n=String(e.getId());if(!(n in this.idIndex_))this.idIndex_[n]=e;else if(e instanceof Gt){const r=this.idIndex_[n];r instanceof Gt?Array.isArray(r)?r.push(e):this.idIndex_[n]=[r,e]:i=!1}else i=!1}return i&&(it(!(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=[],n=[];for(let r=0,o=t.length;r{e||(e=!0,this.addFeature(i.element),e=!1)}),t.addEventListener(Ot.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(ot);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(i=>{this.removeFeatureInternal(i)});for(const i in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[i])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const e=new Fe(Wt.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(n){const r=n.getGeometry();if(r instanceof Gt||r.intersectsCoordinate(t))return e(n)})}forEachFeatureInExtent(t,e){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureIntersectingExtent(t,e){return this.forEachFeatureInExtent(t,function(i){const n=i.getGeometry();if(n instanceof Gt||n.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(),si(this.nullGeometryFeatures_)||he(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 n=Al(t,e);return[].concat(...n.map(r=>this.featuresRtree_.getInExtent(r)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,e){const i=t[0],n=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||Di,this.featuresRtree_.forEachInExtent(l,function(h){if(e(h)){const c=h.getGeometry(),u=a;if(a=c instanceof Gt?0:c.closestPointXY(i,n,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new Fe(Wt.FEATURESLOADEND,void 0,c))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Fe(Wt.FEATURESLOADERROR))}),n.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_,i=e.forEachInExtent(t,function(n){if(pn(n.extent,t))return n});i&&e.remove(i)}removeFeatures(t){let e=!1;for(let i=0,n=t.length;i0}}else if(t.type==et.POINTERDOWN){const i=this.handleDownEvent(t);this.handlingDownUpSequence=i,e=this.stopDown(i)}else t.type==et.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 $o(s){const t=s.length;let e=0,i=0;for(let n=0;n=e?s[t-e]:s[t]}function bi(s,t){const e=s.length;let i=Math.floor(t);const n=t-i;i>=e?i-=e:i<0&&(i+=e);let r=i+1;r>=e&&(r-=e);const o=s[i],a=o[0],l=o[1],h=s[r],c=h[0]-a,u=h[1]-l;return[a+c*n,l+u*n]}const hs={index:-1,endIndex:NaN,closestTargetDistance:1/0};function kg(s,t,e,i){const n=s[0],r=s[1];let o=1/0,a=-1,l=NaN;for(let u=0;ud.startIndex?_d.startIndex&&(_-=f.length)),l=_,a=u)}const h=t.targets[a];let c=h.ring;if(t.targetIndex===a&&c){const u=bi(h.coordinates,l),d=e.getPixelFromCoordinate(u),f=e.getPixelFromCoordinate(t.startCoord);kl(d,f)>i&&(c=!1)}if(c){const u=h.coordinates,d=u.length,f=h.startIndex,g=l;if(fo){const l=bi(s,i),h=bi(s,n);return us(l,h)}let a=0;if(i{const l=o||new Ks([NaN,NaN]),h=qt(r[0]),c=Ol(h,qt(r[r.length-1]));return l.setCenterAndRadius(h,Math.sqrt(c),this.geometryLayout_),l};else{let r;n==="Point"?r=Se:n==="LineString"?r=ce:n==="Polygon"&&(r=ue),i=(o,a,l)=>(a?n==="Polygon"?o[0].length?a.setCoordinates([o[0].concat([o[0][0]])],this.geometryLayout_):a.setCoordinates([],this.geometryLayout_):a.setCoordinates(o,this.geometryLayout_):a=new r(o,this.geometryLayout_),a)}}this.geometryFunction_=i,this.dragVertexDelay_=t.dragVertexDelay!==void 0?t.dragVertexDelay:500,this.finishCoordinate_=null,this.sketchFeature_=null,this.sketchPoint_=null,this.sketchCoords_=null,this.sketchLine_=null,this.sketchLineCoords_=null,this.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,this.overlay_=new un({source:new dn({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:Dg(),updateWhileInteracting:!0}),this.geometryName_=t.geometryName,this.condition_=t.condition?t.condition:To,this.freehandCondition_,t.freehand?this.freehandCondition_=ys:this.freehandCondition_=t.freehandCondition?t.freehandCondition:Qr,this.traceCondition_,this.setTrace(t.trace||!1),this.traceState_={active:!1},this.traceSource_=t.traceSource||t.source||null,this.addChangeListener(ho.ACTIVE,this.updateState_)}setTrace(t){let e;t?t===!0?e=ys:e=t:e=Zu,this.traceCondition_=e}setMap(t){super.setMap(t),this.updateState_()}setFreehand(t){this.freehand_=t,this.freehand_?this.freehandCondition_=ys:this.freehandCondition_=this.options_&&this.options_.freehandCondition?this.options_.freehandCondition:Qr}getOverlay(){return this.overlay_}getFreehand(){return this.freehand_}handleEvent(t){t.originalEvent.type===U.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!=="Point"&&this.freehandCondition_(t);let e=t.type===et.POINTERMOVE,i=!0;return!this.freehand_&&this.lastDragTime_&&t.type===et.POINTERDRAG&&(Date.now()-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,e=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)),this.freehand_&&t.type===et.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===et.POINTERDOWN?i=!1:e&&this.getPointerCount()<2?(i=t.type===et.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===et.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===et.DBLCLICK&&(i=!1),super.handleEvent(t)&&i}handleDownEvent(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(()=>{this.handlePointerMove_(new xe(et.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))},this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)}deactivateTrace_(){this.traceState_={active:!1}}toggleTraceState_(t){if(!this.traceSource_||!this.traceCondition_(t))return;if(this.traceState_.active){this.deactivateTrace_();return}const e=this.getMap(),i=e.getCoordinateFromPixel([t.pixel[0]-this.snapTolerance_,t.pixel[1]+this.snapTolerance_]),n=e.getCoordinateFromPixel([t.pixel[0]+this.snapTolerance_,t.pixel[1]-this.snapTolerance_]),r=Wr([i,n]),o=this.traceSource_.getFeaturesInExtent(r);if(o.length===0)return;const a=Fg(t.coordinate,o);a.length&&(this.traceState_={active:!0,startCoord:t.coordinate.slice(),targets:a,targetIndex:-1})}addOrRemoveTracedCoordinates_(t,e){const i=t.startIndex<=t.endIndex,n=t.startIndex<=e;i===n?i&&e>t.endIndex||!i&&et.endIndex)&&this.removeTracedCoordinates_(e,t.endIndex):(this.removeTracedCoordinates_(t.startIndex,t.endIndex),this.addTracedCoordinates_(t,t.startIndex,e))}removeTracedCoordinates_(t,e){if(t===e)return;let i=0;if(t0&&this.removeLastPoints_(i)}addTracedCoordinates_(t,e,i){if(e===i)return;const n=[];if(e=o;--a)n.push(Ii(t.coordinates,a))}n.length&&this.appendCoordinates(n)}updateTrace_(t){const e=this.traceState_;if(!e.active)return;if(e.targetIndex===-1){const a=t.map.getPixelFromCoordinate(e.startCoord);if(kl(a,t.pixel)this.squaredClickTolerance_:o<=this.squaredClickTolerance_,!this.shouldHandle_)return}if(!this.finishCoordinate_){this.createOrUpdateSketchPoint_(t.coordinate.slice());return}this.updateTrace_(t),this.modifyDrawing_(t.coordinate)}atFinish_(t,e){let i=!1;if(this.sketchFeature_){let n=!1,r=[this.finishCoordinate_];const o=this.mode_;if(o==="Point")i=!0;else if(o==="Circle")i=this.sketchCoords_.length===2;else if(o==="LineString")n=!e&&this.sketchCoords_.length>this.minPoints_;else if(o==="Polygon"){const a=this.sketchCoords_;n=a[0].length>this.minPoints_,r=[a[0][0],a[0][a[0].length-2]],e?r=[a[0][0]]:r=[a[0][0],a[0][a[0].length-2]]}if(n){const a=this.getMap();for(let l=0,h=r.length;l=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),this.geometryFunction_(r,e,i)):o==="Polygon"&&(r=this.sketchCoords_[0],r.length>=this.maxPoints_&&(this.freehand_?r.pop():n=!0),r.push(t.slice()),n&&(this.finishCoordinate_=r[0]),this.geometryFunction_(this.sketchCoords_,e,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),n?this.finishDrawing():this.sketchFeature_}removeLastPoints_(t){if(!this.sketchFeature_)return;const e=this.sketchFeature_.getGeometry(),i=this.getMap().getView().getProjection(),n=this.mode_;for(let r=0;r=2){this.finishCoordinate_=o[o.length-2].slice();const a=this.finishCoordinate_.slice();o[o.length-1]=a,this.createOrUpdateSketchPoint_(a)}this.geometryFunction_(o,e,i),e.getType()==="Polygon"&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(e)}else if(n==="Polygon"){o=this.sketchCoords_[0],o.splice(-2,1);const a=this.sketchLine_.getGeometry();if(o.length>=2){const l=o[o.length-2].slice();o[o.length-1]=l,this.createOrUpdateSketchPoint_(l)}a.setCoordinates(o),this.geometryFunction_(this.sketchCoords_,e,i)}if(o.length===1){this.abortDrawing();break}}this.updateSketchFeatures_()}removeLastPoint(){this.removeLastPoints_(1)}finishDrawing(){const t=this.abortDrawing_();if(!t)return null;let e=this.sketchCoords_;const i=t.getGeometry(),n=this.getMap().getView().getProjection();return this.mode_==="LineString"?(e.pop(),this.geometryFunction_(e,i,n)):this.mode_==="Polygon"&&(e[0].pop(),this.geometryFunction_(e,i,n),e=i.getCoordinates()),this.type_==="MultiPoint"?t.setGeometry(new Gn([e])):this.type_==="MultiLineString"?t.setGeometry(new Ni([e])):this.type_==="MultiPolygon"&&t.setGeometry(new Gi([e])),this.dispatchEvent(new gs(fs.DRAWEND,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t),t}abortDrawing_(){this.finishCoordinate_=null;const t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),this.deactivateTrace_(),t}abortDrawing(){const t=this.abortDrawing_();t&&this.dispatchEvent(new gs(fs.DRAWABORT,t))}appendCoordinates(t){const e=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(t[0]);let n;if(e==="LineString"||e==="Circle")n=this.sketchCoords_;else if(e==="Polygon")n=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&n.shift(),n.pop();for(let o=0;o{},scale:15e5,setScale:()=>{},coordinates:[-.187,5.6037],setCoordinates:()=>{},activeInteraction:"pan",setActiveInteraction:()=>{}});function Yn(){return G.useContext(Uh)}const Gg=Xs([-.187,5.6037]),jg=12;function zg({theme:s}){const t=s==="dark",{map:e,drawLayer:i,activeInteraction:n,setActiveInteraction:r}=Yn(),o=G.useRef(null),a=G.useRef(null),l=G.useRef(null),h=G.useRef(null),c=[{id:"pan",icon:Cc,label:"Pan",description:"Pan / navigate the map",shortcut:"P",group:"navigate"},{id:"zoom-in",icon:Wc,label:"Zoom In",description:"Zoom into map view (+)",shortcut:"+",group:"navigate"},{id:"zoom-out",icon:Uc,label:"Zoom Out",description:"Zoom out of map view (-)",shortcut:"-",group:"navigate"},{id:"draw",icon:Ac,label:"Draw Polygon",description:"Sketch planning polygons on the map",shortcut:"D",Symbol:ac,group:"draw"},{id:"measure-line",icon:Dc,label:"Measure Distance",description:"Measure distances on the map (ol-ext)",shortcut:"M",Symbol:yl,group:"draw"},{id:"measure-area",icon:Gc,label:"Measure Area",description:"Measure area of a polygon (ol-ext)",shortcut:"A",Symbol:lc,group:"draw"},{id:"reset",icon:kc,label:"Reset View",description:"Return to Accra overview",shortcut:"R",Symbol:hc,group:"meta"}],u=()=>{e&&(o.current&&(e.removeInteraction(o.current),o.current=null),a.current&&(e.removeInteraction(a.current),a.current=null),l.current&&(e.removeOverlay(l.current),l.current=null),h.current&&(h.current.remove(),h.current=null))},d=()=>{if(!e)return;const g=document.createElement("div");g.className="ol-tooltip ol-tooltip-measure",g.style.cssText=` background: rgba(30,26,75,0.92); color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 12px; font-family: "Exo", sans-serif; white-space: nowrap; pointer-events: none; border: 1px solid rgba(255,255,255,0.2); `,h.current=g;const _=new Yh({element:g,offset:[0,-15],positioning:"bottom-center",stopEvent:!1});e.addOverlay(_),l.current=_};G.useEffect(()=>{if(!(!e||!i)){switch(u(),n){case"draw":{const g=new Or({source:i.getSource(),type:"Polygon"});e.addInteraction(g),o.current=g;break}case"measure-line":{d();const g=new Or({source:i.getSource(),type:"LineString"});g.on("drawstart",()=>{h.current&&(h.current.textContent="Click to continue drawing")}),g.on("drawend",_=>{const m=_.feature.getGeometry(),p=zl(m,{projection:"EPSG:3857"}),x=p>1e3?`${(p/1e3).toFixed(2)} km`:`${p.toFixed(0)} m`;h.current&&(h.current.textContent=`Distance: ${x}`),console.info("[LUPMIS] Distance measurement:",x)}),e.addInteraction(g),e.on("pointermove",_=>{l.current&&l.current.setPosition(_.coordinate)}),a.current=g;break}case"measure-area":{d();const g=new Or({source:i.getSource(),type:"Polygon"});g.on("drawstart",()=>{h.current&&(h.current.textContent="Click to continue drawing")}),g.on("drawend",_=>{const m=_.feature.getGeometry(),p=Xl(m,{projection:"EPSG:3857"}),x=p>1e6?`${(p/1e6).toFixed(2)} km²`:`${p.toFixed(0)} m²`;h.current&&(h.current.textContent=`Area: ${x}`),console.info("[LUPMIS] Area measurement:",x)}),e.addInteraction(g),e.on("pointermove",_=>{l.current&&l.current.setPosition(_.coordinate)}),a.current=g;break}}return()=>{u()}}},[n,e,i]),G.useEffect(()=>{if(!e)return;const g=_=>{if(_.target.tagName!=="INPUT")switch(_.key){case"+":case"=":f("zoom-in");break;case"-":f("zoom-out");break;case"p":case"P":f("pan");break;case"d":case"D":f("draw");break;case"m":case"M":f("measure-line");break;case"a":case"A":f("measure-area");break;case"r":case"R":f("reset");break;case"Escape":f("pan");break}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[e]);const f=g=>{if(!e)return;const _=e.getView();if(g==="zoom-in"){const m=_.getZoom()??12;_.animate({zoom:Math.min(m+1,19),duration:300});return}if(g==="zoom-out"){const m=_.getZoom()??12;_.animate({zoom:Math.max(m-1,8),duration:300});return}if(g==="reset"){_.animate({center:Gg,zoom:jg,duration:600}),r("pan");return}r(g)};return C.jsxs("div",{className:` rounded-xl shadow-lg flex flex-col gap-1.5 p-2 backdrop-blur-sm transition-colors bg-card/95 border border-border `,role:"toolbar","aria-label":"Map controls",children:[c.map(g=>{const _=g.icon,m=n===g.id,p=g.Symbol,x=c[c.indexOf(g)-1],w=x&&x.group!==g.group;return C.jsxs(cc.Fragment,{children:[w&&C.jsx("div",{className:"h-px bg-border mx-1 my-0.5"}),C.jsx(ua,{content:`${g.label}${g.shortcut?` (${g.shortcut})`:""}`,position:"right",children:C.jsxs("button",{onClick:()=>f(g.id),className:` w-10 h-10 rounded-lg flex items-center justify-center transition-all relative group ${m?"bg-primary text-primary-foreground shadow-md scale-105":"text-foreground hover:bg-accent hover:text-accent-foreground"} `,"aria-label":g.label,"aria-pressed":m,children:[m&&p&&C.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-10 pointer-events-none",children:C.jsx(p,{size:32,color:"currentColor"})}),C.jsx(_,{size:18,className:"relative z-10"}),m&&C.jsx("div",{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-5 h-0.5 bg-brand-orange-warm rounded-full"})]})})]},g.id)}),n==="draw"&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"h-px bg-border mx-1 my-0.5"}),C.jsx(ua,{content:"Clear sketches (C)",position:"right",children:C.jsx("button",{onClick:()=>{i?.getSource()?.clear()},className:"w-10 h-10 rounded-lg flex items-center justify-center text-destructive hover:bg-destructive/10 transition-all","aria-label":"Clear drawn features",children:C.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("path",{d:"M3 6h18M19 6l-1 14H6L5 6M10 11v6M14 11v6M9 6V4h6v2"})})})})]})]})}const Xg=[{id:-1,title:"Parcel GH-0345-22",subtitle:"Tema Industrial Area, Ref Zone Z-001",type:"parcel",lat:5.68,lon:-.045},{id:-2,title:"Parcel GH-1102-19",subtitle:"Accra CBD, Ref Zone Z-002",type:"parcel",lat:5.56,lon:-.19},{id:-3,title:"Parcel GH-0871-23",subtitle:"Spintex Residential, Ref Zone Z-003",type:"parcel",lat:5.63,lon:-.09}];function Wg(s,t){const[e,i]=G.useState(s);return G.useEffect(()=>{const n=setTimeout(()=>i(s),t);return()=>clearTimeout(n)},[s,t]),e}function Yg({theme:s,onOpenChange:t}){const{map:e}=Yn(),[i,n]=G.useState(""),[r,o]=G.useState([]),[a,l]=G.useState(!1),[h,c]=G.useState(!1),[u,d]=G.useState(-1),f=G.useRef(null),g=G.useRef(null),_=Wg(i,350),m=G.useCallback(async E=>{if(!E.trim()||E.trim().length<2){o([]);return}g.current&&g.current.abort(),g.current=new AbortController;const T=Xg.filter(M=>M.title.toLowerCase().includes(E.toLowerCase())||M.subtitle.toLowerCase().includes(E.toLowerCase()));l(!0);try{const M=`https://nominatim.openstreetmap.org/search?q=${encodeURIComponent(E+" Ghana")}&format=json&limit=5&countrycodes=gh&addressdetails=0`,S=(await(await fetch(M,{signal:g.current.signal,headers:{"Accept-Language":"en"}})).json()).map(A=>({id:A.place_id,title:A.display_name.split(",")[0].trim(),subtitle:A.display_name.split(",").slice(1,3).join(",").trim(),type:"location",lat:parseFloat(A.lat),lon:parseFloat(A.lon)}));o([...T,...S])}catch(M){M.name!=="AbortError"&&o(T)}finally{l(!1)}},[]);G.useEffect(()=>{m(_)},[_,m]);const p=E=>{e&&(e.getView().animate({center:Xs([E.lon,E.lat]),zoom:E.type==="parcel"?16:14,duration:800}),n(E.title),o([]),t(!1),c(!1))},x=E=>{r.length&&(E.key==="ArrowDown"?(E.preventDefault(),d(T=>Math.min(T+1,r.length-1))):E.key==="ArrowUp"?(E.preventDefault(),d(T=>Math.max(T-1,0))):E.key==="Enter"&&u>=0?(E.preventDefault(),p(r[u])):E.key==="Escape"&&(o([]),c(!1),t(!1)))},w=h&&(r.length>0||a||i.length>=2&&!a),y={location:{label:"Location",color:"bg-brand-green-bright/10 text-brand-green-bright"},place:{label:"Place",color:"bg-primary/10 text-primary"},parcel:{label:"Parcel ID",color:"bg-brand-orange-warm/10 text-brand-orange-warm"}};return C.jsxs("div",{className:"w-80",role:"search",children:[C.jsxs("div",{className:` rounded-xl shadow-lg flex items-center backdrop-blur-sm transition-all ${h?"ring-2 ring-primary ring-offset-2 ring-offset-background":""} bg-card/95 border border-border `,children:[C.jsx("div",{className:"pl-3 flex-shrink-0",children:a?C.jsx(fa,{size:18,className:"text-primary animate-spin"}):C.jsx(yl,{size:20,color:"var(--brand-blue-strong)"})}),C.jsx("input",{ref:f,type:"text",value:i,onChange:E=>{n(E.target.value),t(!0)},onFocus:()=>{c(!0),t(!0)},onBlur:()=>setTimeout(()=>c(!1),180),onKeyDown:x,placeholder:"Search location or parcel ID…",className:` flex-1 px-3 py-3 bg-transparent outline-none text-[length:var(--text-sm)] font-[family:var(--font-body)] text-foreground placeholder:text-muted-foreground `,"aria-label":"Search locations and parcels","aria-expanded":w,"aria-controls":"search-results","aria-autocomplete":"list"}),i&&C.jsx("button",{onClick:()=>{n(""),o([]),f.current?.focus()},className:"p-2 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Clear search",children:C.jsx(xl,{size:14})}),C.jsx("button",{onClick:()=>m(i),className:"w-11 h-11 flex items-center justify-center text-primary hover:bg-accent rounded-r-xl transition-colors flex-shrink-0","aria-label":"Submit search",children:C.jsx(gc,{size:18})})]}),w&&C.jsxs("div",{id:"search-results",className:` mt-2 rounded-xl shadow-lg overflow-hidden backdrop-blur-sm bg-card/95 border border-border `,role:"listbox","aria-label":"Search results",children:[a&&r.length===0&&C.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 text-muted-foreground",children:[C.jsx(fa,{size:14,className:"animate-spin"}),C.jsx("span",{className:"text-[length:var(--text-sm)]",children:"Searching Nominatim…"})]}),!a&&i.length>=2&&r.length===0&&C.jsxs("div",{className:"px-4 py-4 text-center",children:[C.jsxs("p",{className:"text-muted-foreground text-[length:var(--text-sm)]",children:['No results for "',i,'"']}),C.jsx("p",{className:"text-muted-foreground text-[length:var(--text-xs)] mt-1",children:"Try a district, city, or parcel reference"})]}),r.map((E,T)=>{const M=u===T,b=E.type==="parcel"?Pc:wl,R=y[E.type]??y.location;return C.jsx("div",{role:"option","aria-selected":M,onMouseEnter:()=>d(T),onMouseDown:()=>p(E),className:` px-4 py-3 cursor-pointer transition-all ${M?"bg-accent":"hover:bg-accent/50"} ${T!==r.length-1?"border-b border-border":""} `,children:C.jsxs("div",{className:"flex items-start gap-3",children:[C.jsx("div",{className:`mt-0.5 flex-shrink-0 ${M?"text-primary":"text-muted-foreground"}`,children:C.jsx(b,{size:16})}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("div",{className:"text-[length:var(--text-sm)] font-[weight:var(--font-weight-medium)] text-foreground truncate",children:E.title}),C.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[C.jsx("span",{className:`text-[length:var(--text-xs)] px-1.5 py-0.5 rounded-full ${R.color}`,children:R.label}),E.subtitle&&C.jsx("span",{className:"text-[length:var(--text-xs)] text-muted-foreground truncate",children:E.subtitle})]})]})]})},E.id)}),r.length>0&&C.jsx("div",{className:"px-4 py-2 border-t border-border flex items-center justify-between",children:C.jsxs("span",{className:"text-[length:var(--text-xs)] text-muted-foreground",children:[r.length," result",r.length!==1?"s":""," · Nominatim OSM"]})})]})]})}const _s={Zoning:"#005EB8","Land Use":"#B9D9EB",Utilities:"#FF9E1B"};function Ug({theme:s,isOpen:t,onOpenChange:e}){const i=s==="dark",{osmLayer:n,satelliteLayer:r,zoningLayer:o,landUseLayer:a,utilitiesLayer:l}=Yn(),[h,c]=G.useState("osm"),[u,d]=G.useState(!0),[f,g]=G.useState(!0),[_,m]=G.useState(!1),[p,x]=G.useState(80),w=S=>{c(S),n?.setVisible(S==="osm"),r?.setVisible(S==="satellite")},y=S=>{d(S),o?.setVisible(S)},E=S=>{g(S),a?.setVisible(S)},T=S=>{m(S),l?.setVisible(S)},M=S=>{x(S),o?.setOpacity(S/100)};G.useEffect(()=>{o&&o.setOpacity(p/100)},[o]);const b=[u,f,_].filter(Boolean).length,R=` peer w-4 h-4 rounded border-2 border-border cursor-pointer transition-colors focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background `;return C.jsxs("div",{className:` w-72 rounded-xl shadow-lg backdrop-blur-sm transition-colors bg-card/95 border border-border `,role:"region","aria-label":"Layer controls",children:[C.jsxs("div",{className:"px-4 py-3 flex items-center justify-between border-b border-border",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx(uc,{size:20,color:"var(--brand-blue-strong)"}),C.jsx("h3",{className:"font-[weight:var(--font-weight-semibold)] text-foreground",children:"Layers"}),C.jsx("span",{className:` ml-1 px-1.5 py-0.5 rounded-full bg-primary/10 text-primary text-[length:var(--text-xs)] font-[weight:var(--font-weight-semibold)] `,children:b})]}),C.jsx("button",{onClick:()=>e(!t),className:"p-1 rounded hover:bg-accent transition-colors","aria-label":t?"Collapse layers":"Expand layers","aria-expanded":t,children:t?C.jsx(xc,{size:18,className:"text-muted-foreground"}):C.jsx(dc,{size:18,className:"text-muted-foreground"})})]}),t&&C.jsxs("div",{className:"p-4 space-y-5",children:[C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[C.jsx(El,{size:14,color:"var(--muted-foreground)"}),C.jsx("span",{className:"text-[length:var(--text-xs)] font-[weight:var(--font-weight-semibold)] uppercase tracking-wider text-muted-foreground",children:"Base Map"})]}),C.jsx("div",{className:"space-y-2",children:[{id:"osm",label:"OpenStreetMap",desc:"Vector tiles"},{id:"satellite",label:"ESRI Satellite",desc:"Aerial imagery"}].map(S=>C.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group",children:[C.jsx("input",{type:"radio",name:"basemap",checked:h===S.id,onChange:()=>w(S.id),className:R+" rounded-full",style:{accentColor:"var(--primary)"},"aria-label":`Use ${S.label}`}),C.jsxs("div",{children:[C.jsx("span",{className:"text-[length:var(--text-sm)] text-foreground group-hover:text-primary transition-colors",children:S.label}),C.jsx("span",{className:"block text-[length:var(--text-xs)] text-muted-foreground",children:S.desc})]})]},S.id))})]}),C.jsx("div",{className:"h-px bg-border"}),C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[C.jsx(vc,{size:14,className:"text-muted-foreground"}),C.jsx("span",{className:"text-[length:var(--text-xs)] font-[weight:var(--font-weight-semibold)] uppercase tracking-wider text-muted-foreground",children:"Planning Layers"})]}),C.jsxs("div",{className:"space-y-3",children:[C.jsxs("div",{children:[C.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group",children:[C.jsxs("div",{className:"relative flex-shrink-0",children:[C.jsx("input",{type:"checkbox",checked:u,onChange:S=>y(S.target.checked),className:R,style:{accentColor:"var(--primary)"},"aria-label":"Toggle Zoning layer"}),C.jsx("span",{className:"absolute top-0.5 left-0.5 pointer-events-none",children:u?C.jsx(vl,{size:10,className:"text-primary-foreground"}):C.jsx(Rl,{size:10,className:"text-muted-foreground"})})]}),C.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[C.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0 border",style:{backgroundColor:`${_s.Zoning}30`,borderColor:_s.Zoning}}),C.jsx("span",{className:"text-[length:var(--text-sm)] text-foreground group-hover:text-primary transition-colors",children:"Zoning"}),C.jsx("span",{className:"ml-auto text-[length:var(--text-xs)] text-muted-foreground",children:"5 zones"})]})]}),u&&C.jsxs("div",{className:"mt-2 ml-8 p-2 bg-accent/50 rounded-lg",children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsx("span",{className:"text-[length:var(--text-xs)] text-muted-foreground",children:"Opacity"}),C.jsxs("span",{className:"text-[length:var(--text-xs)] font-[weight:var(--font-weight-semibold)] text-primary",children:[p,"%"]})]}),C.jsx("input",{type:"range",min:"10",max:"100",value:p,onChange:S=>M(Number(S.target.value)),className:"w-full h-2 rounded-full appearance-none cursor-pointer bg-border focus:outline-none",style:{background:`linear-gradient(to right, var(--primary) 0%, var(--primary) ${p}%, var(--border) ${p}%, var(--border) 100%)`},"aria-label":"Zoning layer opacity"})]})]}),C.jsx(al,{label:"Land Use",description:"3 areas",swatch:_s["Land Use"],checked:f,onChange:E,checkboxClass:R}),C.jsx(al,{label:"Utilities",description:"5 assets",swatch:_s.Utilities,checked:_,onChange:T,checkboxClass:R})]})]}),C.jsxs("div",{className:"pt-2 border-t border-border flex items-center justify-between",children:[C.jsxs("p",{className:"text-[length:var(--text-xs)] text-muted-foreground",children:[b," overlay",b!==1?"s":""," active"]}),C.jsx("button",{onClick:()=>{y(!0),E(!0),T(!1),M(80)},className:"text-[length:var(--text-xs)] text-primary hover:underline transition-colors",children:"Reset"})]})]})]})}function al({label:s,description:t,swatch:e,checked:i,onChange:n,checkboxClass:r}){return C.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer group",children:[C.jsxs("div",{className:"relative flex-shrink-0",children:[C.jsx("input",{type:"checkbox",checked:i,onChange:o=>n(o.target.checked),className:r,style:{accentColor:"var(--primary)"},"aria-label":`Toggle ${s} layer`}),C.jsx("span",{className:"absolute top-0.5 left-0.5 pointer-events-none",children:i?C.jsx(vl,{size:10,className:"text-primary-foreground"}):C.jsx(Rl,{size:10,className:"text-muted-foreground"})})]}),C.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[C.jsx("div",{className:"w-2.5 h-2.5 rounded-sm flex-shrink-0 border",style:{backgroundColor:`${e}30`,borderColor:e}}),C.jsx("span",{className:"text-[length:var(--text-sm)] text-foreground group-hover:text-primary transition-colors",children:s}),C.jsx("span",{className:"ml-auto text-[length:var(--text-xs)] text-muted-foreground",children:t})]})]})}const Bg={Active:{bg:"bg-success/10",text:"text-success",dot:"bg-success"},Pending:{bg:"bg-warning/10",text:"text-warning-foreground",dot:"bg-warning"},Review:{bg:"bg-primary/10",text:"text-primary",dot:"bg-primary"}},ll={industrial:"#FF9E1B",commercial:"#005EB8",residential:"#41B6A6",agricultural:"#006B3F",mixed:"#1E1A4B",transport:"#333F48",ecology:"#41B6A6",institutional:"#8B6F47",power:"#FF9E1B",water:"#41B6A6",default:"#7A7A7A"};function Zg({theme:s}){const t=s==="dark",{map:e,popupData:i,setPopupData:n}=Yn(),r=G.useRef(null),o=G.useRef(null);G.useEffect(()=>{if(!e||!r.current||o.current)return;const c=new Yh({element:r.current,autoPan:{animation:{duration:250}},positioning:"bottom-center",stopEvent:!0,offset:[0,-12]});return e.addOverlay(c),o.current=c,()=>{e.removeOverlay(c),o.current=null}},[e]),G.useEffect(()=>{if(o.current)if(i){const c=Xs([i.coordinate[0],i.coordinate[1]]);o.current.setPosition(c)}else o.current.setPosition(void 0)},[i]);const a=()=>n(null),l=ll[i?.type??"default"]??ll.default,h=i?[{label:"Parcel ID",value:i.id,icon:wl,color:"var(--brand-blue-strong)"},{label:"Zone",value:i.zone,icon:zc,color:l},{label:"Owner",value:i.owner,icon:_c,color:"var(--brand-green-bright)"},{label:"Status",value:i.status,icon:pc,color:"var(--success)",badge:!0},{label:"Area",value:i.area,icon:Tc,color:"var(--brand-orange-warm)"},{label:"Coordinates",value:`${i.coordinate[1]}°N, ${Math.abs(i.coordinate[0])}°W`,icon:bc,color:"var(--brand-blue-gray)"}]:[];return C.jsx("div",{ref:r,className:` relative rounded-xl shadow-xl w-80 backdrop-blur-sm transition-opacity duration-200 pointer-events-auto ${i?"opacity-100":"opacity-0 pointer-events-none"} bg-card/95 border border-border `,role:"dialog","aria-labelledby":"popup-title","aria-hidden":!i,children:i&&C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"px-4 py-3 flex items-center justify-between border-b border-border",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx(El,{size:18,color:"var(--brand-blue-strong)"}),C.jsx("h3",{id:"popup-title",className:"font-[weight:var(--font-weight-semibold)] text-foreground text-[length:var(--text-sm)] max-w-[180px] truncate",title:i.name,children:i.name})]}),C.jsx("button",{onClick:a,className:"p-1.5 rounded-lg transition-colors hover:bg-accent text-muted-foreground hover:text-foreground","aria-label":"Close popup",children:C.jsx(xl,{size:16})})]}),C.jsxs("div",{className:"p-4 space-y-2",children:[C.jsx("div",{className:"flex justify-center py-1",children:C.jsx(Cl,{size:40,color:"var(--brand-blue-strong)",className:"opacity-10"})}),h.map((c,u)=>{const d=c.icon,f=Bg[c.value];return C.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-lg bg-accent/50 hover:bg-accent transition-colors",children:[C.jsxs("div",{className:"flex items-center gap-2.5",children:[C.jsx("div",{className:"p-1.5 rounded-md flex-shrink-0",style:{backgroundColor:`${c.color}18`},children:C.jsx(d,{size:13,style:{color:c.color}})}),C.jsx("span",{className:"text-[length:var(--text-xs)] text-muted-foreground",children:c.label})]}),c.badge&&f?C.jsxs("span",{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[length:var(--text-xs)] font-[weight:var(--font-weight-semibold)] ${f.bg} ${f.text}`,children:[C.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.dot}`}),c.value]}):C.jsx("span",{className:"text-[length:var(--text-xs)] font-[weight:var(--font-weight-semibold)] text-foreground text-right max-w-[120px] truncate",children:c.value})]},u)})]}),C.jsxs("div",{className:"px-4 pb-4 flex gap-2",children:[C.jsx(da,{variant:"primary",size:"sm",className:"flex-1",onClick:()=>console.info("[LUPMIS] View full record for",i?.id),children:"Full Record"}),C.jsx(da,{variant:"ghost",size:"sm",onClick:a,children:"Close"})]}),C.jsx("div",{className:` absolute -bottom-2 left-1/2 -translate-x-1/2 w-4 h-4 rotate-45 border-r border-b border-border bg-card `})]})})}const Pn={POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTEROUT:"pointerout"};class Kg extends Bs{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_=$(i,Pn.POINTERDOWN,this.handlePointerDown_,this),this.originalPointerMoveEvent_,this.relayedListenerKey_=$(i,Pn.POINTERMOVE,this.relayMoveEvent_,this),this.boundHandleTouchMove_=this.handleTouchMove_.bind(this),this.element_.addEventListener(U.TOUCHMOVE,this.boundHandleTouchMove_,Kl?{passive:!1}:!1)}emulateClick_(t){let e=new xe(et.CLICK,this.map_,t);this.dispatchEvent(e),this.clickTimeoutId_!==void 0?(clearTimeout(this.clickTimeoutId_),this.clickTimeoutId_=void 0,e=new xe(et.DBLCLICK,this.map_,t),this.dispatchEvent(e)):this.clickTimeoutId_=setTimeout(()=>{this.clickTimeoutId_=void 0;const i=new xe(et.SINGLECLICK,this.map_,t);this.dispatchEvent(i)},250)}updateActivePointers_(t){const e=t,i=e.pointerId;if(e.type==et.POINTERUP||e.type==et.POINTERCANCEL){delete this.trackedTouches_[i];for(const n in this.trackedTouches_)if(this.trackedTouches_[n].target!==e.target){delete this.trackedTouches_[n];break}}else(e.type==et.POINTERDOWN||e.type==et.POINTERMOVE)&&(this.trackedTouches_[i]=e);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(t){this.updateActivePointers_(t);const e=new xe(et.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(ot),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 xe(et.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($(i,et.POINTERMOVE,this.handlePointerMove_,this),$(i,et.POINTERUP,this.handlePointerUp_,this),$(this.element_,et.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push($(this.element_.getRootNode(),et.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(t){if(this.isMoving_(t)){this.updateActivePointers_(t),this.dragging_=!0;const e=new xe(et.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 xe(et.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_&&(ot(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(U.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(ot(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(ot),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const Et={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},N={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4},Os=1/0;class Vg{constructor(t,e){this.priorityFunction_=t,this.keyFunction_=e,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Fn(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 n=this.keyFunction_(i);return delete this.queuedElements_[n],i}enqueue(t){it(!(this.keyFunction_(t)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const e=this.priorityFunction_(t);return e!=Os?(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_,n=e.length,r=e[t],o=i[t],a=t;for(;t>1;){const l=this.getLeftChildIndex_(t),h=this.getRightChildIndex_(t),c=ht;){const a=this.getParentIndex_(e);if(n[a]>o)i[e]=i[a],n[e]=n[a],e=a;else break}i[e]=r,n[e]=o}reprioritize(){const t=this.priorityFunction_,e=this.elements_,i=this.priorities_;let n=0;const r=e.length;let o,a,l;for(a=0;at.apply(null,i),i=>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(U.CHANGE,this.boundHandleTileChange_),e}getTilesLoading(){return this.tilesLoading_}handleTileChange(t){const e=t.target,i=e.getState();if(i===N.LOADED||i===N.ERROR||i===N.EMPTY){i!==N.ERROR&&e.removeEventListener(U.CHANGE,this.boundHandleTileChange_);const n=e.getKey();n in this.tilesLoadingKeys_&&(delete this.tilesLoadingKeys_[n],--this.tilesLoading_),this.tileChangeCallback_()}}loadMoreTiles(t,e){let i=0;for(;this.tilesLoading_0;){const n=this.dequeue()[0],r=n.getKey();n.getState()===N.IDLE&&!(r in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[r]=!0,++this.tilesLoading_,++i,n.load())}}}function $g(s,t,e,i,n){if(!s||!(e in s.wantedTiles)||!s.wantedTiles[e][t.getKey()])return Os;const r=s.viewState.center,o=i[0]-r[0],a=i[1]-r[1];return 65536*Math.log(n)+Math.sqrt(o*o+a*a)/n}class Un extends ie{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;en.getAttributions(t)));if(this.attributions_!==void 0&&(Array.isArray(this.attributions_)?this.attributions_.forEach(n=>i.add(n)):i.add(this.attributions_)),!this.overrideCollapsible_){const n=!e.some(r=>r.getSource()?.getAttributionsCollapsible()===!1);this.setCollapsible(n)}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(n=>Nu(()=>n))),i=e.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!Be(e,this.renderedAttributions_)){ch(this.ulElement_);for(let n=0,r=e.length;n0&&i%(2*Math.PI)!==0?e.animate({rotation:0,duration:this.duration_,easing:Wi}):e.setRotation(0))}render(t){const e=t.frameState;if(!e)return;const i=e.viewState.rotation;if(i!=this.rotation_){const n="rotate("+i+"rad)";if(this.autoHide_){const r=this.element.classList.contains(is);!r&&i===0?this.element.classList.add(is):r&&i!==0&&this.element.classList.remove(is)}this.label_.style.transform=n}this.rotation_=i}}class Qg extends Un{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,n=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",h=t.zoomOutTipLabel!==void 0?t.zoomOutTipLabel:"Zoom out",c=document.createElement("button");c.className=n,c.setAttribute("type","button"),c.title=l,c.appendChild(typeof o=="string"?document.createTextNode(o):o),c.addEventListener(U.CLICK,this.handleClick_.bind(this,i),!1);const u=document.createElement("button");u.className=r,u.setAttribute("type","button"),u.title=h,u.appendChild(typeof a=="string"?document.createTextNode(a):a),u.addEventListener(U.CLICK,this.handleClick_.bind(this,-i),!1);const d=e+" "+jn+" "+Xo,f=this.element;f.className=d,f.appendChild(c),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 n=i.getZoom();if(n!==void 0){const r=i.getConstrainedZoom(n+t);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:r,duration:this.duration_,easing:Wi})):i.setZoom(r)}}}function Bh(s){s=s||{};const t=new Zt;return(s.zoom===void 0||s.zoom)&&t.push(new Qg(s.zoomOptions)),(s.rotate===void 0||s.rotate)&&t.push(new Jg(s.rotateOptions)),(s.attribution===void 0||s.attribution)&&t.push(new qg(s.attributionOptions)),t}class t_{constructor(t,e,i){this.decay_=t,this.minVelocity_=e,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(t,e){this.points_.push(t,e,Date.now())}end(){if(this.points_.length<6)return!1;const t=Date.now()-this.delay_,e=this.points_.length-3;if(this.points_[e+2]0&&this.points_[i+2]>t;)i-=3;const n=this.points_[e+2]-this.points_[i+2];if(n<1e3/60)return!1;const r=this.points_[e]-this.points_[i],o=this.points_[e+1]-this.points_[i+1];return this.angle_=Math.atan2(o,r),this.initialVelocity_=Math.sqrt(r*r+o*o)/n,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class e_ extends Wn{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==et.DBLCLICK){const i=t.originalEvent,n=t.map,r=t.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=n.getView();Ho(a,o,r,this.duration_),i.preventDefault(),e=!0}return!e}}class i_ extends Yi{constructor(t){super({stopDown:Xi}),t=t||{},this.kinetic_=t.kinetic,this.lastCentroid=null,this.lastPointersCount_,this.panning_=!1;const e=t.condition?t.condition:Jr(To,Vu);this.condition_=t.onFocusOnly?Jr(Vl,e):e,this.noKinetic_=!1}handleDragEvent(t){const e=t.map;this.panning_||(this.panning_=!0,e.getView().beginInteraction());const i=this.targetPointers,n=e.getEventPixel($o(i));if(i.length==this.lastPointersCount_){if(this.kinetic_&&this.kinetic_.update(n[0],n[1]),this.lastCentroid){const r=[this.lastCentroid[0]-n[0],n[1]-this.lastCentroid[1]],a=t.map.getView();tu(r,a.getResolution()),po(r,a.getRotation()),a.adjustCenterInternal(r)}}else this.kinetic_&&this.kinetic_.begin();this.lastCentroid=n,this.lastPointersCount_=i.length,t.originalEvent.preventDefault()}handleUpEvent(t){const e=t.map,i=e.getView();if(this.targetPointers.length===0){if(!this.noKinetic_&&this.kinetic_&&this.kinetic_.end()){const n=this.kinetic_.getDistance(),r=this.kinetic_.getAngle(),o=i.getCenterInternal(),a=e.getPixelFromCoordinateInternal(o),l=e.getCoordinateFromPixelInternal([a[0]-n*Math.cos(r),a[1]-n*Math.sin(r)]);i.animateInternal({center:i.getConstrainedCenter(l),duration:500,easing:Wi})}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 n_ extends Yi{constructor(t){t=t||{},super({stopDown:Xi}),this.condition_=t.condition?t.condition:Uu,this.lastAngle_=void 0,this.duration_=t.duration!==void 0?t.duration:250}handleDragEvent(t){if(!gr(t))return;const e=t.map,i=e.getView();if(i.getConstraints().rotation===Zo)return;const n=e.getSize(),r=t.pixel,o=Math.atan2(n[1]/2-r[1],r[0]-n[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(t){return gr(t)?(t.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(t){return gr(t)&&Hl(t)&&this.condition_(t)?(t.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class s_ extends Us{constructor(t){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+t,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const t=this.startPixel_,e=this.endPixel_,i="px",n=this.element_.style;n.left=Math.min(t[0],e[0])+i,n.top=Math.min(t[1],e[1])+i,n.width=Math.abs(e[0]-t[0])+i,n.height=Math.abs(e[1]-t[1])+i}setMap(t){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const 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_,n=[t,[t[0],e[1]],e,[e[0],t[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);n[4]=n[0].slice(),this.geometry_?this.geometry_.setCoordinates([n]):this.geometry_=new ue([n])}getGeometry(){return this.geometry_}}const yi={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class nn extends fe{constructor(t,e,i){super(t),this.coordinate=e,this.mapBrowserEvent=i}}class r_ extends Yi{constructor(t){super(),this.on,this.once,this.un,t=t??{},this.box_=new s_(t.className||"ol-dragbox"),this.minArea_=t.minArea??64,t.onBoxEnd&&(this.onBoxEnd=t.onBoxEnd),this.startPixel_=null,this.condition_=t.condition??Hl,this.boxEndCondition_=t.boxEndCondition??this.defaultBoxEndCondition}defaultBoxEndCondition(t,e,i){const n=i[0]-e[0],r=i[1]-e[1];return n*n+r*r>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(t){this.startPixel_&&(this.box_.setPixels(this.startPixel_,t.pixel),this.dispatchEvent(new nn(yi.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 nn(e?yi.BOXEND:yi.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 nn(yi.BOXSTART,t.coordinate,t)),!0):!1}onBoxEnd(t){}setActive(t){t||(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new nn(yi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setActive(t)}setMap(t){this.getMap()&&(this.box_.setMap(null),this.startPixel_&&(this.dispatchEvent(new nn(yi.BOXCANCEL,this.startPixel_,null)),this.startPixel_=null)),super.setMap(t)}}class o_ extends r_{constructor(t){t=t||{};const e=t.condition?t.condition:Qr;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 n=this.getGeometry();if(this.out_){const r=i.rotatedExtentForGeometry(n),o=i.getResolutionForExtentInternal(r),a=i.getResolution()/o;n=n.clone(),n.scale(a*a)}i.fitInternal(n,{duration:this.duration_,easing:Wi})}}const He={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class a_ extends Wn{constructor(t){super(),t=t||{},this.defaultCondition_=function(e){return To(e)&&$l(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==U.KEYDOWN){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==He.DOWN||n==He.LEFT||n==He.RIGHT||n==He.UP)){const o=t.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,h=0;n==He.DOWN?h=-a:n==He.LEFT?l=-a:n==He.RIGHT?l=a:h=a;const c=[l,h];po(c,o.getRotation()),Og(o,c,this.duration_),i.preventDefault(),e=!0}}return!e}}class l_ extends Wn{constructor(t){super(),t=t||{},this.condition_=t.condition?t.condition:function(e){return!Ku(e)&&$l(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==U.KEYDOWN||t.type==U.KEYPRESS){const i=t.originalEvent,n=i.key;if(this.condition_(t)&&(n==="+"||n==="-")){const r=t.map,o=n==="+"?this.delta_:-this.delta_,a=r.getView();Ho(a,o,void 0,this.duration_),i.preventDefault(),e=!0}}return!e}}const h_=40,c_=300;class u_ extends Wn{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:ys;this.condition_=t.onFocusOnly?Jr(Vl,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!==U.WHEEL)return!0;const i=t.map,n=t.originalEvent;n.preventDefault(),this.useAnchor_&&(this.lastAnchor_=t.pixel);let r=n.deltaY;switch(n.deltaMode){case WheelEvent.DOM_DELTA_LINE:r*=h_;break;case WheelEvent.DOM_DELTA_PAGE:r*=c_;break}if(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=-at(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(e.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),Ho(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 d_ extends Yi{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Xi),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],n=this.targetPointers[1],r=Math.atan2(n.clientY-i.clientY,n.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!==Zo&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel($o(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 f_ extends Yi{constructor(t){t=t||{};const e=t;e.stopDown||(e.stopDown=Xi),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],n=this.targetPointers[1],r=i.clientX-n.clientX,o=i.clientY-n.clientY,a=Math.sqrt(r*r+o*o);this.lastDistance_!==void 0&&(e=this.lastDistance_/a),this.lastDistance_=a;const l=t.map,h=l.getView();e!=1&&(this.lastScaleDelta_=e),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel($o(this.targetPointers))),l.render(),h.adjustResolutionInternal(e,this.anchor_)}handleUpEvent(t){if(this.targetPointers.length<2){const i=t.map.getView(),n=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,n),!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 g_(s){s=s||{};const t=new Zt,e=new t_(-.005,.05,100);return(s.altShiftDragRotate===void 0||s.altShiftDragRotate)&&t.push(new n_),(s.doubleClickZoom===void 0||s.doubleClickZoom)&&t.push(new e_({delta:s.zoomDelta,duration:s.zoomDuration})),(s.dragPan===void 0||s.dragPan)&&t.push(new i_({onFocusOnly:s.onFocusOnly,kinetic:e})),(s.pinchRotate===void 0||s.pinchRotate)&&t.push(new d_),(s.pinchZoom===void 0||s.pinchZoom)&&t.push(new f_({duration:s.zoomDuration})),(s.keyboard===void 0||s.keyboard)&&(t.push(new a_),t.push(new l_({delta:s.zoomDelta,duration:s.zoomDuration}))),(s.mouseWheelZoom===void 0||s.mouseWheelZoom)&&t.push(new u_({onFocusOnly:s.onFocusOnly,duration:s.zoomDuration})),(s.shiftDragZoom===void 0||s.shiftDragZoom)&&t.push(new o_({duration:s.zoomDuration})),t}const De={ADDLAYER:"addlayer",REMOVELAYER:"removelayer"};class Ge extends fe{constructor(t,e){super(t),this.layer=e}}const kr={LAYERS:"layers"};class Ui extends Gh{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(kr.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Zt(i.slice(),{unique:!0}):it(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Zt(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(ot),this.layersListenerKeys_.length=0;const t=this.getLayers();this.layersListenerKeys_.push($(t,Ot.ADD,this.handleLayersAdd_,this),$(t,Ot.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(ot);Fn(this.listenerKeys_);const e=t.getArray();for(let i=0,n=e.length;i=0;--E){const T=_[E],M=T.layer;if(M.hasRenderer()&&Vo(T,c)&&a.call(l,M)){const b=M.getRenderer(),R=M.getSource();if(b&&R){const S=R.getWrapX()?f:t,A=u.bind(null,T.managed);x[0]=S[0]+g[y][0],x[1]=S[1]+g[y][1],h=b.forEachFeatureAtCoordinate(x,e,i,A,p)}if(h)return h}}if(p.length===0)return;const w=1/p.length;return p.forEach((y,E)=>y.distanceSq+=E*w),p.sort((y,E)=>y.distanceSq-E.distanceSq),p.some(y=>h=y.callback(y.feature,y.layer,y.geometry)),h}hasFeatureAtCoordinate(t,e,i,n,r,o){return this.forEachFeatureAtCoordinate(t,e,i,n,Di,this,r,o)!==void 0}getMap(){return this.map_}renderFrame(t){X()}scheduleExpireIconCache(t){Bt.canExpireCache()&&t.postRenderFunctions.push(m_)}}function m_(s,t){Bt.expire()}class p_ extends __{constructor(t){super(t),this.fontChangeListenerKey_=$(wi,Fi.PROPERTYCHANGE,t.redrawText,t),this.element_=Yt?uh():document.createElement("div");const e=this.element_.style;e.position="absolute",e.width="100%",e.height="100%",e.zIndex="0",this.element_.className=jn+" ol-layers";const i=t.getViewport();i&&i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0}dispatchRenderEvent(t,e){const i=this.getMap();if(i.hasListener(t)){const n=new Th(t,void 0,e);i.dispatchEvent(n)}}disposeInternal(){ot(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(Ut.PRECOMPOSE,t);const e=t.layerStatesArray.sort((h,c)=>h.zIndex-c.zIndex);e.some(h=>h.layer instanceof jh&&h.layer.getDeclutter())&&(t.declutter={});const n=t.viewState;this.children_.length=0;const r=[];let o=null;for(let h=0,c=e.length;h0)&&(h.fillStyle=d,h.fillRect(0,0,l.width,l.height)),Xe(u)&&u.width>0){h.save();const f=c.style.opacity||u.style.opacity;h.globalAlpha=f===""?1:Number(f);const g=u.style.transform;if(g)h.transform(...to(g));else{const _=parseFloat(u.style.width)/u.width,m=parseFloat(u.style.height)/u.height;h.transform(_,0,0,m,0,0)}h.drawImage(u,0,0),h.restore()}}}this.dispatchRenderEvent(Ut.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 n=e[i],r=n.layer;r.getDeclutter()&&r.renderDeclutter(t,n)}e.forEach(i=>i.layer.renderDeferred(t))}}}function Zh(s){if(s instanceof sr){s.setMapInternal(null);return}s instanceof Ui&&s.getLayers().forEach(Zh)}function Kh(s,t){if(s instanceof sr){s.setMapInternal(t);return}if(s instanceof Ui){const e=s.getLayers().getArray();for(let i=0,n=e.length;ithis.updateSize())),this.controls=e.controls||(Yt?new Zt:Bh()),this.interactions=e.interactions||(Yt?new Zt:g_({onFocusOnly:!0})),this.overlays_=e.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new Hg(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Et.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Et.VIEW,this.handleViewChanged_),this.addChangeListener(Et.SIZE,this.handleSizeChanged_),this.addChangeListener(Et.TARGET,this.handleTargetChanged_),this.setProperties(e.values);const i=this;t.view&&!(t.view instanceof ae)&&t.view.then(function(n){i.setView(new ae(n))}),this.controls.addEventListener(Ot.ADD,n=>{n.element.setMap(this)}),this.controls.addEventListener(Ot.REMOVE,n=>{n.element.setMap(null)}),this.interactions.addEventListener(Ot.ADD,n=>{n.element.setMap(this)}),this.interactions.addEventListener(Ot.REMOVE,n=>{n.element.setMap(null)}),this.overlays_.addEventListener(Ot.ADD,n=>{this.addOverlayInternal_(n.element)}),this.overlays_.addEventListener(Ot.REMOVE,n=>{const r=n.element.getId();r!==void 0&&delete this.overlayIdIndex_[r.toString()],n.element.setMap(null)}),this.controls.forEach(n=>{n.setMap(this)}),this.interactions.forEach(n=>{n.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){Kh(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 n=this.getCoordinateFromPixelInternal(t);i=i!==void 0?i:{};const r=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:Di,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(n,this.frameState_,r,a,e,null,o,null)}getFeaturesAtPixel(t,e){const i=[];return this.forEachFeatureAtPixel(t,function(n){i.push(n)},e),i}getAllLayers(){const t=[];function e(i){i.forEach(function(n){n instanceof Ui?e(n.getLayers()):t.push(n)})}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 n=e.layerFilter!==void 0?e.layerFilter:Di,r=e.hitTolerance!==void 0?e.hitTolerance:0,o=e.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,r,o,n,null)}getEventCoordinate(t){return this.getCoordinateFromPixel(this.getEventPixel(t))}getEventCoordinateInternal(t){return this.getCoordinateFromPixelInternal(this.getEventPixel(t))}getEventPixel(t){const i=this.viewport_.getBoundingClientRect(),n=this.getSize(),r=i.width/n[0],o=i.height/n[1],a="changedTouches"in t?t.changedTouches[0]:t;return[(a.clientX-i.left)/r,(a.clientY-i.top)/o]}getTarget(){return this.get(Et.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(t){return qr(this.getCoordinateFromPixelInternal(t),this.getView().getProjection())}getCoordinateFromPixelInternal(t){const e=this.frameState_;return e?_t(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(Et.LAYERGROUP)}setLayers(t){const e=this.getLayerGroup();if(t instanceof Zt){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=0;r--){const o=n[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 n=this.maxTilesLoading_,r=n;if(t){const o=t.viewHints;if(o[Ct.ANIMATING]||o[Ct.INTERACTING]){const a=Date.now()-t.time>8;n=a?0:8,r=a?0:2}}e.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(t){const e=this.getLayerGroup();e&&this.handleLayerRemove_(new Ge("removelayer",e)),this.set(Et.LAYERGROUP,t)}setSize(t){this.set(Et.SIZE,t)}setTarget(t){this.set(Et.TARGET,t)}setView(t){if(!t||t instanceof ae){this.set(Et.VIEW,t);return}this.set(Et.VIEW,new ae);const e=this;t.then(function(i){e.setView(new ae(i))})}updateSize(){const t=this.getTargetElement();let e;if(t){let n,r;if(Xe(t)){const o=t.getContext("2d").getTransform();n=t.width/o.a,r=t.height/o.d}else{const o=getComputedStyle(t);n=t.offsetWidth-parseFloat(o.borderLeftWidth)-parseFloat(o.paddingLeft)-parseFloat(o.paddingRight)-parseFloat(o.borderRightWidth),r=t.offsetHeight-parseFloat(o.borderTopWidth)-parseFloat(o.paddingTop)-parseFloat(o.paddingBottom)-parseFloat(o.borderBottomWidth)}!isNaN(n)&&!isNaN(r)&&(e=[Math.max(0,n),Math.max(0,r)],!Ga(e)&&(t.offsetWidth||t.offsetHeight||t.getClientRects().length)&&Sl("No map visible because the map container's width or height are 0."))}const i=this.getSize();e&&(!i||!Be(e,i))&&(this.setSize(e),this.updateViewportSize_(e))}updateViewportSize_(t){const e=this.getView();e&&e.setViewportSize(t)}}function x_(s){let t=null;s.keyboardEventTarget!==void 0&&(t=typeof s.keyboardEventTarget=="string"?document.getElementById(s.keyboardEventTarget):s.keyboardEventTarget);const e={},i=s.layers&&typeof s.layers.getLayers=="function"?s.layers:new Ui({layers:s.layers});e[Et.LAYERGROUP]=i,e[Et.TARGET]=s.target,e[Et.VIEW]=s.view instanceof ae?s.view:new ae;let n;s.controls!==void 0&&(Array.isArray(s.controls)?n=new Zt(s.controls.slice()):(it(typeof s.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),n=s.controls));let r;s.interactions!==void 0&&(Array.isArray(s.interactions)?r=new Zt(s.interactions.slice()):(it(typeof s.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),r=s.interactions));let o;return s.overlays!==void 0?Array.isArray(s.overlays)?o=new Zt(s.overlays.slice()):(it(typeof s.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=s.overlays):o=new Zt,{controls:n,interactions:r,keyboardEventTarget:t,overlays:o,values:e}}class qo extends Bs{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(U.CHANGE)}release(){this.setState(N.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(t){if(this.state!==N.EMPTY){if(this.state!==N.ERROR&&this.state>t)throw new Error("Tile load sequence violation");this.state=t,this.changed()}}load(){X()}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 n=e-i+1e3/60;return n>=this.transition_?1:Nh(n/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()}}function co(s){return s instanceof Image||s instanceof HTMLCanvasElement||s instanceof HTMLVideoElement||s instanceof ImageBitmap?s:null}const E_=new Error("disposed"),C_=[256,256];class hl extends qo{constructor(t){const e=N.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=co(this.data_);return t?[t.width,t.height]:C_}getData(){return this.data_}getError(){return this.error_}load(){if(this.state!==N.IDLE&&this.state!==N.ERROR)return;this.state=N.LOADING,this.changed();const t=this;this.loader_().then(function(e){t.data_=e,t.state=N.LOADED,t.changed()}).catch(function(e){t.error_=e,t.state=N.ERROR,t.changed()})}disposeInternal(){this.controller_&&(this.controller_.abort(E_),this.controller_=null),super.disposeInternal()}}class Vh extends qo{constructor(t,e,i,n,r,o){super(t,e,o),this.crossOrigin_=n?.crossOrigin,this.referrerPolicy_=n?.referrerPolicy,this.src_=i,this.key=i,this.image_,Yt?this.image_=new OffscreenCanvas(1,1):(this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.unlisten_=null,this.tileLoadFunction_=r}getImage(){return this.image_}setImage(t){this.image_=t,this.state=N.LOADED,this.unlistenImage_(),this.changed()}getCrossOrigin(){return this.crossOrigin_}getReferrerPolicy(){return this.referrerPolicy_}handleImageError_(){this.state=N.ERROR,this.unlistenImage_(),this.image_=w_(),this.changed()}handleImageLoad_(){if(Yt)this.state=N.LOADED;else{const t=this.image_;t.naturalWidth&&t.naturalHeight?this.state=N.LOADED:this.state=N.EMPTY}this.unlistenImage_(),this.changed()}load(){this.state==N.ERROR&&(this.state=N.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_),this.referrerPolicy_!==void 0&&(this.image_.referrerPolicy=this.referrerPolicy_)),this.state==N.IDLE&&(this.state=N.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=bd(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 w_(){const s=dt(1,1);return s.fillStyle="rgba(0,0,0,0)",s.fillRect(0,0,1,1),s.canvas}class Jo{constructor(t,e,i,n){this.minX=t,this.maxX=e,this.minY=i,this.maxY=n}contains(t){return this.containsXY(t[1],t[2])}containsTileRange(t){return this.minX<=t.minX&&t.maxX<=this.maxX&&this.minY<=t.minY&&t.maxY<=this.maxY}containsXY(t,e){return this.minX<=t&&t<=this.maxX&&this.minY<=e&&e<=this.maxY}equals(t){return this.minX==t.minX&&this.minY==t.minY&&this.maxX==t.maxX&&this.maxY==t.maxY}extend(t){t.minXthis.maxX&&(this.maxX=t.maxX),t.minYthis.maxY&&(this.maxY=t.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(t){return this.minX<=t.maxX&&this.maxX>=t.minX&&this.minY<=t.maxY&&this.maxY>=t.minY}}function xi(s,t,e,i,n){return n!==void 0?(n.minX=s,n.maxX=t,n.minY=e,n.maxY=i,n):new Jo(s,t,e,i)}let Fr;const Li=[];function cl(s,t,e,i,n){s.beginPath(),s.moveTo(0,0),s.lineTo(t,e),s.lineTo(i,n),s.closePath(),s.save(),s.clip(),s.fillRect(0,0,Math.max(t,i)+1,Math.max(e,n)),s.restore()}function Dr(s,t){return Math.abs(s[t*4]-210)>2||Math.abs(s[t*4+3]-.75*255)>2}function v_(){if(Fr===void 0){const s=dt(6,6,Li);s.globalCompositeOperation="lighter",s.fillStyle="rgba(210, 0, 0, 0.75)",cl(s,4,5,4,0),cl(s,4,5,0,5);const t=s.getImageData(0,0,3,3).data;Fr=Dr(t,0)||Dr(t,4)||Dr(t,8),$s(s),Li.push(s.canvas)}return Fr}function ul(s,t,e,i){const n=Ys(e,t,s);let r=Rs(t,i,e);const o=t.getMetersPerUnit();o!==void 0&&(r*=o);const a=s.getMetersPerUnit();a!==void 0&&(r/=a);const l=s.getExtent();if(!l||Ai(l,n)){const h=Rs(s,r,n)/r;isFinite(h)&&h>0&&(r/=h)}return r}function R_(s,t,e,i){const n=Ue(e);let r=ul(s,t,n,i);return(!isFinite(r)||r<=0)&&mo(e,function(o){return r=ul(s,t,o,i),isFinite(r)&&r>0}),r}function S_(s,t,e,i,n,r,o,a,l,h,c,u,d,f){const g=dt(Math.round(e*s),Math.round(e*t),Li);if(u||(g.imageSmoothingEnabled=!1),l.length===0)return g.canvas;g.scale(e,e);function _(E){return Math.round(E*e)/e}g.globalCompositeOperation="lighter";const m=Vt();l.forEach(function(E,T,M){bl(m,E.extent)});let p;const x=e/i,w=(u?1:1+Math.pow(2,-24))/x;p=dt(Math.round(st(m)*x),Math.round(Tt(m)*x),Li),u||(p.imageSmoothingEnabled=!1),l.forEach(function(E,T,M){if(E.image.width>0&&E.image.height>0){if(E.clipExtent){p.save();const O=(E.clipExtent[0]-m[0])*x,L=-(E.clipExtent[3]-m[3])*x,W=st(E.clipExtent)*x,P=Tt(E.clipExtent)*x;p.rect(u?O:Math.round(O),u?L:Math.round(L),u?W:Math.round(O+W)-Math.round(O),u?P:Math.round(L+P)-Math.round(L)),p.clip()}const b=(E.extent[0]-m[0])*x,R=-(E.extent[3]-m[3])*x,S=st(E.extent)*x,A=Tt(E.extent)*x;p.drawImage(E.image,h,h,E.image.width-2*h,E.image.height-2*h,u?b:Math.round(b),u?R:Math.round(R),u?S:Math.round(b+S)-Math.round(b),u?A:Math.round(R+A)-Math.round(R)),E.clipExtent&&p.restore()}});const y=hi(o);return a.getTriangles().forEach(function(E,T,M){const b=E.source,R=E.target;let S=b[0][0],A=b[0][1],O=b[1][0],L=b[1][1],W=b[2][0],P=b[2][1];const Y=_((R[0][0]-y[0])/r),j=_(-(R[0][1]-y[1])/r),F=_((R[1][0]-y[0])/r),D=_(-(R[1][1]-y[1])/r),V=_((R[2][0]-y[0])/r),q=_(-(R[2][1]-y[1])/r),J=S,K=A;S=0,A=0,O-=J,L-=K,W-=J,P-=K;const lt=[[O,L,0,0,F-Y],[W,P,0,0,V-Y],[0,0,O,L,D-j],[0,0,W,P,q-j]],I=$c(lt);if(!I)return;if(g.save(),g.beginPath(),v_()||!u){g.moveTo(F,D);const rt=4,Mt=Y-F,Pt=j-D;for(let Dt=0;Dt_t(a,Ys(w,this.targetProj_,this.sourceProj_))):xn(this.targetProj_,this.sourceProj_);this.transformInv_=function(w){const y=w[0]+"/"+w[1];return l[y]||(l[y]=h(w)),l[y]},this.maxSourceExtent_=n,this.errorThresholdSquared_=r*r,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!n&&!!this.sourceProj_.getExtent()&&st(n)>=st(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?st(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?st(this.targetProj_.getExtent()):null;const c=hi(i),u=Gs(i),d=Ns(i),f=Ds(i),g=this.transformInv_(c),_=this.transformInv_(u),m=this.transformInv_(d),p=this.transformInv_(f),x=T_+(o?Math.max(0,Math.ceil(Math.log2(Ur(i)/(o*o*256*256)))):0);if(this.addQuad_(c,u,d,f,g,_,m,p,x),this.wrapsXInSource_){let w=1/0;this.triangles_.forEach(function(y,E,T){w=Math.min(w,y.source[0][0],y.source[1][0],y.source[2][0])}),this.triangles_.forEach(y=>{if(Math.max(y.source[0][0],y.source[1][0],y.source[2][0])-w>this.sourceWorldWidth_/2){const E=[[y.source[0][0],y.source[0][1]],[y.source[1][0],y.source[1][1]],[y.source[2][0],y.source[2][1]]];E[0][0]-w>this.sourceWorldWidth_/2&&(E[0][0]-=this.sourceWorldWidth_),E[1][0]-w>this.sourceWorldWidth_/2&&(E[1][0]-=this.sourceWorldWidth_),E[2][0]-w>this.sourceWorldWidth_/2&&(E[2][0]-=this.sourceWorldWidth_);const T=Math.min(E[0][0],E[1][0],E[2][0]);Math.max(E[0][0],E[1][0],E[2][0])-T.5&&u<1;let g=!1;if(h>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const m=Wr([t,e,i,n]);g=st(m)/this.targetWorldWidth_>dl||g}!f&&this.sourceProj_.isGlobal()&&u&&(g=u>dl||g)}if(!g&&this.maxSourceExtent_&&isFinite(c[0])&&isFinite(c[1])&&isFinite(c[2])&&isFinite(c[3])&&!St(c,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(h>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(h>0){if(!g){const m=[(t[0]+i[0])/2,(t[1]+i[1])/2],p=this.transformInv_(m);let x;f?x=(ni(r[0],d)+ni(a[0],d))/2-ni(p[0],d):x=(r[0]+a[0])/2-p[0];const w=(r[1]+a[1])/2-p[1];g=x*x+w*w>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),x=[(n[0]+t[0])/2,(n[1]+t[1])/2],w=this.transformInv_(x);this.addQuad_(t,e,m,x,r,o,p,w,h-1),this.addQuad_(x,m,i,n,w,p,a,l,h-1)}else{const m=[(t[0]+e[0])/2,(t[1]+e[1])/2],p=this.transformInv_(m),x=[(i[0]+n[0])/2,(i[1]+n[1])/2],w=this.transformInv_(x);this.addQuad_(t,m,x,n,r,p,w,l,h-1),this.addQuad_(m,e,i,x,p,o,a,w,h-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}(_&11)==0&&this.addTriangle_(t,i,n,r,a,l),(_&14)==0&&this.addTriangle_(t,i,e,r,a,o),_&&((_&13)==0&&this.addTriangle_(e,n,t,o,l,r),(_&7)==0&&this.addTriangle_(e,n,i,o,l,a))}calculateSourceExtent(){const t=Vt();return this.triangles_.forEach(function(e,i,n){const r=e.source;fn(t,r[0]),fn(t,r[1]),fn(t,r[2])}),t}getTriangles(){return this.triangles_}}const b_=.5;class Hh extends qo{constructor(t,e,i,n,r,o,a,l,h,c,u,d){super(r,N.IDLE,d),this.renderEdges_=u!==void 0?u:!1,this.pixelRatio_=a,this.gutter_=l,this.canvas_=null,this.sourceTileGrid_=e,this.targetTileGrid_=n,this.wrappedTileCoord_=o||r,this.sourceTiles_=[],this.sourcesListenerKeys_=null,this.sourceZ_=0,this.clipExtent_=t.canWrapX()?t.getExtent():void 0;const f=n.getTileCoordExtent(this.wrappedTileCoord_),g=this.targetTileGrid_.getExtent();let _=this.sourceTileGrid_.getExtent();const m=g?ii(f,g):f;if(Ur(m)===0){this.state=N.EMPTY;return}const p=t.getExtent();p&&(_?_=ii(_,p):_=p);const x=n.getResolution(this.wrappedTileCoord_[0]),w=R_(t,i,m,x);if(!isFinite(w)||w<=0){this.state=N.EMPTY;return}const y=c!==void 0?c:b_;if(this.triangulation_=new I_(t,i,m,_,w*y,x),this.triangulation_.getTriangles().length===0){this.state=N.EMPTY;return}this.sourceZ_=e.getZForResolution(w);let E=this.triangulation_.calculateSourceExtent();if(_&&(t.canWrapX()?(E[1]=at(E[1],_[1],_[3]),E[3]=at(E[3],_[1],_[3])):E=ii(E,_)),!Ur(E))this.state=N.EMPTY;else{let T=0,M=0;t.canWrapX()&&(T=st(p),M=Math.floor((E[0]-p[0])/T)),Al(E.slice(),t,!0).forEach(R=>{const S=e.getTileRangeForExtentAndZ(R,this.sourceZ_);for(let A=S.minX;A<=S.maxX;A++)for(let O=S.minY;O<=S.maxY;O++){const L=M*T;this.sourceTiles_.push({getTile:()=>h(this.sourceZ_,A,O,a),offset:L})}++M}),this.sourceTiles_.length===0&&(this.state=N.EMPTY)}}getImage(){return this.canvas_}reproject_(){const t=[];if(this.sourceTiles_.forEach(e=>{const i=e.tile;if(i&&i.getState()==N.LOADED){const n=this.sourceTileGrid_.getTileCoordExtent(i.tileCoord);n[0]+=e.offset,n[2]+=e.offset;const r=this.clipExtent_?.slice();r&&(r[0]+=e.offset,r[2]+=e.offset),t.push({extent:n,clipExtent:r,image:i.getImage()})}}),this.sourceTiles_.length=0,t.length===0)this.state=N.ERROR;else{const e=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(e),n=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_=S_(n,r,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,t,this.gutter_,this.renderEdges_,this.interpolate),this.state=N.LOADED}this.changed()}load(){for(const t of this.sourceTiles_)t.tile=t.getTile();if(this.state==N.IDLE){this.state=N.LOADING,this.changed();let t=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(({tile:e})=>{const i=e.getState();if(i==N.IDLE||i==N.LOADING){t++;const n=$(e,U.CHANGE,r=>{const o=e.getState();(o==N.LOADED||o==N.ERROR||o==N.EMPTY)&&(ot(n),t--,t===0&&(this.unlistenSources_(),this.reproject_()))});this.sourcesListenerKeys_.push(n)}}),t===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function({tile:e},i,n){e.getState()==N.IDLE&&e.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(ot),this.sourcesListenerKeys_=null}release(){this.canvas_&&($s(this.canvas_.getContext("2d")),Li.push(this.canvas_),this.canvas_=null),this.sourceTiles_.length=0,super.release()}}class fl{constructor(t){this.highWaterMark=t!==void 0?t:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}deleteOldest(){const t=this.pop();t instanceof Us&&t.dispose()}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(t){for(;this.canExpireCache();)this.deleteOldest()}clear(){for(;this.oldest_;)this.deleteOldest()}containsKey(t){return this.entries_.hasOwnProperty(t)}forEach(t){let e=this.oldest_;for(;e;)t(e.value_,e.key_,this),e=e.newer}get(t,e){const i=this.entries_[t];return it(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 it(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){it(!(t in this.entries_),"Tried to set a value for a key that is used already");const i={key_:t,newer:null,older:this.newest_,value_:e};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[t]=i,++this.count_}setSize(t){this.highWaterMark=t}}function ks(s,t,e,i){return i!==void 0?(i[0]=s,i[1]=t,i[2]=e,i):[s,t,e]}function M_(s,t,e){return s+"/"+t+"/"+e}function Es(s,t,e,i,n){return`${Q(s)},${t},${M_(e,i,n)}`}function P_(s){return L_(s[0],s[1],s[2])}function L_(s,t,e){return(t<e||e>t.getMaxZoom())return!1;const r=t.getFullTileRange(e);return r?r.containsXY(i,n):!0}function Nr(s,t,e){if(!(e in s))return s[e]=new Set([t]),!0;const i=s[e],n=i.has(t);return n||i.add(t),!n}function O_(s,t,e){const i=s[e];return i?i.delete(t):!1}function gl(s,t){const e=s.layerStatesArray[s.layerIndex];e.extent&&(t=ii(t,je(e.extent,s.viewState.projection)));const i=e.layer.getRenderSource();if(!i.getWrapX()){const n=i.getTileGridForProjection(s.viewState.projection).getExtent();n&&(t=ii(t,n))}return t}class k_ extends Ih{constructor(t,e){super(t),e=e||{},this.extentChanged=!0,this.renderComplete=!1,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedTiles=[],this.renderedSourceKey_,this.renderedSourceRevision_,this.tempExtent=Vt(),this.tempTileRange_=new Jo(0,0,0,0),this.tempTileCoord_=ks(0,0,0);const i=e.cacheSize!==void 0?e.cacheSize:512;this.tileCache_=new fl(i),this.sourceTileCache_=null,this.maxStaleKeys=i*.5}getTileCache(){return this.tileCache_}getSourceTileCache(){return this.sourceTileCache_||(this.sourceTileCache_=new fl(512)),this.sourceTileCache_}getOrCreateTile(t,e,i,n){const r=this.tileCache_,a=this.getLayer().getSource(),l=Es(a,a.getKey(),t,e,i);let h;if(r.containsKey(l))h=r.get(l);else{const c=n.viewState.projection,u=a.getProjection();if(h=a.getTile(t,e,i,n.pixelRatio,c,!u||gn(u,c)?void 0:this.getSourceTileCache()),!h)return null;r.set(l,h)}return h}getTile(t,e,i,n){const r=this.getOrCreateTile(t,e,i,n);return r||null}getData(t){const e=this.frameState;if(!e)return null;const i=this.getLayer(),n=_t(e.pixelToCoordinateTransform,t.slice()),r=i.getExtent();if(r&&!Ai(r,n))return null;const o=e.viewState,a=i.getRenderSource(),l=a.getTileGridForProjection(o.projection),h=a.getTilePixelRatio(e.pixelRatio);for(let c=l.getZForResolution(o.resolution);c>=l.getMinZoom();--c){const u=l.getTileCoordForCoordAndZ(n,c),d=this.getTile(c,u[1],u[2],e);if(!d||d.getState()!==N.LOADED)continue;const f=l.getOrigin(c),g=kt(l.getTileSize(c)),_=l.getResolution(c);let m;if(d instanceof Vh||d instanceof Hh)m=d.getImage();else if(d instanceof hl){if(m=co(d.getData()),!m)continue}else continue;const p=Math.floor(h*((n[0]-f[0])/_-u[1]*g[0])),x=Math.floor(h*((f[1]-n[1])/_-u[2]*g[1])),w=Math.round(h*a.getGutterForProjection(o.projection));return this.getImageData(m,p+w,x+w)}return null}prepareFrame(t){this.renderedProjection?t.viewState.projection!==this.renderedProjection&&(this.tileCache_.clear(),this.renderedProjection=t.viewState.projection):this.renderedProjection=t.viewState.projection;const e=this.getLayer().getSource();if(!e)return!1;const i=e.getRevision();return this.renderedSourceRevision_?this.renderedSourceRevision_!==i&&(this.renderedSourceRevision_=i,this.renderedSourceKey_===e.getKey()&&(this.tileCache_.clear(),this.sourceTileCache_?.clear())):this.renderedSourceRevision_=i,!0}enqueueTilesForNextExtent(){return!0}enqueueTiles(t,e,i,n,r){const o=t.viewState,a=this.getLayer(),l=a.getRenderSource(),h=l.getTileGridForProjection(o.projection),c=Q(l);c in t.wantedTiles||(t.wantedTiles[c]={});const u=t.wantedTiles[c],d=a.getMapInternal(),f=Math.max(i-r,h.getMinZoom(),h.getZForResolution(Math.min(a.getMaxResolution(),d?d.getView().getResolutionForZoom(Math.max(a.getMinZoom(),0)):h.getResolution(0)),l.zDirection)),g=o.rotation,_=g?Pl(o.center,o.resolution,g,t.size):void 0;for(let m=i;m>=f;--m){const p=h.getTileRangeForExtentAndZ(e,m,this.tempTileRange_),x=h.getResolution(m);for(let w=p.minX;w<=p.maxX;++w)for(let y=p.minY;y<=p.maxY;++y){if(g&&!h.tileCoordIntersectsViewport([m,w,y],_))continue;const E=this.getTile(m,w,y,t);if(!E||!Nr(n,E,m))continue;const M=E.getKey();if(u[M]=!0,E.getState()===N.IDLE&&!t.tileQueue.isKeyQueued(M)){const b=ks(m,w,y,this.tempTileCoord_);t.tileQueue.enqueue([E,c,h.getTileCoordCenter(b),x])}}}}findStaleTile_(t,e){const i=this.tileCache_,n=t[0],r=t[1],o=t[2],a=this.getStaleKeys();for(let l=0;l0&&setTimeout(()=>{this.enqueueTiles(t,R,d-1,M,b-1)},0),!(d in M))return this.container;const S=Q(this),A=t.time;for(const F of M[d]){const D=F.getState();if(D===N.EMPTY)continue;const V=F.tileCoord;if(D===N.LOADED&&F.getAlpha(S,A)===1){F.endTransition(S);continue}if(D!==N.ERROR&&(this.renderComplete=!1),this.findStaleTile_(V,M)){O_(M,F,d),t.animate=!0;continue}if(this.findAltTiles_(u,V,d+1,M))continue;const K=u.getMinZoom();for(let lt=d-1;lt>=K&&!this.findAltTiles_(u,V,lt,M);--lt);}const O=f/o*l/m,L=this.getRenderContext(t);Me(this.tempTransform,p/2,x/2,O,O,0,-p/2,-x/2),i.extent&&this.clipUnrotated(L,t,w),c.getInterpolate()||(L.imageSmoothingEnabled=!1),this.preRender(L,t);const W=Object.keys(M).map(Number);W.sort(Re);let P;const Y=[],j=[];for(let F=W.length-1;F>=0;--F){const D=W[F],V=c.getTilePixelSize(D,l,r),J=u.getResolution(D)/f,K=V[0]*J*O,lt=V[1]*J*O,I=u.getTileCoordForCoordAndZ(hi(T),D),ut=u.getTileCoordExtent(I),rt=_t(this.tempTransform,[m*(ut[0]-T[0])/f,m*(T[3]-ut[3])/f]),Mt=m*c.getGutterForProjection(r);for(const Pt of M[D]){if(Pt.getState()!==N.LOADED)continue;const Dt=Pt.tileCoord,Bi=I[1]-Dt[1],Bn=Math.round(rt[0]-(Bi-1)*K),Zi=I[2]-Dt[2],rr=Math.round(rt[1]-(Zi-1)*lt),ne=Math.round(rt[0]-Bi*K),Ht=Math.round(rt[1]-Zi*lt),se=Bn-ne,Le=rr-Ht,Zn=W.length===1;let Ki=!1;P=[ne,Ht,ne+se,Ht,ne+se,Ht+Le,ne,Ht+Le];for(let fi=0,Kn=Y.length;fi{const q=Q(c),J=V.wantedTiles[q],K=J?Object.keys(J).length:0;this.updateCacheSize(K),this.tileCache_.expireCache(),this.sourceTileCache_?.expireCache()};t.postRenderFunctions.push(F)}return this.container}updateCacheSize(t){this.tileCache_.highWaterMark=Math.max(this.tileCache_.highWaterMark,t*2)}drawTile(t,e,i,n,r,o,a,l){let h;if(t instanceof hl){if(h=co(t.getData()),!h)throw new Error("Rendering array data is not yet supported")}else h=this.getTileImage(t);if(!h)return;const c=this.getRenderContext(e),u=Q(this),d=e.layerStatesArray[e.layerIndex],f=d.opacity*(l?t.getAlpha(u,e.time):1),g=f!==c.globalAlpha;g&&(c.save(),c.globalAlpha=f),c.drawImage(h,a,a,h.width-2*a,h.height-2*a,i,n,r,o),g&&c.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 n=Q(e);n in t||(t[n]={}),t[n][i.getKey()]=!0}}const ms={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class F_ extends sr{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(ms.PRELOAD)}setPreload(t){this.set(ms.PRELOAD,t)}getUseInterimTilesOnError(){return this.get(ms.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(t){this.set(ms.USE_INTERIM_TILES_ON_ERROR,t)}getData(t){return super.getData(t)}}class _l extends F_{constructor(t){super(t)}createRenderer(){return new k_(this,{cacheSize:this.getCacheSize()})}}const Ei=[0,0,0],Ne=5;class $h{constructor(t){this.minZoom=t.minZoom!==void 0?t.minZoom:0,this.resolutions_=t.resolutions,it(Du(this.resolutions_,(n,r)=>r-n),"`resolutions` must be sorted in descending order");let e;if(!t.origins){for(let n=0,r=this.resolutions_.length-1;n{const o=new Jo(Math.min(0,n[0]),Math.max(n[0]-1,-1),Math.min(0,n[1]),Math.max(n[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 n=this.getTileRangeForExtentAndZ(t,e);for(let r=n.minX,o=n.maxX;r<=o;++r)for(let a=n.minY,l=n.maxY;a<=l;++a)i([e,r,a])}forEachTileCoordParentTileRange(t,e,i,n){let r,o,a,l=null,h=t[0]-1;for(this.zoomFactor_===2?(o=t[1],a=t[2]):l=this.getTileCoordExtent(t,n);h>=this.minZoom;){if(o!==void 0&&a!==void 0?(o=Math.floor(o/2),a=Math.floor(a/2),r=xi(o,o,a,a,i)):r=this.getTileRangeForExtentAndZ(l,h,i),e(h,r))return!0;--h}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(t){return this.origin_?this.origin_:this.origins_[t]}getOrigins(){return this.origins_}getResolution(t){return this.resolutions_[t]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(t,e,i){if(t[0]this.maxZoom||e0?i:Math.max(r/e[0],n/e[1]);const o=t+1,a=new Array(o);for(let l=0;lthis.getTileInternal(g,_,m,p,a,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.tileOptions);return f.key=h,f}getTileInternal(t,e,i,n,r,o){const a=this.getKey(),l=Es(this,a,t,e,i);if(o&&o.containsKey(l))return o.get(l);const h=this.createTile_(t,e,i,n,r,a);return o?.set(l,h),h}setRenderReprojectionEdges(t){this.renderReprojectionEdges_!=t&&(this.renderReprojectionEdges_=t,this.changed())}setTileGridForProjection(t,e){const i=ht(t);if(i){const n=Q(i);n in this.tileGridForProjection||(this.tileGridForProjection[n]=e)}}}function J_(s,t){if(Yt){const e=s.getCrossOrigin();let i="same-origin",n="same-origin";e==="anonymous"||e===""?(i="cors",n="omit"):e==="use-credentials"&&(i="cors",n="include");const r={mode:i,credentials:n,referrerPolicy:s.getReferrerPolicy()};fetch(t,r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.blob()}).then(o=>createImageBitmap(o)).then(o=>{const a=s.getImage();a.width=o.width,a.height=o.height,a.getContext("2d").drawImage(o,0,0),o.close?.(),a.dispatchEvent(new Event("load"))}).catch(()=>{s.getImage().dispatchEvent(new Event("error"))});return}s.getImage().src=t}class Qh extends q_{constructor(t){t=t||{};const e=t.projection!==void 0?t.projection:"EPSG:3857",i=t.tileGrid!==void 0?t.tileGrid:G_({extent:Qo(e),maxResolution:t.maxResolution,maxZoom:t.maxZoom,minZoom:t.minZoom,tileSize:t.tileSize});super({attributions:t.attributions,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin,referrerPolicy:t.referrerPolicy,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 Q_='© OpenStreetMap contributors.';class tm extends Qh{constructor(t){t=t||{};let e;t.attributions!==void 0?e=t.attributions:e=[Q_];const i=t.url!==void 0?t.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:e,attributionsCollapsible:!1,cacheSize:t.cacheSize,crossOrigin:t.crossOrigin!==void 0?t.crossOrigin:"anonymous",referrerPolicy:t.referrerPolicy||"origin-when-cross-origin",interpolate:t.interpolate,maxZoom:t.maxZoom!==void 0?t.maxZoom:19,reprojectionErrorThreshold:t.reprojectionErrorThreshold,tileLoadFunction:t.tileLoadFunction,transition:t.transition,url:i,wrapX:t.wrapX,zDirection:t.zDirection})}}class em{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=we,this.supportedMediaTypes=null}getReadOptions(t,e){if(e){let i=e.dataProjection?ht(e.dataProjection):this.readProjection(t);e.extent&&i&&i.getUnits()==="tile-pixels"&&(i=ht(i),i.setWorldExtent(e.extent)),e={dataProjection:i,featureProjection:e.featureProjection}}return this.adaptOptions(e)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return X()}readFeature(t,e){return X()}readFeatures(t,e){return X()}readGeometry(t,e){return X()}readProjection(t){return X()}writeFeature(t,e){return X()}writeFeatures(t,e){return X()}writeGeometry(t,e){return X()}}function ea(s,t,e){const i=e?ht(e.featureProjection):null,n=e?ht(e.dataProjection):null;let r=s;if(i&&n&&!gn(i,n)){t&&(r=s.clone());const o=t?i:n,a=t?n:i;o.getUnits()==="tile-pixels"?r.transform(o,a):r.applyTransform(xn(o,a))}if(t&&e&&e.decimals!==void 0){const o=Math.pow(10,e.decimals),a=function(l){for(let h=0,c=l.length;htc({...s,geometry:r})).flat();const i=e.type==="MultiPolygon"?"Polygon":e.type;if(i==="GeometryCollection"||i==="Circle")throw new Error("Unsupported geometry type: "+i);const n=e.layout.length;return ea(new Gt(i,i==="Polygon"?nm(e.flatCoordinates,e.ends,n):e.flatCoordinates,e.ends?.flat(),n,s.properties||{},s.id).enableSimplifyTransformed(),!1,t)}function ia(s,t){if(!s)return null;if(Array.isArray(s)){const i=s.map(n=>ia(n,t));return new Mn(i)}const e=im[s.type];return ea(new e(s.flatCoordinates,s.layout||"XY",s.ends),!1,t)}class sm extends em{constructor(){super()}getType(){return"json"}readFeature(t,e){return this.readFeatureFromObject(ps(t),this.getReadOptions(t,e))}readFeatures(t,e){return this.readFeaturesFromObject(ps(t),this.getReadOptions(t,e))}readFeatureFromObject(t,e){return X()}readFeaturesFromObject(t,e){return X()}readGeometry(t,e){return this.readGeometryFromObject(ps(t),this.getReadOptions(t,e))}readGeometryFromObject(t,e){return X()}readProjection(t){return this.readProjectionFromObject(ps(t))}readProjectionFromObject(t){return X()}writeFeature(t,e){return JSON.stringify(this.writeFeatureObject(t,e))}writeFeatureObject(t,e){return X()}writeFeatures(t,e){return JSON.stringify(this.writeFeaturesObject(t,e))}writeFeaturesObject(t,e){return X()}writeGeometry(t,e){return JSON.stringify(this.writeGeometryObject(t,e))}writeGeometryObject(t,e){return X()}}function ps(s){if(typeof s=="string"){const t=JSON.parse(s);return t||null}return s!==null?s:null}class rm extends sm{constructor(t){t=t||{},super(),this.dataProjection=ht(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=ht(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,e){let i=null;t.type==="Feature"?i=t:i={type:"Feature",geometry:t,properties:null};const n=na(i.geometry);if(this.featureClass===Gt)return tc({geometry:n,id:i.id,properties:i.properties},e);const r=new we;return this.geometryName_?r.setGeometryName(this.geometryName_):this.extractGeometryName_&&i.geometry_name&&r.setGeometryName(i.geometry_name),r.setGeometry(ia(n,e)),"id"in i&&r.setId(i.id),i.properties&&r.setProperties(i.properties,!0),r}readFeaturesFromObject(t,e){const i=t;let n=null;if(i.type==="FeatureCollection"){const r=t;n=[];const o=r.features;for(let a=0,l=o.length;a=l){d=_,f=m,g=p;break}else if(f>=a)break;_=d,m=f,p=g,++u}const x=this.scaleBar_?this.createScaleBar(f,d,c):d.toFixed(g<0?-g:0)+" "+c;this.renderedHTML_!=x&&(this.innerElement_.innerHTML=x,this.renderedHTML_=x),this.renderedWidth_!=f&&(this.innerElement_.style.width=f+"px",this.renderedWidth_=f),this.renderedVisible_||(this.element.style.display="",this.renderedVisible_=!0)}createScaleBar(t,e,i){const n=this.getScaleForResolution(),r=n<1?Math.round(1/n).toLocaleString()+" : 1":"1 : "+Math.round(n).toLocaleString(),o=this.scaleBarSteps_,a=t/o,l=[this.createMarker("absolute")];for(let c=0;c
`+this.createMarker("relative")+(c%2===0||o===2?this.createStepText(c,t,!1,e,i):"")+"")}return l.push(this.createStepText(o,t,!0,e,i)),(this.scaleBarText_?`
`+r+"
":"")+l.join("")}createMarker(t){return`
`}createStepText(t,e,i,n,r){const a=(t===0?0:Math.round(n/this.scaleBarSteps_*t*100)/100)+(t===0?"":" "+r),l=t===0?-3:e/this.scaleBarSteps_*-1,h=t===0?0:e/this.scaleBarSteps_*2;return`
`+a+"
"}getScaleForResolution(){const t=Rs(this.viewState_.projection,this.viewState_.resolution,this.viewState_.center,"m"),e=this.dpi_||sn,i=1e3/25.4;return t*i*e}render(t){const e=t.frameState;e?this.viewState_=e.viewState:this.viewState_=null,this.updateElement_()}}const Rm={type:"FeatureCollection",features:[{type:"Feature",properties:{id:"Z-001",name:"Tema Industrial Corridor",zone:"Industrial",type:"industrial",area:"4,820 ha",owner:"Ghana Free Zones Authority",status:"Active"},geometry:{type:"Polygon",coordinates:[[[-.07,5.66],[-.02,5.66],[-.02,5.7],[-.07,5.7],[-.07,5.66]]]}},{type:"Feature",properties:{id:"Z-002",name:"Accra CBD Zone",zone:"Commercial",type:"commercial",area:"1,240 ha",owner:"AMA – Accra Metro",status:"Active"},geometry:{type:"Polygon",coordinates:[[[-.215,5.54],[-.165,5.54],[-.165,5.58],[-.215,5.58],[-.215,5.54]]]}},{type:"Feature",properties:{id:"Z-003",name:"Spintex Residential Estate",zone:"Residential",type:"residential",area:"2,100 ha",owner:"LUSPA – Greater Accra",status:"Active"},geometry:{type:"Polygon",coordinates:[[[-.12,5.61],[-.06,5.61],[-.06,5.655],[-.12,5.655],[-.12,5.61]]]}},{type:"Feature",properties:{id:"Z-004",name:"Accra Plains Agricultural Reserve",zone:"Agricultural",type:"agricultural",area:"7,640 ha",owner:"Ministry of Food & Agriculture",status:"Pending"},geometry:{type:"Polygon",coordinates:[[[-.28,5.56],[-.22,5.56],[-.22,5.62],[-.28,5.62],[-.28,5.56]]]}},{type:"Feature",properties:{id:"Z-005",name:"Adentan Mixed-Use Corridor",zone:"Mixed-Use",type:"mixed",area:"890 ha",owner:"Adentan Municipal Assembly",status:"Review"},geometry:{type:"Polygon",coordinates:[[[-.17,5.665],[-.12,5.665],[-.12,5.705],[-.17,5.705],[-.17,5.665]]]}}]},Sm={type:"FeatureCollection",features:[{type:"Feature",properties:{id:"LU-001",name:"Accra-Tema Motorway Buffer",type:"transport",area:"620 ha"},geometry:{type:"Polygon",coordinates:[[[-.19,5.595],[-.05,5.595],[-.05,5.615],[-.19,5.615],[-.19,5.595]]]}},{type:"Feature",properties:{id:"LU-002",name:"Korle Lagoon Ecological Zone",type:"ecology",area:"340 ha"},geometry:{type:"Polygon",coordinates:[[[-.235,5.53],[-.195,5.53],[-.195,5.56],[-.235,5.56],[-.235,5.53]]]}},{type:"Feature",properties:{id:"LU-003",name:"Legon University Campus",type:"institutional",area:"1,120 ha"},geometry:{type:"Polygon",coordinates:[[[-.205,5.64],[-.17,5.64],[-.17,5.675],[-.205,5.675],[-.205,5.64]]]}}]},Tm={type:"FeatureCollection",features:[{type:"Feature",properties:{id:"UT-001",name:"Kpone Power Plant",type:"power",status:"Active"},geometry:{type:"Point",coordinates:[-.052,5.693]}},{type:"Feature",properties:{id:"UT-002",name:"Tema Water Works",type:"water",status:"Active"},geometry:{type:"Point",coordinates:[-.012,5.668]}},{type:"Feature",properties:{id:"UT-003",name:"Accra Sewage Treatment",type:"sewage",status:"Active"},geometry:{type:"Point",coordinates:[-.252,5.527]}},{type:"Feature",properties:{id:"UT-004",name:"GHACEM Cement Works",type:"industrial",status:"Active"},geometry:{type:"Point",coordinates:[-.037,5.682]}},{type:"Feature",properties:{id:"UT-005",name:"Kotoka Intl Airport",type:"transport",status:"Active"},geometry:{type:"Point",coordinates:[-.165,5.605]}}]},Fs={industrial:{fill:"rgba(255, 158, 27, 0.20)",stroke:"#FF9E1B"},commercial:{fill:"rgba(0, 94, 184, 0.18)",stroke:"#005EB8"},residential:{fill:"rgba(65, 182, 166, 0.20)",stroke:"#41B6A6"},agricultural:{fill:"rgba(0, 107, 63, 0.20)",stroke:"#006B3F"},mixed:{fill:"rgba(30, 26, 75, 0.18)",stroke:"#1E1A4B"},default:{fill:"rgba(122,122,122, 0.15)",stroke:"#7A7A7A"}},pl={power:"#FF9E1B",water:"#41B6A6",sewage:"#8B6F47",industrial:"#005EB8",transport:"#1E1A4B",default:"#7A7A7A"};function Xr(s,t){const e=s.get("type")||"default",i=Fs[e]??Fs.default;return new wt({fill:new It({color:i.fill}),stroke:new Ft({color:i.stroke,width:2})})}function Im(s,t){const e=s.get("type")||"default",i=Fs[e]??Fs.default;return new wt({fill:new It({color:i.fill.replace("0.20","0.40").replace("0.18","0.38")}),stroke:new Ft({color:i.stroke,width:3}),text:new tr({text:s.get("name"),font:"500 11px 'Exo', sans-serif",fill:new It({color:"#1E1A4B"}),stroke:new Ft({color:"#fff",width:3}),overflow:!0})})}function bm(s,t){return new wt({fill:new It({color:"rgba(185, 217, 235, 0.18)"}),stroke:new Ft({color:"#B9D9EB",width:1.5,lineDash:[6,4]})})}function Mm(s,t){const e=s.get("type")||"default",i=pl[e]??pl.default;return new wt({image:new ui({radius:7,fill:new It({color:i}),stroke:new Ft({color:"#fff",width:2})})})}function Pm(s,t){return new wt({fill:new It({color:"rgba(30, 26, 75, 0.12)"}),stroke:new Ft({color:"#1E1A4B",width:2.5,lineDash:[8,4]}),image:new ui({radius:5,fill:new It({color:"#1E1A4B"}),stroke:new Ft({color:"#fff",width:1.5})})})}function Lm({theme:s,children:t}){const e=G.useRef(null),i=G.useRef(null),n=G.useRef(null),[r,o]=G.useState(null),[a,l]=G.useState(null),[h,c]=G.useState(null),[u,d]=G.useState(null),[f,g]=G.useState(null),[_,m]=G.useState(null),[p,x]=G.useState(null),[w,y]=G.useState(5e4),[E,T]=G.useState([-.187,5.6037]),[M,b]=G.useState("pan"),R=new rm({featureProjection:"EPSG:3857"});G.useEffect(()=>{if(!e.current||n.current)return;const A=new _l({source:new tm,visible:!0,properties:{title:"OpenStreetMap",type:"base"}}),O=new _l({source:new Qh({url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",attributions:"Tiles © Esri",maxZoom:19}),visible:!1,properties:{title:"Satellite",type:"base"}}),L=new dn({features:R.readFeatures(Rm)}),W=new un({source:L,style:Xr,visible:!0,properties:{title:"Zoning",type:"overlay"}}),P=new dn({features:R.readFeatures(Sm)}),Y=new un({source:P,style:bm,visible:!0,properties:{title:"Land Use",type:"overlay"}}),j=new dn({features:R.readFeatures(Tm)}),F=new un({source:j,style:Mm,visible:!1,properties:{title:"Utilities",type:"overlay"}}),D=new dn,V=new un({source:D,style:Pm,properties:{title:"Draw Layer",type:"draw"}}),q=new vm({units:"metric",bar:!1,minWidth:80}),J=new Cm({coordinateFormat:Jc(4),projection:"EPSG:4326",className:"ol-mouse-position",placeholder:"—"}),K=new y_({target:e.current,layers:[A,O,Y,W,F,V],view:new ae({center:Xs([-.187,5.6037]),zoom:12,minZoom:8,maxZoom:19}),controls:Bh({zoom:!1,attribution:!0,rotate:!1}).extend([q,J])});return n.current=K,o(A),l(O),c(W),d(Y),g(F),m(V),K.getView().on("change:resolution",()=>{const I=K.getView().getResolution()??1;y(Math.round(I*96/.0254))}),K.on("pointermove",lt=>{if(lt.dragging)return;const I=va(lt.coordinate);T([Math.round(I[0]*1e4)/1e4,Math.round(I[1]*1e4)/1e4])}),K.on("singleclick",lt=>{let I=!1;K.forEachFeatureAtPixel(lt.pixel,ut=>{if(I)return;I=!0;const rt=ut.getProperties(),Mt=va(lt.coordinate);x({id:rt.id??"N/A",name:rt.name??"Unknown Feature",type:rt.type??"unknown",zone:rt.zone??rt.type??"—",area:rt.area??"—",owner:rt.owner??"—",status:rt.status??"Active",coordinate:[Math.round(Mt[0]*1e4)/1e4,Math.round(Mt[1]*1e4)/1e4]}),W.setStyle((Pt,Dt)=>Pt===ut?Im(Pt):Xr(Pt))},{layerFilter:ut=>ut===W||ut===Y||ut===F}),I||(x(null),W.setStyle(Xr))}),K.on("pointermove",lt=>{const I=K.hasFeatureAtPixel(lt.pixel),ut=K.getViewport();ut.style.cursor=I?"pointer":""}),()=>{K.setTarget(void 0),n.current=null}},[]),G.useEffect(()=>{if(!e.current)return;const A=e.current.querySelector(".ol-viewport");A&&A.classList.toggle("dark",s==="dark")},[s]);const S={map:n.current,osmLayer:r,satelliteLayer:a,zoningLayer:h,landUseLayer:u,utilitiesLayer:f,drawLayer:_,popupData:p,setPopupData:x,scale:w,setScale:y,coordinates:E,setCoordinates:T,activeInteraction:M,setActiveInteraction:b};return C.jsxs(Uh.Provider,{value:S,children:[C.jsx("div",{ref:e,className:`absolute inset-0 w-full h-full ${s==="dark"?"dark":""}`,"aria-label":"Interactive planning map",role:"application"}),C.jsx("div",{ref:i,id:"ol-popup-anchor"}),t]})}function Am(s){const[t,e]=G.useState(()=>s?s==="dark":document.documentElement.classList.contains("dark"));return G.useEffect(()=>{if(s){e(s==="dark");return}const i=new MutationObserver(()=>{e(document.documentElement.classList.contains("dark"))});return i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()},[s]),t?"dark":"light"}function Om({theme:s}){const t=s==="dark",{scale:e,coordinates:i,popupData:n}=Yn(),[r,o]=G.useState(!0),[a,l]=G.useState(!0),h=e>=1e3?`1:${(e/1e3).toFixed(0)}k`:`1:${e}`;return C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 pointer-events-none",children:!n&&C.jsx(fc,{status:"success",message:"Map ready · Click a feature to inspect"})}),C.jsx("div",{className:"absolute top-6 left-6 z-40",children:C.jsx(zg,{theme:s})}),C.jsx("div",{className:"absolute top-6 right-6 z-40",children:C.jsx(Yg,{theme:s,isOpen:r,onOpenChange:o})}),C.jsx("div",{className:"absolute top-28 right-6 z-40",children:C.jsx(Ug,{theme:s,isOpen:a,onOpenChange:l})}),C.jsx(Zg,{theme:s}),C.jsxs("div",{className:"absolute bottom-32 left-6 z-30 space-y-2 pointer-events-none",children:[C.jsxs("div",{className:` hidden items-center gap-2 px-3 py-1.5 rounded-lg backdrop-blur-sm shadow-sm bg-card/95 border border-border `,children:[C.jsx("div",{className:`w-2 h-2 rounded-full ${t?"bg-brand-blue-light":"bg-brand-blue-strong"}`}),C.jsxs("span",{className:"text-[length:var(--text-xs)] text-foreground",children:[s==="light"?"Light Mode":"Dark Mode"," · OpenLayers"]})]}),C.jsxs("div",{className:` flex items-center gap-3 px-4 py-3 rounded-xl backdrop-blur-sm shadow-md bg-card/95 border border-border `,children:[C.jsx(Cl,{size:30,color:"var(--brand-blue-strong)"}),C.jsxs("div",{children:[C.jsx("h6",{className:"font-[weight:var(--font-weight-bold)] text-foreground",children:"GIS Planning Platform"}),C.jsx("p",{className:"text-[length:var(--text-xs)] text-muted-foreground",children:"LUPMIS 2.0 · Spatial Intelligence"})]})]})]}),C.jsx("div",{className:"absolute bottom-32 left-1/2 -translate-x-1/2 z-30 pointer-events-none",children:C.jsxs("div",{className:` flex items-center gap-4 px-4 py-2 rounded-xl backdrop-blur-sm shadow-sm bg-card/95 border border-border text-[length:var(--text-xs)] text-muted-foreground `,children:[C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{children:"Scale"}),C.jsx("span",{className:"font-[weight:var(--font-weight-semibold)] text-foreground",children:h})]}),C.jsx("div",{className:"w-px h-3 bg-border"}),C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{children:"Lon"}),C.jsx("span",{className:"font-mono font-[weight:var(--font-weight-semibold)] text-foreground",children:i[0]})]}),C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{children:"Lat"}),C.jsx("span",{className:"font-mono font-[weight:var(--font-weight-semibold)] text-foreground",children:i[1]})]})]})}),C.jsx("div",{className:"absolute bottom-32 right-6 z-30 pointer-events-none",children:C.jsxs("div",{className:` px-3 py-1.5 rounded-full backdrop-blur-sm bg-accent/50 border border-border text-[length:var(--text-xs)] text-muted-foreground `,children:["Press ",C.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-foreground mx-1",children:"?"})," for shortcuts · ",C.jsx("kbd",{className:"px-1.5 py-0.5 bg-muted rounded text-foreground mx-1",children:"Esc"})," to pan"]})})]})}function Wm({theme:s}){const t=Am(s);return C.jsx("div",{className:"relative w-full h-screen overflow-hidden bg-background",children:C.jsx(Lm,{theme:t,children:C.jsx(Om,{theme:t})})})}export{Wm as GISMapMockup};