| @@ -1,18 +1,18 @@ |
| 1 | | -var{defineProperty:JQ,getOwnPropertyNames:qK,getOwnPropertyDescriptor:RK}=Object,MK=Object.prototype.hasOwnProperty;function DK($){return this[$]}var l8=($)=>{var Q=(j6??=new WeakMap).get($),K;if(Q)return Q;if(Q=JQ({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var W of qK($))if(!MK.call(Q,W))JQ(Q,W,{get:DK.bind($,W),enumerable:!(K=RK($,W))||K.enumerable})}return j6.set($,Q),Q},j6,IK=($)=>$;function jK($,Q){this[$]=IK.bind(null,Q)}var C0=($,Q)=>{for(var K in Q)JQ($,K,{get:Q[K],enumerable:!0,configurable:!0,set:jK.bind(Q,K)})},k=($,Q)=>()=>($&&(Q=$($=0)),Q);function T6(){let $=Error("The operation was aborted.");return $.name="AbortError",$}async function PQ($,Q){let{cache:K,signal:W,noStore:J,forceNetwork:U}=Q;if(W?.aborted)throw T6();if(!U){let V=await K.get($);if(V)return{data:V.data,mime:V.mime,fromCache:!0}}try{let V=await fetch($,{signal:W}),X=new Uint8Array(await V.arrayBuffer()),Y=V.headers.get("content-type")??"application/octet-stream";if(!J)await K.put($,X,Y);return{data:X,mime:Y,fromCache:!1}}catch(V){if(W?.aborted)throw T6();let X=await K.get($);if(X)return{data:X.data,mime:X.mime,fromCache:!0};throw V}}function p8(){let $=new Map;return{get:async(Q)=>$.get(Q),put:async(Q)=>{$.set(Q.key,Q)},delete:async(Q)=>{$.delete(Q)},clear:async()=>{$.clear()},all:async()=>[...$.values()],close:()=>{$=new Map}}}class S8{_ttlMs;_maxEntries;_maxBytes;_customBackend;_backend;constructor($={}){this._ttlMs=$.ttlMs??0,this._maxEntries=$.maxEntries??Number.POSITIVE_INFINITY,this._maxBytes=$.maxBytes??Number.POSITIVE_INFINITY,this._customBackend=$.backend,this._backend=$.backend??p8()}async get($){let Q=await this._backend.get($);if(!Q)return;if(this._isExpired(Q)){await this._backend.delete($);return}return Q}async put($,Q,K){let W={key:$,data:Q,mime:K,bytes:Q.byteLength,addedAt:Date.now()};await this._backend.put(W)}async delete($){await this._backend.delete($)}async clear(){await this._backend.clear()}async size(){let $=await this._backend.all(),Q=0;for(let K of $)Q+=K.bytes;return{entries:$.length,bytes:Q}}async prune(){let $=await this._backend.all(),Q=[];for(let J of $)if(this._isExpired(J))await this._backend.delete(J.key);else Q.push(J);Q.sort((J,U)=>J.addedAt-U.addedAt);let K=0;for(let J of Q)K+=J.bytes;let W=Q.length;while(Q.length>0&&(W>this._maxEntries||K>this._maxBytes)){let J=Q.shift();await this._backend.delete(J.key),K-=J.bytes,W-=1}}async close(){if(this._backend.close)await this._backend.close();if(this._customBackend)this._backend=p8();else this._backend=p8()}_isExpired($){if(this._ttlMs<=0)return!1;return Date.now()-$.addedAt>this._ttlMs}}function j$(){if(!I$)I$=new S8;return I$}async function _J(){if(I$)await I$.close(),I$=void 0}var I$,P7=()=>{};function TK($){if(Array.isArray($))return{west:$[0],south:$[1],east:$[2],north:$[3]};return $}function C6($,Q){return Math.floor(($+180)/360*2**Q)}function O6($,Q){let K=$*Math.PI/180;return Math.floor((1-Math.log(Math.tan(K)+1/Math.cos(K))/Math.PI)/2*2**Q)}function X8($,Q){let K=2**Q-1;if($<0)return 0;if($>K)return K;return $}function CK($,Q){let{west:K,south:W,east:J,north:U}=TK($),[V,X]=Q,Y=[];for(let Z=V;Z<=X;Z++){let H=X8(C6(Math.min(K,J),Z),Z),A=X8(C6(Math.max(K,J),Z),Z),G=X8(O6(Math.max(W,U),Z),Z),F=X8(O6(Math.min(W,U),Z),Z);for(let N=H;N<=A;N++)for(let q=G;q<=F;q++)Y.push({x:N,y:q,z:Z})}return Y}function OK($,Q){return $.replace("{z}",String(Q.z)).replace("{x}",String(Q.x)).replace("{y}",String(Q.y))}async function EK($,Q){let K=$.cache??j$(),W=Math.max(1,$.concurrency??4),J=CK($.bounds,$.zoomRange),U=J.length,V={saved:0,failed:0,skipped:0},X=0,Y=0;async function Z(){while(X<J.length){let A=X++,G=J[A],F=OK($.tileUrl,G);try{if((await PQ(F,{cache:K,signal:$.signal})).fromCache)V.skipped++;else V.saved++}catch{V.failed++}Y++,Q?.fire("offline:progress",{completed:Y,total:U,coord:G})}}let H=[];for(let A=0;A<Math.min(W,J.length);A++)H.push(Z());return await Promise.all(H),V}var BK=k(()=>{P7()}),P8=k(()=>{P7(),BK()}),L7={};C0(L7,{falseFn:()=>M0,formatNum:()=>_0,lastId:()=>vQ,noop:()=>wK,setLastId:()=>kK,setOptions:()=>t,splitWords:()=>L0,stamp:()=>u,template:()=>zQ,throttle:()=>LQ,wrapNum:()=>m$});function u($){if(!("_tsmap_id"in $))$._tsmap_id=++vQ;return $._tsmap_id}function kK($){vQ=$}function LQ($,Q,K){let W=!1,J=!1;function U(){if(W=!1,J)V.apply(K,J),J=!1}function V(...X){if(W)J=X;else $.apply(K,X),setTimeout(U,Q),W=!0}return V}function m$($,Q,K){let W=Q[1],J=Q[0],U=W-J;return $===W&&K?$:(($-J)%U+U)%U+J}function M0(...$){return!1}function _0($,Q){if(Q===!1)return $;let K=10**(Q===void 0?6:Q);return Math.round($*K)/K}function L0($){return $.trim().split(/\s+/)}function t($,Q){if(!Object.hasOwn($,"options"))$.options=$.options?Object.create($.options):{};if(Q){for(let K in Q)if(Object.hasOwn(Q,K))$.options[K]=Q[K]}return $.options}function zQ($,Q){return $.replace(z7,(K,W)=>{let J=W.trim(),U=Q[J];if(U===void 0)throw Error(`No value provided for variable ${K}`);else if(typeof U==="function")U=U(Q);return U})}function wK(){}var vQ=0,z7,f=k(()=>{z7=/\{([^{}]+)\}/g});class D{x;y;constructor($,Q,K){if(!D.validate($,Q))throw Error(`Invalid Point object: (${$}, ${Q})`);let J,U;if($ instanceof D)return $;else if(Array.isArray($))J=$[0],U=$[1];else if(typeof $==="object"&&$!==null&&"x"in $&&"y"in $)J=$.x,U=$.y;else J=$,U=Q;this.x=K?Math.round(J):J,this.y=K?Math.round(U):U}static validate($,Q){if($ instanceof D||Array.isArray($))return!0;if($&&typeof $==="object"&&"x"in $&&"y"in $)return!0;if(($||$===0)&&(Q||Q===0))return!0;return!1}clone(){let $=new D(0,0);return $.x=this.x,$.y=this.y,$}add($){return this.clone()._add(new D($))}_add($){return this.x+=$.x,this.y+=$.y,this}subtract($){return this.clone()._subtract(new D($))}_subtract($){return this.x-=$.x,this.y-=$.y,this}divideBy($){return this.clone()._divideBy($)}_divideBy($){return this.x/=$,this.y/=$,this}multiplyBy($){return this.clone()._multiplyBy($)}_multiplyBy($){return this.x*=$,this.y*=$,this}scaleBy($){return new D(this.x*$.x,this.y*$.y)}unscaleBy($){return new D(this.x/$.x,this.y/$.y)}round(){return this.clone()._round()}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}floor(){return this.clone()._floor()}_floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.clone()._ceil()}_ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}trunc(){return this.clone()._trunc()}_trunc(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}distanceTo($){let Q=new D($),K=Q.x-this.x,W=Q.y-this.y;return Math.sqrt(K*K+W*W)}equals($){let Q=new D($);return Q.x===this.x&&Q.y===this.y}contains($){let Q=new D($);return Math.abs(Q.x)<=Math.abs(this.x)&&Math.abs(Q.y)<=Math.abs(this.y)}toString(){return`Point(${_0(this.x)}, ${_0(this.y)})`}}function UQ($,Q,K){if($ instanceof D)return $;if(Array.isArray($))return new D($[0],$[1]);if($===void 0||$===null)return $;if(typeof $==="object"&&"x"in $&&"y"in $)return new D($.x,$.y);return new D($,Q,K)}var l=k(()=>{f()});class P{min;max;constructor($,Q){if(!$)return;if($ instanceof P)return $;let K=Q?[$,Q]:$;for(let W of K)this.extend(W)}extend($){let Q,K;if(!$)return this;if($ instanceof D||Array.isArray($)&&typeof $[0]==="number"||$&&"x"in $)Q=K=UQ($);else{let W=new P($);if(Q=W.min,K=W.max,!Q||!K)return this}if(!this.min&&!this.max)this.min=Q.clone(),this.max=K.clone();else this.min.x=Math.min(Q.x,this.min.x),this.max.x=Math.max(K.x,this.max.x),this.min.y=Math.min(Q.y,this.min.y),this.max.y=Math.max(K.y,this.max.y);return this}getCenter($){return new D((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,$)}getBottomLeft(){return new D(this.min.x,this.max.y)}getTopRight(){return new D(this.max.x,this.min.y)}getTopLeft(){return this.min}getBottomRight(){return this.max}getSize(){return this.max.subtract(this.min)}contains($){let Q,K,W=$;if(Array.isArray(W)&&typeof W[0]==="number"||W instanceof D)W=UQ(W);else W=new P(W);if(W instanceof P)Q=W.min,K=W.max;else Q=K=W;return Q.x>=this.min.x&&K.x<=this.max.x&&Q.y>=this.min.y&&K.y<=this.max.y}intersects($){let Q=new P($),K=this.min,W=this.max,J=Q.min,U=Q.max,V=U.x>=K.x&&J.x<=W.x,X=U.y>=K.y&&J.y<=W.y;return V&&X}overlaps($){let Q=new P($),K=this.min,W=this.max,J=Q.min,U=Q.max,V=U.x>K.x&&J.x<W.x,X=U.y>K.y&&J.y<W.y;return V&&X}isValid(){return!!(this.min&&this.max)}pad($){let Q=this.min,K=this.max,W=Math.abs(Q.x-K.x)*$,J=Math.abs(Q.y-K.y)*$;return new P(new D(Q.x-W,Q.y-J),new D(K.x+W,K.y+J))}equals($){if(!$)return!1;let Q=new P($);return this.min.equals(Q.getTopLeft())&&this.max.equals(Q.getBottomRight())}}function _K($,Q){if(!$||$ instanceof P)return $;return new P($,Q)}var W0=k(()=>{l()});function u0($){return($[2]-$[0])*($[3]-$[1])}function Y8($){return $[2]-$[0]+($[3]-$[1])}function Z8($,Q){let K=Math.max($[2],Q[2])-Math.min($[0],Q[0]),W=Math.max($[3],Q[3])-Math.min($[1],Q[1]);return K*W}function SK($,Q){let K=Math.max($[0],Q[0]),W=Math.max($[1],Q[1]),J=Math.min($[2],Q[2]),U=Math.min($[3],Q[3]);if(J<K||U<W)return 0;return(J-K)*(U-W)}function E6($,Q){return $[0]<=Q[0]&&$[1]<=Q[1]&&$[2]>=Q[2]&&$[3]>=Q[3]}function B6($,Q){return Q[0]<=$[2]&&Q[1]<=$[3]&&Q[2]>=$[0]&&Q[3]>=$[1]}function k6($,Q,K){return $[0]<=Q&&Q<=$[2]&&$[1]<=K&&K<=$[3]}function k0(){return[1/0,1/0,-1/0,-1/0]}function j0($,Q){if(Q[0]<$[0])$[0]=Q[0];if(Q[1]<$[1])$[1]=Q[1];if(Q[2]>$[2])$[2]=Q[2];if(Q[3]>$[3])$[3]=Q[3];return $}function h0($,Q,K){let W=$.bbox;W[0]=1/0,W[1]=1/0,W[2]=-1/0,W[3]=-1/0;let J=$.children;for(let U=Q;U<K;U++)j0(W,J[U].bbox)}function w6($){return{bbox:k0(),children:$,leaf:!1}}class v7{_maxEntries;_minEntries;_root;_size;constructor($){let Q=Math.max(4,$?.maxEntries??9),K=Math.max(2,$?.minEntries??Math.ceil(Q*0.4));this._maxEntries=Q,this._minEntries=Math.min(K,Math.floor(Q/2)),this._root={bbox:k0(),children:[],leaf:!0},this._size=0}size(){return this._size}clear(){return this._root={bbox:k0(),children:[],leaf:!0},this._size=0,this}insert($,Q){let K={bbox:[$[0],$[1],$[2],$[3]],data:Q};return this._insertRecord(K),this._size++,this}remove($,Q,K){let W=K??((V,X)=>V===X),J=[];if(this._removeFrom(this._root,$,Q,W,J))this._size--,this._condense(J);return this}_removeFrom($,Q,K,W,J){let U=$.children;if(!U)return!1;if(J.push($),$.leaf){for(let V=0;V<U.length;V++){let X=U[V];if(X.data!==void 0&&W(X.data,K))return U.splice(V,1),!0}return J.pop(),!1}for(let V=0;V<U.length;V++){let X=U[V];if(!E6(X.bbox,Q))continue;if(this._removeFrom(X,Q,K,W,J))return!0}return J.pop(),!1}search($){let Q=[],K=this._root;if(!B6(K.bbox,$))return Q;let W=[K];while(W.length>0){let J=W.pop(),U=J.children;if(!U)continue;for(let V=0;V<U.length;V++){let X=U[V];if(!B6(X.bbox,$))continue;if(J.leaf)Q.push({bbox:X.bbox,data:X.data});else if(E6($,X.bbox))this._collectAll(X,Q);else W.push(X)}}return Q}searchPoint($,Q){let K=[],W=this._root;if(!k6(W.bbox,$,Q))return K;let J=[W];while(J.length>0){let U=J.pop(),V=U.children;if(!V)continue;for(let X=0;X<V.length;X++){let Y=V[X];if(!k6(Y.bbox,$,Q))continue;if(U.leaf)K.push({bbox:Y.bbox,data:Y.data});else J.push(Y)}}return K}all(){let $=[];return this._collectAll(this._root,$),$}load($){if($.length===0)return this;if($.length<this._minEntries){for(let U of $)this.insert(U.bbox,U.data);return this}let Q=$.map((U)=>{return{bbox:[U.bbox[0],U.bbox[1],U.bbox[2],U.bbox[3]],data:U.data}}),K=this._buildSTR(Q,0,Q.length-1,this._chooseHeight(Q.length));if(this._size===0)return this._root=K,this._size=$.length,this;let W=this._height(this._root),J=this._height(K);if(W===J)this._mergeRoots(K),this._size+=$.length;else if(W<J){let U=this._root;this._root=K,this._size=$.length;let V=[];this._collectAll(U,V);for(let X of V)this.insert(X.bbox,X.data)}else{let U=W-J;this._insertSubtree(K,U),this._size+=$.length}return this}_collectAll($,Q){let K=[$];while(K.length>0){let W=K.pop(),J=W.children;if(!J)continue;if(W.leaf)for(let U=0;U<J.length;U++){let V=J[U];Q.push({bbox:V.bbox,data:V.data})}else for(let U=0;U<J.length;U++)K.push(J[U])}}_height($){let Q=0,K=$;while(!K.leaf){Q++;let W=K.children?.[0];if(!W)break;K=W}return Q}_mergeRoots($){let Q=this._root;if(Q.leaf!==$.leaf){let W=[];this._collectAll($,W);for(let J of W)this.insert(J.bbox,J.data);return}let K=$.children;for(let W of K)Q.children.push(W);if(h0(Q,0,Q.children.length),Q.children.length>this._maxEntries){let W=this._splitChildren(Q),J=w6([Q,W]);this._root=J,h0(J,0,2)}}_chooseHeight($){if($<=this._maxEntries)return 0;return Math.ceil(Math.log($)/Math.log(this._maxEntries))}_buildSTR($,Q,K,W){return this._buildSTRInner($,Q,K,W,!0)}_buildSTRInner($,Q,K,W,J){let U=K-Q+1,V=this._maxEntries;if(U<=V){let G=$.slice(Q,K+1),F={bbox:k0(),children:G,leaf:J};return h0(F,0,G.length),F}let X=Math.max(W-1,0),Y=Math.ceil(U/V**X),Z=Math.ceil(Math.sqrt(Math.ceil(U/Y))),H=Y*Z;S6($,Q,K,H,LK);let A=[];for(let G=Q;G<=K;G+=H){let F=Math.min(G+H-1,K);S6($,G,F,Y,zK);for(let N=G;N<=F;N+=Y){let q=Math.min(N+Y-1,F),R=$.slice(N,q+1),I={bbox:k0(),children:R,leaf:J};h0(I,0,R.length),A.push(I)}}if(A.length===1)return A[0];return this._buildSTRInner(A,0,A.length-1,W-1,!1)}_insertRecord($){let Q=[],K=this._root;while(!K.leaf){Q.push(K);let J=K.children,U=J[0],V=Z8(U.bbox,$.bbox)-u0(U.bbox),X=u0(U.bbox);for(let Y=1;Y<J.length;Y++){let Z=J[Y],H=u0(Z.bbox),A=Z8(Z.bbox,$.bbox)-H;if(A<V)V=A,X=H,U=Z;else if(A===V&&H<X)X=H,U=Z}K=U}Q.push(K),K.children.push($),j0(K.bbox,$.bbox);let W=Q.length-1;while(W>=0){if(Q[W].children.length>this._maxEntries)this._split(Q,W);else j0(Q[W].bbox,$.bbox);W--}}_insertSubtree($,Q){let K=[],W=this._root,J=0;while(J<Q&&!W.leaf){K.push(W);let V=W.children,X=V[0],Y=Z8(X.bbox,$.bbox)-u0(X.bbox),Z=u0(X.bbox);for(let H=1;H<V.length;H++){let A=V[H],G=u0(A.bbox),F=Z8(A.bbox,$.bbox)-G;if(F<Y)Y=F,Z=G,X=A}W=X,J++}K.push(W),W.children.push($),j0(W.bbox,$.bbox);let U=K.length-1;while(U>=0){if(K[U].children.length>this._maxEntries)this._split(K,U);else j0(K[U].bbox,$.bbox);U--}}_split($,Q){let K=$[Q],W=this._splitChildren(K);if(Q===0)this._root=w6([K,W]),h0(this._root,0,2);else $[Q-1].children.push(W),h0($[Q-1],0,$[Q-1].children.length)}_splitChildren($){let Q=$.children,K=this._maxEntries,W=this._minEntries;this._chooseSplitAxis(Q,W,K);let J=this._chooseSplitIndex(Q,W,K),U=Q.splice(J,Q.length-J),V={bbox:k0(),children:U,leaf:$.leaf};return h0($,0,Q.length),h0(V,0,U.length),V}_chooseSplitAxis($,Q,K){$.sort(_6);let W=this._allDistMargin($,Q,K);$.sort(PK);let J=this._allDistMargin($,Q,K);if(W<J)$.sort(_6)}_allDistMargin($,Q,K){let W=k0(),J=k0();for(let X=0;X<Q;X++)j0(W,$[X].bbox);for(let X=$.length-Q;X<$.length;X++)j0(J,$[X].bbox);let U=Y8(W)+Y8(J),V=$.length;for(let X=Q;X<V-Q;X++)j0(W,$[X].bbox),U+=Y8(W);for(let X=V-Q-1;X>=Q;X--)j0(J,$[X].bbox),U+=Y8(J);return U}_chooseSplitIndex($,Q,K){let W=Q,J=1/0,U=1/0,V=$.length;for(let X=Q;X<=V-Q;X++){let Y=k0();for(let G=0;G<X;G++)j0(Y,$[G].bbox);let Z=k0();for(let G=X;G<V;G++)j0(Z,$[G].bbox);let H=SK(Y,Z),A=u0(Y)+u0(Z);if(H<J)J=H,U=A,W=X;else if(H===J&&A<U)U=A,W=X}return W}_condense($){let Q=[];for(let K=$.length-1;K>=0;K--){let W=$[K];if(W.children&&W.children.length===0)if(K>0){let J=$[K-1],U=J.children.indexOf(W);if(U>=0)J.children.splice(U,1)}else{this.clear();return}else if(W.children&&W.children.length<this._minEntries&&K>0){this._collectLeafNodes(W,Q);let J=$[K-1],U=J.children.indexOf(W);if(U>=0)J.children.splice(U,1)}else h0(W,0,W.children?.length??0)}if(Q.length>0)for(let K of Q){let W=K.children;if(!W)continue;for(let J of W)this.insert(J.bbox,J.data),this._size--}}_collectLeafNodes($,Q){let K=[$];while(K.length>0){let W=K.pop();if(W.leaf)Q.push(W);else if(W.children)for(let J of W.children)K.push(J)}}}function _6($,Q){return $.bbox[0]-Q.bbox[0]}function PK($,Q){return $.bbox[1]-Q.bbox[1]}function LK($,Q){return $.bbox[0]+$.bbox[2]-(Q.bbox[0]+Q.bbox[2])}function zK($,Q){return $.bbox[1]+$.bbox[3]-(Q.bbox[1]+Q.bbox[3])}function S6($,Q,K,W,J){let U=$.slice(Q,K+1);U.sort(J);for(let V=0;V<U.length;V++)$[Q+V]=U[V]}class Y${_a;_b;_c;_d;constructor($,Q,K,W){if(Array.isArray($)){this._a=$[0],this._b=$[1],this._c=$[2],this._d=$[3];return}this._a=$,this._b=Q,this._c=K,this._d=W}transform($,Q){return this._transform($.clone(),Q)}_transform($,Q){return Q||=1,$.x=Q*(this._a*$.x+this._b),$.y=Q*(this._c*$.y+this._d),$}untransform($,Q){return Q||=1,new D(($.x/Q-this._b)/this._a,($.y/Q-this._d)/this._c)}}function vK($,Q,K,W){return new Y$($,Q,K,W)}var a$=k(()=>{l()});class z{_southWest;_northEast;constructor($,Q){if(!$)return;if($ instanceof z)return $;let K=Q?[$,Q]:$;for(let W of K)this.extend(W)}extend($){let Q=this._southWest,K=this._northEast,W,J;if($ instanceof O)W=$,J=$;else if($ instanceof z){if(W=$._southWest,J=$._northEast,!W||!J)return this}else{if(!$)return this;if(O.validate($))return this.extend(new O($));return this.extend(new z($))}if(!Q&&!K)this._southWest=new O(W.lat,W.lng),this._northEast=new O(J.lat,J.lng);else Q.lat=Math.min(W.lat,Q.lat),Q.lng=Math.min(W.lng,Q.lng),K.lat=Math.max(J.lat,K.lat),K.lng=Math.max(J.lng,K.lng);return this}pad($){let Q=this._southWest,K=this._northEast,W=Math.abs(Q.lat-K.lat)*$,J=Math.abs(Q.lng-K.lng)*$;return new z(new O(Q.lat-W,Q.lng-J),new O(K.lat+W,K.lng+J))}getCenter(){return new O((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)}getSouthWest(){return this._southWest}getNorthEast(){return this._northEast}getNorthWest(){return new O(this.getNorth(),this.getWest())}getSouthEast(){return new O(this.getSouth(),this.getEast())}getWest(){return this._southWest.lng}getSouth(){return this._southWest.lat}getEast(){return this._northEast.lng}getNorth(){return this._northEast.lat}contains($){let Q=$;if(O.validate(Q))Q=new O(Q);else Q=new z(Q);let K=this._southWest,W=this._northEast,J,U;if(Q instanceof z)J=Q.getSouthWest(),U=Q.getNorthEast();else J=U=Q;return J.lat>=K.lat&&U.lat<=W.lat&&J.lng>=K.lng&&U.lng<=W.lng}intersects($){let Q=new z($),K=this._southWest,W=this._northEast,J=Q.getSouthWest(),U=Q.getNorthEast(),V=U.lat>=K.lat&&J.lat<=W.lat,X=U.lng>=K.lng&&J.lng<=W.lng;return V&&X}overlaps($){let Q=new z($),K=this._southWest,W=this._northEast,J=Q.getSouthWest(),U=Q.getNorthEast(),V=U.lat>K.lat&&J.lat<W.lat,X=U.lng>K.lng&&J.lng<W.lng;return V&&X}toBBoxString(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")}equals($,Q){if(!$)return!1;let K=new z($);return this._southWest.equals(K.getSouthWest(),Q)&&this._northEast.equals(K.getNorthEast(),Q)}isValid(){return!!(this._southWest&&this._northEast)}}function fK($,Q){if($ instanceof z)return $;return new z($,Q)}var A0=k(()=>{Y0()});class L8{static projection=void 0;static transformation=void 0;static code;static wrapLng;static wrapLat;static infinite=!1;static latLngToPoint($,Q){let K=this.projection.project($),W=this.scale(Q);return this.transformation._transform(K,W)}static pointToLatLng($,Q){let K=this.scale(Q),W=this.transformation.untransform($,K);return this.projection.unproject(W)}static project($){return this.projection.project($)}static unproject($){return this.projection.unproject($)}static scale($){return 256*2**$}static zoom($){return Math.log($/256)/Math.LN2}static getProjectedBounds($){if(this.infinite)return null;let Q=this.projection.bounds,K=this.scale($),W=this.transformation.transform(Q.min,K),J=this.transformation.transform(Q.max,K);return new P(W,J)}static distance($,Q){return 0}static wrapLatLng($){let Q=new O($),K=this.wrapLng?m$(Q.lng,this.wrapLng,!0):Q.lng,W=this.wrapLat?m$(Q.lat,this.wrapLat,!0):Q.lat,J=Q.alt;return new O(W,K,J)}static wrapLatLngBounds($){let Q=new z($),K=Q.getCenter(),W=this.wrapLatLng(K),J=K.lat-W.lat,U=K.lng-W.lng;if(J===0&&U===0)return Q;let V=Q.getSouthWest(),X=Q.getNorthEast(),Y=new O(V.lat-J,V.lng-U),Z=new O(X.lat-J,X.lng-U);return new z(Y,Z)}}var fQ=k(()=>{f(),W0(),Y0(),A0()}),s0,C$=k(()=>{fQ(),s0=class extends L8{static wrapLng=[-180,180];static R=6371000;static distance(Q,K){let W=Math.PI/180,J=Q.lat*W,U=K.lat*W,V=Math.sin((K.lat-Q.lat)*W/2),X=Math.sin((K.lng-Q.lng)*W/2),Y=V*V+Math.cos(J)*Math.cos(U)*X*X,Z=2*Math.atan2(Math.sqrt(Y),Math.sqrt(1-Y));return this.R*Z}}});class O{lat;lng;alt;constructor($,Q,K){if(!O.validate($,Q,K))throw Error(`Invalid LatLng object: (${$}, ${Q})`);let J,U,V;if($ instanceof O)return $;else if(Array.isArray($)&&typeof $[0]!=="object")if($.length===3)J=$[0],U=$[1],V=$[2];else J=$[0],U=$[1];else if(typeof $==="object"&&$!==null&&"lat"in $){let X=$;J=X.lat,U="lng"in X?X.lng:X.lon,V=X.alt}else J=$,U=Q,V=K;if(this.lat=+J,this.lng=+U,V!==void 0)this.alt=+V}static validate($,Q,K){if($ instanceof O||typeof $==="object"&&$!==null&&"lat"in $)return!0;if($&&Array.isArray($)&&typeof $[0]!=="object"){if($.length===3||$.length===2)return!0;return!1}if(($||$===0)&&(Q||Q===0))return!0;return!1}equals($,Q){if(!$)return!1;let K=new O($);return Math.max(Math.abs(this.lat-K.lat),Math.abs(this.lng-K.lng))<=(Q??0.000000001)}toString($){return`LatLng(${_0(this.lat,$)}, ${_0(this.lng,$)})`}distanceTo($){return s0.distance(this,new O($))}wrap(){return s0.wrapLatLng(this)}toBounds($){let Q=180*$/40075017,K=Q/Math.cos(Math.PI/180*this.lat);return new z([this.lat-Q,this.lng-K],[this.lat+Q,this.lng+K])}clone(){let $=new O(0,0);return $.lat=this.lat,$.lng=this.lng,$.alt=this.alt,$}}function hK($,Q,K){if($ instanceof O)return $;if($===null||$===void 0)return $;return new O($,Q,K)}var Y0=k(()=>{f(),C$(),A0()});function f7($,Q,K){return-1e4+($*65536+Q*256+K)*0.1}function h7($,Q,K){return $*256+Q+K/256-32768}function bK($){return $==="terrarium"?h7:f7}function xK($,Q="mapbox"){let K=$.length/4|0,W=new Float32Array(K),J=bK(Q);for(let U=0,V=0;U<K;U++,V+=4)W[U]=J($[V],$[V+1],$[V+2]);return W}function b7($,Q,K,W){let J=P6(K,0,Q-1),U=P6(W,0,Q-1),V=Math.floor(J),X=Math.floor(U),Y=Math.min(Q-1,V+1),Z=Math.min(Q-1,X+1),H=J-V,A=U-X,G=$[X*Q+V],F=$[X*Q+Y],N=$[Z*Q+V],q=$[Z*Q+Y],R=G*(1-H)+F*H,I=N*(1-H)+q*H;return R*(1-A)+I*A}function P6($,Q,K){return $<Q?Q:$>K?K:$}function yK($){let Q=$.demSize;if(Q<2)throw RangeError("demSize must be >= 2");if($.elevation.length<Q*Q)throw RangeError(`elevation array is too small for demSize=${Q}`);let K=$.tileSize??Q,W=Math.max(1,Math.floor($.resolution??32)),J=$.exaggeration??1,U=$.unitsPerMeter??1,V=W+1,X=V*V,Y=new Float32Array(X*6),Z=K/W,H=(Q-1)/W;for(let F=0;F<V;F++){let N=F*Z,q=F*H;for(let R=0;R<V;R++){let I=R*Z,C=R*H,j=b7($.elevation,Q,C,q)*J*U,E=(F*V+R)*6;Y[E]=I,Y[E+1]=N,Y[E+2]=j,Y[E+3]=0,Y[E+4]=0,Y[E+5]=1}}for(let F=0;F<V;F++)for(let N=0;N<V;N++){let q=Math.max(0,N-1),R=Math.min(V-1,N+1),I=Math.max(0,F-1),C=Math.min(V-1,F+1),M=Y[(F*V+q)*6+2],j=Y[(F*V+R)*6+2],E=Y[(I*V+N)*6+2],_=Y[(C*V+N)*6+2],x=(R-q)*Z||1,n=(C-I)*Z||1,p=-(j-M)/x,J0=-(_-E)/n,a=1,y=Math.hypot(p,J0,1)||1,o=(F*V+N)*6;Y[o+3]=p/y,Y[o+4]=J0/y,Y[o+5]=1/y}let A=new Uint32Array(W*W*6),G=0;for(let F=0;F<W;F++)for(let N=0;N<W;N++){let q=F*V+N,R=q+1,I=q+V,C=I+1;A[G++]=q,A[G++]=I,A[G++]=R,A[G++]=R,A[G++]=I,A[G++]=C}return{positions:Y,indices:A,vertexCount:X,indexCount:A.length,resolution:W}}var x7=()=>{};class y7{constructor($){this._tiles=new Map,this._opts={demSize:$?.demSize??256,encoding:$?.encoding??"mapbox",meshResolution:$?.meshResolution??32,exaggeration:$?.exaggeration??1}}get demSize(){return this._opts.demSize}get encoding(){return this._opts.encoding}get meshResolution(){return this._opts.meshResolution}get exaggeration(){return this._opts.exaggeration}setExaggeration($){if(!Number.isFinite($))throw RangeError("exaggeration must be a finite number");this._opts.exaggeration=$}addTilePixels($,Q){let K=this._opts.demSize*this._opts.demSize*4;if(Q.length<K)throw RangeError(`pixel buffer too small: got ${Q.length}, need ${K}`);this._tiles.set(N$($),xK(Q,this._opts.encoding))}addTileElevation($,Q){let K=this._opts.demSize*this._opts.demSize;if(Q.length<K)throw RangeError(`elevation grid too small: got ${Q.length}, need ${K}`);this._tiles.set(N$($),Q)}hasTile($){return this._tiles.has(N$($))}getTile($){return this._tiles.get(N$($))}deleteTile($){this._tiles.delete(N$($))}clear(){this._tiles.clear()}size(){return this._tiles.size}queryElevation($,Q,K){let W=uK(Q,-85.05112878,85.05112878),J=Math.max(0,Math.floor(K));for(let U=J;U>=0;U--){let V=gK($,U),X=mK(W,U),Y=this._tiles.get(N$({z:U,x:V,y:X}));if(!Y)continue;let Z=dK($,U)-V*this._opts.demSize,H=cK(W,U)-X*this._opts.demSize;return b7(Y,this._opts.demSize,Z,H)}return null}}function N$($){return`${$.z}/${$.x}/${$.y}`}function uK($,Q,K){return $<Q?Q:$>K?K:$}function gK($,Q){return Math.floor(($+180)/360*2**Q)}function mK($,Q){let K=$*Math.PI/180;return Math.floor((1-Math.log(Math.tan(K)+1/Math.cos(K))/Math.PI)/2*2**Q)}function dK($,Q){return($+180)/360*2**Q*256}function cK($,Q){let K=$*Math.PI/180;return(1-Math.log(Math.tan(K)+1/Math.cos(K))/Math.PI)/2*2**Q*256}var u7=()=>{},L6=6378137,p0,hQ=k(()=>{W0(),l(),Y0(),p0={R:L6,MAX_LATITUDE:85.0511287798,project($){let Q=new O($),K=Math.PI/180,W=this.MAX_LATITUDE,J=Math.max(Math.min(W,Q.lat),-W),U=Math.sin(J*K);return new D(this.R*Q.lng*K,this.R*Math.log((1+U)/(1-U))/2)},unproject($){let Q=new D($),K=180/Math.PI;return new O((2*Math.atan(Math.exp(Q.y/this.R))-Math.PI/2)*K,Q.x*K/this.R)},bounds:(()=>{let $=L6*Math.PI;return new P([-$,-$],[$,$])})()}}),O8,lK,g7=k(()=>{a$(),hQ(),C$(),O8=class extends s0{static code="EPSG:3857";static projection=p0;static transformation=(()=>{let Q=0.5/(Math.PI*p0.R);return new Y$(Q,0.5,-Q,0.5)})()},lK=class extends O8{static code="EPSG:900913"}});function z6($){if(typeof navigator>"u"||typeof navigator.userAgent>"u")return!1;return navigator.userAgent.toLowerCase().includes($)}var i8,v6,f6,n8,s8,h6,b6,x6,y6,u6,X0,e0=k(()=>{i8=z6("chrome"),v6=!i8&&z6("safari"),f6=typeof globalThis.orientation<"u",n8=typeof window>"u"?!1:!!window.PointerEvent,s8=typeof window>"u"?!1:("ontouchstart"in window)||!!window.TouchEvent,h6=s8||n8,b6=typeof window>"u"||typeof window.devicePixelRatio>"u"?!1:window.devicePixelRatio>1,x6=typeof navigator>"u"||typeof navigator.platform>"u"?!1:navigator.platform.startsWith("Mac"),y6=typeof navigator>"u"||typeof navigator.platform>"u"?!1:navigator.platform.startsWith("Linux"),u6={chrome:i8,safari:v6,mobile:f6,pointer:n8,touch:h6,touchNative:s8,retina:b6,mac:x6,linux:y6},X0=u6}),m7={};C0(m7,{cleanupPointers:()=>pK,disablePointerDetection:()=>c7,enablePointerDetection:()=>d7,getPointers:()=>z0});function d7($){$.addEventListener("pointerdown",l7,{capture:!0}),$.addEventListener("pointermove",p7,{capture:!0}),$.addEventListener("pointerup",E8,{capture:!0}),$.addEventListener("pointercancel",E8,{capture:!0}),r0.clear()}function c7($){$.removeEventListener("pointerdown",l7,{capture:!0}),$.removeEventListener("pointermove",p7,{capture:!0}),$.removeEventListener("pointerup",E8,{capture:!0}),$.removeEventListener("pointercancel",E8,{capture:!0})}function l7($){$.target.setPointerCapture($.pointerId),r0.set($.pointerId,$)}function p7($){if(r0.has($.pointerId))r0.set($.pointerId,$)}function E8($){$.target.releasePointerCapture($.pointerId),r0.delete($.pointerId)}function z0(){return[...r0.values()]}function pK(){r0.clear()}var r0,Z$=k(()=>{r0=new Map});function iK($){let Q={bubbles:$.bubbles,cancelable:$.cancelable,composed:$.composed,detail:2,view:$.view,screenX:$.screenX,screenY:$.screenY,clientX:$.clientX,clientY:$.clientY,ctrlKey:$.ctrlKey,shiftKey:$.shiftKey,altKey:$.altKey,metaKey:$.metaKey,button:$.button,buttons:$.buttons,relatedTarget:$.relatedTarget};if(typeof PointerEvent<"u"&&$ instanceof PointerEvent)return Q={...Q,pointerId:$.pointerId,width:$.width,height:$.height,pressure:$.pressure,tangentialPressure:$.tangentialPressure,tiltX:$.tiltX,tiltY:$.tiltY,twist:$.twist,pointerType:$.pointerType,isPrimary:$.isPrimary},new PointerEvent("dblclick",Q);return new MouseEvent("dblclick",Q)}function nK($,Q){$.addEventListener("dblclick",Q);let K=0,W;function J(U){if(U.detail!==1){W=U.detail;return}if(U.pointerType==="mouse"||U.sourceCapabilities&&!U.sourceCapabilities.firesTouchEvents)return;let V=s7(U);if(V.some((Y)=>Y instanceof HTMLLabelElement&&Y.attributes.getNamedItem("for"))&&!V.some((Y)=>Y instanceof HTMLInputElement||Y instanceof HTMLSelectElement))return;let X=Date.now();if(X-K<=rK){if(W++,W===2)U.target.dispatchEvent(iK(U))}else W=1;K=X}return $.addEventListener("click",J),{dblclick:Q,simDblclick:J}}function sK($,Q){$.removeEventListener("dblclick",Q.dblclick),$.removeEventListener("click",Q.simDblclick)}var rK=200,aK=k(()=>{i()}),oK={};C0(oK,{create:()=>v,disableImageDrag:()=>yQ,disableTextSelection:()=>bQ,enableImageDrag:()=>uQ,enableTextSelection:()=>xQ,get:()=>i7,getPosition:()=>J$,getScale:()=>mQ,getSizedParentNode:()=>n7,preventOutline:()=>gQ,restoreOutline:()=>B8,setPosition:()=>K0,setTransform:()=>W$,toBack:()=>t$,toFront:()=>o$});function i7($){return typeof $==="string"?document.getElementById($):$}function v($,Q,K){let W=document.createElement($);return W.className=Q??"",K?.appendChild(W),W}function o$($){let Q=$.parentNode;if(Q&&Q.lastChild!==$)Q.appendChild($)}function t$($){let Q=$.parentNode;if(Q&&Q.firstChild!==$)Q.insertBefore($,Q.firstChild)}function W$($,Q,K,W,J){let U=Q??new D(0,0),V=W?` rotate(${W}deg)`:"",X=J?` rotateX(${J}deg)`:"",Y=K?` scale(${K})`:"";$.style.transform=`translate3d(${U.x}px,${U.y}px,0)${X}${V}${Y}`}function K0($,Q,K,W){if(dQ.set($,Q),K!==void 0)VQ.set($,K);if(W!==void 0)XQ.set($,W);let J=K??VQ.get($)??0,U=W??XQ.get($)??0;W$($,Q,void 0,J||void 0,U||void 0)}function J$($){return dQ.get($)??new D(0,0)}function bQ(){let $=d$[k8];if($==="none")return;I8=$,d$[k8]="none"}function xQ(){if(typeof I8>"u")return;d$[k8]=I8,I8=void 0}function yQ(){B(window,"dragstart",a0)}function uQ(){h(window,"dragstart",a0)}function gQ($){let Q=$;while(Q.tabIndex===-1)Q=Q.parentNode;if(!Q.style)return;B8(),j8=Q,YQ=Q.style.outlineStyle,Q.style.outlineStyle="none",B(window,"keydown",B8)}function B8(){if(!j8)return;j8.style.outlineStyle=YQ,j8=void 0,YQ=void 0,h(window,"keydown",B8)}function n7($){let Q=$;do Q=Q.parentNode;while((!Q.offsetWidth||!Q.offsetHeight)&&Q!==document.body);return Q}function mQ($){let Q=$.getBoundingClientRect();return{x:Q.width/$.offsetWidth||1,y:Q.height/$.offsetHeight||1,boundingClientRect:Q}}var dQ,VQ,XQ,d$,k8,I8,j8,YQ,r=k(()=>{i(),l(),dQ=new WeakMap,VQ=new WeakMap,XQ=new WeakMap,d$=typeof document>"u"?{}:document.documentElement.style,k8=["userSelect","WebkitUserSelect"].find(($)=>($ in d$))}),ZQ={};C0(ZQ,{PointerEvents:()=>m7,disableClickPropagation:()=>O$,disableScrollPropagation:()=>cQ,getPointerPosition:()=>r7,getPropagationPath:()=>s7,getWheelDelta:()=>o7,getWheelPxFactor:()=>a7,isExternalTarget:()=>lQ,off:()=>h,on:()=>B,preventDefault:()=>a0,stop:()=>o0,stopPropagation:()=>i0});function B($,Q,K,W){if(Q&&typeof Q==="object")for(let[J,U]of Object.entries(Q))HQ($,J,U,K);else for(let J of L0(Q))HQ($,J,K,W);return this}function h($,Q,K,W){if(arguments.length===1)g6($),delete $[x0];else if(Q&&typeof Q==="object")for(let[J,U]of Object.entries(Q))AQ($,J,U,K);else{let J=L0(Q);if(arguments.length===2)g6($,(U)=>J.includes(U));else for(let U of J)AQ($,U,K,W)}return this}function g6($,Q){for(let K of Object.keys($[x0]??{})){let W=K.split(/\d/)[0];if(!Q||Q(W))AQ($,W,null,null,K)}}function HQ($,Q,K,W){let J=Q+u(K)+(W?`_${u(W)}`:"");if($[x0]&&$[x0][J])return;let U=function(X){return K.call(W||$,X)},V=U;if(X0.touch&&Q==="dblclick")U=nK($,U);else if("addEventListener"in $)if(Q==="wheel"||Q==="mousewheel")$.addEventListener(w8[Q]||Q,U,{passive:!1});else if(Q==="pointerenter"||Q==="pointerleave")U=function(X){if(lQ($,X))V(X)},$.addEventListener(w8[Q],U,!1);else $.addEventListener(Q,V,!1);else $.attachEvent(`on${Q}`,U);$[x0]??={},$[x0][J]=U}function AQ($,Q,K,W,J){J??=Q+u(K)+(W?`_${u(W)}`:"");let U=$[x0]&&$[x0][J];if(!U)return;if(X0.touch&&Q==="dblclick")sK($,U);else if("removeEventListener"in $)$.removeEventListener(w8[Q]||Q,U,!1);else $.detachEvent(`on${Q}`,U);$[x0][J]=null}function i0($){if($.stopPropagation)$.stopPropagation();else if($.originalEvent)$.originalEvent._stopped=!0;else $.cancelBubble=!0;return this}function cQ($){return HQ($,"wheel",i0),this}function O$($){return B($,"pointerdown dblclick contextmenu",i0),$._tsmap_disable_click=!0,this}function a0($){return $.preventDefault?.(),this}function o0($){return a0($),i0($),this}function s7($){return $.composedPath()}function r7($,Q){if(!Q)return new D($.clientX,$.clientY);let K=mQ(Q),W=K.boundingClientRect;return new D(($.clientX-W.left)/K.x-Q.clientLeft,($.clientY-W.top)/K.y-Q.clientTop)}function a7(){let $=window.devicePixelRatio;return X0.linux&&X0.chrome?$:X0.mac?$*3:$>0?2*$:1}function o7($){return $.deltaY&&$.deltaMode===0?-$.deltaY/a7():$.deltaY&&$.deltaMode===1?-$.deltaY*20:$.deltaY&&$.deltaMode===2?-$.deltaY*60:$.deltaX||$.deltaZ?0:0}function lQ($,Q){let K=Q.relatedTarget;if(!K)return!0;try{while(K&&K!==$)K=K.parentNode}catch{return!1}return K!==$}var x0="_tsmap_events",w8,i=k(()=>{e0(),f(),Z$(),l(),aK(),r(),w8={pointerenter:"pointerover",pointerleave:"pointerout",wheel:typeof window>"u"?!1:!("onwheel"in window)&&"mousewheel"}});class E${static include($){let Q=this.prototype.options;for(let W of K($))this.prototype[W]=$[W];if($.options)this.prototype.options=Q,this.mergeOptions($.options);return this;function*K(W){do{if(W===Object||W===Object.prototype)break;for(let J of Object.getOwnPropertyNames(W))yield J}while((W=Object.getPrototypeOf(W))!==void 0)}}static setDefaultOptions($){return t(this.prototype,$),this}static mergeOptions($){return this.prototype.options??={},Object.assign(this.prototype.options,$),this}static addInitHook($,...Q){let K=typeof $==="function"?$:function(){this[$].apply(this,Q)};if(!Object.hasOwn(this.prototype,"_initHooks"))this.prototype._initHooks=[];return this.prototype._initHooks.push(K),this}_initHooksCalled=!1;initialize(...$){}constructor(...$){t(this),this.initialize(...$),this.callInitHooks()}callInitHooks(){if(this._initHooksCalled)return;let $=[],Q=this;while((Q=Object.getPrototypeOf(Q))!==null)$.push(Q);$.reverse();for(let K of $)for(let W of K._initHooks??[])W.call(this);this._initHooksCalled=!0}}var e$=k(()=>{f()});function H8($,Q){if(typeof Q==="string"){if(Q.length===0)throw TypeError(`Evented.${$}: event type must be a non-empty string.`);return}if(Q!==null&&typeof Q==="object"&&!Array.isArray(Q))return;throw TypeError(`Evented.${$}: first argument must be a string or a { type: handler } object, got ${Q===null?"null":Array.isArray(Q)?"array":typeof Q}.`)}var R0,B$=k(()=>{f(),e$(),R0=class $ extends E${static __REMOVED_EVENTS=["mousedown","mouseup","mouseover","mouseout","mousemove"];on(Q,K,W){if(H8("on",Q),typeof Q==="object")for(let[J,U]of Object.entries(Q))this._on(J,U,K);else for(let J of L0(Q))this._on(J,K,W);return this}off(Q,K,W){if(!arguments.length)delete this._events;else if(typeof Q==="object"){H8("off",Q);for(let[J,U]of Object.entries(Q))this._off(J,U,K)}else{H8("off",Q);let J=arguments.length===1;for(let U of L0(Q))if(J)this._off(U);else this._off(U,K,W)}return this}_on(Q,K,W,J){if($.__REMOVED_EVENTS.includes(Q))console.error(`The event ${Q} has been removed. Use the PointerEvent variant instead.`);if(typeof K!=="function"){console.warn(`wrong listener type: ${typeof K}`);return}if(this._listens(Q,K,W)!==!1)return;if(W===this)W=void 0;let U={fn:K,ctx:W};if(J)U.once=!0;this._events??={},this._events[Q]??=[],this._events[Q].push(U)}_off(Q,K,W){if(!this._events)return;let J=this._events[Q];if(!J)return;if(arguments.length===1){if(this._firingCount)for(let V of J)V.fn=M0;delete this._events[Q];return}if(typeof K!=="function"){console.warn(`wrong listener type: ${typeof K}`);return}let U=this._listens(Q,K,W);if(U!==!1&&typeof U==="number"){let V=J[U];if(this._firingCount)V.fn=M0,this._events[Q]=J=J.slice();J.splice(U,1)}}fire(Q,K,W){if(!this.listens(Q,W))return this;let J={...K,type:Q,target:this,sourceTarget:K?.sourceTarget||this};if(this._events){let U=this._events[Q];if(U){this._firingCount=(this._firingCount||0)+1;for(let V of U){let X=V.fn;if(V.once)this.off(Q,X,V.ctx);X.call(V.ctx||this,J)}this._firingCount--}}if(W)this._propagateEvent(J);return this}listens(Q,K,W,J){if(typeof Q!=="string")console.warn('"string" type argument expected');let U=K;if(typeof K!=="function")J=!!K,U=void 0,W=void 0;if(this._events?.[Q]?.length){if(this._listens(Q,U,W)!==!1)return!0}if(J){for(let V of Object.values(this._eventParents??{}))if(V.listens(Q,K,W,J))return!0}return!1}_listens(Q,K,W){if(!this._events)return!1;let J=this._events[Q]??[];if(!K)return J.length?0:!1;if(W===this)W=void 0;let U=J.findIndex((V)=>V.fn===K&&V.ctx===W);return U===-1?!1:U}once(Q,K,W){if(H8("once",Q),typeof Q==="object")for(let[J,U]of Object.entries(Q))this._on(J,U,K,!0);else for(let J of L0(Q))this._on(J,K,W,!0);return this}addEventParent(Q){return this._eventParents??={},this._eventParents[u(Q)]=Q,this}removeEventParent(Q){if(this._eventParents)delete this._eventParents[u(Q)];return this}_propagateEvent(Q){for(let K of Object.values(this._eventParents??{}))K.fire(Q.type,{propagatedFrom:Q.target,...Q},!0)}addEventListener=this.on;removeEventListener=this.off;clearAllEventListeners=this.off;addOneTimeEventListener=this.once;fireEvent=this.fire;hasEventListeners=this.listens}}),tK={};C0(tK,{cubicBezier:()=>Z5,easeInCubic:()=>W5,easeInOutCubic:()=>GQ,easeInOutQuad:()=>K5,easeInOutQuart:()=>X5,easeInQuad:()=>$5,easeInQuart:()=>U5,easeOutBack:()=>Y5,easeOutCubic:()=>J5,easeOutQuad:()=>Q5,easeOutQuart:()=>V5,linear:()=>eK});function eK($){return $}function $5($){return $*$}function Q5($){return 1-(1-$)*(1-$)}function K5($){return $<0.5?2*$*$:1-(-2*$+2)**2/2}function W5($){return $*$*$}function J5($){return 1-(1-$)**3}function GQ($){return $<0.5?4*$*$*$:1-(-2*$+2)**3/2}function U5($){return $*$*$*$}function V5($){return 1-(1-$)**4}function X5($){return $<0.5?8*$*$*$*$:1-(-2*$+2)**4/2}function Y5($){let W=$-1;return 1+2.70158*W*W*W+1.70158*W*W}function Z5($,Q,K,W){let J=3*$-3*K+1,U=-6*$+3*K,V=3*$,X=3*Q-3*W+1,Y=-6*Q+3*W,Z=3*Q,H=(F)=>((J*F+U)*F+V)*F,A=(F)=>((X*F+Y)*F+Z)*F,G=(F)=>(3*J*F+2*U)*F+V;return function(N){if(N<=0)return 0;if(N>=1)return 1;let q=N;for(let R=0;R<10;R++){let I=H(q)-N;if(Math.abs(I)<0.00001)return A(q);let C=G(q);if(Math.abs(C)<0.000001)break;q-=I/C}return A(q)}}var pQ,t7=k(()=>{B$(),pQ=class extends R0{constructor(){super();this._easing=GQ,this._startTime=0,this._lastTime=0,this._duration=0,this._running=!1,this._pendingStart=!1}run(Q){if(this._running)this._finish(!1);this._opts=Q,this._easing=Q.easing??GQ,this._duration=Math.max(0,Q.duration),this._running=!0,this._pendingStart=!0,this._startTime=0,this._lastTime=0,this._animId=requestAnimationFrame((K)=>this._tick(K))}cancel(){if(!this._running)return;this._finish(!1)}stop(){this.cancel()}isRunning(){return this._running}_tick(Q){if(!this._running)return;if(this._pendingStart){if(this._pendingStart=!1,this._startTime=Q,this._lastTime=Q,this._opts?.onStart?.(),this.fire("start"),this._duration<=0){this._emitFrame(1,1,0),this._finish(!0);return}}let K=Q-this._startTime,W=(Q-this._lastTime)/1000;if(this._lastTime=Q,K>=this._duration){this._emitFrame(1,1,W),this._finish(!0);return}let J=K/this._duration,U=this._easing(J);if(this._emitFrame(J,U,W),this._running)this._animId=requestAnimationFrame((V)=>this._tick(V))}_emitFrame(Q,K,W){let J={progress:Q,t:K,dt:W};this._opts?.onFrame(J),this.fire("frame",J)}_finish(Q){let K=this._opts;if(this._animId!==void 0)cancelAnimationFrame(this._animId),this._animId=void 0;this._running=!1,this._pendingStart=!1,this._opts=void 0,K?.onEnd?.(Q),this.fire("end",{completed:Q})}}}),iQ,e7=k(()=>{r(),B$(),iQ=class extends R0{run(Q,K,W,J){this.stop(),this._el=Q,this._inProgress=!0,this._duration=W??0.25,this._easeOutPower=1/Math.max(J??0.5,0.2),this._startPos=J$(Q),this._offset=K.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()}stop(){if(!this._inProgress)return;this._step(!0),this._complete()}_animate(){this._animId=requestAnimationFrame(this._animate.bind(this)),this._step()}_step(Q){let K=+new Date-this._startTime,W=this._duration*1000;if(K<W)this._runFrame(this._easeOut(K/W),Q);else this._runFrame(1),this._complete()}_runFrame(Q,K){let W=this._startPos.add(this._offset.multiplyBy(Q));if(K)W._round();K0(this._el,W),this.fire("step")}_complete(){cancelAnimationFrame(this._animId),this._inProgress=!1,this.fire("end")}_easeOut(Q){return 1-(1-Q)**this._easeOutPower}}});function n0($){return $<0?0:$>1?1:$}function H5($){return $<0?0:$>255?255:$}function N0($){let Q=$.charCodeAt(0);if(Q>=48&&Q<=57)return Q-48;if(Q>=97&&Q<=102)return Q-87;if(Q>=65&&Q<=70)return Q-55;return Number.NaN}function A5($){let Q=$.length;if(Q===3||Q===4){let K=N0($[0]),W=N0($[1]),J=N0($[2]),U=Q===4?N0($[3]):15;if(Number.isNaN(K)||Number.isNaN(W)||Number.isNaN(J)||Number.isNaN(U))return null;return[K*17/255,W*17/255,J*17/255,U*17/255]}if(Q===6||Q===8){let K=N0($[0])<<4|N0($[1]),W=N0($[2])<<4|N0($[3]),J=N0($[4])<<4|N0($[5]),U=Q===8?N0($[6])<<4|N0($[7]):255;if(Number.isNaN(K)||Number.isNaN(W)||Number.isNaN(J)||Number.isNaN(U))return null;return[K/255,W/255,J/255,U/255]}return null}function r8($){let Q=$.trim();if(Q.endsWith("%")){let W=Number.parseFloat(Q.slice(0,-1));if(Number.isNaN(W))return Number.NaN;return n0(W/100)}let K=Number.parseFloat(Q);if(Number.isNaN(K))return Number.NaN;return H5(K)/255}function m6($){let Q=$.trim();if(Q.endsWith("%")){let W=Number.parseFloat(Q.slice(0,-1));if(Number.isNaN(W))return Number.NaN;return n0(W/100)}let K=Number.parseFloat(Q);if(Number.isNaN(K))return Number.NaN;return n0(K)}function G5($,Q,K){let W=($%360+360)%360,J=(1-Math.abs(2*K-1))*Q,U=J*(1-Math.abs(W/60%2-1)),V=K-J/2,X=0,Y=0,Z=0;if(W<60)X=J,Y=U,Z=0;else if(W<120)X=U,Y=J,Z=0;else if(W<180)X=0,Y=J,Z=U;else if(W<240)X=0,Y=U,Z=J;else if(W<300)X=U,Y=0,Z=J;else X=J,Y=0,Z=U;return[n0(X+V),n0(Y+V),n0(Z+V)]}function F5($){if($.includes(","))return $.split(",").map((U)=>U.trim()).filter((U)=>U.length>0);let Q=$.indexOf("/"),K=Q>=0?$.slice(0,Q):$,W=Q>=0?$.slice(Q+1):"",J=K.trim().split(/\s+/).filter((U)=>U.length>0);if(W.trim().length>0)J.push(W.trim());return J}function z8($){if(typeof $!=="string")return null;let Q=$.trim().toLowerCase();if(Q.length===0)return null;if(Q.startsWith("#"))return A5(Q.slice(1));let K=Q.indexOf("(");if(K>0&&Q.endsWith(")")){let J=Q.slice(0,K),U=Q.slice(K+1,-1),V=F5(U);if(J==="rgb"||J==="rgba"){if(V.length<3||V.length>4)return null;let X=r8(V[0]),Y=r8(V[1]),Z=r8(V[2]),H=V.length===4?m6(V[3]):1;if(Number.isNaN(X)||Number.isNaN(Y)||Number.isNaN(Z)||Number.isNaN(H))return null;return[X,Y,Z,H]}if(J==="hsl"||J==="hsla"){if(V.length<3||V.length>4)return null;let X=V[0].trim(),Y=Number.parseFloat(X.endsWith("deg")?X.slice(0,-3):X),Z=V[1].trim(),H=V[2].trim();if(!Z.endsWith("%")||!H.endsWith("%"))return null;let A=Number.parseFloat(Z.slice(0,-1))/100,G=Number.parseFloat(H.slice(0,-1))/100;if(Number.isNaN(Y)||Number.isNaN(A)||Number.isNaN(G))return null;let[F,N,q]=G5(Y,n0(A),n0(G)),R=V.length===4?m6(V[3]):1;if(Number.isNaN(R))return null;return[F,N,q,R]}return null}let W=$9[Q];if(W!==void 0)return z8(W);return null}function d6($,Q,K){let W=K<0?0:K>1?1:K;return[$[0]+(Q[0]-$[0])*W,$[1]+(Q[1]-$[1])*W,$[2]+(Q[2]-$[2])*W,$[3]+(Q[3]-$[3])*W]}var $9,v8=k(()=>{$9={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",steelblue:"#4682b4",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",transparent:"rgba(0,0,0,0)",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}}),T,v0=k(()=>{T=class extends Error{constructor(Q,K,W=[]){let J=W.length>0?`[${W.map((U)=>JSON.stringify(U)).join("][")}] `:"";super(`${J}${Q}`);this.name="ExpressionError",this.expression=K,this.path=W.slice()}}});function w($,Q){f8[$]=Q}function N5($){return f8[$]}function q5($){return Object.prototype.hasOwnProperty.call(f8,$)}var f8,$$=k(()=>{f8={}});function z$($){let Q=!1,K=!1,W=!1;for(let J of $){if(J.dependsOnZoom)Q=!0;if(J.dependsOnFeature)K=!0;if(J.dependsOnFeatureState)W=!0}return{dependsOnZoom:Q,dependsOnFeature:K,dependsOnFeatureState:W}}function R5(){w("to-string",($,Q,K)=>{if($.length!==1)throw new T(`"to-string" expects 1 argument, got ${$.length}`,["to-string",...$],K);let W=Q($[0],"value",K.concat(1));return{evaluate:(J)=>{let U=W.evaluate(J);if(U===null||U===void 0)return"";if(typeof U==="string")return U;if(typeof U==="number"||typeof U==="boolean")return String(U);try{return JSON.stringify(U)}catch{return String(U)}},returnType:"string",...z$([W])}}),w("to-number",($,Q,K)=>{if($.length<1)throw new T('"to-number" expects at least 1 argument',["to-number",...$],K);let W=$.map((U,V)=>Q(U,"value",K.concat(V+1))),J=["to-number",...$];return{evaluate:(U)=>{for(let V=0;V<W.length;V++){let X=W[V].evaluate(U);if(X===null||X===void 0)continue;if(typeof X==="number"){if(!Number.isNaN(X))return X;continue}if(typeof X==="boolean")return X?1:0;if(typeof X==="string"){let Y=X.trim();if(Y.length===0)continue;let Z=Number(Y);if(!Number.isNaN(Z))return Z}}throw new T('"to-number": could not convert any argument to a number',J)},returnType:"number",...z$(W)}}),w("to-boolean",($,Q,K)=>{if($.length!==1)throw new T(`"to-boolean" expects 1 argument, got ${$.length}`,["to-boolean",...$],K);let W=Q($[0],"value",K.concat(1));return{evaluate:(J)=>{let U=W.evaluate(J);if(U===null||U===void 0)return!1;if(typeof U==="number")return U!==0&&!Number.isNaN(U);if(typeof U==="string")return U.length>0;if(typeof U==="boolean")return U;if(Array.isArray(U))return U.length>0;if(typeof U==="object")return!0;return Boolean(U)},returnType:"boolean",...z$([W])}}),w("to-rgba",($,Q,K)=>{if($.length!==1)throw new T(`"to-rgba" expects 1 argument, got ${$.length}`,["to-rgba",...$],K);let W=Q($[0],"color",K.concat(1)),J=["to-rgba",...$];return{evaluate:(U)=>{let V=W.evaluate(U),X=c6(V);if(!X)throw new T(`"to-rgba": cannot convert ${String(V)} to a color`,J);return[Math.round(X[0]*255),Math.round(X[1]*255),Math.round(X[2]*255),X[3]]},returnType:"array",...z$([W])}}),w("to-color",($,Q,K)=>{if($.length<1)throw new T('"to-color" expects at least 1 argument',["to-color",...$],K);let W=$.map((U,V)=>Q(U,"value",K.concat(V+1))),J=["to-color",...$];return{evaluate:(U)=>{for(let V=0;V<W.length;V++){let X=W[V].evaluate(U),Y=c6(X);if(Y)return M5(Y)}throw new T('"to-color": could not convert any argument to a color',J)},returnType:"color",...z$(W)}})}function c6($){if(typeof $==="string")return z8($);if(Array.isArray($)&&($.length===3||$.length===4)){let Q=Number($[0]),K=Number($[1]),W=Number($[2]),J=$.length===4?Number($[3]):1;if([Q,K,W,J].some(Number.isNaN))return null;return[d0(Q/255),d0(K/255),d0(W/255),d0(J)]}return null}function d0($){return $<0?0:$>1?1:$}function M5($){let Q=Math.round(d0($[0])*255),K=Math.round(d0($[1])*255),W=Math.round(d0($[2])*255),J=d0($[3]);return`rgba(${Q},${K},${W},${J===1?"1":String(Number(J.toFixed(4)))})`}var D5=k(()=>{v8(),v0(),$$()});function l6($){let Q=!1,K=!1,W=!1;for(let J of $){if(J.dependsOnZoom)Q=!0;if(J.dependsOnFeature)K=!0;if(J.dependsOnFeatureState)W=!0}return{dependsOnZoom:Q,dependsOnFeature:K,dependsOnFeatureState:W}}function p6($,Q){if($.length===0||Q<$[0])return-1;let K=0,W=$.length-1;while(K<W){let J=K+W+1>>1;if($[J]<=Q)K=J;else W=J-1}return K}function FQ($,Q,K){if($===Q)return 0;let W=(K-$)/(Q-$);return W<0?0:W>1?1:W}function I5($,Q,K,W){if(Q===K)return 0;if($===1)return FQ(Q,K,W);let J=K-Q,U=W-Q,V=($**U-1)/($**J-1);return V<0?0:V>1?1:V}function j5($,Q,K,W){let J=3*$,U=3*(K-$)-J,V=1-J-U,X=3*Q,Y=3*(W-Q)-X,Z=1-X-Y,H=(F)=>((V*F+U)*F+J)*F,A=(F)=>((Z*F+Y)*F+X)*F,G=(F)=>(3*V*F+2*U)*F+J;return(F)=>{if(F<=0)return 0;if(F>=1)return 1;let N=F;for(let C=0;C<8;C++){let M=H(N)-F;if(Math.abs(M)<0.000001)return A(N);let j=G(N);if(Math.abs(j)<0.000001)break;N-=M/j}let q=0,R=1,I=F;for(let C=0;C<20;C++){let M=H(I)-F;if(Math.abs(M)<0.000001)return A(I);if(M>0)R=I;else q=I;I=(q+R)/2}return A(I)}}function T5($,Q){if(!Array.isArray($)||$.length===0)throw new T('"interpolate": interpolation type required',$,Q);let K=$[0];if(K==="linear")return{kind:"linear"};if(K==="exponential"){let W=Number($[1]);if(!Number.isFinite(W)||W<=0)throw new T('"interpolate": exponential base must be a positive number',$,Q);return{kind:"exponential",base:W}}if(K==="cubic-bezier"){let W=Number($[1]),J=Number($[2]),U=Number($[3]),V=Number($[4]);if([W,J,U,V].some((X)=>!Number.isFinite(X)))throw new T('"interpolate": cubic-bezier requires 4 numeric control points',$,Q);return{kind:"cubic-bezier",bezier:j5(W,J,U,V)}}throw new T(`"interpolate": unknown interpolation type ${JSON.stringify(K)}`,$,Q)}function C5($){if($==="number")return(Q,K,W)=>{let J=Number(Q),U=Number(K);return J+(U-J)*W};if($==="color")return(Q,K,W)=>{let J=A8(Q),U=A8(K);if(!J||!U)return Q;return i6(d6(J,U,W))};if($==="string")return(Q,K,W)=>{if(typeof Q!=="string"||typeof K!=="string")return W<1?Q:K;let J=A8(Q),U=A8(K);if(!J||!U)return W<1?Q:K;return i6(d6(J,U,W))};if($==="array")return(Q,K,W)=>{if(!Array.isArray(Q)||!Array.isArray(K)||Q.length!==K.length)return Q;let J=Array(Q.length);for(let U=0;U<Q.length;U++){let V=Number(Q[U]),X=Number(K[U]);J[U]=V+(X-V)*W}return J};return(Q,K,W)=>W<1?Q:K}function A8($){if(typeof $==="string")return z8($);if(Array.isArray($)&&($.length===3||$.length===4)){let Q=Number($[0])/255,K=Number($[1])/255,W=Number($[2])/255,J=$.length===4?Number($[3]):1;if([Q,K,W,J].some(Number.isNaN))return null;return[c0(Q),c0(K),c0(W),c0(J)]}return null}function c0($){return $<0?0:$>1?1:$}function i6($){let Q=Math.round(c0($[0])*255),K=Math.round(c0($[1])*255),W=Math.round(c0($[2])*255),J=c0($[3]);return`rgba(${Q},${K},${W},${J===1?"1":String(Number(J.toFixed(4)))})`}function O5(){w("interpolate",($,Q,K,W)=>{if($.length<4||$.length%2!==0)throw new T(`"interpolate" expects interpolation, input, (stop, value)+ — got ${$.length} arguments`,["interpolate",...$],K);let J=T5($[0],K.concat(1)),U=Q($[1],"number",K.concat(2)),V=W==="value"?"value":W,X=[],Y=[];for(let G=2;G<$.length;G+=2){let F=$[G];if(typeof F!=="number")throw new T(`"interpolate": stop input at position ${G} must be a number literal`,["interpolate",...$],K.concat(G+1));X.push(F),Y.push(Q($[G+1],V,K.concat(G+2)))}for(let G=1;G<X.length;G++)if(X[G]<=X[G-1])throw new T('"interpolate": stop inputs must be strictly increasing',["interpolate",...$],K);let Z=W!=="value"?W:Y[0].returnType,H=C5(Z),A=[U,...Y];return{evaluate:(G)=>{let F=Number(U.evaluate(G));if(!Number.isFinite(F))return Y[0].evaluate(G);let N=p6(X,F);if(N<0)return Y[0].evaluate(G);if(N>=X.length-1)return Y[Y.length-1].evaluate(G);let q=X[N],R=X[N+1],I;if(J.kind==="linear")I=FQ(q,R,F);else if(J.kind==="exponential")I=I5(J.base,q,R,F);else{let C=FQ(q,R,F);I=J.bezier(C)}return H(Y[N].evaluate(G),Y[N+1].evaluate(G),I)},returnType:Z,...l6(A)}}),w("step",($,Q,K,W)=>{if($.length<4||$.length%2!==0)throw new T(`"step" expects input, fallback, (stop, value)+ — got ${$.length} arguments`,["step",...$],K);let J=Q($[0],"number",K.concat(1)),U=Q($[1],W,K.concat(2)),V=[],X=[];for(let H=2;H<$.length;H+=2){let A=$[H];if(typeof A!=="number")throw new T(`"step": stop input at position ${H} must be a number literal`,["step",...$],K.concat(H+1));V.push(A),X.push(Q($[H+1],W,K.concat(H+2)))}for(let H=1;H<V.length;H++)if(V[H]<=V[H-1])throw new T('"step": stop inputs must be strictly increasing',["step",...$],K);let Y=W!=="value"?W:X.length>0?X[0].returnType:U.returnType,Z=[J,U,...X];return{evaluate:(H)=>{let A=Number(J.evaluate(H));if(!Number.isFinite(A))return U.evaluate(H);let G=p6(V,A);if(G<0)return U.evaluate(H);return X[G].evaluate(H)},returnType:Y,...l6(Z)}})}var E5=k(()=>{v8(),v0(),$$()});function q0($){let Q=!1,K=!1,W=!1;for(let J of $){if(J.dependsOnZoom)Q=!0;if(J.dependsOnFeature)K=!0;if(J.dependsOnFeatureState)W=!0}return{dependsOnZoom:Q,dependsOnFeature:K,dependsOnFeatureState:W}}function v$($,Q){if($===Q)return!0;return!1}function B5($,Q){if(typeof $==="number"&&typeof Q==="number"){if(Number.isNaN($)||Number.isNaN(Q))return Number.NaN;return $<Q?-1:$>Q?1:0}if(typeof $==="string"&&typeof Q==="string")return $<Q?-1:$>Q?1:0;return Number.NaN}function k5(){w("!",(Q,K,W)=>{if(Q.length!==1)throw new T(`"!" expects 1 argument, got ${Q.length}`,["!",...Q],W);let J=K(Q[0],"boolean",W.concat(1));return{evaluate:(U)=>!J.evaluate(U),returnType:"boolean",...q0([J])}}),w("==",(Q,K,W)=>{if(Q.length!==2)throw new T(`"==" expects 2 arguments, got ${Q.length}`,["==",...Q],W);let J=K(Q[0],"value",W.concat(1)),U=K(Q[1],"value",W.concat(2));return{evaluate:(V)=>v$(J.evaluate(V),U.evaluate(V)),returnType:"boolean",...q0([J,U])}}),w("!=",(Q,K,W)=>{if(Q.length!==2)throw new T(`"!=" expects 2 arguments, got ${Q.length}`,["!=",...Q],W);let J=K(Q[0],"value",W.concat(1)),U=K(Q[1],"value",W.concat(2));return{evaluate:(V)=>!v$(J.evaluate(V),U.evaluate(V)),returnType:"boolean",...q0([J,U])}});let $=(Q)=>{w(Q,(K,W,J)=>{if(K.length!==2)throw new T(`"${Q}" expects 2 arguments, got ${K.length}`,[Q,...K],J);let U=W(K[0],"value",J.concat(1)),V=W(K[1],"value",J.concat(2));return{evaluate:(X)=>{let Y=B5(U.evaluate(X),V.evaluate(X));if(Number.isNaN(Y))return!1;switch(Q){case"<":return Y<0;case"<=":return Y<=0;case">":return Y>0;case">=":return Y>=0}},returnType:"boolean",...q0([U,V])}})};$("<"),$("<="),$(">"),$(">="),w("all",(Q,K,W)=>{let J=Q.map((U,V)=>K(U,"boolean",W.concat(V+1)));return{evaluate:(U)=>{for(let V=0;V<J.length;V++)if(!J[V].evaluate(U))return!1;return!0},returnType:"boolean",...q0(J)}}),w("any",(Q,K,W)=>{let J=Q.map((U,V)=>K(U,"boolean",W.concat(V+1)));return{evaluate:(U)=>{for(let V=0;V<J.length;V++)if(J[V].evaluate(U))return!0;return!1},returnType:"boolean",...q0(J)}}),w("none",(Q,K,W)=>{let J=Q.map((U,V)=>K(U,"boolean",W.concat(V+1)));return{evaluate:(U)=>{for(let V=0;V<J.length;V++)if(J[V].evaluate(U))return!1;return!0},returnType:"boolean",...q0(J)}}),w("case",(Q,K,W,J)=>{if(Q.length<3||Q.length%2!==1)throw new T(`"case" expects an odd number of arguments >= 3 (cond, val, ..., fallback), got ${Q.length}`,["case",...Q],W);let U=[];for(let Y=0;Y<Q.length-1;Y+=2)U.push({cond:K(Q[Y],"boolean",W.concat(Y+1)),val:K(Q[Y+1],J,W.concat(Y+2))});let V=K(Q[Q.length-1],J,W.concat(Q.length)),X=[V];for(let Y of U)X.push(Y.cond),X.push(Y.val);return{evaluate:(Y)=>{for(let Z=0;Z<U.length;Z++){let H=U[Z];if(H.cond.evaluate(Y))return H.val.evaluate(Y)}return V.evaluate(Y)},returnType:J,...q0(X)}}),w("match",(Q,K,W,J)=>{if(Q.length<4||Q.length%2!==0)throw new T(`"match" expects input, (label, value)+, fallback — got ${Q.length} arguments`,["match",...Q],W);let U=K(Q[0],"value",W.concat(1)),V=[];for(let Z=1;Z<Q.length-1;Z+=2){let H=Q[Z],A=Array.isArray(H)?H:[H];for(let G of A)if(typeof G!=="string"&&typeof G!=="number"&&typeof G!=="boolean")throw new T('"match" labels must be strings, numbers, or booleans',["match",...Q],W.concat(Z+1));V.push({labels:A,val:K(Q[Z+1],J,W.concat(Z+2))})}let X=K(Q[Q.length-1],J,W.concat(Q.length)),Y=[U,X];for(let Z of V)Y.push(Z.val);return{evaluate:(Z)=>{let H=U.evaluate(Z);for(let A=0;A<V.length;A++){let G=V[A];for(let F=0;F<G.labels.length;F++)if(v$(H,G.labels[F]))return G.val.evaluate(Z)}return X.evaluate(Z)},returnType:J,...q0(Y)}}),w("coalesce",(Q,K,W,J)=>{if(Q.length===0)throw new T('"coalesce" expects at least 1 argument',["coalesce"],W);let U=Q.map((V,X)=>K(V,J,W.concat(X+1)));return{evaluate:(V)=>{for(let X=0;X<U.length;X++){let Y=U[X].evaluate(V);if(Y!==null&&Y!==void 0)return Y}return null},returnType:J,...q0(U)}}),w("in",(Q,K,W)=>{if(Q.length<1)throw new T('"in" expects at least 1 argument',["in",...Q],W);let J=K(Q[0],"value",W.concat(1)),U=Q.slice(1);return{evaluate:(V)=>{let X=J.evaluate(V);for(let Y=0;Y<U.length;Y++)if(v$(X,U[Y]))return!0;return!1},returnType:"boolean",...q0([J])}}),w("!in",(Q,K,W)=>{if(Q.length<1)throw new T('"!in" expects at least 1 argument',["!in",...Q],W);let J=K(Q[0],"value",W.concat(1)),U=Q.slice(1);return{evaluate:(V)=>{let X=J.evaluate(V);for(let Y=0;Y<U.length;Y++)if(v$(X,U[Y]))return!1;return!0},returnType:"boolean",...q0([J])}}),w("!has",(Q,K,W)=>{if(Q.length<1||Q.length>2)throw new T(`"!has" expects 1 or 2 arguments, got ${Q.length}`,["!has",...Q],W);if(typeof Q[0]!=="string")throw new T('"!has" key must be a string literal',["!has",...Q],W);let J=Q[0];return{evaluate:(U)=>{let V=U.feature?U.feature.properties:void 0;return V?!Object.prototype.hasOwnProperty.call(V,J):!0},returnType:"boolean",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}})}var w5=k(()=>{v0(),$$()});function _5(){w("literal",($,Q,K)=>{if($.length!==1)throw new T(`"literal" expects 1 argument, got ${$.length}`,["literal",...$],K);let W=$[0];return{evaluate:()=>W,returnType:S5(W),dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),w("get",($,Q,K)=>{if($.length<1||$.length>2)throw new T(`"get" expects 1 or 2 arguments, got ${$.length}`,["get",...$],K);if(typeof $[0]!=="string")throw new T('"get" key must be a string literal',["get",...$],K);let W=$[0];if($.length===2){let J=Q($[1],"value",K.concat(2));return{evaluate:(U)=>{let V=J.evaluate(U);if(V&&typeof V==="object")return V[W];return},returnType:"value",dependsOnZoom:J.dependsOnZoom,dependsOnFeature:J.dependsOnFeature,dependsOnFeatureState:J.dependsOnFeatureState}}return{evaluate:(J)=>{let U=J.feature?J.feature.properties:void 0;return U?U[W]:void 0},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),w("has",($,Q,K)=>{if($.length<1||$.length>2)throw new T(`"has" expects 1 or 2 arguments, got ${$.length}`,["has",...$],K);if(typeof $[0]!=="string")throw new T('"has" key must be a string literal',["has",...$],K);let W=$[0];if($.length===2){let J=Q($[1],"value",K.concat(2));return{evaluate:(U)=>{let V=J.evaluate(U);if(V&&typeof V==="object")return Object.prototype.hasOwnProperty.call(V,W);return!1},returnType:"boolean",dependsOnZoom:J.dependsOnZoom,dependsOnFeature:J.dependsOnFeature,dependsOnFeatureState:J.dependsOnFeatureState}}return{evaluate:(J)=>{let U=J.feature?J.feature.properties:void 0;return U?Object.prototype.hasOwnProperty.call(U,W):!1},returnType:"boolean",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),w("at",($,Q,K)=>{if($.length!==2)throw new T(`"at" expects 2 arguments, got ${$.length}`,["at",...$],K);let W=Q($[0],"number",K.concat(1)),J=Q($[1],"array",K.concat(2));return{evaluate:(U)=>{let V=J.evaluate(U),X=W.evaluate(U);if(!Array.isArray(V)||typeof X!=="number")return;if(X<0||X>=V.length||!Number.isFinite(X))return;return V[Math.floor(X)]},returnType:"value",dependsOnZoom:W.dependsOnZoom||J.dependsOnZoom,dependsOnFeature:W.dependsOnFeature||J.dependsOnFeature,dependsOnFeatureState:W.dependsOnFeatureState||J.dependsOnFeatureState}}),w("length",($,Q,K)=>{if($.length!==1)throw new T(`"length" expects 1 argument, got ${$.length}`,["length",...$],K);let W=Q($[0],"value",K.concat(1));return{evaluate:(J)=>{let U=W.evaluate(J);if(typeof U==="string"||Array.isArray(U))return U.length;return 0},returnType:"number",dependsOnZoom:W.dependsOnZoom,dependsOnFeature:W.dependsOnFeature,dependsOnFeatureState:W.dependsOnFeatureState}}),w("properties",($,Q,K)=>{if($.length!==0)throw new T(`"properties" takes no arguments, got ${$.length}`,["properties",...$],K);return{evaluate:(W)=>W.feature?W.feature.properties:{},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),w("geometry-type",($,Q,K)=>{if($.length!==0)throw new T(`"geometry-type" takes no arguments, got ${$.length}`,["geometry-type",...$],K);return{evaluate:(W)=>{if(!W.feature)return"Unknown";switch(W.feature.type){case 1:return"Point";case 2:return"LineString";case 3:return"Polygon";default:return"Unknown"}},returnType:"string",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),w("id",($,Q,K)=>{if($.length!==0)throw new T(`"id" takes no arguments, got ${$.length}`,["id",...$],K);return{evaluate:(W)=>W.feature?W.feature.id:void 0,returnType:"value",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),w("zoom",($,Q,K)=>{if($.length!==0)throw new T(`"zoom" takes no arguments, got ${$.length}`,["zoom",...$],K);return{evaluate:(W)=>W.zoom,returnType:"number",dependsOnZoom:!0,dependsOnFeature:!1,dependsOnFeatureState:!1}}),w("line-progress",($,Q,K)=>{if($.length!==0)throw new T(`"line-progress" takes no arguments, got ${$.length}`,["line-progress",...$],K);return{evaluate:(W)=>W.lineProgress??0,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),w("feature-state",($,Q,K)=>{if($.length!==1)throw new T(`"feature-state" expects 1 argument, got ${$.length}`,["feature-state",...$],K);if(typeof $[0]!=="string")throw new T('"feature-state" key must be a string literal',["feature-state",...$],K);let W=$[0];return{evaluate:(J)=>{let U=J.featureState;return U?U[W]:void 0},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!0}})}function S5($){if($===null)return"null";if(typeof $==="string")return"string";if(typeof $==="number")return"number";if(typeof $==="boolean")return"boolean";if(Array.isArray($))return"array";return"value"}var P5=k(()=>{v0(),$$()});function Q0($,Q,K){if(typeof $!=="number"||Number.isNaN($))throw new T(`"${Q}": expected number, got ${String($)}`,K);return $}function I0($){let Q=!1,K=!1,W=!1;for(let J of $){if(J.dependsOnZoom)Q=!0;if(J.dependsOnFeature)K=!0;if(J.dependsOnFeatureState)W=!0}return{dependsOnZoom:Q,dependsOnFeature:K,dependsOnFeatureState:W}}function L5(){w("+",(Q,K,W)=>{let J=Q.map((V,X)=>K(V,"number",W.concat(X+1))),U=["+",...Q];return{evaluate:(V)=>{let X=0;for(let Y=0;Y<J.length;Y++)X+=Q0(J[Y].evaluate(V),"+",U);return X},returnType:"number",...I0(J)}}),w("*",(Q,K,W)=>{let J=Q.map((V,X)=>K(V,"number",W.concat(X+1))),U=["*",...Q];return{evaluate:(V)=>{let X=1;for(let Y=0;Y<J.length;Y++)X*=Q0(J[Y].evaluate(V),"*",U);return X},returnType:"number",...I0(J)}}),w("-",(Q,K,W)=>{if(Q.length!==1&&Q.length!==2)throw new T(`"-" expects 1 or 2 arguments, got ${Q.length}`,["-",...Q],W);let J=Q.map((Y,Z)=>K(Y,"number",W.concat(Z+1))),U=["-",...Q];if(J.length===1){let Y=J[0];return{evaluate:(Z)=>-Q0(Y.evaluate(Z),"-",U),returnType:"number",...I0(J)}}let V=J[0],X=J[1];return{evaluate:(Y)=>Q0(V.evaluate(Y),"-",U)-Q0(X.evaluate(Y),"-",U),returnType:"number",...I0(J)}}),w("/",(Q,K,W)=>{if(Q.length!==2)throw new T(`"/" expects 2 arguments, got ${Q.length}`,["/",...Q],W);let J=K(Q[0],"number",W.concat(1)),U=K(Q[1],"number",W.concat(2)),V=["/",...Q];return{evaluate:(X)=>{let Y=Q0(J.evaluate(X),"/",V),Z=Q0(U.evaluate(X),"/",V);if(Z===0)throw new T('"/": divide by zero',V);return Y/Z},returnType:"number",...I0([J,U])}}),w("%",(Q,K,W)=>{if(Q.length!==2)throw new T(`"%" expects 2 arguments, got ${Q.length}`,["%",...Q],W);let J=K(Q[0],"number",W.concat(1)),U=K(Q[1],"number",W.concat(2)),V=["%",...Q];return{evaluate:(X)=>{let Y=Q0(J.evaluate(X),"%",V),Z=Q0(U.evaluate(X),"%",V);if(Z===0)throw new T('"%": divide by zero',V);return Y%Z},returnType:"number",...I0([J,U])}}),w("^",(Q,K,W)=>{if(Q.length!==2)throw new T(`"^" expects 2 arguments, got ${Q.length}`,["^",...Q],W);let J=K(Q[0],"number",W.concat(1)),U=K(Q[1],"number",W.concat(2)),V=["^",...Q];return{evaluate:(X)=>Q0(J.evaluate(X),"^",V)**Q0(U.evaluate(X),"^",V),returnType:"number",...I0([J,U])}}),w("min",(Q,K,W)=>{if(Q.length<1)throw new T('"min" expects at least 1 argument',["min"],W);let J=Q.map((V,X)=>K(V,"number",W.concat(X+1))),U=["min",...Q];return{evaluate:(V)=>{let X=1/0;for(let Y=0;Y<J.length;Y++){let Z=Q0(J[Y].evaluate(V),"min",U);if(Z<X)X=Z}return X},returnType:"number",...I0(J)}}),w("max",(Q,K,W)=>{if(Q.length<1)throw new T('"max" expects at least 1 argument',["max"],W);let J=Q.map((V,X)=>K(V,"number",W.concat(X+1))),U=["max",...Q];return{evaluate:(V)=>{let X=-1/0;for(let Y=0;Y<J.length;Y++){let Z=Q0(J[Y].evaluate(V),"max",U);if(Z>X)X=Z}return X},returnType:"number",...I0(J)}});let $=(Q,K,W)=>{w(Q,(J,U,V)=>{if(J.length!==1)throw new T(`"${Q}" expects 1 argument, got ${J.length}`,[Q,...J],V);let X=U(J[0],"number",V.concat(1)),Y=[Q,...J];return{evaluate:(Z)=>{let H=Q0(X.evaluate(Z),Q,Y);if(W)W(H,Y);return K(H)},returnType:"number",...I0([X])}})};$("abs",Math.abs),$("floor",Math.floor),$("ceil",Math.ceil),$("round",Math.round),$("sqrt",Math.sqrt,(Q,K)=>{if(Q<0)throw new T('"sqrt": input must be non-negative',K)}),$("ln",Math.log,(Q,K)=>{if(Q<=0)throw new T('"ln": input must be positive',K)}),$("log10",Math.log10,(Q,K)=>{if(Q<=0)throw new T('"log10": input must be positive',K)}),$("log2",Math.log2,(Q,K)=>{if(Q<=0)throw new T('"log2": input must be positive',K)}),w("e",(Q,K,W)=>{if(Q.length!==0)throw new T(`"e" takes no arguments, got ${Q.length}`,["e",...Q],W);return{evaluate:()=>Math.E,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),w("pi",(Q,K,W)=>{if(Q.length!==0)throw new T(`"pi" takes no arguments, got ${Q.length}`,["pi",...Q],W);return{evaluate:()=>Math.PI,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),w("rand",(Q,K,W)=>{if(Q.length<2||Q.length>3)throw new T(`"rand" expects 2 or 3 arguments, got ${Q.length}`,["rand",...Q],W);let J=K(Q[0],"number",W.concat(1)),U=K(Q[1],"number",W.concat(2)),V=Q.length===3?K(Q[2],"number",W.concat(3)):null,X=["rand",...Q],Y=1,Z=()=>{return Y=Y*1664525+1013904223>>>0,Y/4294967296};return{evaluate:(A)=>{let G=Q0(J.evaluate(A),"rand",X),F=Q0(U.evaluate(A),"rand",X);if(V){let N=Q0(V.evaluate(A),"rand",X);return Y=Math.floor(N)>>>0||1,Z(),G+(F-G)*Z()}return G+(F-G)*Math.random()},returnType:"number",...I0(V?[J,U,V]:[J,U])}})}var z5=k(()=>{v0(),$$()});function a8($){let Q=!1,K=!1,W=!1;for(let J of $){if(J.dependsOnZoom)Q=!0;if(J.dependsOnFeature)K=!0;if(J.dependsOnFeatureState)W=!0}return{dependsOnZoom:Q,dependsOnFeature:K,dependsOnFeatureState:W}}function o8($){if($===null||$===void 0)return"";if(typeof $==="string")return $;if(typeof $==="number"||typeof $==="boolean")return String($);try{return JSON.stringify($)}catch{return String($)}}function v5(){w("concat",($,Q,K)=>{let W=$.map((J,U)=>Q(J,"value",K.concat(U+1)));return{evaluate:(J)=>{let U="";for(let V=0;V<W.length;V++)U+=o8(W[V].evaluate(J));return U},returnType:"string",...a8(W)}}),w("downcase",($,Q,K)=>{if($.length!==1)throw new T(`"downcase" expects 1 argument, got ${$.length}`,["downcase",...$],K);let W=Q($[0],"string",K.concat(1));return{evaluate:(J)=>o8(W.evaluate(J)).toLowerCase(),returnType:"string",...a8([W])}}),w("upcase",($,Q,K)=>{if($.length!==1)throw new T(`"upcase" expects 1 argument, got ${$.length}`,["upcase",...$],K);let W=Q($[0],"string",K.concat(1));return{evaluate:(J)=>o8(W.evaluate(J)).toUpperCase(),returnType:"string",...a8([W])}}),w("resolved-locale",($,Q,K)=>{if($.length!==0&&$.length!==1)throw new T(`"resolved-locale" expects 0 or 1 arguments, got ${$.length}`,["resolved-locale",...$],K);return{evaluate:()=>"en",returnType:"string",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}})}var f5=k(()=>{v0(),$$()});function Q9(){if(s6)return;s6=!0,_5(),k5(),L5(),R5(),v5(),O5()}function n6($,Q,K){if(Q==="color"){if(typeof $!=="string")throw new T(`expected color string, got ${typeof $}`,$,K);if(!z8($))throw new T(`invalid color string ${JSON.stringify($)}`,$,K);return{evaluate:()=>$,returnType:"color",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}if(Q==="number"){if(typeof $!=="number"||Number.isNaN($))throw new T(`expected number, got ${String($)}`,$,K)}else if(Q==="boolean"){if(typeof $!=="boolean")throw new T(`expected boolean, got ${typeof $}`,$,K)}else if(Q==="string"||Q==="formatted"||Q==="resolvedImage"){if(typeof $!=="string")throw new T(`expected string, got ${typeof $}`,$,K)}let W=$===null?"null":typeof $==="string"?"string":typeof $==="number"?"number":typeof $==="boolean"?"boolean":Array.isArray($)?"array":"value";return{evaluate:()=>$,returnType:W,dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}function $8($,Q="value",K=[]){if(Q9(),Array.isArray($)){let W=$[0];if(typeof W==="string"){let J=N5(W);if(J){let U=$.slice(1);return J(U,$8,K,Q)}}return n6($,"array",K)}return n6($,Q,K)}var s6=!1,NQ=k(()=>{v8(),v0(),D5(),E5(),w5(),P5(),z5(),f5(),$$()});function K9($){if(Q9(),!Array.isArray($)||$.length===0)return!1;let Q=$[0];return typeof Q==="string"&&q5(Q)}function h5($,Q){let K=[];try{$8($,Q,[])}catch(W){if(W instanceof T)K.push(W.message);else if(W instanceof Error)K.push(W.message);else K.push(String(W))}return K}var r6=k(()=>{NQ(),v0(),$$()});var b5,x5,y5=k(()=>{b5=new Set(["==","!=","<","<=",">",">="]),x5=new Set(["all","any","none"])});var W9=k(()=>{NQ(),v0(),r6(),v8(),NQ(),v0(),y5(),r6()}),a6,o6,t6,e6,$7,Q7,K7,J9,g0,W7,J7,U7,V7,X7,Y7,Z7,U9,V9,X9,u5=k(()=>{a6={"background-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"background-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"}},o6={"fill-antialias":{type:"boolean",default:!0,sdk:"gl"},"fill-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"fill-outline-color":{type:"color",transition:!0,sdk:"gl"},"fill-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"},"fill-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"fill-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"}},t6={"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"fill-extrusion-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"fill-extrusion-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"},"fill-extrusion-height":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"fill-extrusion-base":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,sdk:"gl"}},e6={"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"line-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"line-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"line-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"line-width":{type:"number",default:1,minimum:0,transition:!0,sdk:"gl"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"line-offset":{type:"number",default:0,transition:!0,sdk:"gl"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"line-dasharray":{type:"array",transition:!0,sdk:"gl"},"line-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"},"line-gradient":{type:"color",sdk:"gl"}},$7={"circle-radius":{type:"number",default:5,minimum:0,transition:!0,sdk:"gl"},"circle-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"circle-blur":{type:"number",default:0,transition:!0,sdk:"gl"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"circle-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"circle-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"circle-pitch-scale":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"circle-pitch-alignment":{type:"enum",values:["map","viewport"],default:"viewport",sdk:"gl"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"}},Q7={"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"icon-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,sdk:"gl"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"icon-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"icon-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"text-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,sdk:"gl"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"text-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"text-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"}},K7={"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"raster-hue-rotate":{type:"number",default:0,transition:!0,sdk:"gl"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,sdk:"gl"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,sdk:"gl"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,sdk:"gl"},"raster-resampling":{type:"enum",values:["linear","nearest"],default:"linear",sdk:"gl"},"raster-fade-duration":{type:"number",default:300,minimum:0,sdk:"gl"}},J9={background:a6,fill:o6,"fill-extrusion":t6,line:e6,circle:$7,symbol:Q7,raster:K7},g0={type:"enum",values:["visible","none"],default:"visible",sdk:"gl"},W7={visibility:g0},J7={visibility:g0,"fill-sort-key":{type:"number",sdk:"gl"}},U7={visibility:g0},V7={visibility:g0,"line-cap":{type:"enum",values:["butt","round","square"],default:"butt",sdk:"gl"},"line-join":{type:"enum",values:["bevel","round","miter"],default:"miter",sdk:"gl"},"line-miter-limit":{type:"number",default:2,sdk:"gl"},"line-round-limit":{type:"number",default:1.05,sdk:"gl"},"line-sort-key":{type:"number",sdk:"gl"}},X7={visibility:g0,"circle-sort-key":{type:"number",sdk:"gl"}},Y7={visibility:g0,"symbol-placement":{type:"enum",values:["point","line","line-center"],default:"point",sdk:"gl"},"symbol-spacing":{type:"number",default:250,minimum:1,sdk:"gl"},"symbol-avoid-edges":{type:"boolean",default:!1,sdk:"gl"},"symbol-sort-key":{type:"number",sdk:"gl"},"symbol-z-order":{type:"enum",values:["auto","viewport-y","source"],default:"auto",sdk:"gl"},"icon-allow-overlap":{type:"boolean",default:!1,sdk:"gl"},"icon-ignore-placement":{type:"boolean",default:!1,sdk:"gl"},"icon-optional":{type:"boolean",default:!1,sdk:"gl"},"icon-rotation-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"icon-size":{type:"number",default:1,minimum:0,sdk:"gl"},"icon-text-fit":{type:"enum",values:["none","width","height","both"],default:"none",sdk:"gl"},"icon-text-fit-padding":{type:"array",length:4,default:[0,0,0,0],sdk:"gl"},"icon-image":{type:"resolvedImage",sdk:"gl"},"icon-rotate":{type:"number",default:0,sdk:"gl"},"icon-padding":{type:"padding",default:2,sdk:"gl"},"icon-keep-upright":{type:"boolean",default:!1,sdk:"gl"},"icon-offset":{type:"array",length:2,default:[0,0],sdk:"gl"},"icon-anchor":{type:"enum",values:["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"],default:"center",sdk:"gl"},"icon-pitch-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"text-pitch-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"text-rotation-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"text-field":{type:"formatted",default:"",sdk:"gl"},"text-font":{type:"array",default:["Open Sans Regular","Arial Unicode MS Regular"],sdk:"gl"},"text-size":{type:"number",default:16,minimum:0,sdk:"gl"},"text-max-width":{type:"number",default:10,minimum:0,sdk:"gl"},"text-line-height":{type:"number",default:1.2,sdk:"gl"},"text-letter-spacing":{type:"number",default:0,sdk:"gl"},"text-justify":{type:"enum",values:["auto","left","center","right"],default:"center",sdk:"gl"},"text-radial-offset":{type:"number",default:0,sdk:"gl"},"text-variable-anchor":{type:"array",sdk:"gl"},"text-anchor":{type:"enum",values:["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"],default:"center",sdk:"gl"},"text-max-angle":{type:"number",default:45,sdk:"gl"},"text-writing-mode":{type:"array",sdk:"gl"},"text-rotate":{type:"number",default:0,sdk:"gl"},"text-padding":{type:"number",default:2,minimum:0,sdk:"gl"},"text-keep-upright":{type:"boolean",default:!0,sdk:"gl"},"text-transform":{type:"enum",values:["none","uppercase","lowercase"],default:"none",sdk:"gl"},"text-offset":{type:"array",length:2,default:[0,0],sdk:"gl"},"text-allow-overlap":{type:"boolean",default:!1,sdk:"gl"},"text-ignore-placement":{type:"boolean",default:!1,sdk:"gl"},"text-optional":{type:"boolean",default:!1,sdk:"gl"}},Z7={visibility:g0},U9={background:W7,fill:J7,"fill-extrusion":U7,line:V7,circle:X7,symbol:Y7,raster:Z7},V9=["background","fill","fill-extrusion","line","circle","symbol","raster"],X9=["vector","raster","raster-dem","geojson"]});function S($,Q,K){$.push({message:Q,path:K.slice()})}function l0($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function g5($){switch($){case"color":return"color";case"number":return"number";case"string":return"string";case"boolean":return"boolean";case"array":return"array";case"enum":return"string";case"padding":return"value";case"formatted":return"formatted";case"resolvedImage":return"resolvedImage"}}function m5($,Q){if(Array.isArray($)){if(K9($)){let K=h5($,g5(Q.type));return K.length===0?!0:K}if(Q.type==="array"){if(Q.length!==void 0&&$.length!==Q.length)return!1;return!0}if(Q.type==="padding")return $.length===2||$.length===4;return!1}switch(Q.type){case"color":return typeof $==="string";case"number":if(typeof $!=="number"||Number.isNaN($))return!1;if(Q.minimum!==void 0&&$<Q.minimum)return!1;if(Q.maximum!==void 0&&$>Q.maximum)return!1;return!0;case"string":return typeof $==="string";case"boolean":return typeof $==="boolean";case"enum":return typeof $==="string"&&(Q.values?Q.values.includes($):!0);case"padding":return typeof $==="number";case"formatted":return typeof $==="string";case"resolvedImage":return typeof $==="string";case"array":return!1}}function H7($,Q,K,W,J,U){let V=[],X=$?$[W]:void 0;if(!X)return S(V,`Unknown ${K} property "${W}" for layer type "${Q}"`,U),V;let Y=m5(J,X);if(Y===!0)return V;if(Y===!1)return S(V,`Invalid value for ${K} property "${W}" (expected ${d5(X)})`,U),V;for(let Z of Y)S(V,`Invalid expression for ${K} property "${W}": ${Z}`,U);return V}function d5($){if($.type==="enum"&&$.values)return`one of ${$.values.map((Q)=>`"${Q}"`).join(", ")}`;if($.type==="array"&&$.length!==void 0)return`array of length ${$.length}`;return $.type}function c5($,Q){let K=[],W=Q!==void 0?["sources",Q]:["source"];if(!l0($))return S(K,"Source must be an object",W),K;let J=$.type;if(typeof J!=="string")return S(K,'Source is missing required "type" property',W.concat("type")),K;if(!X9.includes(J))return S(K,`Unknown source type "${J}"`,W.concat("type")),K;if(J==="vector"||J==="raster"||J==="raster-dem"){let U=typeof $.url==="string",V=Array.isArray($.tiles)&&$.tiles.length>0;if(!U&&!V)S(K,`Source of type "${J}" must define either "url" or a non-empty "tiles" array`,W);if($.tiles!==void 0&&!Array.isArray($.tiles))S(K,'"tiles" must be an array of URL templates',W.concat("tiles"));if($.url!==void 0&&typeof $.url!=="string")S(K,'"url" must be a string',W.concat("url"));if($.minzoom!==void 0&&typeof $.minzoom!=="number")S(K,'"minzoom" must be a number',W.concat("minzoom"));if($.maxzoom!==void 0&&typeof $.maxzoom!=="number")S(K,'"maxzoom" must be a number',W.concat("maxzoom"))}if(J==="geojson"){if($.data===void 0)S(K,'GeoJSON source is missing required "data" property',W.concat("data"))}return K}function l5($,Q){let K=[],W=["layer"];if(!l0($))return S(K,"Layer must be an object",W),K;if(typeof $.id!=="string"||$.id.length===0)S(K,'Layer is missing required "id" property',W.concat("id"));let J=$.type;if(typeof J!=="string")return S(K,'Layer is missing required "type" property',W.concat("type")),K;if(!V9.includes(J))return S(K,`Unknown layer type "${J}"`,W.concat("type")),K;let U=J;if(U!=="background"){if(typeof $.source!=="string")S(K,`Layer of type "${U}" is missing required "source" property`,W.concat("source"));else if(Q&&!($.source in Q))S(K,`Layer references undefined source "${$.source}"`,W.concat("source"))}if($.minzoom!==void 0&&typeof $.minzoom!=="number")S(K,'"minzoom" must be a number',W.concat("minzoom"));if($.maxzoom!==void 0&&typeof $.maxzoom!=="number")S(K,'"maxzoom" must be a number',W.concat("maxzoom"));let V=$.paint;if(V!==void 0)if(!l0(V))S(K,'Layer "paint" must be an object',W.concat("paint"));else{let Y=J9[U];for(let Z of Object.keys(V)){let H=H7(Y,U,"paint",Z,V[Z],W.concat("paint",Z));for(let A of H)K.push(A)}}let X=$.layout;if(X!==void 0)if(!l0(X))S(K,'Layer "layout" must be an object',W.concat("layout"));else{let Y=U9[U];for(let Z of Object.keys(X)){let H=H7(Y,U,"layout",Z,X[Z],W.concat("layout",Z));for(let A of H)K.push(A)}}return K}function p5($){let Q=[];if(!l0($))return S(Q,"Style must be an object",[]),Q;if($.version===void 0)S(Q,'Style is missing required "version" property',["version"]);else if($.version!==8)S(Q,`Unsupported style version: ${String($.version)} (expected 8)`,["version"]);let K=$.sources;if(K===void 0)S(Q,'Style is missing required "sources" property',["sources"]);else if(!l0(K))S(Q,'Style "sources" must be an object',["sources"]);else for(let J of Object.keys(K)){let U=c5(K[J],J);for(let V of U)Q.push(V)}let W=$.layers;if(W===void 0)S(Q,'Style is missing required "layers" property',["layers"]);else if(!Array.isArray(W))S(Q,'Style "layers" must be an array',["layers"]);else{let J=new Set,U=l0(K)?K:void 0;for(let V=0;V<W.length;V++){let X=W[V],Y=["layers",String(V)];if(!l0(X)){S(Q,"Layer must be an object",Y);continue}if(typeof X.id==="string")if(J.has(X.id))S(Q,`Duplicate layer id "${X.id}"`,Y.concat("id"));else J.add(X.id);let Z=l5(X,U);for(let H of Z){let A=H.path?H.path.slice(1):[];Q.push({message:H.message,path:Y.concat(A)})}}}if($.name!==void 0&&typeof $.name!=="string")S(Q,'"name" must be a string',["name"]);if($.zoom!==void 0&&typeof $.zoom!=="number")S(Q,'"zoom" must be a number',["zoom"]);if($.bearing!==void 0&&typeof $.bearing!=="number")S(Q,'"bearing" must be a number',["bearing"]);if($.pitch!==void 0&&typeof $.pitch!=="number")S(Q,'"pitch" must be a number',["pitch"]);if($.center!==void 0){let J=$.center;if(!Array.isArray(J)||J.length!==2||typeof J[0]!=="number"||typeof J[1]!=="number")S(Q,'"center" must be a [lng, lat] tuple',["center"])}if($.glyphs!==void 0&&typeof $.glyphs!=="string")S(Q,'"glyphs" must be a string template',["glyphs"]);if($.sprite!==void 0){let J=$.sprite;if(typeof J!=="string"&&!Array.isArray(J))S(Q,'"sprite" must be a string or an array of sprite sources',["sprite"])}return Q}var i5=k(()=>{W9(),u5()});class T8{constructor($,Q){if(Q?.validate!==!1){let W=p5($);if(W.length)throw Error(`Invalid style: ${W.map((J)=>J.message).join("; ")}`)}if(this.spec=this._cloneSpec($),!this.spec.sources)this.spec.sources={};if(!Array.isArray(this.spec.layers))this.spec.layers=[];this.sourceLayers=new Map,this.layerSpecs=new Map;for(let W of this.spec.layers)this.layerSpecs.set(W.id,W)}setPaintProperty($,Q,K){let W=this.layerSpecs.get($);if(!W)throw Error(`no layer with id ${$}`);let J=W;J.paint={...J.paint??{},[Q]:K}}setLayoutProperty($,Q,K){let W=this.layerSpecs.get($);if(!W)throw Error(`no layer with id ${$}`);let J=W;J.layout={...J.layout??{},[Q]:K}}setFilter($,Q){let K=this.layerSpecs.get($);if(!K)throw Error(`no layer with id ${$}`);let W=K;W.filter=Q}setLayerZoomRange($,Q,K){let W=this.layerSpecs.get($);if(!W)throw Error(`no layer with id ${$}`);if(Q!==void 0)W.minzoom=Q;if(K!==void 0)W.maxzoom=K}serialize(){return this._cloneSpec(this.spec)}toVectorStyleLayer($){let Q=$;return{id:Q.id,type:Q.type,sourceLayer:Q["source-layer"]??Q.sourceLayer,minzoom:Q.minzoom,maxzoom:Q.maxzoom,filter:Q.filter,paint:Q.paint??{},layout:Q.layout??{}}}_cloneSpec($){return JSON.parse(JSON.stringify($))}}var n5=k(()=>{i5()});function w0($,Q){if($===Q)return!0;if(typeof $!==typeof Q)return!1;if($===null||Q===null)return $===Q;if(Array.isArray($)){if(!Array.isArray(Q)||$.length!==Q.length)return!1;for(let K=0;K<$.length;K++)if(!w0($[K],Q[K]))return!1;return!0}if(typeof $==="object"&&typeof Q==="object"){let K=$,W=Q,J=Object.keys(K),U=Object.keys(W);if(J.length!==U.length)return!1;for(let V of J){if(!Object.prototype.hasOwnProperty.call(W,V))return!1;if(!w0(K[V],W[V]))return!1}return!0}return!1}function f$($){return{commands:[{command:"setStyle",args:[$]}]}}function A7($){let Q={};for(let K of $)Q[K.id]=K;return Q}function s5($,Q,K){let W=$.paint||{},J=Q.paint||{};for(let U of Object.keys(J))if(!w0(W[U],J[U]))K.push({command:"setPaintProperty",args:[Q.id,U,J[U]]});for(let U of Object.keys(W))if(!(U in J))K.push({command:"setPaintProperty",args:[Q.id,U,void 0]})}function r5($,Q,K){let W=$.layout||{},J=Q.layout||{};for(let U of Object.keys(J))if(!w0(W[U],J[U]))K.push({command:"setLayoutProperty",args:[Q.id,U,J[U]]});for(let U of Object.keys(W))if(!(U in J))K.push({command:"setLayoutProperty",args:[Q.id,U,void 0]})}function a5($,Q){if($.version!==Q.version)return f$(Q);if(!w0($.sprite,Q.sprite))return f$(Q);if($.glyphs!==Q.glyphs)return f$(Q);let K=[];if(!w0($.transition,Q.transition)&&Q.transition!==void 0)K.push({command:"setTransition",args:[Q.transition]});if(!w0($.light,Q.light)&&Q.light!==void 0)K.push({command:"setLight",args:[Q.light]});let W=$.sources||{},J=Q.sources||{};for(let A of Object.keys(W))if(!(A in J))K.push({command:"removeSource",args:[A]});for(let A of Object.keys(J)){let G=W[A],F=J[A];if(G===void 0){K.push({command:"addSource",args:[A,F]});continue}if(w0(G,F))continue;if(G.type==="geojson"&&F.type==="geojson"){let N={...G,data:void 0},q={...F,data:void 0};if(w0(N,q)){K.push({command:"setSourceData",args:[A,F.data]});continue}}K.push({command:"removeSource",args:[A]}),K.push({command:"addSource",args:[A,F]})}let U=$.layers||[],V=Q.layers||[],X=A7(U),Y=A7(V);for(let A of U)if(!(A.id in Y))K.push({command:"removeLayer",args:[A.id]});let Z=U.filter((A)=>(A.id in Y)).map((A)=>A.id),H=V.filter((A)=>(A.id in X)).map((A)=>A.id);if(Z.length!==H.length)return f$(Q);for(let A=0;A<Z.length;A++)if(Z[A]!==H[A])return f$(Q);for(let A=0;A<V.length;A++){let G=V[A],F=X[G.id];if(F===void 0){let j;for(let E=A+1;E<V.length;E++)if(V[E].id in X){j=V[E].id;break}K.push({command:"addLayer",args:[G,j]});continue}if(F.type!==G.type){K.push({command:"removeLayer",args:[G.id]});let j;for(let E=A+1;E<V.length;E++)if(V[E].id in X&&V[E].id!==G.id){j=V[E].id;break}K.push({command:"addLayer",args:[G,j]});continue}let N=F.source,q=G.source,R=F["source-layer"],I=G["source-layer"];if(N!==q||R!==I){K.push({command:"removeLayer",args:[G.id]});let j;for(let E=A+1;E<V.length;E++)if(V[E].id in X&&V[E].id!==G.id){j=V[E].id;break}K.push({command:"addLayer",args:[G,j]});continue}if(F.minzoom!==G.minzoom||F.maxzoom!==G.maxzoom)K.push({command:"setLayerZoomRange",args:[G.id,G.minzoom,G.maxzoom]});let C=F.filter,M=G.filter;if(!w0(C,M))K.push({command:"setFilter",args:[G.id,M]});s5(F,G,K),r5(F,G,K)}return{commands:K}}var o5=`#version 300 es |
| 1 | +var{defineProperty:Ts,getOwnPropertyNames:Ph,getOwnPropertyDescriptor:kh}=Object,Mh=Object.prototype.hasOwnProperty;function Lh(t){return this[t]}var ut=(t)=>{var e=(ur??=new WeakMap).get(t),n;if(e)return e;if(e=Ts({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function"){for(var i of Ph(t))if(!Mh.call(e,i))Ts(e,i,{get:Lh.bind(t,i),enumerable:!(n=kh(t,i))||n.enumerable})}return ur.set(t,e),e},ur,Ah=(t)=>t;function Oh(t,e){this[t]=Ah.bind(null,e)}var tt=(t,e)=>{for(var n in e)Ts(t,n,{get:e[n],enumerable:!0,configurable:!0,set:Oh.bind(e,n)})},P=(t,e)=>()=>(t&&(e=t(t=0)),e);function fr(){let t=Error("The operation was aborted.");return t.name="AbortError",t}async function lo(t,e){let{cache:n,signal:i,noStore:s,forceNetwork:o}=e;if(i?.aborted)throw fr();if(!o){let r=await n.get(t);if(r)return{data:r.data,mime:r.mime,fromCache:!0}}try{let r=await fetch(t,{signal:i}),a=new Uint8Array(await r.arrayBuffer()),l=r.headers.get("content-type")??"application/octet-stream";if(!s)await n.put(t,a,l);return{data:a,mime:l,fromCache:!1}}catch(r){if(i?.aborted)throw fr();let a=await n.get(t);if(a)return{data:a.data,mime:a.mime,fromCache:!0};throw r}}function rs(){let t=new Map;return{get:async(e)=>t.get(e),put:async(e)=>{t.set(e.key,e)},delete:async(e)=>{t.delete(e)},clear:async()=>{t.clear()},all:async()=>[...t.values()],close:()=>{t=new Map}}}class Ni{_ttlMs;_maxEntries;_maxBytes;_customBackend;_backend;constructor(t={}){this._ttlMs=t.ttlMs??0,this._maxEntries=t.maxEntries??Number.POSITIVE_INFINITY,this._maxBytes=t.maxBytes??Number.POSITIVE_INFINITY,this._customBackend=t.backend,this._backend=t.backend??rs()}async get(t){let e=await this._backend.get(t);if(!e)return;if(this._isExpired(e)){await this._backend.delete(t);return}return e}async put(t,e,n){let i={key:t,data:e,mime:n,bytes:e.byteLength,addedAt:Date.now()};await this._backend.put(i)}async delete(t){await this._backend.delete(t)}async clear(){await this._backend.clear()}async size(){let t=await this._backend.all(),e=0;for(let n of t)e+=n.bytes;return{entries:t.length,bytes:e}}async prune(){let t=await this._backend.all(),e=[];for(let s of t)if(this._isExpired(s))await this._backend.delete(s.key);else e.push(s);e.sort((s,o)=>s.addedAt-o.addedAt);let n=0;for(let s of e)n+=s.bytes;let i=e.length;while(e.length>0&&(i>this._maxEntries||n>this._maxBytes)){let s=e.shift();await this._backend.delete(s.key),n-=s.bytes,i-=1}}async close(){if(this._backend.close)await this._backend.close();if(this._customBackend)this._backend=rs();else this._backend=rs()}_isExpired(t){if(this._ttlMs<=0)return!1;return Date.now()-t.addedAt>this._ttlMs}}function nn(){if(!en)en=new Ni;return en}async function Gm(){if(en)await en.close(),en=void 0}var en,Wa=()=>{};function Eh(t){if(Array.isArray(t))return{west:t[0],south:t[1],east:t[2],north:t[3]};return t}function dr(t,e){return Math.floor((t+180)/360*2**e)}function pr(t,e){let n=t*Math.PI/180;return Math.floor((1-Math.log(Math.tan(n)+1/Math.cos(n))/Math.PI)/2*2**e)}function ni(t,e){let n=2**e-1;if(t<0)return 0;if(t>n)return n;return t}function zh(t,e){let{west:n,south:i,east:s,north:o}=Eh(t),[r,a]=e,l=[];for(let c=r;c<=a;c++){let h=ni(dr(Math.min(n,s),c),c),u=ni(dr(Math.max(n,s),c),c),f=ni(pr(Math.max(i,o),c),c),d=ni(pr(Math.min(i,o),c),c);for(let p=h;p<=u;p++)for(let m=f;m<=d;m++)l.push({x:p,y:m,z:c})}return l}function Ch(t,e){return t.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y))}async function Ih(t,e){let n=t.cache??nn(),i=Math.max(1,t.concurrency??4),s=zh(t.bounds,t.zoomRange),o=s.length,r={saved:0,failed:0,skipped:0},a=0,l=0;async function c(){while(a<s.length){let u=a++,f=s[u],d=Ch(t.tileUrl,f);try{if((await lo(d,{cache:n,signal:t.signal})).fromCache)r.skipped++;else r.saved++}catch{r.failed++}l++,e?.fire("offline:progress",{completed:l,total:o,coord:f})}}let h=[];for(let u=0;u<Math.min(i,s.length);u++)h.push(c());return await Promise.all(h),r}var Fh=P(()=>{Wa()}),$i=P(()=>{Wa(),Fh()}),Va={};tt(Va,{falseFn:()=>Et,formatNum:()=>Vt,lastId:()=>uo,noop:()=>Nh,setLastId:()=>Rh,setOptions:()=>et,splitWords:()=>Yt,stamp:()=>j,template:()=>ho,throttle:()=>co,wrapNum:()=>En});function j(t){if(!("_tsmap_id"in t))t._tsmap_id=++uo;return t._tsmap_id}function Rh(t){uo=t}function co(t,e,n){let i=!1,s=!1;function o(){if(i=!1,s)r.apply(n,s),s=!1}function r(...a){if(i)s=a;else t.apply(n,a),setTimeout(o,e),i=!0}return r}function En(t,e,n){let i=e[1],s=e[0],o=i-s;return t===i&&n?t:((t-s)%o+o)%o+s}function Et(...t){return!1}function Vt(t,e){if(e===!1)return t;let n=10**(e===void 0?6:e);return Math.round(t*n)/n}function Yt(t){return t.trim().split(/\s+/)}function et(t,e){if(!Object.hasOwn(t,"options"))t.options=t.options?Object.create(t.options):{};if(e){for(let n in e)if(Object.hasOwn(e,n))t.options[n]=e[n]}return t.options}function ho(t,e){return t.replace(qa,(n,i)=>{let s=i.trim(),o=e[s];if(o===void 0)throw Error(`No value provided for variable ${n}`);else if(typeof o==="function")o=o(e);return o})}function Nh(){}var uo=0,qa,N=P(()=>{qa=/\{([^{}]+)\}/g});class v{x;y;constructor(t,e,n){if(!v.validate(t,e))throw Error(`Invalid Point object: (${t}, ${e})`);let s,o;if(t instanceof v)return t;else if(Array.isArray(t))s=t[0],o=t[1];else if(typeof t==="object"&&t!==null&&"x"in t&&"y"in t)s=t.x,o=t.y;else s=t,o=e;this.x=n?Math.round(s):s,this.y=n?Math.round(o):o}static validate(t,e){if(t instanceof v||Array.isArray(t))return!0;if(t&&typeof t==="object"&&"x"in t&&"y"in t)return!0;if((t||t===0)&&(e||e===0))return!0;return!1}clone(){let t=new v(0,0);return t.x=this.x,t.y=this.y,t}add(t){return this.clone()._add(new v(t))}_add(t){return this.x+=t.x,this.y+=t.y,this}subtract(t){return this.clone()._subtract(new v(t))}_subtract(t){return this.x-=t.x,this.y-=t.y,this}divideBy(t){return this.clone()._divideBy(t)}_divideBy(t){return this.x/=t,this.y/=t,this}multiplyBy(t){return this.clone()._multiplyBy(t)}_multiplyBy(t){return this.x*=t,this.y*=t,this}scaleBy(t){return new v(this.x*t.x,this.y*t.y)}unscaleBy(t){return new v(this.x/t.x,this.y/t.y)}round(){return this.clone()._round()}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}floor(){return this.clone()._floor()}_floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.clone()._ceil()}_ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}trunc(){return this.clone()._trunc()}_trunc(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}distanceTo(t){let e=new v(t),n=e.x-this.x,i=e.y-this.y;return Math.sqrt(n*n+i*i)}equals(t){let e=new v(t);return e.x===this.x&&e.y===this.y}contains(t){let e=new v(t);return Math.abs(e.x)<=Math.abs(this.x)&&Math.abs(e.y)<=Math.abs(this.y)}toString(){return`Point(${Vt(this.x)}, ${Vt(this.y)})`}}function Ps(t,e,n){if(t instanceof v)return t;if(Array.isArray(t))return new v(t[0],t[1]);if(t===void 0||t===null)return t;if(typeof t==="object"&&"x"in t&&"y"in t)return new v(t.x,t.y);return new v(t,e,n)}var G=P(()=>{N()});class I{min;max;constructor(t,e){if(!t)return;if(t instanceof I)return t;let n=e?[t,e]:t;for(let i of n)this.extend(i)}extend(t){let e,n;if(!t)return this;if(t instanceof v||Array.isArray(t)&&typeof t[0]==="number"||t&&"x"in t)e=n=Ps(t);else{let i=new I(t);if(e=i.min,n=i.max,!e||!n)return this}if(!this.min&&!this.max)this.min=e.clone(),this.max=n.clone();else this.min.x=Math.min(e.x,this.min.x),this.max.x=Math.max(n.x,this.max.x),this.min.y=Math.min(e.y,this.min.y),this.max.y=Math.max(n.y,this.max.y);return this}getCenter(t){return new v((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)}getBottomLeft(){return new v(this.min.x,this.max.y)}getTopRight(){return new v(this.max.x,this.min.y)}getTopLeft(){return this.min}getBottomRight(){return this.max}getSize(){return this.max.subtract(this.min)}contains(t){let e,n,i=t;if(Array.isArray(i)&&typeof i[0]==="number"||i instanceof v)i=Ps(i);else i=new I(i);if(i instanceof I)e=i.min,n=i.max;else e=n=i;return e.x>=this.min.x&&n.x<=this.max.x&&e.y>=this.min.y&&n.y<=this.max.y}intersects(t){let e=new I(t),n=this.min,i=this.max,{min:s,max:o}=e,r=o.x>=n.x&&s.x<=i.x,a=o.y>=n.y&&s.y<=i.y;return r&&a}overlaps(t){let e=new I(t),n=this.min,i=this.max,{min:s,max:o}=e,r=o.x>n.x&&s.x<i.x,a=o.y>n.y&&s.y<i.y;return r&&a}isValid(){return!!(this.min&&this.max)}pad(t){let e=this.min,n=this.max,i=Math.abs(e.x-n.x)*t,s=Math.abs(e.y-n.y)*t;return new I(new v(e.x-i,e.y-s),new v(n.x+i,n.y+s))}equals(t){if(!t)return!1;let e=new I(t);return this.min.equals(e.getTopLeft())&&this.max.equals(e.getBottomRight())}}function $h(t,e){if(!t||t instanceof I)return t;return new I(t,e)}var ct=P(()=>{G()});function ce(t){return(t[2]-t[0])*(t[3]-t[1])}function ii(t){return t[2]-t[0]+(t[3]-t[1])}function si(t,e){let n=Math.max(t[2],e[2])-Math.min(t[0],e[0]),i=Math.max(t[3],e[3])-Math.min(t[1],e[1]);return n*i}function Zh(t,e){let n=Math.max(t[0],e[0]),i=Math.max(t[1],e[1]),s=Math.min(t[2],e[2]),o=Math.min(t[3],e[3]);if(s<n||o<i)return 0;return(s-n)*(o-i)}function mr(t,e){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[2]&&t[3]>=e[3]}function _r(t,e){return e[0]<=t[2]&&e[1]<=t[3]&&e[2]>=t[0]&&e[3]>=t[1]}function gr(t,e,n){return t[0]<=e&&e<=t[2]&&t[1]<=n&&n<=t[3]}function Ut(){return[1/0,1/0,-1/0,-1/0]}function $t(t,e){if(e[0]<t[0])t[0]=e[0];if(e[1]<t[1])t[1]=e[1];if(e[2]>t[2])t[2]=e[2];if(e[3]>t[3])t[3]=e[3];return t}function te(t,e,n){let i=t.bbox;i[0]=1/0,i[1]=1/0,i[2]=-1/0,i[3]=-1/0;let s=t.children;for(let o=e;o<n;o++)$t(i,s[o].bbox)}function yr(t){return{bbox:Ut(),children:t,leaf:!1}}class Ga{_maxEntries;_minEntries;_root;_size;constructor(t){let e=Math.max(4,t?.maxEntries??9),n=Math.max(2,t?.minEntries??Math.ceil(e*0.4));this._maxEntries=e,this._minEntries=Math.min(n,Math.floor(e/2)),this._root={bbox:Ut(),children:[],leaf:!0},this._size=0}size(){return this._size}clear(){return this._root={bbox:Ut(),children:[],leaf:!0},this._size=0,this}insert(t,e){let n={bbox:[t[0],t[1],t[2],t[3]],data:e};return this._insertRecord(n),this._size++,this}remove(t,e,n){let i=n??((r,a)=>r===a),s=[];if(this._removeFrom(this._root,t,e,i,s))this._size--,this._condense(s);return this}_removeFrom(t,e,n,i,s){let o=t.children;if(!o)return!1;if(s.push(t),t.leaf){for(let r=0;r<o.length;r++){let a=o[r];if(a.data!==void 0&&i(a.data,n))return o.splice(r,1),!0}return s.pop(),!1}for(let r=0;r<o.length;r++){let a=o[r];if(!mr(a.bbox,e))continue;if(this._removeFrom(a,e,n,i,s))return!0}return s.pop(),!1}search(t){let e=[],n=this._root;if(!_r(n.bbox,t))return e;let i=[n];while(i.length>0){let s=i.pop(),o=s.children;if(!o)continue;for(let r=0;r<o.length;r++){let a=o[r];if(!_r(a.bbox,t))continue;if(s.leaf)e.push({bbox:a.bbox,data:a.data});else if(mr(t,a.bbox))this._collectAll(a,e);else i.push(a)}}return e}searchPoint(t,e){let n=[],i=this._root;if(!gr(i.bbox,t,e))return n;let s=[i];while(s.length>0){let o=s.pop(),r=o.children;if(!r)continue;for(let a=0;a<r.length;a++){let l=r[a];if(!gr(l.bbox,t,e))continue;if(o.leaf)n.push({bbox:l.bbox,data:l.data});else s.push(l)}}return n}all(){let t=[];return this._collectAll(this._root,t),t}load(t){if(t.length===0)return this;if(t.length<this._minEntries){for(let o of t)this.insert(o.bbox,o.data);return this}let e=t.map((o)=>({bbox:[o.bbox[0],o.bbox[1],o.bbox[2],o.bbox[3]],data:o.data})),n=this._buildSTR(e,0,e.length-1,this._chooseHeight(e.length));if(this._size===0)return this._root=n,this._size=t.length,this;let i=this._height(this._root),s=this._height(n);if(i===s)this._mergeRoots(n),this._size+=t.length;else if(i<s){let o=this._root;this._root=n,this._size=t.length;let r=[];this._collectAll(o,r);for(let a of r)this.insert(a.bbox,a.data)}else{let o=i-s;this._insertSubtree(n,o),this._size+=t.length}return this}_collectAll(t,e){let n=[t];while(n.length>0){let i=n.pop(),s=i.children;if(!s)continue;if(i.leaf)for(let o=0;o<s.length;o++){let r=s[o];e.push({bbox:r.bbox,data:r.data})}else for(let o=0;o<s.length;o++)n.push(s[o])}}_height(t){let e=0,n=t;while(!n.leaf){e++;let i=n.children?.[0];if(!i)break;n=i}return e}_mergeRoots(t){let e=this._root;if(e.leaf!==t.leaf){let i=[];this._collectAll(t,i);for(let s of i)this.insert(s.bbox,s.data);return}let n=t.children;for(let i of n)e.children.push(i);if(te(e,0,e.children.length),e.children.length>this._maxEntries){let i=this._splitChildren(e),s=yr([e,i]);this._root=s,te(s,0,2)}}_chooseHeight(t){if(t<=this._maxEntries)return 0;return Math.ceil(Math.log(t)/Math.log(this._maxEntries))}_buildSTR(t,e,n,i){return this._buildSTRInner(t,e,n,i,!0)}_buildSTRInner(t,e,n,i,s){let o=n-e+1,r=this._maxEntries;if(o<=r){let f=t.slice(e,n+1),d={bbox:Ut(),children:f,leaf:s};return te(d,0,f.length),d}let a=Math.max(i-1,0),l=Math.ceil(o/r**a),c=Math.ceil(Math.sqrt(Math.ceil(o/l))),h=l*c;wr(t,e,n,h,Dh);let u=[];for(let f=e;f<=n;f+=h){let d=Math.min(f+h-1,n);wr(t,f,d,l,jh);for(let p=f;p<=d;p+=l){let m=Math.min(p+l-1,d),_=t.slice(p,m+1),g={bbox:Ut(),children:_,leaf:s};te(g,0,_.length),u.push(g)}}if(u.length===1)return u[0];return this._buildSTRInner(u,0,u.length-1,i-1,!1)}_insertRecord(t){let e=[],n=this._root;while(!n.leaf){e.push(n);let s=n.children,o=s[0],r=si(o.bbox,t.bbox)-ce(o.bbox),a=ce(o.bbox);for(let l=1;l<s.length;l++){let c=s[l],h=ce(c.bbox),u=si(c.bbox,t.bbox)-h;if(u<r)r=u,a=h,o=c;else if(u===r&&h<a)a=h,o=c}n=o}e.push(n),n.children.push(t),$t(n.bbox,t.bbox);let i=e.length-1;while(i>=0){if(e[i].children.length>this._maxEntries)this._split(e,i);else $t(e[i].bbox,t.bbox);i--}}_insertSubtree(t,e){let n=[],i=this._root,s=0;while(s<e&&!i.leaf){n.push(i);let r=i.children,a=r[0],l=si(a.bbox,t.bbox)-ce(a.bbox),c=ce(a.bbox);for(let h=1;h<r.length;h++){let u=r[h],f=ce(u.bbox),d=si(u.bbox,t.bbox)-f;if(d<l)l=d,c=f,a=u}i=a,s++}n.push(i),i.children.push(t),$t(i.bbox,t.bbox);let o=n.length-1;while(o>=0){if(n[o].children.length>this._maxEntries)this._split(n,o);else $t(n[o].bbox,t.bbox);o--}}_split(t,e){let n=t[e],i=this._splitChildren(n);if(e===0)this._root=yr([n,i]),te(this._root,0,2);else t[e-1].children.push(i),te(t[e-1],0,t[e-1].children.length)}_splitChildren(t){let e=t.children,n=this._maxEntries,i=this._minEntries;this._chooseSplitAxis(e,i,n);let s=this._chooseSplitIndex(e,i,n),o=e.splice(s,e.length-s),r={bbox:Ut(),children:o,leaf:t.leaf};return te(t,0,e.length),te(r,0,o.length),r}_chooseSplitAxis(t,e,n){t.sort(br);let i=this._allDistMargin(t,e,n);t.sort(Bh);let s=this._allDistMargin(t,e,n);if(i<s)t.sort(br)}_allDistMargin(t,e,n){let i=Ut(),s=Ut();for(let a=0;a<e;a++)$t(i,t[a].bbox);for(let a=t.length-e;a<t.length;a++)$t(s,t[a].bbox);let o=ii(i)+ii(s),r=t.length;for(let a=e;a<r-e;a++)$t(i,t[a].bbox),o+=ii(i);for(let a=r-e-1;a>=e;a--)$t(s,t[a].bbox),o+=ii(s);return o}_chooseSplitIndex(t,e,n){let i=e,s=1/0,o=1/0,r=t.length;for(let a=e;a<=r-e;a++){let l=Ut();for(let f=0;f<a;f++)$t(l,t[f].bbox);let c=Ut();for(let f=a;f<r;f++)$t(c,t[f].bbox);let h=Zh(l,c),u=ce(l)+ce(c);if(h<s)s=h,o=u,i=a;else if(h===s&&u<o)o=u,i=a}return i}_condense(t){let e=[];for(let n=t.length-1;n>=0;n--){let i=t[n];if(i.children&&i.children.length===0)if(n>0){let s=t[n-1],o=s.children.indexOf(i);if(o>=0)s.children.splice(o,1)}else{this.clear();return}else if(i.children&&i.children.length<this._minEntries&&n>0){this._collectLeafNodes(i,e);let s=t[n-1],o=s.children.indexOf(i);if(o>=0)s.children.splice(o,1)}else te(i,0,i.children?.length??0)}if(e.length>0)for(let n of e){let i=n.children;if(!i)continue;for(let s of i)this.insert(s.bbox,s.data),this._size--}}_collectLeafNodes(t,e){let n=[t];while(n.length>0){let i=n.pop();if(i.leaf)e.push(i);else if(i.children)for(let s of i.children)n.push(s)}}}function br(t,e){return t.bbox[0]-e.bbox[0]}function Bh(t,e){return t.bbox[1]-e.bbox[1]}function Dh(t,e){return t.bbox[0]+t.bbox[2]-(e.bbox[0]+e.bbox[2])}function jh(t,e){return t.bbox[1]+t.bbox[3]-(e.bbox[1]+e.bbox[3])}function wr(t,e,n,i,s){let o=t.slice(e,n+1);o.sort(s);for(let r=0;r<o.length;r++)t[e+r]=o[r]}class Be{_a;_b;_c;_d;constructor(t,e,n,i){if(Array.isArray(t)){this._a=t[0],this._b=t[1],this._c=t[2],this._d=t[3];return}this._a=t,this._b=e,this._c=n,this._d=i}transform(t,e){return this._transform(t.clone(),e)}_transform(t,e){return e||=1,t.x=e*(this._a*t.x+this._b),t.y=e*(this._c*t.y+this._d),t}untransform(t,e){return e||=1,new v((t.x/e-this._b)/this._a,(t.y/e-this._d)/this._c)}}function Uh(t,e,n,i){return new Be(t,e,n,i)}var Hn=P(()=>{G()});class R{_southWest;_northEast;constructor(t,e){if(!t)return;if(t instanceof R)return t;let n=e?[t,e]:t;for(let i of n)this.extend(i)}extend(t){let e=this._southWest,n=this._northEast,i,s;if(t instanceof S)i=t,s=t;else if(t instanceof R){if(i=t._southWest,s=t._northEast,!i||!s)return this}else{if(!t)return this;if(S.validate(t))return this.extend(new S(t));return this.extend(new R(t))}if(!e&&!n)this._southWest=new S(i.lat,i.lng),this._northEast=new S(s.lat,s.lng);else e.lat=Math.min(i.lat,e.lat),e.lng=Math.min(i.lng,e.lng),n.lat=Math.max(s.lat,n.lat),n.lng=Math.max(s.lng,n.lng);return this}pad(t){let e=this._southWest,n=this._northEast,i=Math.abs(e.lat-n.lat)*t,s=Math.abs(e.lng-n.lng)*t;return new R(new S(e.lat-i,e.lng-s),new S(n.lat+i,n.lng+s))}getCenter(){return new S((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)}getSouthWest(){return this._southWest}getNorthEast(){return this._northEast}getNorthWest(){return new S(this.getNorth(),this.getWest())}getSouthEast(){return new S(this.getSouth(),this.getEast())}getWest(){return this._southWest.lng}getSouth(){return this._southWest.lat}getEast(){return this._northEast.lng}getNorth(){return this._northEast.lat}contains(t){let e=t;if(S.validate(e))e=new S(e);else e=new R(e);let n=this._southWest,i=this._northEast,s,o;if(e instanceof R)s=e.getSouthWest(),o=e.getNorthEast();else s=o=e;return s.lat>=n.lat&&o.lat<=i.lat&&s.lng>=n.lng&&o.lng<=i.lng}intersects(t){let e=new R(t),n=this._southWest,i=this._northEast,s=e.getSouthWest(),o=e.getNorthEast(),r=o.lat>=n.lat&&s.lat<=i.lat,a=o.lng>=n.lng&&s.lng<=i.lng;return r&&a}overlaps(t){let e=new R(t),n=this._southWest,i=this._northEast,s=e.getSouthWest(),o=e.getNorthEast(),r=o.lat>n.lat&&s.lat<i.lat,a=o.lng>n.lng&&s.lng<i.lng;return r&&a}toBBoxString(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")}equals(t,e){if(!t)return!1;let n=new R(t);return this._southWest.equals(n.getSouthWest(),e)&&this._northEast.equals(n.getNorthEast(),e)}isValid(){return!!(this._southWest&&this._northEast)}}function Hh(t,e){if(t instanceof R)return t;return new R(t,e)}var vt=P(()=>{_t()});class Zi{static projection=void 0;static transformation=void 0;static code;static wrapLng;static wrapLat;static infinite=!1;static latLngToPoint(t,e){let n=this.projection.project(t),i=this.scale(e);return this.transformation._transform(n,i)}static pointToLatLng(t,e){let n=this.scale(e),i=this.transformation.untransform(t,n);return this.projection.unproject(i)}static project(t){return this.projection.project(t)}static unproject(t){return this.projection.unproject(t)}static scale(t){return 256*2**t}static zoom(t){return Math.log(t/256)/Math.LN2}static getProjectedBounds(t){if(this.infinite)return null;let e=this.projection.bounds,n=this.scale(t),i=this.transformation.transform(e.min,n),s=this.transformation.transform(e.max,n);return new I(i,s)}static distance(t,e){return 0}static wrapLatLng(t){let e=new S(t),n=this.wrapLng?En(e.lng,this.wrapLng,!0):e.lng,i=this.wrapLat?En(e.lat,this.wrapLat,!0):e.lat,s=e.alt;return new S(i,n,s)}static wrapLatLngBounds(t){let e=new R(t),n=e.getCenter(),i=this.wrapLatLng(n),s=n.lat-i.lat,o=n.lng-i.lng;if(s===0&&o===0)return e;let r=e.getSouthWest(),a=e.getNorthEast(),l=new S(r.lat-s,r.lng-o),c=new S(a.lat-s,a.lng-o);return new R(l,c)}}var fo=P(()=>{N(),ct(),_t(),vt()}),we,on=P(()=>{fo(),we=class extends Zi{static wrapLng=[-180,180];static R=6371000;static distance(e,n){let i=Math.PI/180,s=e.lat*i,o=n.lat*i,r=Math.sin((n.lat-e.lat)*i/2),a=Math.sin((n.lng-e.lng)*i/2),l=r*r+Math.cos(s)*Math.cos(o)*a*a,c=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l));return this.R*c}}});class S{lat;lng;alt;constructor(t,e,n){if(!S.validate(t,e,n))throw Error(`Invalid LatLng object: (${t}, ${e})`);let s,o,r;if(t instanceof S)return t;else if(Array.isArray(t)&&typeof t[0]!=="object")if(t.length===3)s=t[0],o=t[1],r=t[2];else s=t[0],o=t[1];else if(typeof t==="object"&&t!==null&&"lat"in t){let a=t;s=a.lat,o="lng"in a?a.lng:a.lon,r=a.alt}else s=t,o=e,r=n;if(this.lat=+s,this.lng=+o,r!==void 0)this.alt=+r}static validate(t,e,n){if(t instanceof S||typeof t==="object"&&t!==null&&"lat"in t)return!0;if(t&&Array.isArray(t)&&typeof t[0]!=="object"){if(t.length===3||t.length===2)return!0;return!1}if((t||t===0)&&(e||e===0))return!0;return!1}equals(t,e){if(!t)return!1;let n=new S(t);return Math.max(Math.abs(this.lat-n.lat),Math.abs(this.lng-n.lng))<=(e??0.000000001)}toString(t){return`LatLng(${Vt(this.lat,t)}, ${Vt(this.lng,t)})`}distanceTo(t){return we.distance(this,new S(t))}wrap(){return we.wrapLatLng(this)}toBounds(t){let e=180*t/40075017,n=e/Math.cos(Math.PI/180*this.lat);return new R([this.lat-e,this.lng-n],[this.lat+e,this.lng+n])}clone(){let t=new S(0,0);return t.lat=this.lat,t.lng=this.lng,t.alt=this.alt,t}}function Wh(t,e,n){if(t instanceof S)return t;if(t===null||t===void 0)return t;return new S(t,e,n)}var _t=P(()=>{N(),on(),vt()});function po(t,e,n){return-1e4+(t*65536+e*256+n)*0.1}function mo(t,e,n){return t*256+e+n/256-32768}function Vh(t){return t==="terrarium"?mo:po}function qh(t,e="mapbox"){let n=t.length/4|0,i=new Float32Array(n),s=Vh(e);for(let o=0,r=0;o<n;o++,r+=4)i[o]=s(t[r],t[r+1],t[r+2]);return i}function Ya(t,e,n,i){let s=vr(n,0,e-1),o=vr(i,0,e-1),r=Math.floor(s),a=Math.floor(o),l=Math.min(e-1,r+1),c=Math.min(e-1,a+1),h=s-r,u=o-a,f=t[a*e+r],d=t[a*e+l],p=t[c*e+r],m=t[c*e+l],_=f*(1-h)+d*h,g=p*(1-h)+m*h;return _*(1-u)+g*u}function vr(t,e,n){return t<e?e:t>n?n:t}function Gh(t){let e=t.demSize;if(e<2)throw RangeError("demSize must be >= 2");if(t.elevation.length<e*e)throw RangeError(`elevation array is too small for demSize=${e}`);let n=t.tileSize??e,i=Math.max(1,Math.floor(t.resolution??32)),s=t.exaggeration??1,o=t.unitsPerMeter??1,r=i+1,a=r*r,l=new Float32Array(a*6),c=n/i,h=(e-1)/i;for(let d=0;d<r;d++){let p=d*c,m=d*h;for(let _=0;_<r;_++){let g=_*c,b=_*h,w=Ya(t.elevation,e,b,m)*s*o,T=(d*r+_)*6;l[T]=g,l[T+1]=p,l[T+2]=w,l[T+3]=0,l[T+4]=0,l[T+5]=1}}for(let d=0;d<r;d++)for(let p=0;p<r;p++){let m=Math.max(0,p-1),_=Math.min(r-1,p+1),g=Math.max(0,d-1),b=Math.min(r-1,d+1),y=l[(d*r+m)*6+2],w=l[(d*r+_)*6+2],T=l[(g*r+p)*6+2],L=l[(b*r+p)*6+2],C=(_-m)*c||1,D=(b-g)*c||1,W=-(w-y)/C,J=-(L-T)/D,gt=1,E=Math.hypot(W,J,1)||1,V=(d*r+p)*6;l[V+3]=W/E,l[V+4]=J/E,l[V+5]=1/E}let u=new Uint32Array(i*i*6),f=0;for(let d=0;d<i;d++)for(let p=0;p<i;p++){let m=d*r+p,_=m+1,g=m+r,b=g+1;u[f++]=m,u[f++]=g,u[f++]=_,u[f++]=_,u[f++]=g,u[f++]=b}return{positions:l,indices:u,vertexCount:a,indexCount:u.length,resolution:i}}var Ka=()=>{};class Xa{constructor(t){this._tiles=new Map,this._opts={demSize:t?.demSize??256,encoding:t?.encoding??"mapbox",meshResolution:t?.meshResolution??32,exaggeration:t?.exaggeration??1}}get demSize(){return this._opts.demSize}get encoding(){return this._opts.encoding}get meshResolution(){return this._opts.meshResolution}get exaggeration(){return this._opts.exaggeration}setExaggeration(t){if(!Number.isFinite(t))throw RangeError("exaggeration must be a finite number");this._opts.exaggeration=t}addTilePixels(t,e){let n=this._opts.demSize*this._opts.demSize*4;if(e.length<n)throw RangeError(`pixel buffer too small: got ${e.length}, need ${n}`);this._tiles.set(Ve(t),qh(e,this._opts.encoding))}addTileElevation(t,e){let n=this._opts.demSize*this._opts.demSize;if(e.length<n)throw RangeError(`elevation grid too small: got ${e.length}, need ${n}`);this._tiles.set(Ve(t),e)}hasTile(t){return this._tiles.has(Ve(t))}getTile(t){return this._tiles.get(Ve(t))}deleteTile(t){this._tiles.delete(Ve(t))}clear(){this._tiles.clear()}size(){return this._tiles.size}queryElevation(t,e,n){let i=Yh(e,-85.05112878,85.05112878),s=Math.max(0,Math.floor(n));for(let o=s;o>=0;o--){let r=Kh(t,o),a=Xh(i,o),l=this._tiles.get(Ve({z:o,x:r,y:a}));if(!l)continue;let c=Jh(t,o)-r*this._opts.demSize,h=Qh(i,o)-a*this._opts.demSize;return Ya(l,this._opts.demSize,c,h)}return null}}function Ve(t){return`${t.z}/${t.x}/${t.y}`}function Yh(t,e,n){return t<e?e:t>n?n:t}function Kh(t,e){return Math.floor((t+180)/360*2**e)}function Xh(t,e){let n=t*Math.PI/180;return Math.floor((1-Math.log(Math.tan(n)+1/Math.cos(n))/Math.PI)/2*2**e)}function Jh(t,e){return(t+180)/360*2**e*256}function Qh(t,e){let n=t*Math.PI/180;return(1-Math.log(Math.tan(n)+1/Math.cos(n))/Math.PI)/2*2**e*256}var Ja=()=>{},xr=6378137,ye,_o=P(()=>{ct(),G(),_t(),ye={R:xr,MAX_LATITUDE:85.0511287798,project(t){let e=new S(t),n=Math.PI/180,i=this.MAX_LATITUDE,s=Math.max(Math.min(i,e.lat),-i),o=Math.sin(s*n);return new v(this.R*e.lng*n,this.R*Math.log((1+o)/(1-o))/2)},unproject(t){let e=new v(t),n=180/Math.PI;return new S((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*n,e.x*n/this.R)},bounds:(()=>{let t=xr*Math.PI;return new I([-t,-t],[t,t])})()}}),Pi,tu,Qa=P(()=>{Hn(),_o(),on(),Pi=class extends we{static code="EPSG:3857";static projection=ye;static transformation=(()=>{let e=0.5/(Math.PI*ye.R);return new Be(e,0.5,-e,0.5)})()},tu=class extends Pi{static code="EPSG:900913"}});function ks(t){if(t.length<3)return 0;let e=0;for(let n=0,i=t.length;n<i;n++){let s=t[n],o=t[(n+1)%i],r=o[0]-s[0];if(r>180)r-=360;else if(r<-180)r+=360;e+=r*pe*(2+Math.sin(s[1]*pe)+Math.sin(o[1]*pe))}return e*Ms*Ms/2}function tl(t){if(t.length===0)return 0;let e=Math.abs(ks(t[0]));for(let n=1;n<t.length;n++)e-=Math.abs(ks(t[n]));return Math.max(0,e)}function he(t){let e=0;for(let n of t)e+=tl(n);return e}function eu(t,e=!0){let n=0,i=e?t.length:t.length-1;for(let s=0;s<i;s++)n+=zn(t[s],t[(s+1)%t.length]);return n}function zn(t,e){let n=(e[1]-t[1])*pe,i=(e[0]-t[0])*pe,s=t[1]*pe,o=e[1]*pe,r=Math.sin(n/2)**2+Math.sin(i/2)**2*Math.cos(s)*Math.cos(o);return 2*Ms*Math.asin(Math.min(1,Math.sqrt(r)))}function nu(t,e={}){let n=e.locale,i=Math.max(0,t);if(e.units==="imperial"){let s=i*10.763910417;if(s<43560)return`${Ht(s,0).toLocaleString(n)} ft²`;let o=i/4046.8564224;if(o<640)return`${Ht(o,o<10?2:1).toLocaleString(n)} acres`;return`${Ht(i/2589988.110336,2).toLocaleString(n)} mi²`}if(i<1e4)return`${Ht(i,0).toLocaleString(n)} m²`;if(i<1e6)return`${Ht(i/1e4,i<1e5?2:1).toLocaleString(n)} ha`;return`${Ht(i/1e6,i<1e7?2:1).toLocaleString(n)} km²`}function Ym(t,e={}){let n=e.locale,i=Math.max(0,t);if(e.units==="imperial"){let s=i/1609.344;if(s<0.1)return`${Ht(i*3.280839895,0).toLocaleString(n)} ft`;return`${Ht(s,2).toLocaleString(n)} mi`}if(i<1000)return`${Ht(i,0).toLocaleString(n)} m`;return`${Ht(i/1000,2).toLocaleString(n)} km`}function Ht(t,e){let n=10**e;return Math.round(t*n)/n}var Ms=6371008.8,pe,Bi=P(()=>{pe=Math.PI/180});class Cn{point;left;otherEvent;isSubject;type;inOut;otherInOut;inResult;contourId;constructor(t,e,n,i,s=sl){this.point=t,this.left=e,this.otherEvent=n,this.isSubject=i,this.type=s,this.inOut=!1,this.otherInOut=!1,this.inResult=!1,this.contourId=0}isBelow(t){let e=this.point,n=this.otherEvent.point;return this.left?In(e,n,t)>0:In(n,e,t)>0}isAbove(t){return!this.isBelow(t)}isVertical(){return this.point[0]===this.otherEvent.point[0]}}function In(t,e,n){return(t[0]-n[0])*(e[1]-n[1])-(e[0]-n[0])*(t[1]-n[1])}function ft(t,e){return t[0]===e[0]&&t[1]===e[1]}function ie(t,e){let n=t.point,i=e.point;if(n[0]>i[0])return 1;if(n[0]<i[0])return-1;if(n[1]!==i[1])return n[1]>i[1]?1:-1;if(t.left!==e.left)return t.left?1:-1;if(In(n,t.otherEvent.point,e.otherEvent.point)!==0)return t.isBelow(e.otherEvent.point)?-1:1;return!t.isSubject&&e.isSubject?1:-1}function iu(t,e){if(t===e)return 0;if(In(t.point,t.otherEvent.point,e.point)!==0||In(t.point,t.otherEvent.point,e.otherEvent.point)!==0){if(ft(t.point,e.point))return t.isBelow(e.otherEvent.point)?-1:1;if(t.point[0]===e.point[0])return t.point[1]<e.point[1]?-1:1;if(ie(t,e)===1)return e.isAbove(t.point)?-1:1;return t.isBelow(e.point)?-1:1}if(t.isSubject===e.isSubject){let n=t.point,i=e.point;if(n[0]===i[0]&&n[1]===i[1]){if(n=t.otherEvent.point,i=e.otherEvent.point,n[0]===i[0]&&n[1]===i[1])return 0;return t.contourId>e.contourId?1:-1}return ie(t,e)===1?1:-1}return t.isSubject?-1:1}class el{_data=[];get length(){return this._data.length}push(t){let e=this._data;e.push(t);let n=e.length-1;while(n>0){let i=n-1>>1;if(ie(e[n],e[i])>=0)break;let s=e[i];e[i]=e[n],e[n]=s,n=i}}pop(){let t=this._data,e=t[0],n=t.pop();if(t.length===0)return e;t[0]=n;let i=0,s=t.length>>1;while(i<s){let o=2*i+1,r=o+1;if(r<t.length&&ie(t[r],t[o])<0)o=r;if(ie(t[o],t[i])>=0)break;let a=t[o];t[o]=t[i],t[i]=a,i=o}return e}}class nl{_items=[];insert(t){let e=0,n=this._items.length;while(e<n){let i=e+n>>1;if(iu(this._items[i],t)<0)e=i+1;else n=i}return this._items.splice(e,0,t),e}remove(t){let e=this._items.indexOf(t);if(e!==-1)this._items.splice(e,1)}indexOf(t){return this._items.indexOf(t)}at(t){return t>=0&&t<this._items.length?this._items[t]:null}}function su(t,e,n,i){let s=[e[0]-t[0],e[1]-t[1]],o=[i[0]-n[0],i[1]-n[1]],r=[n[0]-t[0],n[1]-t[1]],a=(_,g)=>_[0]*g[1]-_[1]*g[0],l=(_,g)=>_[0]*g[0]+_[1]*g[1],c=(_,g,b)=>[_[0]+g*b[0],_[1]+g*b[1]],h=a(s,o);if(h*h>0){let _=a(r,o)/h;if(_<0||_>1)return null;let g=a(r,s)/h;if(g<0||g>1)return null;if(_===0||_===1)return[c(t,_,s)];if(g===0||g===1)return[c(n,g,o)];return[c(t,_,s)]}if(a(r,s)**2>0)return null;let u=l(s,s);if(u===0)return null;let f=l(r,s)/u,d=f+l(o,s)/u,p=Math.max(Math.min(f,d),0),m=Math.min(Math.max(f,d),1);if(p>m)return null;if(p===m)return[c(t,p,s)];return[c(t,p,s),c(t,m,s)]}function ue(t,e,n){let i=new Cn(e,!1,t,t.isSubject),s=new Cn(e,!0,t.otherEvent,t.isSubject);if(i.contourId=t.contourId,s.contourId=t.contourId,ie(s,t.otherEvent)>0)t.otherEvent.left=!0,s.left=!1;t.otherEvent.otherEvent=s,t.otherEvent=i,n.push(s),n.push(i)}function as(t,e,n){let i=su(t.point,t.otherEvent.point,e.point,e.otherEvent.point);if(!i)return 0;let s=i.length;if(s===1&&(ft(t.point,e.point)||ft(t.otherEvent.point,e.otherEvent.point)))return 0;if(s===2&&t.isSubject===e.isSubject)return 0;if(s===1){if(!ft(t.point,i[0])&&!ft(t.otherEvent.point,i[0]))ue(t,i[0],n);if(!ft(e.point,i[0])&&!ft(e.otherEvent.point,i[0]))ue(e,i[0],n);return 1}let o=[],r=!1,a=!1;if(ft(t.point,e.point))r=!0;else if(ie(t,e)===1)o.push(e,t);else o.push(t,e);if(ft(t.otherEvent.point,e.otherEvent.point))a=!0;else if(ie(t.otherEvent,e.otherEvent)===1)o.push(e.otherEvent,t.otherEvent);else o.push(t.otherEvent,e.otherEvent);if(r){if(e.type=ol,t.type=e.inOut===t.inOut?rl:al,!a)ue(o[1].otherEvent,o[0].point,n);return 2}if(a)return ue(o[0],o[1].point,n),3;if(o[0]!==o[3].otherEvent)return ue(o[0],o[1].point,n),ue(o[1],o[2].point,n),3;return ue(o[0],o[1].point,n),ue(o[3].otherEvent,o[2].point,n),3}function ou(t,e){switch(t.type){case sl:switch(e){case Es:return!t.otherInOut;case Rn:return t.otherInOut;case ki:return t.isSubject&&t.otherInOut||!t.isSubject&&!t.otherInOut;case Mi:return!0}return!1;case rl:return e===Es||e===Rn;case al:return e===ki;default:return!1}}function bn(t,e,n){if(e===null)t.inOut=!1,t.otherInOut=!0;else if(t.isSubject===e.isSubject)t.inOut=!e.inOut,t.otherInOut=e.otherInOut;else t.inOut=!e.otherInOut,t.otherInOut=e.isVertical()?!e.inOut:e.inOut;t.inResult=ou(t,n)}function ru(t,e,n){let i=new el,s=0,o=(c,h)=>{for(let u of c)for(let f of u){s++;let d=au(f);for(let p=0;p<d.length;p++){let m=d[p],_=d[(p+1)%d.length];if(ft(m,_))continue;let g=new Cn(m,!1,null,h),b=new Cn(_,!1,g,h);if(g.otherEvent=b,g.contourId=s,b.contourId=s,ie(g,b)>0)b.left=!0;else g.left=!0;i.push(g),i.push(b)}}};o(t,!0),o(e,!1);let r=new nl,a=[];while(i.length>0){let c=i.pop();if(c.left){let h=r.insert(c),u=r.at(h-1),f=r.at(h+1);if(bn(c,u,n),f&&as(c,f,i)===2)bn(c,u,n),bn(f,c,n);if(u&&as(u,c,i)===2){let d=r.at(r.indexOf(u)-1);bn(u,d,n),bn(c,u,n)}a.push(c)}else{let h=c.otherEvent,u=r.indexOf(h);if(u!==-1){let f=r.at(u-1),d=r.at(u+1);if(r.remove(h),f&&d)as(f,d,i)}}}let l=[];for(let c of a)if(c.inResult&&c.type!==ol)l.push({from:c.point,to:c.otherEvent.point});return l}function au(t){let e=[];for(let n of t){let i=e[e.length-1];if(!i||!ft(i,n))e.push([n[0],n[1]])}while(e.length>1&&ft(e[0],e[e.length-1]))e.pop();return e}function Sr(t){return`${t[0]},${t[1]}`}function lu(t){let e=Array.from({length:t.length},()=>!1),n=new Map,i=(o,r,a)=>{let l={edge:a,to:r,angle:Math.atan2(r[1]-o[1],r[0]-o[0])},c=Sr(o),h=n.get(c);if(h)h.push(l);else n.set(c,[l])};for(let o=0;o<t.length;o++){let{from:r,to:a}=t[o];if(ft(r,a)){e[o]=!0;continue}i(r,a,o),i(a,r,o)}let s=[];for(let o=0;o<t.length;o++){if(e[o])continue;let r=t[o].from,a=[r],l=r,c=t[o].to;e[o]=!0;for(let h=0;h<=t.length+1;h++){if(a.push(c),ft(c,r))break;let u=n.get(Sr(c));if(!u)break;let f=Math.atan2(l[1]-c[1],l[0]-c[0]),d=null,p=1/0;for(let m of u){if(e[m.edge])continue;let _=f-m.angle;while(_<=0)_+=Math.PI*2;while(_>Math.PI*2)_-=Math.PI*2;if(_<p)p=_,d=m}if(!d)break;e[d.edge]=!0,l=c,c=d.to}if(a.length>=4&&ft(a[0],a[a.length-1]))s.push(a)}return s}function Ls(t){let e=0;for(let n=0,i=t.length-1;n<i;n++)e+=(t[n+1][0]-t[n][0])*(t[n+1][1]+t[n][1]);return e}function Fn(t,e){let n=!1;for(let i=0,s=e.length-2;i<e.length-1;s=i++){let o=e[i][0],r=e[i][1],a=e[s][0],l=e[s][1];if(r>t[1]!==l>t[1]&&t[0]<(a-o)*(t[1]-r)/(l-r)+o)n=!n}return n}function cu(t){for(let e=0;e<t.length-1;e++){let n=t[e],i=t[(e+1)%(t.length-1)],s=[(n[0]+i[0])/2,(n[1]+i[1])/2],o=i[0]-n[0],r=i[1]-n[1],a=Math.hypot(o,r);if(a===0)continue;let l=a*0.000001,c=[s[0]-r/a*l,s[1]+o/a*l];if(Fn(c,t))return c;let h=[s[0]+r/a*l,s[1]-o/a*l];if(Fn(h,t))return h}return t[0]}function hu(t){let e=t.filter((a)=>Math.abs(Ls(a))>0),n=e.map(cu),i=e.map(()=>-1),s=e.map(()=>0);for(let a=0;a<e.length;a++){let l=-1,c=1/0;for(let h=0;h<e.length;h++){if(a===h)continue;if(!Fn(n[a],e[h]))continue;let u=Math.abs(Ls(e[h]));if(u<c)c=u,l=h;s[a]++}i[a]=l}let o=[],r=new Map;for(let a=0;a<e.length;a++){if(s[a]%2!==0)continue;r.set(a,o.length),o.push([Tr(e[a],!0)])}for(let a=0;a<e.length;a++){if(s[a]%2===0)continue;let l=i[a]===-1?void 0:r.get(i[a]);if(l===void 0)continue;o[l].push(Tr(e[a],!1))}return o}function Tr(t,e){let n=Ls(t)>0,i=t.map((s)=>[s[0],s[1]]);if(n===e)i.reverse();return i}function Di(t,e,n){if(t.length===0){if(n===Rn||n===Mi)return Pr(e);return[]}if(e.length===0){if(n===Rn||n===ki||n===Mi)return Pr(t);return[]}return hu(lu(ru(t,e,n)))}function Pr(t){return t.map((e)=>e.map((n)=>n.map((i)=>[i[0],i[1]])))}function As(t,e){return Di(t,e,Rn)}function Os(t,e){return Di(t,e,Es)}function ls(t,e){return Di(t,e,ki)}function Km(t,e){return Di(t,e,Mi)}function Xm(t,e){return Os(t,e).length>0}function il(t,e){for(let n of t){if(n.length===0||!Fn(e,kr(n[0])))continue;let i=!1;for(let s=1;s<n.length;s++)if(Fn(e,kr(n[s]))){i=!0;break}if(!i)return!0}return!1}function kr(t){if(t.length>0&&!ft(t[0],t[t.length-1]))return[...t,t[0]];return t}var Es=0,Rn=1,ki=2,Mi=3,sl=0,ol=1,rl=2,al=3;function uu(t){if(!Array.isArray(t))throw new Ke("ring must be an array of positions");if(t.length<4)throw new Ke(`ring needs at least 4 positions to enclose an area, got ${t.length}`);for(let e=0;e<t.length;e++){let n=t[e];if(!Array.isArray(n)||n.length<2)throw new Ke(`position ${e} is not a [lng, lat] pair`);let[i,s]=n;if(!Number.isFinite(i)||!Number.isFinite(s))throw new Ke(`position ${e} is not finite: [${i}, ${s}] — a receiver losing lock reports this`);if(s<-90||s>90)throw new Ke(`position ${e} has latitude ${s}, outside [-90, 90]`)}}function fu(t){let e=!1;for(let s=1;s<t.length;s++)if(Math.abs(t[s][0]-t[s-1][0])>180){e=!0;break}if(!e)return t;let n=[[t[0][0],t[0][1]]],i=0;for(let s=1;s<t.length;s++){let o=t[s][0]-t[s-1][0];if(o>180)i-=360;else if(o<-180)i+=360;n.push([t[s][0]+i,t[s][1]])}return n}function du(t){let e=Li(t).slice(0,-1),n=e.length;if(n<3)return[Li(t)];let i=[],s=[];for(let o=0;o<n;o++){let r=e[o],a=e[(o+1)%n];s.push(r);for(let l=0;l+2<s.length;l++){let c=mu(r,a,s[l],s[l+1]);if(!c)continue;i.push([c,...s.slice(l+1),c]),s.length=l+1,s.push(c);break}}return i.push([...s,s[0]]),i.filter((o)=>o.length>=4)}function pu(t){let e=[[Li(t)]];if(!_u(t))return e;let n=du(t);if(n.length<=1)return e;let i=[];for(let s of n)i=As(i,[[s]]);return i}function mu(t,e,n,i){let s=e[0]-t[0],o=e[1]-t[1],r=i[0]-n[0],a=i[1]-n[1],l=s*a-o*r;if(l===0)return null;let c=n[0]-t[0],h=n[1]-t[1],u=(c*a-h*r)/l,f=(c*o-h*s)/l;if(u<=0||u>=1||f<=0||f>=1)return null;return[t[0]+s*u,t[1]+o*u]}function _u(t){let e=Li(t),n=e.length-1;if(n<4)return!1;for(let i=0;i<n;i++)for(let s=i+2;s<n;s++){if(i===0&&s===n-1)continue;if(gu(e[i],e[i+1],e[s],e[s+1]))return!0}return!1}function gu(t,e,n,i){let s=oi(t,e,n),o=oi(t,e,i),r=oi(n,i,t),a=oi(n,i,e);return(s>0&&o<0||s<0&&o>0)&&(r>0&&a<0||r<0&&a>0)}function oi(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(e[1]-t[1])*(n[0]-t[0])}function Li(t){if(t.length===0)return t;let e=t[0],n=t[t.length-1];if(e[0]===n[0]&&e[1]===n[1])return t;return[...t,e]}function Mr(t){return uu(t),pu(fu(t))}var Ke,ll=P(()=>{Ke=class extends Error{constructor(e){super(e);this.name="InvalidGeometryError"}}});function Lr(t){if(typeof navigator>"u"||typeof navigator.userAgent>"u")return!1;return navigator.userAgent.toLowerCase().includes(t)}var cs,Ar,Or,hs,us,Er,zr,Cr,Ir,Fr,pt,Te=P(()=>{cs=Lr("chrome"),Ar=!cs&&Lr("safari"),Or=typeof globalThis.orientation<"u",hs=typeof window>"u"?!1:!!window.PointerEvent,us=typeof window>"u"?!1:("ontouchstart"in window)||!!window.TouchEvent,Er=us||hs,zr=typeof window>"u"||typeof window.devicePixelRatio>"u"?!1:window.devicePixelRatio>1,Cr=typeof navigator>"u"||typeof navigator.platform>"u"?!1:navigator.platform.startsWith("Mac"),Ir=typeof navigator>"u"||typeof navigator.platform>"u"?!1:navigator.platform.startsWith("Linux"),Fr={chrome:cs,safari:Ar,mobile:Or,pointer:hs,touch:Er,touchNative:us,retina:zr,mac:Cr,linux:Ir},pt=Fr}),cl={};tt(cl,{cleanupPointers:()=>yu,disablePointerDetection:()=>ul,enablePointerDetection:()=>hl,getPointers:()=>Kt});function hl(t){t.addEventListener("pointerdown",fl,{capture:!0}),t.addEventListener("pointermove",dl,{capture:!0}),t.addEventListener("pointerup",Ai,{capture:!0}),t.addEventListener("pointercancel",Ai,{capture:!0}),ve.clear()}function ul(t){t.removeEventListener("pointerdown",fl,{capture:!0}),t.removeEventListener("pointermove",dl,{capture:!0}),t.removeEventListener("pointerup",Ai,{capture:!0}),t.removeEventListener("pointercancel",Ai,{capture:!0})}function fl(t){t.target.setPointerCapture(t.pointerId),ve.set(t.pointerId,t)}function dl(t){if(ve.has(t.pointerId))ve.set(t.pointerId,t)}function Ai(t){t.target.releasePointerCapture(t.pointerId),ve.delete(t.pointerId)}function Kt(){return[...ve.values()]}function yu(){ve.clear()}var ve,De=P(()=>{ve=new Map});function bu(t){let e={bubbles:t.bubbles,cancelable:t.cancelable,composed:t.composed,detail:2,view:t.view,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,button:t.button,buttons:t.buttons,relatedTarget:t.relatedTarget};if(typeof PointerEvent<"u"&&t instanceof PointerEvent)return e={...e,pointerId:t.pointerId,width:t.width,height:t.height,pressure:t.pressure,tangentialPressure:t.tangentialPressure,tiltX:t.tiltX,tiltY:t.tiltY,twist:t.twist,pointerType:t.pointerType,isPrimary:t.isPrimary},new PointerEvent("dblclick",e);return new MouseEvent("dblclick",e)}function wu(t,e){t.addEventListener("dblclick",e);let n=0,i;function s(o){if(o.detail!==1){i=o.detail;return}if(o.pointerType==="mouse"||o.sourceCapabilities&&!o.sourceCapabilities.firesTouchEvents)return;let r=_l(o);if(r.some((l)=>l instanceof HTMLLabelElement&&l.attributes.getNamedItem("for"))&&!r.some((l)=>l instanceof HTMLInputElement||l instanceof HTMLSelectElement))return;let a=Date.now();if(a-n<=xu){if(i++,i===2)o.target.dispatchEvent(bu(o))}else i=1;n=a}return t.addEventListener("click",s),{dblclick:e,simDblclick:s}}function vu(t,e){t.removeEventListener("dblclick",e.dblclick),t.removeEventListener("click",e.simDblclick)}var xu=200,Su=P(()=>{H()}),Tu={};tt(Tu,{create:()=>A,disableImageDrag:()=>bo,disableTextSelection:()=>go,enableImageDrag:()=>wo,enableTextSelection:()=>yo,get:()=>pl,getPosition:()=>Re,getScale:()=>xo,getSizedParentNode:()=>ml,preventOutline:()=>vo,restoreOutline:()=>Oi,setPosition:()=>lt,setTransform:()=>Fe,toBack:()=>Vn,toFront:()=>Wn});function pl(t){return typeof t==="string"?document.getElementById(t):t}function A(t,e,n){let i=document.createElement(t);return i.className=e??"",n?.appendChild(i),i}function Wn(t){let e=t.parentNode;if(e&&e.lastChild!==t)e.appendChild(t)}function Vn(t){let e=t.parentNode;if(e&&e.firstChild!==t)e.insertBefore(t,e.firstChild)}function Fe(t,e,n,i,s){let o=e??new v(0,0),r=i?` rotate(${i}deg)`:"",a=s?` rotateX(${s}deg)`:"",l=n?` scale(${n})`:"";t.style.transform=`translate3d(${o.x}px,${o.y}px,0)${a}${r}${l}`}function lt(t,e,n,i){if(So.set(t,e),n!==void 0)zs.set(t,n);if(i!==void 0)Cs.set(t,i);let s=n??zs.get(t)??0,o=i??Cs.get(t)??0;Fe(t,e,void 0,s||void 0,o||void 0)}function Re(t){return So.get(t)??new v(0,0)}function go(){let t=Nn[Ei];if(t==="none")return;bi=t,Nn[Ei]="none"}function yo(){if(typeof bi>"u")return;Nn[Ei]=bi,bi=void 0}function bo(){k(window,"dragstart",xe)}function wo(){Z(window,"dragstart",xe)}function vo(t){let e=t;while(e.tabIndex===-1)e=e.parentNode;if(!e.style)return;Oi(),wi=e,Is=e.style.outlineStyle,e.style.outlineStyle="none",k(window,"keydown",Oi)}function Oi(){if(!wi)return;wi.style.outlineStyle=Is,wi=void 0,Is=void 0,Z(window,"keydown",Oi)}function ml(t){let e=t;do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function xo(t){let e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}var So,zs,Cs,Nn,Ei,bi,wi,Is,Y=P(()=>{H(),G(),So=new WeakMap,zs=new WeakMap,Cs=new WeakMap,Nn=typeof document>"u"?{}:document.documentElement.style,Ei=["userSelect","WebkitUserSelect"].find((t)=>(t in Nn))}),Fs={};tt(Fs,{PointerEvents:()=>cl,disableClickPropagation:()=>se,disableScrollPropagation:()=>ji,getPointerPosition:()=>gl,getPropagationPath:()=>_l,getWheelDelta:()=>bl,getWheelPxFactor:()=>yl,isExternalTarget:()=>To,off:()=>Z,on:()=>k,preventDefault:()=>xe,stop:()=>dt,stopPropagation:()=>be});function k(t,e,n,i){if(e&&typeof e==="object")for(let[s,o]of Object.entries(e))Rs(t,s,o,n);else for(let s of Yt(e))Rs(t,s,n,i);return this}function Z(t,e,n,i){if(arguments.length===1)Rr(t),delete t[ne];else if(e&&typeof e==="object")for(let[s,o]of Object.entries(e))Ns(t,s,o,n);else{let s=Yt(e);if(arguments.length===2)Rr(t,(o)=>s.includes(o));else for(let o of s)Ns(t,o,n,i)}return this}function Rr(t,e){for(let n of Object.keys(t[ne]??{})){let i=n.split(/\d/)[0];if(!e||e(i))Ns(t,i,null,null,n)}}function Rs(t,e,n,i){let s=e+j(n)+(i?`_${j(i)}`:"");if(t[ne]&&t[ne][s])return;let o=function(a){return n.call(i||t,a)},r=o;if(pt.touch&&e==="dblclick")o=wu(t,o);else if("addEventListener"in t)if(e==="wheel"||e==="mousewheel")t.addEventListener(zi[e]||e,o,{passive:!1});else if(e==="pointerenter"||e==="pointerleave")o=function(a){if(To(t,a))r(a)},t.addEventListener(zi[e],o,!1);else t.addEventListener(e,r,!1);else t.attachEvent(`on${e}`,o);t[ne]??={},t[ne][s]=o}function Ns(t,e,n,i,s){s??=e+j(n)+(i?`_${j(i)}`:"");let o=t[ne]&&t[ne][s];if(!o)return;if(pt.touch&&e==="dblclick")vu(t,o);else if("removeEventListener"in t)t.removeEventListener(zi[e]||e,o,!1);else t.detachEvent(`on${e}`,o);t[ne][s]=null}function be(t){if(t.stopPropagation)t.stopPropagation();else if(t.originalEvent)t.originalEvent._stopped=!0;else t.cancelBubble=!0;return this}function ji(t){return Rs(t,"wheel",be),this}function se(t){return k(t,"pointerdown dblclick contextmenu",be),t._tsmap_disable_click=!0,this}function xe(t){return t.preventDefault?.(),this}function dt(t){return xe(t),be(t),this}function _l(t){return t.composedPath()}function gl(t,e){if(!e)return new v(t.clientX,t.clientY);let n=xo(e),i=n.boundingClientRect;return new v((t.clientX-i.left)/n.x-e.clientLeft,(t.clientY-i.top)/n.y-e.clientTop)}function yl(){let t=window.devicePixelRatio;return pt.linux&&pt.chrome?t:pt.mac?t*3:t>0?2*t:1}function bl(t){return t.deltaY&&t.deltaMode===0?-t.deltaY/yl():t.deltaY&&t.deltaMode===1?-t.deltaY*20:t.deltaY&&t.deltaMode===2?-t.deltaY*60:t.deltaX||t.deltaZ?0:0}function To(t,e){let n=e.relatedTarget;if(!n)return!0;try{while(n&&n!==t)n=n.parentNode}catch{return!1}return n!==t}var ne="_tsmap_events",zi,H=P(()=>{Te(),N(),De(),G(),Su(),Y(),zi={pointerenter:"pointerover",pointerleave:"pointerout",wheel:typeof window>"u"?!1:!("onwheel"in window)&&"mousewheel"}});class rn{static include(t){let e=this.prototype.options;for(let i of n(t))this.prototype[i]=t[i];if(t.options)this.prototype.options=e,this.mergeOptions(t.options);return this;function*n(i){do{if(i===Object||i===Object.prototype)break;for(let s of Object.getOwnPropertyNames(i))yield s}while((i=Object.getPrototypeOf(i))!==void 0)}}static setDefaultOptions(t){return et(this.prototype,t),this}static mergeOptions(t){return this.prototype.options??={},Object.assign(this.prototype.options,t),this}static addInitHook(t,...e){let n=typeof t==="function"?t:function(){this[t].apply(this,e)};if(!Object.hasOwn(this.prototype,"_initHooks"))this.prototype._initHooks=[];return this.prototype._initHooks.push(n),this}_initHooksCalled=!1;initialize(...t){}constructor(...t){et(this),this.initialize(...t),this.callInitHooks()}callInitHooks(){if(this._initHooksCalled)return;let t=[],e=this;while((e=Object.getPrototypeOf(e))!==null)t.push(e);t.reverse();for(let n of t)for(let i of n._initHooks??[])i.call(this);this._initHooksCalled=!0}}var qn=P(()=>{N()});function ri(t,e){if(typeof e==="string"){if(e.length===0)throw TypeError(`Evented.${t}: event type must be a non-empty string.`);return}if(e!==null&&typeof e==="object"&&!Array.isArray(e))return;throw TypeError(`Evented.${t}: first argument must be a string or a { type: handler } object, got ${e===null?"null":Array.isArray(e)?"array":typeof e}.`)}var wt,Pe=P(()=>{N(),qn(),wt=class t extends rn{static __REMOVED_EVENTS=["mousedown","mouseup","mouseover","mouseout","mousemove"];on(e,n,i){if(ri("on",e),typeof e==="object")for(let[s,o]of Object.entries(e))this._on(s,o,n);else for(let s of Yt(e))this._on(s,n,i);return this}off(e,n,i){if(!arguments.length)delete this._events;else if(typeof e==="object"){ri("off",e);for(let[s,o]of Object.entries(e))this._off(s,o,n)}else{ri("off",e);let s=arguments.length===1;for(let o of Yt(e))if(s)this._off(o);else this._off(o,n,i)}return this}_on(e,n,i,s){if(t.__REMOVED_EVENTS.includes(e))console.error(`The event ${e} has been removed. Use the PointerEvent variant instead.`);if(typeof n!=="function"){console.warn(`wrong listener type: ${typeof n}`);return}if(this._listens(e,n,i)!==!1)return;if(i===this)i=void 0;let o={fn:n,ctx:i};if(s)o.once=!0;this._events??={},this._events[e]??=[],this._events[e].push(o)}_off(e,n,i){if(!this._events)return;let s=this._events[e];if(!s)return;if(arguments.length===1){if(this._firingCount)for(let r of s)r.fn=Et;delete this._events[e];return}if(typeof n!=="function"){console.warn(`wrong listener type: ${typeof n}`);return}let o=this._listens(e,n,i);if(o!==!1&&typeof o==="number"){let r=s[o];if(this._firingCount)r.fn=Et,this._events[e]=s=s.slice();s.splice(o,1)}}fire(e,n,i){if(!this.listens(e,i))return this;let s={...n,type:e,target:this,sourceTarget:n?.sourceTarget||this};if(this._events){let o=this._events[e];if(o){this._firingCount=(this._firingCount||0)+1;for(let r of o){let a=r.fn;if(r.once)this.off(e,a,r.ctx);a.call(r.ctx||this,s)}this._firingCount--}}if(i)this._propagateEvent(s);return this}listens(e,n,i,s){if(typeof e!=="string")console.warn('"string" type argument expected');let o=n;if(typeof n!=="function")s=!!n,o=void 0,i=void 0;if(this._events?.[e]?.length){if(this._listens(e,o,i)!==!1)return!0}if(s){for(let r of Object.values(this._eventParents??{}))if(r.listens(e,n,i,s))return!0}return!1}_listens(e,n,i){if(!this._events)return!1;let s=this._events[e]??[];if(!n)return s.length?0:!1;if(i===this)i=void 0;let o=s.findIndex((r)=>r.fn===n&&r.ctx===i);return o===-1?!1:o}once(e,n,i){if(ri("once",e),typeof e==="object")for(let[s,o]of Object.entries(e))this._on(s,o,n,!0);else for(let s of Yt(e))this._on(s,n,i,!0);return this}addEventParent(e){return this._eventParents??={},this._eventParents[j(e)]=e,this}removeEventParent(e){if(this._eventParents)delete this._eventParents[j(e)];return this}_propagateEvent(e){for(let n of Object.values(this._eventParents??{}))n.fire(e.type,{propagatedFrom:e.target,...e},!0)}addEventListener=this.on;removeEventListener=this.off;clearAllEventListeners=this.off;addOneTimeEventListener=this.once;fireEvent=this.fire;hasEventListeners=this.listens}}),Pu={};tt(Pu,{cubicBezier:()=>Ru,easeInCubic:()=>Ou,easeInOutCubic:()=>$s,easeInOutQuad:()=>Au,easeInOutQuart:()=>Iu,easeInQuad:()=>Mu,easeInQuart:()=>zu,easeOutBack:()=>Fu,easeOutCubic:()=>Eu,easeOutQuad:()=>Lu,easeOutQuart:()=>Cu,linear:()=>ku});function ku(t){return t}function Mu(t){return t*t}function Lu(t){return 1-(1-t)*(1-t)}function Au(t){return t<0.5?2*t*t:1-(-2*t+2)**2/2}function Ou(t){return t*t*t}function Eu(t){return 1-(1-t)**3}function $s(t){return t<0.5?4*t*t*t:1-(-2*t+2)**3/2}function zu(t){return t*t*t*t}function Cu(t){return 1-(1-t)**4}function Iu(t){return t<0.5?8*t*t*t*t:1-(-2*t+2)**4/2}function Fu(t){let i=t-1;return 1+2.70158*i*i*i+1.70158*i*i}function Ru(t,e,n,i){let s=3*t-3*n+1,o=-6*t+3*n,r=3*t,a=3*e-3*i+1,l=-6*e+3*i,c=3*e,h=(d)=>((s*d+o)*d+r)*d,u=(d)=>((a*d+l)*d+c)*d,f=(d)=>(3*s*d+2*o)*d+r;return function(p){if(p<=0)return 0;if(p>=1)return 1;let m=p;for(let _=0;_<10;_++){let g=h(m)-p;if(Math.abs(g)<0.00001)return u(m);let b=f(m);if(Math.abs(b)<0.000001)break;m-=g/b}return u(m)}}var Po,wl=P(()=>{Pe(),Po=class extends wt{constructor(){super();this._easing=$s,this._startTime=0,this._lastTime=0,this._duration=0,this._running=!1,this._pendingStart=!1}run(e){if(this._running)this._finish(!1);this._opts=e,this._easing=e.easing??$s,this._duration=Math.max(0,e.duration),this._running=!0,this._pendingStart=!0,this._startTime=0,this._lastTime=0,this._animId=requestAnimationFrame((n)=>this._tick(n))}cancel(){if(!this._running)return;this._finish(!1)}stop(){this.cancel()}isRunning(){return this._running}_tick(e){if(!this._running)return;if(this._pendingStart){if(this._pendingStart=!1,this._startTime=e,this._lastTime=e,this._opts?.onStart?.(),this.fire("start"),this._duration<=0){this._emitFrame(1,1,0),this._finish(!0);return}}let n=e-this._startTime,i=(e-this._lastTime)/1000;if(this._lastTime=e,n>=this._duration){this._emitFrame(1,1,i),this._finish(!0);return}let s=n/this._duration,o=this._easing(s);if(this._emitFrame(s,o,i),this._running)this._animId=requestAnimationFrame((r)=>this._tick(r))}_emitFrame(e,n,i){let s={progress:e,t:n,dt:i};this._opts?.onFrame(s),this.fire("frame",s)}_finish(e){let n=this._opts;if(this._animId!==void 0)cancelAnimationFrame(this._animId),this._animId=void 0;this._running=!1,this._pendingStart=!1,this._opts=void 0,n?.onEnd?.(e),this.fire("end",{completed:e})}}}),ko,vl=P(()=>{Y(),Pe(),ko=class extends wt{run(e,n,i,s){this.stop(),this._el=e,this._inProgress=!0,this._duration=i??0.25,this._easeOutPower=1/Math.max(s??0.5,0.2),this._startPos=Re(e),this._offset=n.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()}stop(){if(!this._inProgress)return;this._step(!0),this._complete()}_animate(){this._animId=requestAnimationFrame(this._animate.bind(this)),this._step()}_step(e){let n=+new Date-this._startTime,i=this._duration*1000;if(n<i)this._runFrame(this._easeOut(n/i),e);else this._runFrame(1),this._complete()}_runFrame(e,n){let i=this._startPos.add(this._offset.multiplyBy(e));if(n)i._round();lt(this._el,i),this.fire("step")}_complete(){cancelAnimationFrame(this._animId),this._inProgress=!1,this.fire("end")}_easeOut(e){return 1-(1-e)**this._easeOutPower}}});function Ot(t){return t<0?0:t>1?1:t}function Nu(t){return t<0?0:t>255?255:t}function At(t){let e=t.charCodeAt(0);if(e>=48&&e<=57)return e-48;if(e>=97&&e<=102)return e-87;if(e>=65&&e<=70)return e-55;return Number.NaN}function $u(t){let e=t.length;if(e===3||e===4){let n=At(t[0]),i=At(t[1]),s=At(t[2]),o=e===4?At(t[3]):15;if(Number.isNaN(n)||Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(o))return null;return[n*17/255,i*17/255,s*17/255,o*17/255]}if(e===6||e===8){let n=At(t[0])<<4|At(t[1]),i=At(t[2])<<4|At(t[3]),s=At(t[4])<<4|At(t[5]),o=e===8?At(t[6])<<4|At(t[7]):255;if(Number.isNaN(n)||Number.isNaN(i)||Number.isNaN(s)||Number.isNaN(o))return null;return[n/255,i/255,s/255,o/255]}return null}function fs(t){let e=t.trim();if(e.endsWith("%")){let i=Number.parseFloat(e.slice(0,-1));if(Number.isNaN(i))return Number.NaN;return Ot(i/100)}let n=Number.parseFloat(e);if(Number.isNaN(n))return Number.NaN;return Nu(n)/255}function Nr(t){let e=t.trim();if(e.endsWith("%")){let i=Number.parseFloat(e.slice(0,-1));if(Number.isNaN(i))return Number.NaN;return Ot(i/100)}let n=Number.parseFloat(e);if(Number.isNaN(n))return Number.NaN;return Ot(n)}function Zu(t,e,n){let i=(t%360+360)%360,s=(1-Math.abs(2*n-1))*e,o=s*(1-Math.abs(i/60%2-1)),r=n-s/2,a=0,l=0,c=0;if(i<60)a=s,l=o,c=0;else if(i<120)a=o,l=s,c=0;else if(i<180)a=0,l=s,c=o;else if(i<240)a=0,l=o,c=s;else if(i<300)a=o,l=0,c=s;else a=s,l=0,c=o;return[Ot(a+r),Ot(l+r),Ot(c+r)]}function Bu(t){if(t.includes(","))return t.split(",").map((o)=>o.trim()).filter((o)=>o.length>0);let e=t.indexOf("/"),n=e>=0?t.slice(0,e):t,i=e>=0?t.slice(e+1):"",s=n.trim().split(/\s+/).filter((o)=>o.length>0);if(i.trim().length>0)s.push(i.trim());return s}function Gn(t){if(typeof t!=="string")return null;let e=t.trim().toLowerCase();if(e.length===0)return null;if(e.startsWith("#"))return $u(e.slice(1));let n=e.indexOf("(");if(n>0&&e.endsWith(")")){let s=e.slice(0,n),o=e.slice(n+1,-1),r=Bu(o);if(s==="rgb"||s==="rgba"){if(r.length<3||r.length>4)return null;let a=fs(r[0]),l=fs(r[1]),c=fs(r[2]),h=r.length===4?Nr(r[3]):1;if(Number.isNaN(a)||Number.isNaN(l)||Number.isNaN(c)||Number.isNaN(h))return null;return[a,l,c,h]}if(s==="hsl"||s==="hsla"){if(r.length<3||r.length>4)return null;let a=r[0].trim(),l=Number.parseFloat(a.endsWith("deg")?a.slice(0,-3):a),c=r[1].trim(),h=r[2].trim();if(!c.endsWith("%")||!h.endsWith("%"))return null;let u=Number.parseFloat(c.slice(0,-1))/100,f=Number.parseFloat(h.slice(0,-1))/100;if(Number.isNaN(l)||Number.isNaN(u)||Number.isNaN(f))return null;let[d,p,m]=Zu(l,Ot(u),Ot(f)),_=r.length===4?Nr(r[3]):1;if(Number.isNaN(_))return null;return[d,p,m,_]}return null}let i=xl[e];if(i!==void 0)return Gn(i);return null}function Zs(t,e,n){let i=n<0?0:n>1?1:n;return[t[0]+(e[0]-t[0])*i,t[1]+(e[1]-t[1])*i,t[2]+(e[2]-t[2])*i,t[3]+(e[3]-t[3])*i]}function Du(t){let e=Math.round(Ot(t[0])*255),n=Math.round(Ot(t[1])*255),i=Math.round(Ot(t[2])*255),s=Ot(t[3]),o=s===1?"1":String(Number(s.toFixed(4)));return`rgba(${e},${n},${i},${o})`}var xl,Ui=P(()=>{xl={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",steelblue:"#4682b4",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",transparent:"rgba(0,0,0,0)",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}}),x,zt=P(()=>{x=class extends Error{constructor(e,n,i=[]){let s=i.length>0?`[${i.map((o)=>JSON.stringify(o)).join("][")}] `:"";super(`${s}${e}`);this.name="ExpressionError",this.expression=n,this.path=i.slice()}}});function M(t,e){Hi[t]=e}function ju(t){return Hi[t]}function Uu(t){return Object.prototype.hasOwnProperty.call(Hi,t)}var Hi,Xt=P(()=>{Hi={}});function Hu(t){let e=!1,n=!1,i=!1;for(let s of t){if(s.dependsOnZoom)e=!0;if(s.dependsOnFeature)n=!0;if(s.dependsOnFeatureState)i=!0}return{dependsOnZoom:e,dependsOnFeature:n,dependsOnFeatureState:i}}function Wu(){M("let",(t,e,n)=>{if(t.length<3||t.length%2===0)throw new x(`"let" expects name/value pairs followed by a body, got ${t.length} arguments`,["let",...t],n);let i=[],s=[];for(let r=0;r<t.length-1;r+=2){let a=t[r];if(typeof a!=="string")throw new x(`"let": binding name must be a string, got ${typeof a}`,["let",...t],n);i.push(a),s.push(e(t[r+1],"value",n.concat(r+2)))}let o=e(t[t.length-1],"value",n.concat(t.length));return{evaluate:(r)=>{let a={...r.bindings};for(let l=0;l<i.length;l++)a[i[l]]=s[l].evaluate(r);return o.evaluate({...r,bindings:a})},returnType:o.returnType,...Hu([...s,o])}}),M("var",(t,e,n)=>{if(t.length!==1)throw new x(`"var" expects 1 argument, got ${t.length}`,["var",...t],n);let i=t[0];if(typeof i!=="string")throw new x(`"var": name must be a string, got ${typeof i}`,["var",...t],n);return{evaluate:(s)=>{if(!s.bindings||!(i in s.bindings))throw new x(`"var": unbound name ${JSON.stringify(i)}`,["var",i]);return s.bindings[i]},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}})}var Vu=P(()=>{zt(),Xt()});function wn(t){let e=!1,n=!1,i=!1;for(let s of t){if(s.dependsOnZoom)e=!0;if(s.dependsOnFeature)n=!0;if(s.dependsOnFeatureState)i=!0}return{dependsOnZoom:e,dependsOnFeature:n,dependsOnFeatureState:i}}function qu(){M("to-string",(t,e,n)=>{if(t.length!==1)throw new x(`"to-string" expects 1 argument, got ${t.length}`,["to-string",...t],n);let i=e(t[0],"value",n.concat(1));return{evaluate:(s)=>{let o=i.evaluate(s);if(o===null||o===void 0)return"";if(typeof o==="string")return o;if(typeof o==="number"||typeof o==="boolean")return String(o);try{return JSON.stringify(o)}catch{return String(o)}},returnType:"string",...wn([i])}}),M("to-number",(t,e,n)=>{if(t.length<1)throw new x('"to-number" expects at least 1 argument',["to-number",...t],n);let i=t.map((o,r)=>e(o,"value",n.concat(r+1))),s=["to-number",...t];return{evaluate:(o)=>{for(let r=0;r<i.length;r++){let a=i[r].evaluate(o);if(a===null||a===void 0)continue;if(typeof a==="number"){if(!Number.isNaN(a))return a;continue}if(typeof a==="boolean")return a?1:0;if(typeof a==="string"){let l=a.trim();if(l.length===0)continue;let c=Number(l);if(!Number.isNaN(c))return c}}throw new x('"to-number": could not convert any argument to a number',s)},returnType:"number",...wn(i)}}),M("to-boolean",(t,e,n)=>{if(t.length!==1)throw new x(`"to-boolean" expects 1 argument, got ${t.length}`,["to-boolean",...t],n);let i=e(t[0],"value",n.concat(1));return{evaluate:(s)=>{let o=i.evaluate(s);if(o===null||o===void 0)return!1;if(typeof o==="number")return o!==0&&!Number.isNaN(o);if(typeof o==="string")return o.length>0;if(typeof o==="boolean")return o;if(Array.isArray(o))return o.length>0;if(typeof o==="object")return!0;return Boolean(o)},returnType:"boolean",...wn([i])}}),M("to-rgba",(t,e,n)=>{if(t.length!==1)throw new x(`"to-rgba" expects 1 argument, got ${t.length}`,["to-rgba",...t],n);let i=e(t[0],"color",n.concat(1)),s=["to-rgba",...t];return{evaluate:(o)=>{let r=i.evaluate(o),a=$r(r);if(!a)throw new x(`"to-rgba": cannot convert ${String(r)} to a color`,s);return[Math.round(a[0]*255),Math.round(a[1]*255),Math.round(a[2]*255),a[3]]},returnType:"array",...wn([i])}}),M("to-color",(t,e,n)=>{if(t.length<1)throw new x('"to-color" expects at least 1 argument',["to-color",...t],n);let i=t.map((o,r)=>e(o,"value",n.concat(r+1))),s=["to-color",...t];return{evaluate:(o)=>{for(let r=0;r<i.length;r++){let a=i[r].evaluate(o),l=$r(a);if(l)return Gu(l)}throw new x('"to-color": could not convert any argument to a color',s)},returnType:"color",...wn(i)}})}function $r(t){if(typeof t==="string")return Gn(t);if(Array.isArray(t)&&(t.length===3||t.length===4)){let e=Number(t[0]),n=Number(t[1]),i=Number(t[2]),s=t.length===4?Number(t[3]):1;if([e,n,i,s].some(Number.isNaN))return null;return[me(e/255),me(n/255),me(i/255),me(s)]}return null}function me(t){return t<0?0:t>1?1:t}function Gu(t){let e=Math.round(me(t[0])*255),n=Math.round(me(t[1])*255),i=Math.round(me(t[2])*255),s=me(t[3]);return`rgba(${e},${n},${i},${s===1?"1":String(Number(s.toFixed(4)))})`}var Yu=P(()=>{Ui(),zt(),Xt()});function ai(t){return t*Math.PI/180}function Ku(t,e){let[n,i]=t,[s,o]=e,r=ai(o-i),a=ai(s-n),l=Math.sin(r/2),c=Math.sin(a/2),h=l*l+Math.cos(ai(i))*Math.cos(ai(o))*c*c;return 2*Qu*Math.asin(Math.min(1,Math.sqrt(h)))}function Zr(t,e){let[n,i]=t,s=!1;for(let o=0,r=e.length-1;o<e.length;r=o++){let[a,l]=e[o],[c,h]=e[r],u=(c-a)*(i-l)-(h-l)*(n-a);if(Math.abs(u)<0.000000000001&&Math.min(a,c)-0.000000000001<=n&&n<=Math.max(a,c)+0.000000000001&&Math.min(l,h)-0.000000000001<=i&&i<=Math.max(l,h)+0.000000000001)return!0;if(l>i!==h>i){let f=a+(i-l)/(h-l)*(c-a);if(n<f)s=!s}}return s}function Xu(t,e){if(!e.length||!Zr(t,e[0]))return!1;for(let n=1;n<e.length;n++)if(Zr(t,e[n]))return!1;return!0}function Bs(t){if(!t)return[];if(t.type==="Polygon")return[t.coordinates];if(t.type==="MultiPolygon")return t.coordinates;if(t.type==="Feature")return Bs(t.geometry);if(t.type==="FeatureCollection")return(t.features??[]).flatMap((e)=>Bs(e));return[]}function Mn(t){if(!t)return[];switch(t.type){case"Point":return[t.coordinates];case"MultiPoint":case"LineString":return t.coordinates;case"MultiLineString":case"Polygon":return t.coordinates.flat();case"MultiPolygon":return t.coordinates.flat(2);case"Feature":return Mn(t.geometry);case"FeatureCollection":return(t.features??[]).flatMap((e)=>Mn(e));default:return[]}}function Br(t){let e=t.feature?.geometry;return typeof e==="function"?e():void 0}function Dr(){return{dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}function Ju(){M("within",(t,e,n)=>{if(t.length!==1)throw new x(`"within" expects 1 argument, got ${t.length}`,["within",...t],n);let i=Bs(t[0]);if(!i.length)throw new x('"within": argument must be a GeoJSON Polygon or MultiPolygon',["within",...t],n);return{evaluate:(s)=>{let o=Br(s),r=Mn(o);if(!r.length)return!1;return r.every((a)=>i.some((l)=>Xu(a,l)))},returnType:"boolean",...Dr()}}),M("distance",(t,e,n)=>{if(t.length!==1)throw new x(`"distance" expects 1 argument, got ${t.length}`,["distance",...t],n);let i=Mn(t[0]);if(!i.length)throw new x('"distance": argument must be a GeoJSON geometry',["distance",...t],n);return{evaluate:(s)=>{let o=Mn(Br(s));if(!o.length)return 1/0;let r=1/0;for(let a of o)for(let l of i){let c=Ku(a,l);if(c<r)r=c}return r},returnType:"number",...Dr()}})}var Qu=6371008.8,tf=P(()=>{zt(),Xt()});function jr(t){let e=!1,n=!1,i=!1;for(let s of t){if(s.dependsOnZoom)e=!0;if(s.dependsOnFeature)n=!0;if(s.dependsOnFeatureState)i=!0}return{dependsOnZoom:e,dependsOnFeature:n,dependsOnFeatureState:i}}function Ur(t,e){if(t.length===0||e<t[0])return-1;let n=0,i=t.length-1;while(n<i){let s=n+i+1>>1;if(t[s]<=e)n=s;else i=s-1}return n}function Ds(t,e,n){if(t===e)return 0;let i=(n-t)/(e-t);return i<0?0:i>1?1:i}function ef(t,e,n,i){if(e===n)return 0;if(t===1)return Ds(e,n,i);let s=n-e,o=i-e,r=(t**o-1)/(t**s-1);return r<0?0:r>1?1:r}function nf(t,e,n,i){let s=3*t,o=3*(n-t)-s,r=1-s-o,a=3*e,l=3*(i-e)-a,c=1-a-l,h=(d)=>((r*d+o)*d+s)*d,u=(d)=>((c*d+l)*d+a)*d,f=(d)=>(3*r*d+2*o)*d+s;return(d)=>{if(d<=0)return 0;if(d>=1)return 1;let p=d;for(let b=0;b<8;b++){let y=h(p)-d;if(Math.abs(y)<0.000001)return u(p);let w=f(p);if(Math.abs(w)<0.000001)break;p-=y/w}let m=0,_=1,g=d;for(let b=0;b<20;b++){let y=h(g)-d;if(Math.abs(y)<0.000001)return u(g);if(y>0)_=g;else m=g;g=(m+_)/2}return u(g)}}function sf(t,e){if(!Array.isArray(t)||t.length===0)throw new x('"interpolate": interpolation type required',t,e);let n=t[0];if(n==="linear")return{kind:"linear"};if(n==="exponential"){let i=Number(t[1]);if(!Number.isFinite(i)||i<=0)throw new x('"interpolate": exponential base must be a positive number',t,e);return{kind:"exponential",base:i}}if(n==="cubic-bezier"){let i=Number(t[1]),s=Number(t[2]),o=Number(t[3]),r=Number(t[4]);if([i,s,o,r].some((a)=>!Number.isFinite(a)))throw new x('"interpolate": cubic-bezier requires 4 numeric control points',t,e);return{kind:"cubic-bezier",bezier:nf(i,s,o,r)}}throw new x(`"interpolate": unknown interpolation type ${JSON.stringify(n)}`,t,e)}function of(t){if(t==="number")return(e,n,i)=>{let s=Number(e),o=Number(n);return s+(o-s)*i};if(t==="color")return(e,n,i)=>{let s=li(e),o=li(n);if(!s||!o)return e;return Hr(Zs(s,o,i))};if(t==="string")return(e,n,i)=>{if(typeof e!=="string"||typeof n!=="string")return i<1?e:n;let s=li(e),o=li(n);if(!s||!o)return i<1?e:n;return Hr(Zs(s,o,i))};if(t==="array")return(e,n,i)=>{if(!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length)return e;let s=Array(e.length);for(let o=0;o<e.length;o++){let r=Number(e[o]),a=Number(n[o]);s[o]=r+(a-r)*i}return s};return(e,n,i)=>i<1?e:n}function li(t){if(typeof t==="string")return Gn(t);if(Array.isArray(t)&&(t.length===3||t.length===4)){let e=Number(t[0])/255,n=Number(t[1])/255,i=Number(t[2])/255,s=t.length===4?Number(t[3]):1;if([e,n,i,s].some(Number.isNaN))return null;return[_e(e),_e(n),_e(i),_e(s)]}return null}function _e(t){return t<0?0:t>1?1:t}function Hr(t){let e=Math.round(_e(t[0])*255),n=Math.round(_e(t[1])*255),i=Math.round(_e(t[2])*255),s=_e(t[3]);return`rgba(${e},${n},${i},${s===1?"1":String(Number(s.toFixed(4)))})`}function rf(){M("interpolate",(t,e,n,i)=>{if(t.length<4||t.length%2!==0)throw new x(`"interpolate" expects interpolation, input, (stop, value)+ — got ${t.length} arguments`,["interpolate",...t],n);let s=sf(t[0],n.concat(1)),o=e(t[1],"number",n.concat(2)),r=i==="value"?"value":i,a=[],l=[];for(let f=2;f<t.length;f+=2){let d=t[f];if(typeof d!=="number")throw new x(`"interpolate": stop input at position ${f} must be a number literal`,["interpolate",...t],n.concat(f+1));a.push(d),l.push(e(t[f+1],r,n.concat(f+2)))}for(let f=1;f<a.length;f++)if(a[f]<=a[f-1])throw new x('"interpolate": stop inputs must be strictly increasing',["interpolate",...t],n);let c=i!=="value"?i:l[0].returnType,h=of(c),u=[o,...l];return{evaluate:(f)=>{let d=Number(o.evaluate(f));if(!Number.isFinite(d))return l[0].evaluate(f);let p=Ur(a,d);if(p<0)return l[0].evaluate(f);if(p>=a.length-1)return l[l.length-1].evaluate(f);let m=a[p],_=a[p+1],g;if(s.kind==="linear")g=Ds(m,_,d);else if(s.kind==="exponential")g=ef(s.base,m,_,d);else{let b=Ds(m,_,d);g=s.bezier(b)}return h(l[p].evaluate(f),l[p+1].evaluate(f),g)},returnType:c,...jr(u)}}),M("step",(t,e,n,i)=>{if(t.length<4||t.length%2!==0)throw new x(`"step" expects input, fallback, (stop, value)+ — got ${t.length} arguments`,["step",...t],n);let s=e(t[0],"number",n.concat(1)),o=e(t[1],i,n.concat(2)),r=[],a=[];for(let h=2;h<t.length;h+=2){let u=t[h];if(typeof u!=="number")throw new x(`"step": stop input at position ${h} must be a number literal`,["step",...t],n.concat(h+1));r.push(u),a.push(e(t[h+1],i,n.concat(h+2)))}for(let h=1;h<r.length;h++)if(r[h]<=r[h-1])throw new x('"step": stop inputs must be strictly increasing',["step",...t],n);let l=i!=="value"?i:a.length>0?a[0].returnType:o.returnType,c=[s,o,...a];return{evaluate:(h)=>{let u=Number(s.evaluate(h));if(!Number.isFinite(u))return o.evaluate(h);let f=Ur(r,u);if(f<0)return o.evaluate(h);return a[f].evaluate(h)},returnType:l,...jr(c)}})}var af=P(()=>{Ui(),zt(),Xt()});function Pt(t){let e=!1,n=!1,i=!1;for(let s of t){if(s.dependsOnZoom)e=!0;if(s.dependsOnFeature)n=!0;if(s.dependsOnFeatureState)i=!0}return{dependsOnZoom:e,dependsOnFeature:n,dependsOnFeatureState:i}}function qe(t,e){if(t===e)return!0;return!1}function lf(t,e){if(typeof t==="number"&&typeof e==="number"){if(Number.isNaN(t)||Number.isNaN(e))return Number.NaN;return t<e?-1:t>e?1:0}if(typeof t==="string"&&typeof e==="string")return t<e?-1:t>e?1:0;return Number.NaN}function cf(){M("!",(e,n,i)=>{if(e.length!==1)throw new x(`"!" expects 1 argument, got ${e.length}`,["!",...e],i);let s=n(e[0],"boolean",i.concat(1));return{evaluate:(o)=>!s.evaluate(o),returnType:"boolean",...Pt([s])}}),M("==",(e,n,i)=>{if(e.length!==2)throw new x(`"==" expects 2 arguments, got ${e.length}`,["==",...e],i);let s=n(e[0],"value",i.concat(1)),o=n(e[1],"value",i.concat(2));return{evaluate:(r)=>qe(s.evaluate(r),o.evaluate(r)),returnType:"boolean",...Pt([s,o])}}),M("!=",(e,n,i)=>{if(e.length!==2)throw new x(`"!=" expects 2 arguments, got ${e.length}`,["!=",...e],i);let s=n(e[0],"value",i.concat(1)),o=n(e[1],"value",i.concat(2));return{evaluate:(r)=>!qe(s.evaluate(r),o.evaluate(r)),returnType:"boolean",...Pt([s,o])}});let t=(e)=>{M(e,(n,i,s)=>{if(n.length!==2)throw new x(`"${e}" expects 2 arguments, got ${n.length}`,[e,...n],s);let o=i(n[0],"value",s.concat(1)),r=i(n[1],"value",s.concat(2));return{evaluate:(a)=>{let l=lf(o.evaluate(a),r.evaluate(a));if(Number.isNaN(l))return!1;switch(e){case"<":return l<0;case"<=":return l<=0;case">":return l>0;case">=":return l>=0}},returnType:"boolean",...Pt([o,r])}})};t("<"),t("<="),t(">"),t(">="),M("all",(e,n,i)=>{let s=e.map((o,r)=>n(o,"boolean",i.concat(r+1)));return{evaluate:(o)=>{for(let r=0;r<s.length;r++)if(!s[r].evaluate(o))return!1;return!0},returnType:"boolean",...Pt(s)}}),M("any",(e,n,i)=>{let s=e.map((o,r)=>n(o,"boolean",i.concat(r+1)));return{evaluate:(o)=>{for(let r=0;r<s.length;r++)if(s[r].evaluate(o))return!0;return!1},returnType:"boolean",...Pt(s)}}),M("none",(e,n,i)=>{let s=e.map((o,r)=>n(o,"boolean",i.concat(r+1)));return{evaluate:(o)=>{for(let r=0;r<s.length;r++)if(s[r].evaluate(o))return!1;return!0},returnType:"boolean",...Pt(s)}}),M("case",(e,n,i,s)=>{if(e.length<3||e.length%2!==1)throw new x(`"case" expects an odd number of arguments >= 3 (cond, val, ..., fallback), got ${e.length}`,["case",...e],i);let o=[];for(let l=0;l<e.length-1;l+=2)o.push({cond:n(e[l],"boolean",i.concat(l+1)),val:n(e[l+1],s,i.concat(l+2))});let r=n(e[e.length-1],s,i.concat(e.length)),a=[r];for(let l of o)a.push(l.cond),a.push(l.val);return{evaluate:(l)=>{for(let c=0;c<o.length;c++){let h=o[c];if(h.cond.evaluate(l))return h.val.evaluate(l)}return r.evaluate(l)},returnType:s,...Pt(a)}}),M("match",(e,n,i,s)=>{if(e.length<4||e.length%2!==0)throw new x(`"match" expects input, (label, value)+, fallback — got ${e.length} arguments`,["match",...e],i);let o=n(e[0],"value",i.concat(1)),r=[];for(let c=1;c<e.length-1;c+=2){let h=e[c],u=Array.isArray(h)?h:[h];for(let f of u)if(typeof f!=="string"&&typeof f!=="number"&&typeof f!=="boolean")throw new x('"match" labels must be strings, numbers, or booleans',["match",...e],i.concat(c+1));r.push({labels:u,val:n(e[c+1],s,i.concat(c+2))})}let a=n(e[e.length-1],s,i.concat(e.length)),l=[o,a];for(let c of r)l.push(c.val);return{evaluate:(c)=>{let h=o.evaluate(c);for(let u=0;u<r.length;u++){let f=r[u];for(let d=0;d<f.labels.length;d++)if(qe(h,f.labels[d]))return f.val.evaluate(c)}return a.evaluate(c)},returnType:s,...Pt(l)}}),M("coalesce",(e,n,i,s)=>{if(e.length===0)throw new x('"coalesce" expects at least 1 argument',["coalesce"],i);let o=e.map((r,a)=>n(r,s,i.concat(a+1)));return{evaluate:(r)=>{for(let a=0;a<o.length;a++){let l=o[a].evaluate(r);if(l!==null&&l!==void 0)return l}return null},returnType:s,...Pt(o)}}),M("in",(e,n,i)=>{if(e.length<1)throw new x('"in" expects at least 1 argument',["in",...e],i);if(e.length===2&&Array.isArray(e[1])){let r=n(e[0],"value",i.concat(1)),a=n(e[1],"value",i.concat(2));return{evaluate:(l)=>{let c=r.evaluate(l),h=a.evaluate(l);if(Array.isArray(h))return h.some((u)=>qe(c,u));if(typeof h==="string")return typeof c==="string"&&h.includes(c);return!1},returnType:"boolean",...Pt([r,a])}}let s=n(e[0],"value",i.concat(1)),o=e.slice(1);return{evaluate:(r)=>{let a=s.evaluate(r);for(let l=0;l<o.length;l++)if(qe(a,o[l]))return!0;return!1},returnType:"boolean",...Pt([s])}}),M("!in",(e,n,i)=>{if(e.length<1)throw new x('"!in" expects at least 1 argument',["!in",...e],i);let s=n(e[0],"value",i.concat(1)),o=e.slice(1);return{evaluate:(r)=>{let a=s.evaluate(r);for(let l=0;l<o.length;l++)if(qe(a,o[l]))return!1;return!0},returnType:"boolean",...Pt([s])}}),M("!has",(e,n,i)=>{if(e.length<1||e.length>2)throw new x(`"!has" expects 1 or 2 arguments, got ${e.length}`,["!has",...e],i);if(typeof e[0]!=="string")throw new x('"!has" key must be a string literal',["!has",...e],i);let s=e[0];return{evaluate:(o)=>{let r=o.feature?o.feature.properties:void 0;return r?!Object.prototype.hasOwnProperty.call(r,s):!0},returnType:"boolean",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}})}var hf=P(()=>{zt(),Xt()});function uf(){M("literal",(t,e,n)=>{if(t.length!==1)throw new x(`"literal" expects 1 argument, got ${t.length}`,["literal",...t],n);let i=t[0];return{evaluate:()=>i,returnType:ff(i),dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),M("get",(t,e,n)=>{if(t.length<1||t.length>2)throw new x(`"get" expects 1 or 2 arguments, got ${t.length}`,["get",...t],n);if(typeof t[0]!=="string")throw new x('"get" key must be a string literal',["get",...t],n);let i=t[0];if(t.length===2){let s=e(t[1],"value",n.concat(2));return{evaluate:(o)=>{let r=s.evaluate(o);if(r&&typeof r==="object")return r[i];return},returnType:"value",dependsOnZoom:s.dependsOnZoom,dependsOnFeature:s.dependsOnFeature,dependsOnFeatureState:s.dependsOnFeatureState}}return{evaluate:(s)=>{let o=s.feature?s.feature.properties:void 0;return o?o[i]:void 0},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),M("has",(t,e,n)=>{if(t.length<1||t.length>2)throw new x(`"has" expects 1 or 2 arguments, got ${t.length}`,["has",...t],n);if(typeof t[0]!=="string")throw new x('"has" key must be a string literal',["has",...t],n);let i=t[0];if(t.length===2){let s=e(t[1],"value",n.concat(2));return{evaluate:(o)=>{let r=s.evaluate(o);if(r&&typeof r==="object")return Object.prototype.hasOwnProperty.call(r,i);return!1},returnType:"boolean",dependsOnZoom:s.dependsOnZoom,dependsOnFeature:s.dependsOnFeature,dependsOnFeatureState:s.dependsOnFeatureState}}return{evaluate:(s)=>{let o=s.feature?s.feature.properties:void 0;return o?Object.prototype.hasOwnProperty.call(o,i):!1},returnType:"boolean",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),M("at",(t,e,n)=>{if(t.length!==2)throw new x(`"at" expects 2 arguments, got ${t.length}`,["at",...t],n);let i=e(t[0],"number",n.concat(1)),s=e(t[1],"array",n.concat(2));return{evaluate:(o)=>{let r=s.evaluate(o),a=i.evaluate(o);if(!Array.isArray(r)||typeof a!=="number")return;if(a<0||a>=r.length||!Number.isFinite(a))return;return r[Math.floor(a)]},returnType:"value",dependsOnZoom:i.dependsOnZoom||s.dependsOnZoom,dependsOnFeature:i.dependsOnFeature||s.dependsOnFeature,dependsOnFeatureState:i.dependsOnFeatureState||s.dependsOnFeatureState}}),M("length",(t,e,n)=>{if(t.length!==1)throw new x(`"length" expects 1 argument, got ${t.length}`,["length",...t],n);let i=e(t[0],"value",n.concat(1));return{evaluate:(s)=>{let o=i.evaluate(s);if(typeof o==="string"||Array.isArray(o))return o.length;return 0},returnType:"number",dependsOnZoom:i.dependsOnZoom,dependsOnFeature:i.dependsOnFeature,dependsOnFeatureState:i.dependsOnFeatureState}}),M("properties",(t,e,n)=>{if(t.length!==0)throw new x(`"properties" takes no arguments, got ${t.length}`,["properties",...t],n);return{evaluate:(i)=>i.feature?i.feature.properties:{},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),M("geometry-type",(t,e,n)=>{if(t.length!==0)throw new x(`"geometry-type" takes no arguments, got ${t.length}`,["geometry-type",...t],n);return{evaluate:(i)=>{if(!i.feature)return"Unknown";switch(i.feature.type){case 1:return"Point";case 2:return"LineString";case 3:return"Polygon";default:return"Unknown"}},returnType:"string",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),M("id",(t,e,n)=>{if(t.length!==0)throw new x(`"id" takes no arguments, got ${t.length}`,["id",...t],n);return{evaluate:(i)=>i.feature?i.feature.id:void 0,returnType:"value",dependsOnZoom:!1,dependsOnFeature:!0,dependsOnFeatureState:!1}}),M("zoom",(t,e,n)=>{if(t.length!==0)throw new x(`"zoom" takes no arguments, got ${t.length}`,["zoom",...t],n);return{evaluate:(i)=>i.zoom,returnType:"number",dependsOnZoom:!0,dependsOnFeature:!1,dependsOnFeatureState:!1}}),M("line-progress",(t,e,n)=>{if(t.length!==0)throw new x(`"line-progress" takes no arguments, got ${t.length}`,["line-progress",...t],n);return{evaluate:(i)=>i.lineProgress??0,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),M("heatmap-density",(t,e,n)=>{if(t.length!==0)throw new x(`"heatmap-density" takes no arguments, got ${t.length}`,["heatmap-density",...t],n);return{evaluate:(i)=>i.heatmapDensity??0,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),M("feature-state",(t,e,n)=>{if(t.length!==1)throw new x(`"feature-state" expects 1 argument, got ${t.length}`,["feature-state",...t],n);if(typeof t[0]!=="string")throw new x('"feature-state" key must be a string literal',["feature-state",...t],n);let i=t[0];return{evaluate:(s)=>{let o=s.featureState;return o?o[i]:void 0},returnType:"value",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!0}})}function ff(t){if(t===null)return"null";if(typeof t==="string")return"string";if(typeof t==="number")return"number";if(typeof t==="boolean")return"boolean";if(Array.isArray(t))return"array";return"value"}var df=P(()=>{zt(),Xt()});function at(t,e,n){if(typeof t!=="number"||Number.isNaN(t))throw new x(`"${e}": expected number, got ${String(t)}`,n);return t}function Nt(t){let e=!1,n=!1,i=!1;for(let s of t){if(s.dependsOnZoom)e=!0;if(s.dependsOnFeature)n=!0;if(s.dependsOnFeatureState)i=!0}return{dependsOnZoom:e,dependsOnFeature:n,dependsOnFeatureState:i}}function pf(){M("+",(e,n,i)=>{let s=e.map((r,a)=>n(r,"number",i.concat(a+1))),o=["+",...e];return{evaluate:(r)=>{let a=0;for(let l=0;l<s.length;l++)a+=at(s[l].evaluate(r),"+",o);return a},returnType:"number",...Nt(s)}}),M("*",(e,n,i)=>{let s=e.map((r,a)=>n(r,"number",i.concat(a+1))),o=["*",...e];return{evaluate:(r)=>{let a=1;for(let l=0;l<s.length;l++)a*=at(s[l].evaluate(r),"*",o);return a},returnType:"number",...Nt(s)}}),M("-",(e,n,i)=>{if(e.length!==1&&e.length!==2)throw new x(`"-" expects 1 or 2 arguments, got ${e.length}`,["-",...e],i);let s=e.map((l,c)=>n(l,"number",i.concat(c+1))),o=["-",...e];if(s.length===1){let l=s[0];return{evaluate:(c)=>-at(l.evaluate(c),"-",o),returnType:"number",...Nt(s)}}let r=s[0],a=s[1];return{evaluate:(l)=>at(r.evaluate(l),"-",o)-at(a.evaluate(l),"-",o),returnType:"number",...Nt(s)}}),M("/",(e,n,i)=>{if(e.length!==2)throw new x(`"/" expects 2 arguments, got ${e.length}`,["/",...e],i);let s=n(e[0],"number",i.concat(1)),o=n(e[1],"number",i.concat(2)),r=["/",...e];return{evaluate:(a)=>{let l=at(s.evaluate(a),"/",r),c=at(o.evaluate(a),"/",r);if(c===0)throw new x('"/": divide by zero',r);return l/c},returnType:"number",...Nt([s,o])}}),M("%",(e,n,i)=>{if(e.length!==2)throw new x(`"%" expects 2 arguments, got ${e.length}`,["%",...e],i);let s=n(e[0],"number",i.concat(1)),o=n(e[1],"number",i.concat(2)),r=["%",...e];return{evaluate:(a)=>{let l=at(s.evaluate(a),"%",r),c=at(o.evaluate(a),"%",r);if(c===0)throw new x('"%": divide by zero',r);return l%c},returnType:"number",...Nt([s,o])}}),M("^",(e,n,i)=>{if(e.length!==2)throw new x(`"^" expects 2 arguments, got ${e.length}`,["^",...e],i);let s=n(e[0],"number",i.concat(1)),o=n(e[1],"number",i.concat(2)),r=["^",...e];return{evaluate:(a)=>at(s.evaluate(a),"^",r)**at(o.evaluate(a),"^",r),returnType:"number",...Nt([s,o])}}),M("min",(e,n,i)=>{if(e.length<1)throw new x('"min" expects at least 1 argument',["min"],i);let s=e.map((r,a)=>n(r,"number",i.concat(a+1))),o=["min",...e];return{evaluate:(r)=>{let a=1/0;for(let l=0;l<s.length;l++){let c=at(s[l].evaluate(r),"min",o);if(c<a)a=c}return a},returnType:"number",...Nt(s)}}),M("max",(e,n,i)=>{if(e.length<1)throw new x('"max" expects at least 1 argument',["max"],i);let s=e.map((r,a)=>n(r,"number",i.concat(a+1))),o=["max",...e];return{evaluate:(r)=>{let a=-1/0;for(let l=0;l<s.length;l++){let c=at(s[l].evaluate(r),"max",o);if(c>a)a=c}return a},returnType:"number",...Nt(s)}});let t=(e,n,i)=>{M(e,(s,o,r)=>{if(s.length!==1)throw new x(`"${e}" expects 1 argument, got ${s.length}`,[e,...s],r);let a=o(s[0],"number",r.concat(1)),l=[e,...s];return{evaluate:(c)=>{let h=at(a.evaluate(c),e,l);if(i)i(h,l);return n(h)},returnType:"number",...Nt([a])}})};t("abs",Math.abs),t("floor",Math.floor),t("ceil",Math.ceil),t("round",Math.round),t("sqrt",Math.sqrt,(e,n)=>{if(e<0)throw new x('"sqrt": input must be non-negative',n)}),t("ln",Math.log,(e,n)=>{if(e<=0)throw new x('"ln": input must be positive',n)}),t("log10",Math.log10,(e,n)=>{if(e<=0)throw new x('"log10": input must be positive',n)}),t("log2",Math.log2,(e,n)=>{if(e<=0)throw new x('"log2": input must be positive',n)}),t("sin",Math.sin),t("cos",Math.cos),t("tan",Math.tan),t("asin",Math.asin,(e,n)=>{if(e<-1||e>1)throw new x('"asin": input must be in [-1, 1]',n)}),t("acos",Math.acos,(e,n)=>{if(e<-1||e>1)throw new x('"acos": input must be in [-1, 1]',n)}),t("atan",Math.atan),M("e",(e,n,i)=>{if(e.length!==0)throw new x(`"e" takes no arguments, got ${e.length}`,["e",...e],i);return{evaluate:()=>Math.E,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),M("pi",(e,n,i)=>{if(e.length!==0)throw new x(`"pi" takes no arguments, got ${e.length}`,["pi",...e],i);return{evaluate:()=>Math.PI,returnType:"number",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}),M("rand",(e,n,i)=>{if(e.length<2||e.length>3)throw new x(`"rand" expects 2 or 3 arguments, got ${e.length}`,["rand",...e],i);let s=n(e[0],"number",i.concat(1)),o=n(e[1],"number",i.concat(2)),r=e.length===3?n(e[2],"number",i.concat(3)):null,a=["rand",...e],l=1,c=()=>(l=l*1664525+1013904223>>>0,l/4294967296);return{evaluate:(u)=>{let f=at(s.evaluate(u),"rand",a),d=at(o.evaluate(u),"rand",a);if(r){let p=at(r.evaluate(u),"rand",a);return l=Math.floor(p)>>>0||1,c(),f+(d-f)*c()}return f+(d-f)*Math.random()},returnType:"number",...Nt(r?[s,o,r]:[s,o])}})}var mf=P(()=>{zt(),Xt()});class Mo{sections;constructor(t){this.sections=t}toString(){let t="";for(let e of this.sections)t+=e.text;return t}get uniform(){return Sl(this.sections)}}function Sl(t){return t.every((e)=>e.scale===void 0&&e.fontStack===void 0&&e.color===void 0)}function Wr(t){return t instanceof Mo||!!t&&typeof t==="object"&&Array.isArray(t.sections)}function Oe(t){let e=!1,n=!1,i=!1;for(let s of t){if(s.dependsOnZoom)e=!0;if(s.dependsOnFeature)n=!0;if(s.dependsOnFeatureState)i=!0}return{dependsOnZoom:e,dependsOnFeature:n,dependsOnFeatureState:i}}function fe(t){if(t===null||t===void 0)return"";if(typeof t==="string")return t;if(typeof t==="number"||typeof t==="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function _f(){M("concat",(t,e,n)=>{let i=t.map((s,o)=>e(s,"value",n.concat(o+1)));return{evaluate:(s)=>{let o="";for(let r=0;r<i.length;r++)o+=fe(i[r].evaluate(s));return o},returnType:"string",...Oe(i)}}),M("downcase",(t,e,n)=>{if(t.length!==1)throw new x(`"downcase" expects 1 argument, got ${t.length}`,["downcase",...t],n);let i=e(t[0],"string",n.concat(1));return{evaluate:(s)=>fe(i.evaluate(s)).toLowerCase(),returnType:"string",...Oe([i])}}),M("upcase",(t,e,n)=>{if(t.length!==1)throw new x(`"upcase" expects 1 argument, got ${t.length}`,["upcase",...t],n);let i=e(t[0],"string",n.concat(1));return{evaluate:(s)=>fe(i.evaluate(s)).toUpperCase(),returnType:"string",...Oe([i])}}),M("index-of",(t,e,n)=>{if(t.length!==2&&t.length!==3)throw new x(`"index-of" expects 2 or 3 arguments, got ${t.length}`,["index-of",...t],n);let i=e(t[0],"value",n.concat(1)),s=e(t[1],"value",n.concat(2)),o=t.length===3?e(t[2],"number",n.concat(3)):void 0;return{evaluate:(a)=>{let l=i.evaluate(a),c=s.evaluate(a),h=o?Number(o.evaluate(a)):0;if(Array.isArray(c))return c.indexOf(l,h);return fe(c).indexOf(fe(l),h)},returnType:"number",...Oe(o?[i,s,o]:[i,s])}}),M("slice",(t,e,n)=>{if(t.length!==2&&t.length!==3)throw new x(`"slice" expects 2 or 3 arguments, got ${t.length}`,["slice",...t],n);let i=e(t[0],"value",n.concat(1)),s=e(t[1],"number",n.concat(2)),o=t.length===3?e(t[2],"number",n.concat(3)):void 0;return{evaluate:(a)=>{let l=i.evaluate(a),c=Number(s.evaluate(a)),h=o?Number(o.evaluate(a)):void 0;if(Array.isArray(l))return h===void 0?l.slice(c):l.slice(c,h);let u=fe(l);return h===void 0?u.slice(c):u.slice(c,h)},returnType:"value",...Oe(o?[i,s,o]:[i,s])}}),M("number-format",(t,e,n)=>{if(t.length!==2)throw new x(`"number-format" expects 2 arguments, got ${t.length}`,["number-format",...t],n);let i=e(t[0],"number",n.concat(1)),s=t[1];if(s===null||typeof s!=="object"||Array.isArray(s))throw new x('"number-format": second argument must be an options object',["number-format",...t],n);let o=s,r=typeof o.locale==="string"?o.locale:void 0,a={};if(typeof o.currency==="string")a.style="currency",a.currency=o.currency;if(typeof o["min-fraction-digits"]==="number")a.minimumFractionDigits=o["min-fraction-digits"];if(typeof o["max-fraction-digits"]==="number")a.maximumFractionDigits=o["max-fraction-digits"];let l=new Intl.NumberFormat(r,a);return{evaluate:(c)=>l.format(Number(i.evaluate(c))),returnType:"string",...Oe([i])}}),M("format",(t,e,n)=>{if(t.length===0)throw new x('"format" expects at least 1 argument',["format"],n);let i=[];for(let o=0;o<t.length;o++){let r=t[o];if(r!==null&&typeof r==="object"&&!Array.isArray(r))continue;let l={value:e(r,"value",n.concat(o+1))},c=t[o+1];if(c!==null&&typeof c==="object"&&!Array.isArray(c)){let h=c,u=h["font-scale"];if(typeof u==="number")l.scale=u;else if(Array.isArray(u))l.scale=e(u,"number",n.concat(o+2,"font-scale"));let f=h["text-font"];if(Array.isArray(f)&&f[0]==="literal"&&Array.isArray(f[1]))l.fontStack=f[1].map(String);else if(Array.isArray(f)&&f.every((p)=>typeof p==="string"))l.fontStack=f;let d=h["text-color"];if(typeof d==="string")l.color=d;else if(Array.isArray(d))l.color=e(d,"value",n.concat(o+2,"text-color"))}i.push(l)}let s=i.flatMap((o)=>[o.value,typeof o.scale==="object"?o.scale:void 0,typeof o.color==="object"?o.color:void 0].filter(Boolean));return{evaluate:(o)=>new Mo(i.map((r)=>({text:fe(r.value.evaluate(o)),scale:typeof r.scale==="object"?Number(r.scale.evaluate(o)):r.scale,fontStack:r.fontStack,color:typeof r.color==="object"?fe(r.color.evaluate(o)):r.color}))),returnType:"formatted",...Oe(s)}}),M("resolved-locale",(t,e,n)=>{if(t.length!==0&&t.length!==1)throw new x(`"resolved-locale" expects 0 or 1 arguments, got ${t.length}`,["resolved-locale",...t],n);return{evaluate:()=>"en",returnType:"string",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}})}var gf=P(()=>{zt(),Xt()});function Tl(){if(qr)return;qr=!0,uf(),cf(),pf(),qu(),_f(),rf(),Wu(),Ju()}function Vr(t,e,n){if(e==="color"){if(typeof t!=="string")throw new x(`expected color string, got ${typeof t}`,t,n);if(!Gn(t))throw new x(`invalid color string ${JSON.stringify(t)}`,t,n);return{evaluate:()=>t,returnType:"color",dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}if(e==="number"){if(typeof t!=="number"||Number.isNaN(t))throw new x(`expected number, got ${String(t)}`,t,n)}else if(e==="boolean"){if(typeof t!=="boolean")throw new x(`expected boolean, got ${typeof t}`,t,n)}else if(e==="string"||e==="formatted"||e==="resolvedImage"){if(typeof t!=="string")throw new x(`expected string, got ${typeof t}`,t,n)}let i=t===null?"null":typeof t==="string"?"string":typeof t==="number"?"number":typeof t==="boolean"?"boolean":Array.isArray(t)?"array":"value";return{evaluate:()=>t,returnType:i,dependsOnZoom:!1,dependsOnFeature:!1,dependsOnFeatureState:!1}}function ke(t,e="value",n=[]){if(Tl(),Array.isArray(t)){let i=t[0];if(typeof i==="string"){let s=ju(i);if(s){let o=t.slice(1);return s(o,ke,n,e)}}return Vr(t,"array",n)}return Vr(t,e,n)}var qr=!1,js=P(()=>{Ui(),zt(),Vu(),Yu(),tf(),af(),hf(),df(),mf(),gf(),Xt()});function Yn(t){if(Tl(),!Array.isArray(t)||t.length===0)return!1;let e=t[0];return typeof e==="string"&&Uu(e)}function Pl(t,e){let n=[];try{ke(t,e,[])}catch(i){if(i instanceof x)n.push(i.message);else if(i instanceof Error)n.push(i.message);else n.push(String(i))}return n}var Gr=P(()=>{js(),zt(),Xt()});function Lo(t){if(t.length===0)return!1;let e=t[0];if(typeof e!=="string")return!1;if(e==="has"||e==="!has"||e==="in"||e==="!in")return typeof t[1]==="string";if(Ao.has(e))return typeof t[1]==="string";if(Oo.has(e)){for(let n=1;n<t.length;n++){let i=t[n];if(Array.isArray(i)&&Lo(i))return!0}return!1}return!1}function Yr(t){if(t==="$type")return["geometry-type"];if(t==="$id")return["id"];return["get",t]}function kl(t){let e=t[0];if(typeof e!=="string")return t;if(e==="has"){if(typeof t[1]!=="string")return t;return["has",t[1]]}if(e==="!has"){if(typeof t[1]!=="string")return t;return["!has",t[1]]}if(e==="in"||e==="!in"){if(typeof t[1]!=="string")return t;return[e,Yr(t[1]),...t.slice(2)]}if(Ao.has(e)){if(typeof t[1]!=="string")return t;return[e,Yr(t[1]),t[2]]}if(Oo.has(e)){let n=[e];for(let i=1;i<t.length;i++){let s=t[i];if(Array.isArray(s)&&Lo(s))n.push(kl(s));else n.push(s)}return n}return t}function yf(t){if(!Array.isArray(t))return t;if(!Lo(t))return t;return kl(t)}var Ao,Oo,bf=P(()=>{Ao=new Set(["==","!=","<","<=",">",">="]),Oo=new Set(["all","any","none"])}),Ml={};tt(Ml,{ExpressionError:()=>x,compile:()=>ke,convertLegacyFilter:()=>yf,evaluate:()=>wf,formatColor:()=>Du,isExpression:()=>Yn,lerpColor:()=>Zs,parseColor:()=>Gn,validateExpression:()=>Pl});function wf(t,e,n="value"){if(!Yn(t)){if(Array.isArray(t))return t;return t}let i=ke(t,n,[]);try{return i.evaluate(e)}catch(s){if(s instanceof x)throw s;if(s instanceof Error)throw new x(s.message,t);throw new x(String(s),t)}}var Wi=P(()=>{js(),zt(),Gr(),Ui(),js(),zt(),bf(),Gr()}),Kr,Xr,Jr,Qr,ta,ea,na,ia,sa,Ll,Dt,oa,ra,aa,la,ca,ha,ua,fa,da,Al,Ol,El,vf=P(()=>{Kr={"background-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"background-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"}},Xr={"fill-antialias":{type:"boolean",default:!0,sdk:"gl"},"fill-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"fill-outline-color":{type:"color",transition:!0,sdk:"gl"},"fill-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"},"fill-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"fill-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"}},Jr={"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"fill-extrusion-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"fill-extrusion-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"},"fill-extrusion-height":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"fill-extrusion-base":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,sdk:"gl"}},Qr={"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"line-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"line-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"line-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"line-width":{type:"number",default:1,minimum:0,transition:!0,sdk:"gl"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"line-offset":{type:"number",default:0,transition:!0,sdk:"gl"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"line-dasharray":{type:"array",transition:!0,sdk:"gl"},"line-pattern":{type:"resolvedImage",transition:!0,sdk:"gl"},"line-gradient":{type:"color",sdk:"gl"}},ta={"circle-radius":{type:"number",default:5,minimum:0,transition:!0,sdk:"gl"},"circle-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"circle-blur":{type:"number",default:0,transition:!0,sdk:"gl"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"circle-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"circle-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"circle-pitch-scale":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"circle-pitch-alignment":{type:"enum",values:["map","viewport"],default:"viewport",sdk:"gl"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"}},ea={"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"icon-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,sdk:"gl"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"icon-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"icon-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"text-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,sdk:"gl"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,sdk:"gl"},"text-translate":{type:"array",length:2,default:[0,0],transition:!0,sdk:"gl"},"text-translate-anchor":{type:"enum",values:["map","viewport"],default:"map",sdk:"gl"}},na={"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"raster-hue-rotate":{type:"number",default:0,transition:!0,sdk:"gl"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,sdk:"gl"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,sdk:"gl"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,sdk:"gl"},"raster-resampling":{type:"enum",values:["linear","nearest"],default:"linear",sdk:"gl"},"raster-fade-duration":{type:"number",default:300,minimum:0,sdk:"gl"}},ia={"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,sdk:"gl"},"hillshade-illumination-anchor":{type:"enum",values:["map","viewport"],default:"viewport",sdk:"gl"},"hillshade-exaggeration":{type:"number",default:0.5,minimum:0,maximum:1,transition:!0,sdk:"gl"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,sdk:"gl"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,sdk:"gl"}},sa={"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,sdk:"gl"},"heatmap-weight":{type:"number",default:1,minimum:0,sdk:"gl"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,sdk:"gl"},"heatmap-color":{type:"color",default:void 0,sdk:"gl"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,sdk:"gl"}},Ll={background:Kr,fill:Xr,"fill-extrusion":Jr,line:Qr,circle:ta,symbol:ea,raster:na,hillshade:ia,heatmap:sa},Dt={type:"enum",values:["visible","none"],default:"visible",sdk:"gl"},oa={visibility:Dt},ra={visibility:Dt,"fill-sort-key":{type:"number",sdk:"gl"}},aa={visibility:Dt},la={visibility:Dt,"line-cap":{type:"enum",values:["butt","round","square"],default:"butt",sdk:"gl"},"line-join":{type:"enum",values:["bevel","round","miter"],default:"miter",sdk:"gl"},"line-miter-limit":{type:"number",default:2,sdk:"gl"},"line-round-limit":{type:"number",default:1.05,sdk:"gl"},"line-sort-key":{type:"number",sdk:"gl"}},ca={visibility:Dt,"circle-sort-key":{type:"number",sdk:"gl"}},ha={visibility:Dt,"symbol-placement":{type:"enum",values:["point","line","line-center"],default:"point",sdk:"gl"},"symbol-spacing":{type:"number",default:250,minimum:1,sdk:"gl"},"symbol-avoid-edges":{type:"boolean",default:!1,sdk:"gl"},"symbol-sort-key":{type:"number",sdk:"gl"},"symbol-z-order":{type:"enum",values:["auto","viewport-y","source"],default:"auto",sdk:"gl"},"icon-allow-overlap":{type:"boolean",default:!1,sdk:"gl"},"icon-ignore-placement":{type:"boolean",default:!1,sdk:"gl"},"icon-optional":{type:"boolean",default:!1,sdk:"gl"},"icon-rotation-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"icon-size":{type:"number",default:1,minimum:0,sdk:"gl"},"icon-text-fit":{type:"enum",values:["none","width","height","both"],default:"none",sdk:"gl"},"icon-text-fit-padding":{type:"array",length:4,default:[0,0,0,0],sdk:"gl"},"icon-image":{type:"resolvedImage",sdk:"gl"},"icon-rotate":{type:"number",default:0,sdk:"gl"},"icon-padding":{type:"padding",default:2,sdk:"gl"},"icon-keep-upright":{type:"boolean",default:!1,sdk:"gl"},"icon-offset":{type:"array",length:2,default:[0,0],sdk:"gl"},"icon-anchor":{type:"enum",values:["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"],default:"center",sdk:"gl"},"icon-pitch-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"text-pitch-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"text-rotation-alignment":{type:"enum",values:["map","viewport","auto"],default:"auto",sdk:"gl"},"text-field":{type:"formatted",default:"",sdk:"gl"},"text-font":{type:"array",default:["Open Sans Regular","Arial Unicode MS Regular"],sdk:"gl"},"text-size":{type:"number",default:16,minimum:0,sdk:"gl"},"text-max-width":{type:"number",default:10,minimum:0,sdk:"gl"},"text-line-height":{type:"number",default:1.2,sdk:"gl"},"text-letter-spacing":{type:"number",default:0,sdk:"gl"},"text-justify":{type:"enum",values:["auto","left","center","right"],default:"center",sdk:"gl"},"text-radial-offset":{type:"number",default:0,sdk:"gl"},"text-variable-anchor":{type:"array",sdk:"gl"},"text-anchor":{type:"enum",values:["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"],default:"center",sdk:"gl"},"text-max-angle":{type:"number",default:45,sdk:"gl"},"text-writing-mode":{type:"array",sdk:"gl"},"text-rotate":{type:"number",default:0,sdk:"gl"},"text-padding":{type:"number",default:2,minimum:0,sdk:"gl"},"text-keep-upright":{type:"boolean",default:!0,sdk:"gl"},"text-transform":{type:"enum",values:["none","uppercase","lowercase"],default:"none",sdk:"gl"},"text-offset":{type:"array",length:2,default:[0,0],sdk:"gl"},"text-allow-overlap":{type:"boolean",default:!1,sdk:"gl"},"text-ignore-placement":{type:"boolean",default:!1,sdk:"gl"},"text-optional":{type:"boolean",default:!1,sdk:"gl"}},ua={visibility:Dt},fa={visibility:Dt},da={visibility:Dt},Al={background:oa,fill:ra,"fill-extrusion":aa,line:la,circle:ca,symbol:ha,raster:ua,hillshade:fa,heatmap:da},Ol=["background","fill","fill-extrusion","line","circle","symbol","raster","hillshade","heatmap"],El=["vector","raster","raster-dem","geojson"]});function z(t,e,n){t.push({message:e,path:n.slice()})}function ge(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}function xf(t){switch(t){case"color":return"color";case"number":return"number";case"string":return"string";case"boolean":return"boolean";case"array":return"array";case"enum":return"string";case"padding":return"value";case"formatted":return"formatted";case"resolvedImage":return"resolvedImage"}}function Sf(t,e){if(Array.isArray(t)){if(Yn(t)){let n=Pl(t,xf(e.type));return n.length===0?!0:n}if(e.type==="array"){if(e.length!==void 0&&t.length!==e.length)return!1;return!0}if(e.type==="padding")return t.length===2||t.length===4;return!1}switch(e.type){case"color":return typeof t==="string";case"number":if(typeof t!=="number"||Number.isNaN(t))return!1;if(e.minimum!==void 0&&t<e.minimum)return!1;if(e.maximum!==void 0&&t>e.maximum)return!1;return!0;case"string":return typeof t==="string";case"boolean":return typeof t==="boolean";case"enum":return typeof t==="string"&&(e.values?e.values.includes(t):!0);case"padding":return typeof t==="number";case"formatted":return typeof t==="string";case"resolvedImage":return typeof t==="string";case"array":return!1}}function pa(t,e,n,i,s,o){let r=[],a=t?t[i]:void 0;if(!a)return z(r,`Unknown ${n} property "${i}" for layer type "${e}"`,o),r;let l=Sf(s,a);if(l===!0)return r;if(l===!1)return z(r,`Invalid value for ${n} property "${i}" (expected ${Tf(a)})`,o),r;for(let c of l)z(r,`Invalid expression for ${n} property "${i}": ${c}`,o);return r}function Tf(t){if(t.type==="enum"&&t.values)return`one of ${t.values.map((e)=>`"${e}"`).join(", ")}`;if(t.type==="array"&&t.length!==void 0)return`array of length ${t.length}`;return t.type}function Pf(t,e){let n=[],i=e!==void 0?["sources",e]:["source"];if(!ge(t))return z(n,"Source must be an object",i),n;let s=t.type;if(typeof s!=="string")return z(n,'Source is missing required "type" property',i.concat("type")),n;if(!El.includes(s))return z(n,`Unknown source type "${s}"`,i.concat("type")),n;if(s==="vector"||s==="raster"||s==="raster-dem"){let o=typeof t.url==="string",r=Array.isArray(t.tiles)&&t.tiles.length>0;if(!o&&!r)z(n,`Source of type "${s}" must define either "url" or a non-empty "tiles" array`,i);if(t.tiles!==void 0&&!Array.isArray(t.tiles))z(n,'"tiles" must be an array of URL templates',i.concat("tiles"));if(t.url!==void 0&&typeof t.url!=="string")z(n,'"url" must be a string',i.concat("url"));if(t.minzoom!==void 0&&typeof t.minzoom!=="number")z(n,'"minzoom" must be a number',i.concat("minzoom"));if(t.maxzoom!==void 0&&typeof t.maxzoom!=="number")z(n,'"maxzoom" must be a number',i.concat("maxzoom"))}if(s==="geojson"){if(t.data===void 0)z(n,'GeoJSON source is missing required "data" property',i.concat("data"))}return n}function kf(t,e){let n=[],i=["layer"];if(!ge(t))return z(n,"Layer must be an object",i),n;if(typeof t.id!=="string"||t.id.length===0)z(n,'Layer is missing required "id" property',i.concat("id"));let s=t.type;if(typeof s!=="string")return z(n,'Layer is missing required "type" property',i.concat("type")),n;if(!Ol.includes(s))return z(n,`Unknown layer type "${s}"`,i.concat("type")),n;let o=s;if(o!=="background"){if(typeof t.source!=="string")z(n,`Layer of type "${o}" is missing required "source" property`,i.concat("source"));else if(e&&!(t.source in e))z(n,`Layer references undefined source "${t.source}"`,i.concat("source"))}if(t.minzoom!==void 0&&typeof t.minzoom!=="number")z(n,'"minzoom" must be a number',i.concat("minzoom"));if(t.maxzoom!==void 0&&typeof t.maxzoom!=="number")z(n,'"maxzoom" must be a number',i.concat("maxzoom"));let r=t.paint;if(r!==void 0)if(!ge(r))z(n,'Layer "paint" must be an object',i.concat("paint"));else{let l=Ll[o];for(let c of Object.keys(r)){let h=pa(l,o,"paint",c,r[c],i.concat("paint",c));for(let u of h)n.push(u)}}let a=t.layout;if(a!==void 0)if(!ge(a))z(n,'Layer "layout" must be an object',i.concat("layout"));else{let l=Al[o];for(let c of Object.keys(a)){let h=pa(l,o,"layout",c,a[c],i.concat("layout",c));for(let u of h)n.push(u)}}return n}function Mf(t){let e=[];if(!ge(t))return z(e,"Style must be an object",[]),e;if(t.version===void 0)z(e,'Style is missing required "version" property',["version"]);else if(t.version!==8)z(e,`Unsupported style version: ${String(t.version)} (expected 8)`,["version"]);let n=t.sources;if(n===void 0)z(e,'Style is missing required "sources" property',["sources"]);else if(!ge(n))z(e,'Style "sources" must be an object',["sources"]);else for(let s of Object.keys(n)){let o=Pf(n[s],s);for(let r of o)e.push(r)}let i=t.layers;if(i===void 0)z(e,'Style is missing required "layers" property',["layers"]);else if(!Array.isArray(i))z(e,'Style "layers" must be an array',["layers"]);else{let s=new Set,o=ge(n)?n:void 0;for(let r=0;r<i.length;r++){let a=i[r],l=["layers",String(r)];if(!ge(a)){z(e,"Layer must be an object",l);continue}if(typeof a.id==="string")if(s.has(a.id))z(e,`Duplicate layer id "${a.id}"`,l.concat("id"));else s.add(a.id);let c=kf(a,o);for(let h of c){let u=h.path?h.path.slice(1):[];e.push({message:h.message,path:l.concat(u)})}}}if(t.name!==void 0&&typeof t.name!=="string")z(e,'"name" must be a string',["name"]);if(t.zoom!==void 0&&typeof t.zoom!=="number")z(e,'"zoom" must be a number',["zoom"]);if(t.bearing!==void 0&&typeof t.bearing!=="number")z(e,'"bearing" must be a number',["bearing"]);if(t.pitch!==void 0&&typeof t.pitch!=="number")z(e,'"pitch" must be a number',["pitch"]);if(t.center!==void 0){let s=t.center;if(!Array.isArray(s)||s.length!==2||typeof s[0]!=="number"||typeof s[1]!=="number")z(e,'"center" must be a [lng, lat] tuple',["center"])}if(t.glyphs!==void 0&&typeof t.glyphs!=="string")z(e,'"glyphs" must be a string template',["glyphs"]);if(t.sprite!==void 0){let s=t.sprite;if(typeof s!=="string"&&!Array.isArray(s))z(e,'"sprite" must be a string or an array of sprite sources',["sprite"])}return e}var Lf=P(()=>{Wi(),vf()});class vi{constructor(t,e){if(e?.validate!==!1){let i=Mf(t);if(i.length)throw Error(`Invalid style: ${i.map((s)=>s.message).join("; ")}`)}if(this.spec=this._cloneSpec(t),!this.spec.sources)this.spec.sources={};if(!Array.isArray(this.spec.layers))this.spec.layers=[];this.sourceLayers=new Map,this.layerSpecs=new Map;for(let i of this.spec.layers)this.layerSpecs.set(i.id,i)}setPaintProperty(t,e,n){let i=this.layerSpecs.get(t);if(!i)throw Error(`no layer with id ${t}`);let s=i;s.paint={...s.paint??{},[e]:n}}setLayoutProperty(t,e,n){let i=this.layerSpecs.get(t);if(!i)throw Error(`no layer with id ${t}`);let s=i;s.layout={...s.layout??{},[e]:n}}setFilter(t,e){let n=this.layerSpecs.get(t);if(!n)throw Error(`no layer with id ${t}`);let i=n;i.filter=e}setLayerZoomRange(t,e,n){let i=this.layerSpecs.get(t);if(!i)throw Error(`no layer with id ${t}`);if(e!==void 0)i.minzoom=e;if(n!==void 0)i.maxzoom=n}serialize(){return this._cloneSpec(this.spec)}toVectorStyleLayer(t){let e=t;return{id:e.id,type:e.type,sourceLayer:e["source-layer"]??e.sourceLayer,minzoom:e.minzoom,maxzoom:e.maxzoom,filter:e.filter,paint:e.paint??{},layout:e.layout??{}}}_cloneSpec(t){return JSON.parse(JSON.stringify(t))}}var Af=P(()=>{Lf()});function Wt(t,e){if(t===e)return!0;if(typeof t!==typeof e)return!1;if(t===null||e===null)return t===e;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Wt(t[n],e[n]))return!1;return!0}if(typeof t==="object"&&typeof e==="object"){let n=t,i=e,s=Object.keys(n),o=Object.keys(i);if(s.length!==o.length)return!1;for(let r of s){if(!Object.prototype.hasOwnProperty.call(i,r))return!1;if(!Wt(n[r],i[r]))return!1}return!0}return!1}function vn(t){return{commands:[{command:"setStyle",args:[t]}]}}function ma(t){let e={};for(let n of t)e[n.id]=n;return e}function Of(t,e,n){let i=t.paint||{},s=e.paint||{};for(let o of Object.keys(s))if(!Wt(i[o],s[o]))n.push({command:"setPaintProperty",args:[e.id,o,s[o]]});for(let o of Object.keys(i))if(!(o in s))n.push({command:"setPaintProperty",args:[e.id,o,void 0]})}function Ef(t,e,n){let i=t.layout||{},s=e.layout||{};for(let o of Object.keys(s))if(!Wt(i[o],s[o]))n.push({command:"setLayoutProperty",args:[e.id,o,s[o]]});for(let o of Object.keys(i))if(!(o in s))n.push({command:"setLayoutProperty",args:[e.id,o,void 0]})}function zf(t,e){if(t.version!==e.version)return vn(e);if(!Wt(t.sprite,e.sprite))return vn(e);if(t.glyphs!==e.glyphs)return vn(e);let n=[];if(!Wt(t.transition,e.transition)&&e.transition!==void 0)n.push({command:"setTransition",args:[e.transition]});if(!Wt(t.light,e.light)&&e.light!==void 0)n.push({command:"setLight",args:[e.light]});let i=t.sources||{},s=e.sources||{};for(let u of Object.keys(i))if(!(u in s))n.push({command:"removeSource",args:[u]});for(let u of Object.keys(s)){let f=i[u],d=s[u];if(f===void 0){n.push({command:"addSource",args:[u,d]});continue}if(Wt(f,d))continue;if(f.type==="geojson"&&d.type==="geojson"){let p={...f,data:void 0},m={...d,data:void 0};if(Wt(p,m)){n.push({command:"setSourceData",args:[u,d.data]});continue}}n.push({command:"removeSource",args:[u]}),n.push({command:"addSource",args:[u,d]})}let o=t.layers||[],r=e.layers||[],a=ma(o),l=ma(r);for(let u of o)if(!(u.id in l))n.push({command:"removeLayer",args:[u.id]});let c=o.filter((u)=>(u.id in l)).map((u)=>u.id),h=r.filter((u)=>(u.id in a)).map((u)=>u.id);if(c.length!==h.length)return vn(e);for(let u=0;u<c.length;u++)if(c[u]!==h[u])return vn(e);for(let u=0;u<r.length;u++){let f=r[u],d=a[f.id];if(d===void 0){let w;for(let T=u+1;T<r.length;T++)if(r[T].id in a){w=r[T].id;break}n.push({command:"addLayer",args:[f,w]});continue}if(d.type!==f.type){n.push({command:"removeLayer",args:[f.id]});let w;for(let T=u+1;T<r.length;T++)if(r[T].id in a&&r[T].id!==f.id){w=r[T].id;break}n.push({command:"addLayer",args:[f,w]});continue}let p=d.source,m=f.source,_=d["source-layer"],g=f["source-layer"];if(p!==m||_!==g){n.push({command:"removeLayer",args:[f.id]});let w;for(let T=u+1;T<r.length;T++)if(r[T].id in a&&r[T].id!==f.id){w=r[T].id;break}n.push({command:"addLayer",args:[f,w]});continue}if(d.minzoom!==f.minzoom||d.maxzoom!==f.maxzoom)n.push({command:"setLayerZoomRange",args:[f.id,f.minzoom,f.maxzoom]});let b=d.filter,y=f.filter;if(!Wt(b,y))n.push({command:"setFilter",args:[f.id,y]});Of(d,f,n),Ef(d,f,n)}return{commands:n}}var Cf=`#version 300 es |
| 2 | 2 | precision highp float; |
| 3 | 3 | in vec2 a_position; |
| 4 | 4 | uniform mat4 u_matrix; |
| 5 | 5 | void main() { |
| 6 | 6 | gl_Position = u_matrix * vec4(a_position, 0.0, 1.0); |
| 7 | 7 | } |
| 8 | | -`,t5=`#version 300 es |
| 8 | +`,If=`#version 300 es |
| 9 | 9 | precision highp float; |
| 10 | 10 | uniform vec4 u_color; |
| 11 | 11 | out vec4 fragColor; |
| 12 | 12 | void main() { |
| 13 | 13 | fragColor = u_color; |
| 14 | 14 | } |
| 15 | | -`,e5=`#version 300 es |
| 15 | +`,Ff=`#version 300 es |
| 16 | 16 | precision highp float; |
| 17 | 17 | in vec2 a_position; |
| 18 | 18 | in vec2 a_normal; |
| @@ -26,7 +26,7 @@ void main() { |
| 26 | 26 | gl_Position = pos; |
| 27 | 27 | v_edge = a_progress; |
| 28 | 28 | } |
| 29 | | -`,$W=`#version 300 es |
| 29 | +`,Rf=`#version 300 es |
| 30 | 30 | precision highp float; |
| 31 | 31 | uniform vec4 u_color; |
| 32 | 32 | in float v_edge; |
| @@ -36,7 +36,7 @@ void main() { |
| 36 | 36 | float alpha = 1.0 - smoothstep(0.95, 1.0, d); |
| 37 | 37 | fragColor = vec4(u_color.rgb, u_color.a * alpha); |
| 38 | 38 | } |
| 39 | | -`,QW=`#version 300 es |
| 39 | +`,Nf=`#version 300 es |
| 40 | 40 | precision highp float; |
| 41 | 41 | in vec2 a_center; |
| 42 | 42 | in vec2 a_offset; |
| @@ -50,7 +50,7 @@ void main() { |
| 50 | 50 | gl_Position = u_matrix * vec4(pos, 0.0, 1.0); |
| 51 | 51 | v_offset = a_offset * (r / max(u_radius, 0.0001)); |
| 52 | 52 | } |
| 53 | | -`,KW=`#version 300 es |
| 53 | +`,$f=`#version 300 es |
| 54 | 54 | precision highp float; |
| 55 | 55 | uniform vec4 u_color; |
| 56 | 56 | uniform vec4 u_stroke_color; |
| @@ -69,7 +69,7 @@ void main() { |
| 69 | 69 | vec4 ring = vec4(u_stroke_color.rgb, u_stroke_color.a * (outerAlpha - fillAlpha)); |
| 70 | 70 | fragColor = inner + ring; |
| 71 | 71 | } |
| 72 | | -`,WW=`#version 300 es |
| 72 | +`,Zf=`#version 300 es |
| 73 | 73 | precision highp float; |
| 74 | 74 | in vec3 a_position; |
| 75 | 75 | in vec3 a_normal; |
| @@ -79,7 +79,7 @@ void main() { |
| 79 | 79 | gl_Position = u_matrix * vec4(a_position, 1.0); |
| 80 | 80 | v_normal = a_normal; |
| 81 | 81 | } |
| 82 | | -`,JW=`#version 300 es |
| 82 | +`,Bf=`#version 300 es |
| 83 | 83 | precision highp float; |
| 84 | 84 | uniform vec4 u_color; |
| 85 | 85 | uniform float u_opacity; |
| @@ -94,7 +94,7 @@ void main() { |
| 94 | 94 | float light = 0.45 + 0.55 * n; |
| 95 | 95 | fragColor = vec4(u_color.rgb * light, u_color.a * u_opacity); |
| 96 | 96 | } |
| 97 | | -`,UW=`#version 300 es |
| 97 | +`,Df=`#version 300 es |
| 98 | 98 | precision highp float; |
| 99 | 99 | in vec2 a_position; |
| 100 | 100 | out vec2 v_uv; |
| @@ -102,7 +102,7 @@ void main() { |
| 102 | 102 | v_uv = a_position * 0.5 + 0.5; |
| 103 | 103 | gl_Position = vec4(a_position, 0.0, 1.0); |
| 104 | 104 | } |
| 105 | | -`,VW=`#version 300 es |
| 105 | +`,jf=`#version 300 es |
| 106 | 106 | precision highp float; |
| 107 | 107 | uniform vec4 u_sky_color; |
| 108 | 108 | uniform vec4 u_horizon_color; |
| @@ -116,6 +116,7 @@ void main() { |
| 116 | 116 | vec4 color = mix(u_horizon_color, u_sky_color, t); |
| 117 | 117 | fragColor = vec4(color.rgb, color.a * u_pitch_t); |
| 118 | 118 | } |
| 119 | | -`;function Y9($,Q,K){let W=K??2,J=Q&&Q.length>0,U=J?Q[0]*W:$.length,V=H9($,0,U,W,!0),X=[];if(!V||V.next===V.prev)return X;let Y=0,Z=0,H=0,A=0,G=0,F=0,N=0;if(J)V=AW($,Q,V,W);if($.length>80*W){Y=H=$[0],Z=A=$[1];for(let q=W;q<U;q+=W){if(G=$[q],F=$[q+1],G<Y)Y=G;if(F<Z)Z=F;if(G>H)H=G;if(F>A)A=F}N=Math.max(H-Y,A-Z),N=N!==0?32767/N:0}return c$(V,X,W,Y,Z,N,0),X}function SJ($,Q,K,W){let J=Q&&Q.length>0,U=J?Q[0]*K:$.length,V=Math.abs(MQ($,0,U,K));if(J)for(let Y=0,Z=Q.length;Y<Z;Y++){let H=Q[Y]*K,A=Y<Z-1?Q[Y+1]*K:$.length;V-=Math.abs(MQ($,H,A,K))}let X=0;for(let Y=0;Y<W.length;Y+=3){let Z=W[Y]*K,H=W[Y+1]*K,A=W[Y+2]*K;X+=Math.abs(($[Z]-$[A])*($[H+1]-$[Z+1])-($[Z]-$[H])*($[A+1]-$[Z+1]))}return V===0&&X===0?0:Math.abs((X-V)/V)}function Z9($){let Q=[],K=[],W=2,J=0;for(let U=0;U<$.length;U++){let V=$[U];if(U>0)K.push(J);for(let X=0;X<V.length;X++){let Y=V[X];if(Array.isArray(Y))Q.push(Y[0],Y[1]);else Q.push(Y.x,Y.y)}J+=V.length}return{vertices:Q,holes:K,dimensions:2}}function H9($,Q,K,W,J){let U=null;if(J===MQ($,Q,K,W)>0)for(let V=Q;V<K;V+=W)U=G7(V,$[V],$[V+1],U);else for(let V=K-W;V>=Q;V-=W)U=G7(V,$[V],$[V+1],U);if(U&&h8(U,U.next))p$(U),U=U.next;return U}function U$($,Q){if(!$)return $;let K=Q??$,W=$,J=!1;do if(J=!1,!W.steiner&&(h8(W,W.next)||s(W.prev,W,W.next)===0)){if(p$(W),W=K=W.prev,W===W.next)break;J=!0}else W=W.next;while(J||W!==K);return K}function c$($,Q,K,W,J,U,V){if(!$)return;let X=$;if(V===0&&U)NW(X,W,J,U);let Y=X;while(X.prev!==X.next){let{prev:Z,next:H}=X;if(U?YW(X,W,J,U):XW(X)){Q.push(Z.i/K|0,X.i/K|0,H.i/K|0),p$(X),X=H.next,Y=H.next;continue}if(X=H,X===Y){if(V===0)c$(U$(X,null),Q,K,W,J,U,1);else if(V===1){let A=ZW(U$(X,null),Q,K);c$(A,Q,K,W,J,U,2)}else if(V===2)HW(X,Q,K,W,J,U);break}}}function XW($){let Q=$.prev,K=$,W=$.next;if(s(Q,K,W)>=0)return!1;let J=Q.x,U=K.x,V=W.x,X=Q.y,Y=K.y,Z=W.y,H=J<U?J<V?J:V:U<V?U:V,A=X<Y?X<Z?X:Z:Y<Z?Y:Z,G=J>U?J>V?J:V:U>V?U:V,F=X>Y?X>Z?X:Z:Y>Z?Y:Z,N=W.next;while(N!==Q){if(N.x>=H&&N.x<=G&&N.y>=A&&N.y<=F&&M$(J,X,U,Y,V,Z,N.x,N.y)&&s(N.prev,N,N.next)>=0)return!1;N=N.next}return!0}function YW($,Q,K,W){let J=$.prev,U=$,V=$.next;if(s(J,U,V)>=0)return!1;let X=J.x,Y=U.x,Z=V.x,H=J.y,A=U.y,G=V.y,F=X<Y?X<Z?X:Z:Y<Z?Y:Z,N=H<A?H<G?H:G:A<G?A:G,q=X>Y?X>Z?X:Z:Y>Z?Y:Z,R=H>A?H>G?H:G:A>G?A:G,I=qQ(F,N,Q,K,W),C=qQ(q,R,Q,K,W),M=$.prevZ,j=$.nextZ;while(M&&M.z>=I&&j&&j.z<=C){if(M.x>=F&&M.x<=q&&M.y>=N&&M.y<=R&&M!==J&&M!==V&&M$(X,H,Y,A,Z,G,M.x,M.y)&&s(M.prev,M,M.next)>=0)return!1;if(M=M.prevZ,j.x>=F&&j.x<=q&&j.y>=N&&j.y<=R&&j!==J&&j!==V&&M$(X,H,Y,A,Z,G,j.x,j.y)&&s(j.prev,j,j.next)>=0)return!1;j=j.nextZ}while(M&&M.z>=I){if(M.x>=F&&M.x<=q&&M.y>=N&&M.y<=R&&M!==J&&M!==V&&M$(X,H,Y,A,Z,G,M.x,M.y)&&s(M.prev,M,M.next)>=0)return!1;M=M.prevZ}while(j&&j.z<=C){if(j.x>=F&&j.x<=q&&j.y>=N&&j.y<=R&&j!==J&&j!==V&&M$(X,H,Y,A,Z,G,j.x,j.y)&&s(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function ZW($,Q,K){let W=$,J=$;do{let U=W.prev,V=W.next.next;if(!h8(U,V)&&A9(U,W,W.next,V)&&l$(U,V)&&l$(V,U))Q.push(U.i/K|0,W.i/K|0,V.i/K|0),p$(W),p$(W.next),W=J=V;W=W.next}while(W!==J);return U$(W,null)}function HW($,Q,K,W,J,U){let V=$;do{let X=V.next.next;while(X!==V.prev){if(V.i!==X.i&&MW(V,X)){let Y=G9(V,X),Z=U$(V,V.next),H=U$(Y,Y.next);c$(Z,Q,K,W,J,U,0),c$(H,Q,K,W,J,U,0);return}X=X.next}V=V.next}while(V!==$)}function AW($,Q,K,W){let J=[];for(let V=0,X=Q.length;V<X;V++){let Y=Q[V]*W,Z=V<X-1?Q[V+1]*W:$.length,H=H9($,Y,Z,W,!1);if(!H)continue;if(H===H.next)H.steiner=!0;J.push(RW(H))}J.sort((V,X)=>V.x-X.x);let U=K;for(let V=0;V<J.length;V++)U=GW(J[V],U);return U}function GW($,Q){let K=FW($,Q);if(!K)return Q;let W=G9(K,$);return U$(W,W.next),U$(Q,Q.next)}function FW($,Q){let K=Q,W=$.x,J=$.y,U=-1/0,V=null;do{if(J<=K.y&&J>=K.next.y&&K.next.y!==K.y){let G=K.x+(J-K.y)*(K.next.x-K.x)/(K.next.y-K.y);if(G<=W&&G>U){if(U=G,V=K.x<K.next.x?K:K.next,G===W)return V}}K=K.next}while(K!==Q);if(!V)return null;let X=V,Y=V.x,Z=V.y,H=1/0,A;K=V;do{if(W>=K.x&&K.x>=Y&&W!==K.x&&M$(J<Z?W:U,J,Y,Z,J<Z?U:W,J,K.x,K.y)){if(A=Math.abs(J-K.y)/(W-K.x),l$(K,$)&&(A<H||A===H&&(K.x>V.x||K.x===V.x&&jW(V,K))))V=K,H=A}K=K.next}while(K!==X);return V}function NW($,Q,K,W){let J=$;do{if(J.z===0)J.z=qQ(J.x,J.y,Q,K,W);J.prevZ=J.prev,J.nextZ=J.next,J=J.next}while(J!==$);J.prevZ.nextZ=null,J.prevZ=null,qW(J)}function qW($){let Q=$,K=1,W;do{let J=Q;Q=null;let U=null;W=0;while(J){W++;let V=J,X=0;for(let Z=0;Z<K;Z++)if(X++,V=V.nextZ,!V)break;let Y=K;while(X>0||Y>0&&V){let Z;if(X!==0&&(Y===0||!V||J.z<=V.z))Z=J,J=J.nextZ,X--;else Z=V,V=V.nextZ,Y--;if(U)U.nextZ=Z;else Q=Z;Z.prevZ=U,U=Z}J=V}U.nextZ=null,K*=2}while(W>1);return Q}function qQ($,Q,K,W,J){let U=($-K)*J|0,V=(Q-W)*J|0;return U=(U|U<<8)&16711935,U=(U|U<<4)&252645135,U=(U|U<<2)&858993459,U=(U|U<<1)&1431655765,V=(V|V<<8)&16711935,V=(V|V<<4)&252645135,V=(V|V<<2)&858993459,V=(V|V<<1)&1431655765,U|V<<1}function RW($){let Q=$,K=$;do{if(Q.x<K.x||Q.x===K.x&&Q.y<K.y)K=Q;Q=Q.next}while(Q!==$);return K}function M$($,Q,K,W,J,U,V,X){return(J-V)*(Q-X)>=($-V)*(U-X)&&($-V)*(W-X)>=(K-V)*(Q-X)&&(K-V)*(U-X)>=(J-V)*(W-X)}function MW($,Q){return $.next.i!==Q.i&&$.prev.i!==Q.i&&!DW($,Q)&&(l$($,Q)&&l$(Q,$)&&IW($,Q)&&(s($.prev,$,Q.prev)!==0||s($,Q.prev,Q)!==0)||h8($,Q)&&s($.prev,$,$.next)>0&&s(Q.prev,Q,Q.next)>0)}function s($,Q,K){return(Q.y-$.y)*(K.x-Q.x)-(Q.x-$.x)*(K.y-Q.y)}function h8($,Q){return $.x===Q.x&&$.y===Q.y}function A9($,Q,K,W){let J=F8(s($,Q,K)),U=F8(s($,Q,W)),V=F8(s(K,W,$)),X=F8(s(K,W,Q));if(J!==U&&V!==X)return!0;if(J===0&&G8($,K,Q))return!0;if(U===0&&G8($,W,Q))return!0;if(V===0&&G8(K,$,W))return!0;if(X===0&&G8(K,Q,W))return!0;return!1}function G8($,Q,K){return Q.x<=Math.max($.x,K.x)&&Q.x>=Math.min($.x,K.x)&&Q.y<=Math.max($.y,K.y)&&Q.y>=Math.min($.y,K.y)}function F8($){return $>0?1:$<0?-1:0}function DW($,Q){let K=$;do{if(K.i!==$.i&&K.next.i!==$.i&&K.i!==Q.i&&K.next.i!==Q.i&&A9(K,K.next,$,Q))return!0;K=K.next}while(K!==$);return!1}function l$($,Q){return s($.prev,$,$.next)<0?s($,Q,$.next)>=0&&s($,$.prev,Q)>=0:s($,Q,$.prev)<0||s($,$.next,Q)<0}function IW($,Q){let K=$,W=!1,J=($.x+Q.x)/2,U=($.y+Q.y)/2;do{if(K.y>U!==K.next.y>U&&K.next.y!==K.y&&J<(K.next.x-K.x)*(U-K.y)/(K.next.y-K.y)+K.x)W=!W;K=K.next}while(K!==$);return W}function jW($,Q){return s($.prev,$,Q.prev)<0&&s(Q.next,$,$.next)<0}function G9($,Q){let K=RQ($.i,$.x,$.y),W=RQ(Q.i,Q.x,Q.y),J=$.next,U=Q.prev;return $.next=Q,Q.prev=$,K.next=J,J.prev=K,W.next=K,K.prev=W,U.next=W,W.prev=U,W}function G7($,Q,K,W){let J=RQ($,Q,K);if(!W)J.prev=J,J.next=J;else J.next=W.next,J.prev=W,W.next.prev=J,W.next=J;return J}function p$($){if($.next.prev=$.prev,$.prev.next=$.next,$.prevZ)$.prevZ.nextZ=$.nextZ;if($.nextZ)$.nextZ.prevZ=$.prevZ}function RQ($,Q,K){return{i:$,x:Q,y:K,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function MQ($,Q,K,W){let J=0;for(let U=Q,V=K-W;U<K;U+=W)J+=($[V]-$[U])*($[U+1]+$[V+1]),V=U;return J}class F9{gl;canvas;constructor($,Q){this.canvas=$;let K={alpha:Q?.alpha??!0,premultipliedAlpha:Q?.premultipliedAlpha??!0,antialias:Q?.antialias??!0,depth:!1,stencil:!1},W=$.getContext("webgl2",K);if(!W)throw new nQ;this.gl=W,this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA)}compileProgram($,Q){let K=this.gl,W=this._compileShader(K.VERTEX_SHADER,$),J=this._compileShader(K.FRAGMENT_SHADER,Q),U=K.createProgram();if(!U)throw Error("Failed to allocate WebGL program.");if(K.attachShader(U,W),K.attachShader(U,J),K.linkProgram(U),!K.getProgramParameter(U,K.LINK_STATUS)){let V=K.getProgramInfoLog(U)??"";throw K.deleteProgram(U),Error(`WebGL program link failed: ${V}`)}return K.deleteShader(W),K.deleteShader(J),U}_compileShader($,Q){let K=this.gl,W=K.createShader($);if(!W)throw Error("Failed to allocate WebGL shader.");if(K.shaderSource(W,Q),K.compileShader(W),!K.getShaderParameter(W,K.COMPILE_STATUS)){let J=K.getShaderInfoLog(W)??"";throw K.deleteShader(W),Error(`WebGL shader compile failed: ${J} |
| 119 | +`;function zl(t,e,n){let i=n??2,s=e&&e.length>0,o=s?e[0]*i:t.length,r=Il(t,0,o,i,!0),a=[];if(!r||r.next===r.prev)return a;let l=0,c=0,h=0,u=0,f=0,d=0,p=0;if(s)r=qf(t,e,r,i);if(t.length>80*i){l=h=t[0],c=u=t[1];for(let m=i;m<o;m+=i){if(f=t[m],d=t[m+1],f<l)l=f;if(d<c)c=d;if(f>h)h=f;if(d>u)u=d}p=Math.max(h-l,u-c),p=p!==0?32767/p:0}return $n(r,a,i,l,c,p,0),a}function Jm(t,e,n,i){let s=e&&e.length>0,o=s?e[0]*n:t.length,r=Math.abs(Ws(t,0,o,n));if(s)for(let l=0,c=e.length;l<c;l++){let h=e[l]*n,u=l<c-1?e[l+1]*n:t.length;r-=Math.abs(Ws(t,h,u,n))}let a=0;for(let l=0;l<i.length;l+=3){let c=i[l]*n,h=i[l+1]*n,u=i[l+2]*n;a+=Math.abs((t[c]-t[u])*(t[h+1]-t[c+1])-(t[c]-t[h])*(t[u+1]-t[c+1]))}return r===0&&a===0?0:Math.abs((a-r)/r)}function Cl(t){let e=[],n=[],i=2,s=0;for(let o=0;o<t.length;o++){let r=t[o];if(o>0)n.push(s);for(let a=0;a<r.length;a++){let l=r[a];if(Array.isArray(l))e.push(l[0],l[1]);else e.push(l.x,l.y)}s+=r.length}return{vertices:e,holes:n,dimensions:2}}function Il(t,e,n,i,s){let o=null;if(s===Ws(t,e,n,i)>0)for(let r=e;r<n;r+=i)o=_a(r,t[r],t[r+1],o);else for(let r=n-i;r>=e;r-=i)o=_a(r,t[r],t[r+1],o);if(o&&Vi(o,o.next))Bn(o),o=o.next;return o}function Ne(t,e){if(!t)return t;let n=e??t,i=t,s=!1;do if(s=!1,!i.steiner&&(Vi(i,i.next)||Q(i.prev,i,i.next)===0)){if(Bn(i),i=n=i.prev,i===i.next)break;s=!0}else i=i.next;while(s||i!==n);return n}function $n(t,e,n,i,s,o,r){if(!t)return;let a=t;if(r===0&&o)Kf(a,i,s,o);let l=a;while(a.prev!==a.next){let c=a.prev,h=a.next;if(o?Hf(a,i,s,o):Uf(a)){e.push(c.i/n|0,a.i/n|0,h.i/n|0),Bn(a),a=h.next,l=h.next;continue}if(a=h,a===l){if(r===0)$n(Ne(a,null),e,n,i,s,o,1);else if(r===1){let u=Wf(Ne(a,null),e,n);$n(u,e,n,i,s,o,2)}else if(r===2)Vf(a,e,n,i,s,o);break}}}function Uf(t){let e=t.prev,n=t,i=t.next;if(Q(e,n,i)>=0)return!1;let s=e.x,o=n.x,r=i.x,a=e.y,l=n.y,c=i.y,h=s<o?s<r?s:r:o<r?o:r,u=a<l?a<c?a:c:l<c?l:c,f=s>o?s>r?s:r:o>r?o:r,d=a>l?a>c?a:c:l>c?l:c,p=i.next;while(p!==e){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&Je(s,a,o,l,r,c,p.x,p.y)&&Q(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Hf(t,e,n,i){let s=t.prev,o=t,r=t.next;if(Q(s,o,r)>=0)return!1;let a=s.x,l=o.x,c=r.x,h=s.y,u=o.y,f=r.y,d=a<l?a<c?a:c:l<c?l:c,p=h<u?h<f?h:f:u<f?u:f,m=a>l?a>c?a:c:l>c?l:c,_=h>u?h>f?h:f:u>f?u:f,g=Us(d,p,e,n,i),b=Us(m,_,e,n,i),{prevZ:y,nextZ:w}=t;while(y&&y.z>=g&&w&&w.z<=b){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=_&&y!==s&&y!==r&&Je(a,h,l,u,c,f,y.x,y.y)&&Q(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,w.x>=d&&w.x<=m&&w.y>=p&&w.y<=_&&w!==s&&w!==r&&Je(a,h,l,u,c,f,w.x,w.y)&&Q(w.prev,w,w.next)>=0)return!1;w=w.nextZ}while(y&&y.z>=g){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=_&&y!==s&&y!==r&&Je(a,h,l,u,c,f,y.x,y.y)&&Q(y.prev,y,y.next)>=0)return!1;y=y.prevZ}while(w&&w.z<=b){if(w.x>=d&&w.x<=m&&w.y>=p&&w.y<=_&&w!==s&&w!==r&&Je(a,h,l,u,c,f,w.x,w.y)&&Q(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Wf(t,e,n){let i=t,s=t;do{let o=i.prev,r=i.next.next;if(!Vi(o,r)&&Fl(o,i,i.next,r)&&Zn(o,r)&&Zn(r,o))e.push(o.i/n|0,i.i/n|0,r.i/n|0),Bn(i),Bn(i.next),i=s=r;i=i.next}while(i!==s);return Ne(i,null)}function Vf(t,e,n,i,s,o){let r=t;do{let a=r.next.next;while(a!==r.prev){if(r.i!==a.i&&Qf(r,a)){let l=Rl(r,a),c=Ne(r,r.next),h=Ne(l,l.next);$n(c,e,n,i,s,o,0),$n(h,e,n,i,s,o,0);return}a=a.next}r=r.next}while(r!==t)}function qf(t,e,n,i){let s=[];for(let r=0,a=e.length;r<a;r++){let l=e[r]*i,c=r<a-1?e[r+1]*i:t.length,h=Il(t,l,c,i,!1);if(!h)continue;if(h===h.next)h.steiner=!0;s.push(Jf(h))}s.sort((r,a)=>r.x-a.x);let o=n;for(let r=0;r<s.length;r++)o=Gf(s[r],o);return o}function Gf(t,e){let n=Yf(t,e);if(!n)return e;let i=Rl(n,t);return Ne(i,i.next),Ne(e,e.next)}function Yf(t,e){let n=e,{x:i,y:s}=t,o=-1/0,r=null;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){let f=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(f<=i&&f>o){if(o=f,r=n.x<n.next.x?n:n.next,f===i)return r}}n=n.next}while(n!==e);if(!r)return null;let a=r,l=r.x,c=r.y,h=1/0,u;n=r;do{if(i>=n.x&&n.x>=l&&i!==n.x&&Je(s<c?i:o,s,l,c,s<c?o:i,s,n.x,n.y)){if(u=Math.abs(s-n.y)/(i-n.x),Zn(n,t)&&(u<h||u===h&&(n.x>r.x||n.x===r.x&&nd(r,n))))r=n,h=u}n=n.next}while(n!==a);return r}function Kf(t,e,n,i){let s=t;do{if(s.z===0)s.z=Us(s.x,s.y,e,n,i);s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,Xf(s)}function Xf(t){let e=t,n=1,i;do{let s=e;e=null;let o=null;i=0;while(s){i++;let r=s,a=0;for(let c=0;c<n;c++)if(a++,r=r.nextZ,!r)break;let l=n;while(a>0||l>0&&r){let c;if(a!==0&&(l===0||!r||s.z<=r.z))c=s,s=s.nextZ,a--;else c=r,r=r.nextZ,l--;if(o)o.nextZ=c;else e=c;c.prevZ=o,o=c}s=r}o.nextZ=null,n*=2}while(i>1);return e}function Us(t,e,n,i,s){let o=(t-n)*s|0,r=(e-i)*s|0;return o=(o|o<<8)&16711935,o=(o|o<<4)&252645135,o=(o|o<<2)&858993459,o=(o|o<<1)&1431655765,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,o|r<<1}function Jf(t){let e=t,n=t;do{if(e.x<n.x||e.x===n.x&&e.y<n.y)n=e;e=e.next}while(e!==t);return n}function Je(t,e,n,i,s,o,r,a){return(s-r)*(e-a)>=(t-r)*(o-a)&&(t-r)*(i-a)>=(n-r)*(e-a)&&(n-r)*(o-a)>=(s-r)*(i-a)}function Qf(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!td(t,e)&&(Zn(t,e)&&Zn(e,t)&&ed(t,e)&&(Q(t.prev,t,e.prev)!==0||Q(t,e.prev,e)!==0)||Vi(t,e)&&Q(t.prev,t,t.next)>0&&Q(e.prev,e,e.next)>0)}function Q(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Vi(t,e){return t.x===e.x&&t.y===e.y}function Fl(t,e,n,i){let s=hi(Q(t,e,n)),o=hi(Q(t,e,i)),r=hi(Q(n,i,t)),a=hi(Q(n,i,e));if(s!==o&&r!==a)return!0;if(s===0&&ci(t,n,e))return!0;if(o===0&&ci(t,i,e))return!0;if(r===0&&ci(n,t,i))return!0;if(a===0&&ci(n,e,i))return!0;return!1}function ci(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function hi(t){return t>0?1:t<0?-1:0}function td(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Fl(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function Zn(t,e){return Q(t.prev,t,t.next)<0?Q(t,e,t.next)>=0&&Q(t,t.prev,e)>=0:Q(t,e,t.prev)<0||Q(t,t.next,e)<0}function ed(t,e){let n=t,i=!1,s=(t.x+e.x)/2,o=(t.y+e.y)/2;do{if(n.y>o!==n.next.y>o&&n.next.y!==n.y&&s<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x)i=!i;n=n.next}while(n!==t);return i}function nd(t,e){return Q(t.prev,t,e.prev)<0&&Q(e.next,t,t.next)<0}function Rl(t,e){let n=Hs(t.i,t.x,t.y),i=Hs(e.i,e.x,e.y),s=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=s,s.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function _a(t,e,n,i){let s=Hs(t,e,n);if(!i)s.prev=s,s.next=s;else s.next=i.next,s.prev=i,i.next.prev=s,i.next=s;return s}function Bn(t){if(t.next.prev=t.prev,t.prev.next=t.next,t.prevZ)t.prevZ.nextZ=t.nextZ;if(t.nextZ)t.nextZ.prevZ=t.prevZ}function Hs(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ws(t,e,n,i){let s=0;for(let o=e,r=n-i;o<n;o+=i)s+=(t[r]-t[o])*(t[o+1]+t[r+1]),r=o;return s}class Nl{gl;canvas;constructor(t,e){this.canvas=t;let n={alpha:e?.alpha??!0,premultipliedAlpha:e?.premultipliedAlpha??!0,antialias:e?.antialias??!0,depth:!1,stencil:!1},i=t.getContext("webgl2",n);if(!i)throw new Eo;this.gl=i,this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA)}compileProgram(t,e){let n=this.gl,i=this._compileShader(n.VERTEX_SHADER,t),s=this._compileShader(n.FRAGMENT_SHADER,e),o=n.createProgram();if(!o)throw Error("Failed to allocate WebGL program.");if(n.attachShader(o,i),n.attachShader(o,s),n.linkProgram(o),!n.getProgramParameter(o,n.LINK_STATUS)){let r=n.getProgramInfoLog(o)??"";throw n.deleteProgram(o),Error(`WebGL program link failed: ${r}`)}return n.deleteShader(i),n.deleteShader(s),o}_compileShader(t,e){let n=this.gl,i=n.createShader(t);if(!i)throw Error("Failed to allocate WebGL shader.");if(n.shaderSource(i,e),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS)){let s=n.getShaderInfoLog(i)??"";throw n.deleteShader(i),Error(`WebGL shader compile failed: ${s} |
| 120 | 120 | --- source --- |
| 121 | | -${Q}`)}return W}createBuffer($,Q){let K=this.gl,W=K.createBuffer();if(!W)throw Error("Failed to allocate WebGL buffer.");return K.bindBuffer(K.ARRAY_BUFFER,W),K.bufferData(K.ARRAY_BUFFER,$,Q??K.STATIC_DRAW),W}resize($,Q){let K=this.canvas;if(K.width!==$)K.width=$;if(K.height!==Q)K.height=Q;this.gl.viewport(0,0,$,Q)}clear($,Q,K,W){let J=this.gl;J.clearColor($,Q,K,W),J.clear(J.COLOR_BUFFER_BIT)}}var nQ,sQ=k(()=>{nQ=class extends Error{constructor(Q){super(Q??"WebGL2 is not supported in this environment.");this.name="WebGLUnsupportedError"}}});class rQ{ctx;_projection;_fill;_line;_circle;_fillExtrusion;_sky;_buffers;constructor($){this.ctx=new F9($),this._projection=new Float32Array(16),this._buffers=[],this._projection[0]=1,this._projection[5]=1,this._projection[10]=1,this._projection[15]=1,this._fill=this._buildFillProgram(),this._line=this._buildLineProgram(),this._circle=this._buildCircleProgram(),this._fillExtrusion=null,this._sky=null}setProjectionMatrix($){this._projection.set($)}clear(){this.ctx.clear(0,0,0,0)}destroy(){let $=this.ctx.gl;for(let Q of this._buffers)$.deleteBuffer(Q);if(this._buffers.length=0,$.deleteProgram(this._fill.program),$.deleteProgram(this._line.program),$.deleteProgram(this._circle.program),this._fillExtrusion)$.deleteProgram(this._fillExtrusion.program),this._fillExtrusion=null;if(this._sky)$.deleteProgram(this._sky.program),this._sky=null}drawFill($,Q){if($.length<6)return;let K=this.ctx.gl,W=this._fill;if(K.useProgram(W.program),W.u_matrix)K.uniformMatrix4fv(W.u_matrix,!1,this._projection);if(W.u_color)K.uniform4f(W.u_color,Q[0],Q[1],Q[2],Q[3]);let J=this.ctx.createBuffer($);this._buffers.push(J),K.bindBuffer(K.ARRAY_BUFFER,J),K.enableVertexAttribArray(W.a_position),K.vertexAttribPointer(W.a_position,2,K.FLOAT,!1,0,0),K.drawArrays(K.TRIANGLES,0,$.length/2),this._disposeBuffer(J)}drawLine($,Q){if($.length<4)return;let K=TW($);if(K.length===0)return;let W=this.ctx.gl,J=this._line;if(W.useProgram(J.program),J.u_matrix)W.uniformMatrix4fv(J.u_matrix,!1,this._projection);if(J.u_color)W.uniform4f(J.u_color,Q.color[0],Q.color[1],Q.color[2],Q.color[3]);if(J.u_width)W.uniform1f(J.u_width,Q.width);let U=this.ctx.createBuffer(K);this._buffers.push(U),W.bindBuffer(W.ARRAY_BUFFER,U);let V=20;W.enableVertexAttribArray(J.a_position),W.vertexAttribPointer(J.a_position,2,W.FLOAT,!1,V,0),W.enableVertexAttribArray(J.a_normal),W.vertexAttribPointer(J.a_normal,2,W.FLOAT,!1,V,8),W.enableVertexAttribArray(J.a_progress),W.vertexAttribPointer(J.a_progress,1,W.FLOAT,!1,V,16),W.drawArrays(W.TRIANGLE_STRIP,0,K.length/5),this._disposeBuffer(U)}drawCircles($,Q){if($.length<2)return;let K=this.ctx.gl,W=this._circle;if(K.useProgram(W.program),W.u_matrix)K.uniformMatrix4fv(W.u_matrix,!1,this._projection);if(W.u_color)K.uniform4f(W.u_color,Q.color[0],Q.color[1],Q.color[2],Q.color[3]);let J=Q.strokeColor??[0,0,0,0];if(W.u_stroke_color)K.uniform4f(W.u_stroke_color,J[0],J[1],J[2],J[3]);if(W.u_stroke_width)K.uniform1f(W.u_stroke_width,Q.strokeWidth??0);if(W.u_radius)K.uniform1f(W.u_radius,Q.radius);if(typeof K.drawArraysInstanced==="function")this._drawCirclesInstanced(W,$);else this._drawCirclesBatched(W,$)}drawFillExtrusion($,Q,K,W,J,U){if($.length===0)return 0;let V=this._fillExtrusion??(this._fillExtrusion=this._buildFillExtrusionProgram()),X=this.ctx.gl;X.useProgram(V.program);let Y=U??this._projection;if(V.u_matrix)X.uniformMatrix4fv(V.u_matrix,!1,Y);if(V.u_color)X.uniform4f(V.u_color,W[0],W[1],W[2],W[3]);if(V.u_opacity)X.uniform1f(V.u_opacity,J);let Z=[];for(let N=0;N<$.length;N++){let q=$[N].rings;if(!q||q.length===0)continue;let R=Q[N]??0,I=typeof K==="number"?K:K[N]??0;if(R<=I)continue;let C=Z9(q),M=Y9(C.vertices,C.holes,2);for(let j=0;j<M.length;j++){let E=M[j],_=C.vertices[E*2],x=C.vertices[E*2+1];Z.push(_,x,R,0,0,1)}for(let j of q){if(j.length<2)continue;for(let E=0;E<j.length;E++){let _=j[E],x=j[(E+1)%j.length],n=x.y-_.y,p=-(x.x-_.x),J0=Math.hypot(n,p)||1;n/=J0,p/=J0,Z.push(_.x,_.y,I,n,p,0),Z.push(x.x,x.y,I,n,p,0),Z.push(x.x,x.y,R,n,p,0),Z.push(_.x,_.y,I,n,p,0),Z.push(x.x,x.y,R,n,p,0),Z.push(_.x,_.y,R,n,p,0)}}}if(Z.length===0)return 0;let H=new Float32Array(Z),A=this.ctx.createBuffer(H);this._buffers.push(A),X.bindBuffer(X.ARRAY_BUFFER,A);let G=24;X.enableVertexAttribArray(V.a_position),X.vertexAttribPointer(V.a_position,3,X.FLOAT,!1,G,0),X.enableVertexAttribArray(V.a_normal),X.vertexAttribPointer(V.a_normal,3,X.FLOAT,!1,G,12);let F=Z.length/6;return X.drawArrays(X.TRIANGLES,0,F),this._disposeBuffer(A),F}drawSky($,Q,K,W){if(K<=0)return;let J=this._sky??(this._sky=this._buildSkyProgram()),U=this.ctx.gl;if(U.useProgram(J.program),J.u_sky_color)U.uniform4f(J.u_sky_color,$[0],$[1],$[2],$[3]);if(J.u_horizon_color)U.uniform4f(J.u_horizon_color,Q[0],Q[1],Q[2],Q[3]);if(J.u_pitch_t)U.uniform1f(J.u_pitch_t,K);if(J.u_horizon_blend)U.uniform1f(J.u_horizon_blend,W);let V=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),X=this.ctx.createBuffer(V);this._buffers.push(X),U.bindBuffer(U.ARRAY_BUFFER,X),U.enableVertexAttribArray(J.a_position),U.vertexAttribPointer(J.a_position,2,U.FLOAT,!1,0,0),U.drawArrays(U.TRIANGLES,0,6),this._disposeBuffer(X)}drawTerrain($,Q,K,W,J){if($.length===0||Q.length===0)return 0;let U=this._fillExtrusion??(this._fillExtrusion=this._buildFillExtrusionProgram()),V=this.ctx.gl;V.useProgram(U.program);let X=J??this._projection;if(U.u_matrix)V.uniformMatrix4fv(U.u_matrix,!1,X);if(U.u_color)V.uniform4f(U.u_color,K[0],K[1],K[2],K[3]);if(U.u_opacity)V.uniform1f(U.u_opacity,W);let Y=this.ctx.createBuffer($);this._buffers.push(Y),V.bindBuffer(V.ARRAY_BUFFER,Y);let Z=24;V.enableVertexAttribArray(U.a_position),V.vertexAttribPointer(U.a_position,3,V.FLOAT,!1,Z,0),V.enableVertexAttribArray(U.a_normal),V.vertexAttribPointer(U.a_normal,3,V.FLOAT,!1,Z,12);let H=V.createBuffer();return V.bindBuffer(V.ELEMENT_ARRAY_BUFFER,H),V.bufferData(V.ELEMENT_ARRAY_BUFFER,Q,V.STATIC_DRAW),V.drawElements(V.TRIANGLES,Q.length,V.UNSIGNED_INT,0),V.bindBuffer(V.ELEMENT_ARRAY_BUFFER,null),V.deleteBuffer(H),this._disposeBuffer(Y),Q.length}_drawCirclesInstanced($,Q){let K=this.ctx.gl,W=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),J=this.ctx.createBuffer(W);this._buffers.push(J),K.bindBuffer(K.ARRAY_BUFFER,J),K.enableVertexAttribArray($.a_offset),K.vertexAttribPointer($.a_offset,2,K.FLOAT,!1,0,0),K.vertexAttribDivisor($.a_offset,0);let U=this.ctx.createBuffer(Q);this._buffers.push(U),K.bindBuffer(K.ARRAY_BUFFER,U),K.enableVertexAttribArray($.a_center),K.vertexAttribPointer($.a_center,2,K.FLOAT,!1,0,0),K.vertexAttribDivisor($.a_center,1),K.drawArraysInstanced(K.TRIANGLES,0,6,Q.length/2),K.vertexAttribDivisor($.a_center,0),this._disposeBuffer(J),this._disposeBuffer(U)}_drawCirclesBatched($,Q){let K=this.ctx.gl,W=Q.length/2,J=new Float32Array(W*6*4),U=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];for(let Y=0;Y<W;Y++){let Z=Q[Y*2],H=Q[Y*2+1];for(let A=0;A<6;A++){let G=(Y*6+A)*4;J[G]=Z,J[G+1]=H,J[G+2]=U[A*2],J[G+3]=U[A*2+1]}}let V=this.ctx.createBuffer(J);this._buffers.push(V),K.bindBuffer(K.ARRAY_BUFFER,V);let X=16;K.enableVertexAttribArray($.a_center),K.vertexAttribPointer($.a_center,2,K.FLOAT,!1,X,0),K.enableVertexAttribArray($.a_offset),K.vertexAttribPointer($.a_offset,2,K.FLOAT,!1,X,8),K.drawArrays(K.TRIANGLES,0,W*6),this._disposeBuffer(V)}_buildFillProgram(){let $=this.ctx.compileProgram(o5,t5),Q=this.ctx.gl;return{program:$,u_matrix:Q.getUniformLocation($,"u_matrix"),u_color:Q.getUniformLocation($,"u_color"),a_position:Q.getAttribLocation($,"a_position")}}_buildLineProgram(){let $=this.ctx.compileProgram(e5,$W),Q=this.ctx.gl;return{program:$,u_matrix:Q.getUniformLocation($,"u_matrix"),u_color:Q.getUniformLocation($,"u_color"),u_width:Q.getUniformLocation($,"u_width"),a_position:Q.getAttribLocation($,"a_position"),a_normal:Q.getAttribLocation($,"a_normal"),a_progress:Q.getAttribLocation($,"a_progress")}}_buildCircleProgram(){let $=this.ctx.compileProgram(QW,KW),Q=this.ctx.gl;return{program:$,u_matrix:Q.getUniformLocation($,"u_matrix"),u_color:Q.getUniformLocation($,"u_color"),u_stroke_color:Q.getUniformLocation($,"u_stroke_color"),u_stroke_width:Q.getUniformLocation($,"u_stroke_width"),u_radius:Q.getUniformLocation($,"u_radius"),a_center:Q.getAttribLocation($,"a_center"),a_offset:Q.getAttribLocation($,"a_offset")}}_buildFillExtrusionProgram(){let $=this.ctx.compileProgram(WW,JW),Q=this.ctx.gl;return{program:$,u_matrix:Q.getUniformLocation($,"u_matrix"),u_color:Q.getUniformLocation($,"u_color"),u_opacity:Q.getUniformLocation($,"u_opacity"),a_position:Q.getAttribLocation($,"a_position"),a_normal:Q.getAttribLocation($,"a_normal")}}_buildSkyProgram(){let $=this.ctx.compileProgram(UW,VW),Q=this.ctx.gl;return{program:$,u_sky_color:Q.getUniformLocation($,"u_sky_color"),u_horizon_color:Q.getUniformLocation($,"u_horizon_color"),u_pitch_t:Q.getUniformLocation($,"u_pitch_t"),u_horizon_blend:Q.getUniformLocation($,"u_horizon_blend"),a_position:Q.getAttribLocation($,"a_position")}}_disposeBuffer($){let Q=this.ctx.gl,K=this._buffers.indexOf($);if(K>=0)this._buffers.splice(K,1);Q.deleteBuffer($)}}function TW($){let Q=$.length/2;if(Q<2)return new Float32Array(0);let K=[];for(let W=0;W<Q;W++){let J=$[W*2],U=$[W*2+1],V=0,X=0;if(W>0){let A=$[(W-1)*2],G=$[(W-1)*2+1],F=J-A,N=U-G,q=Math.hypot(F,N)||1;V+=F/q,X+=N/q}if(W<Q-1){let A=$[(W+1)*2],G=$[(W+1)*2+1],F=A-J,N=G-U,q=Math.hypot(F,N)||1;V+=F/q,X+=N/q}let Y=Math.hypot(V,X)||1;V/=Y,X/=Y;let Z=-X,H=V;K.push(J,U,Z,H,1),K.push(J,U,-Z,-H,-1)}return new Float32Array(K)}var aQ=k(()=>{sQ()}),H0,O0=k(()=>{f(),B$(),$0(),H0=class extends R0{getEvents(){return{}}onAdd(Q){}onRemove(Q){}beforeAdd(Q){}addTo(Q){return Q.addLayer(this),this}remove(){return this.removeFrom(this._map||this._mapToAdd)}removeFrom(Q){return Q?.removeLayer(this),this}getPane(Q){return this._map.getPane(Q?this.options?.[Q]||Q:this.options.pane)}addInteractiveTarget(Q){return this._map._targets[u(Q)]=this,this}removeInteractiveTarget(Q){return delete this._map._targets[u(Q)],this}getAttribution(){return this.options?.attribution}_layerAdd(Q){let K=Q.target;if(!K.hasLayer(this))return;this._map=K,this._zoomAnimated=K._zoomAnimated;let W=this.getEvents();if(W&&Object.keys(W).length)K.on(W,this),this.once("remove",()=>K.off(W,this));this.onAdd(K),this.fire("add"),K.fire("layeradd",{layer:this})}},H0.setDefaultOptions({pane:"overlayPane",attribution:null,bubblingPointerEvents:!0}),L.include({addLayer($){if(!$._layerAdd)throw Error("The provided object is not a Layer.");let Q=u($);if(this._layers[Q])return this;return this._layers[Q]=$,$._mapToAdd=this,$.beforeAdd(this),this.whenReady($._layerAdd,$),this},removeLayer($){let Q=u($);if(!this._layers[Q])return this;if(this._loaded)$.onRemove(this);if(delete this._layers[Q],this._loaded)this.fire("layerremove",{layer:$}),$.fire("remove");return $._map=$._mapToAdd=null,this},hasLayer($){return u($)in this._layers},eachLayer($,Q){for(let K of Object.values(this._layers))$.call(Q,K);return this},_addLayers($){let Q=$?Array.isArray($)?$:[$]:[];for(let K of Q)this.addLayer(K)},_addZoomLimit($){let Q=$.options;if(!Number.isNaN(Q?.maxZoom)||!Number.isNaN(Q?.minZoom))this._zoomBoundLayers[u($)]=$,this._updateZoomLevels()},_removeZoomLimit($){let Q=u($);if(this._zoomBoundLayers[Q])delete this._zoomBoundLayers[Q],this._updateZoomLevels()},_updateZoomLevels(){let $=1/0,Q=-1/0,K=this._getZoomSpan();for(let W of Object.values(this._zoomBoundLayers)){let J=W.options;$=Math.min($,J.minZoom??1/0),Q=Math.max(Q,J.maxZoom??-1/0)}if(this._layersMaxZoom=Q===-1/0?void 0:Q,this._layersMinZoom=$===1/0?void 0:$,K!==this._getZoomSpan())this.fire("zoomlevelschange");if(this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom)this.setZoom(this._layersMaxZoom);if(this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom)this.setZoom(this._layersMinZoom)}})}),T$,oQ=k(()=>{e0(),f(),r(),A0(),W0(),l(),O0(),T$=class extends H0{_onMove;initialize(Q){t(this,Q)}onAdd(Q){this._initContainer(),this._levels={},this._tiles={},this._resetView()}beforeAdd(Q){Q._addZoomLimit(this)}onRemove(Q){this._removeAllTiles(),this._container?.remove(),Q._removeZoomLimit(this),this._container=void 0,this._tileZoom=void 0,clearTimeout(this._pruneTimeout)}bringToFront(){if(this._map)o$(this._container),this._setAutoZIndex(Math.max);return this}bringToBack(){if(this._map)t$(this._container),this._setAutoZIndex(Math.min);return this}getContainer(){return this._container}setOpacity(Q){return this.options.opacity=Q,this._updateOpacity(),this}setZIndex(Q){return this.options.zIndex=Q,this._updateZIndex(),this}isLoading(){return this._loading}redraw(){if(this._map){this._removeAllTiles();let Q=this._clampZoom(this._map.getZoom());if(Q!==this._tileZoom)this._tileZoom=Q,this._updateLevels();this._update()}return this}getEvents(){let Q={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};if(!this.options.updateWhenIdle){if(!this._onMove)this._onMove=LQ(this._onMoveEnd,this.options.updateInterval,this);Q.move=this._onMove}if(this._zoomAnimated)Q.zoomanim=this._animateZoom;return Q}createTile(Q,K){return document.createElement("div")}getTileSize(){let Q=this.options.tileSize;return Q instanceof D?Q:new D(Q,Q)}_updateZIndex(){if(this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null)this._container.style.zIndex=this.options.zIndex}_setAutoZIndex(Q){let K=this.getPane().children,W=-Q(-1/0,1/0);for(let J of Array.from(K)){let U=J.style.zIndex;if(J!==this._container&&U)W=Q(W,+U)}if(Number.isFinite(W))this.options.zIndex=W+Q(-1,1),this._updateZIndex()}_updateOpacity(){if(!this._map)return;this._container.style.opacity=String(this.options.opacity);let Q=Date.now(),K=!1,W=!1;for(let J of Object.values(this._tiles??{})){if(!J.current||!J.loaded)continue;let U=Math.min(1,(Q-J.loaded)/200);if(J.el.style.opacity=String(U),U<1)K=!0;else{if(J.active)W=!0;else this._onOpaqueTile(J);J.active=!0}}if(W&&!this._noPrune)this._pruneTiles();if(K){if(this._fadeFrame!==void 0)cancelAnimationFrame(this._fadeFrame);this._fadeFrame=requestAnimationFrame(this._updateOpacity.bind(this))}}_onOpaqueTile(Q){}_initContainer(){if(this._container)return;if(this._container=v("div",`tsmap-layer ${this.options.className??""}`),this._updateZIndex(),this.options.opacity<1)this._updateOpacity();this.getPane().appendChild(this._container)}_updateLevels(){let Q=this._tileZoom,K=this.options.maxZoom;if(Q===void 0)return;for(let U of Object.keys(this._levels)){let V=Number(U);if(U=V,this._levels[V].el.children.length||V===Q)this._levels[V].el.style.zIndex=String(K-Math.abs(Q-V)),this._onUpdateLevel(V);else this._levels[V].el.remove(),this._removeTilesAtZoom(V),this._onRemoveLevel(V),delete this._levels[V]}let W=this._levels[Q],J=this._map;if(!W)W=this._levels[Q]={},W.el=v("div","tsmap-tile-container tsmap-zoom-animated",this._container),W.el.style.zIndex=String(K),W.origin=J.project(J.unproject(J.getPixelOrigin()),Q).round(),W.zoom=Q,this._setZoomTransform(W,J.getCenter(),J.getZoom()),M0(W.el.offsetWidth),this._onCreateLevel(W);return this._level=W,W}_onUpdateLevel(Q){}_onRemoveLevel(Q){}_onCreateLevel(Q){}_pruneTiles(){if(!this._map)return;let Q=this._map.getZoom();if(Q>this.options.maxZoom||Q<this.options.minZoom){this._removeAllTiles();return}for(let K of Object.values(this._tiles))K.retain=K.current;for(let K of Object.values(this._tiles))if(K.current&&!K.active){let W=K.coords;if(!this._retainParent(W.x,W.y,W.z,W.z-5))this._retainChildren(W.x,W.y,W.z,W.z+2)}for(let[K,W]of Object.entries(this._tiles))if(!W.retain)this._removeTile(K)}_removeTilesAtZoom(Q){for(let[K,W]of Object.entries(this._tiles))if(W.coords.z===Q)this._removeTile(K)}_removeAllTiles(){for(let Q of Object.keys(this._tiles))this._removeTile(Q)}_invalidateAll(){for(let Q of Object.keys(this._levels))this._levels[Q].el.remove(),this._onRemoveLevel(Number(Q)),delete this._levels[Q];this._removeAllTiles(),this._tileZoom=void 0}_retainParent(Q,K,W,J){let U=Math.floor(Q/2),V=Math.floor(K/2),X=W-1,Y=new D(U,V);Y.z=X;let Z=this._tileCoordsToKey(Y),H=this._tiles[Z];if(H?.active)return H.retain=!0,!0;else if(H?.loaded)H.retain=!0;if(X>J)return this._retainParent(U,V,X,J);return!1}_retainChildren(Q,K,W,J){for(let U=2*Q;U<2*Q+2;U++)for(let V=2*K;V<2*K+2;V++){let X=new D(U,V);X.z=W+1;let Y=this._tileCoordsToKey(X),Z=this._tiles[Y];if(Z?.active){Z.retain=!0;continue}else if(Z?.loaded)Z.retain=!0;if(W+1<J)this._retainChildren(U,V,W+1,J)}}_resetView(Q){let K=Q&&(Q.pinch||Q.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),K,K)}_animateZoom(Q){this._setView(Q.center,Q.zoom,!0,Q.noUpdate)}_clampZoom(Q){let K=this.options;if(K.minNativeZoom!==void 0&&Q<K.minNativeZoom)return K.minNativeZoom;if(K.maxNativeZoom!==void 0&&K.maxNativeZoom<Q)return K.maxNativeZoom;return Q}_setView(Q,K,W,J){let U=Math.round(K);if(this.options.maxZoom!==void 0&&U>this.options.maxZoom||this.options.minZoom!==void 0&&U<this.options.minZoom)U=void 0;else U=this._clampZoom(U);let V=this.options.updateWhenZooming&&U!==this._tileZoom;if(!J||V){if(this._tileZoom=U,this._abortLoading)this._abortLoading();if(this._updateLevels(),this._resetGrid(),U!==void 0)this._update(Q);if(!W)this._pruneTiles();this._noPrune=!!W}this._setZoomTransforms(Q,K)}_setZoomTransforms(Q,K){for(let W of Object.values(this._levels))this._setZoomTransform(W,Q,K)}_setZoomTransform(Q,K,W){let J=this._map.getZoomScale(W,Q.zoom),U=Q.origin.multiplyBy(J).subtract(this._map._getNewPixelOrigin(K,W)).round();W$(Q.el,U,J)}_resetGrid(){let Q=this._map,K=Q.options.crs,W=this._tileSize=this.getTileSize(),J=this._tileZoom,U=this._map.getPixelWorldBounds(this._tileZoom);if(U)this._globalTileRange=this._pxBoundsToTileRange(U);this._wrapX=K.wrapLng&&!this.options.noWrap&&[Math.floor(Q.project([0,K.wrapLng[0]],J).x/W.x),Math.ceil(Q.project([0,K.wrapLng[1]],J).x/W.y)],this._wrapY=K.wrapLat&&!this.options.noWrap&&[Math.floor(Q.project([K.wrapLat[0],0],J).y/W.x),Math.ceil(Q.project([K.wrapLat[1],0],J).y/W.y)]}_onMoveEnd(){if(!this._map||this._map._animatingZoom)return;this._update()}_getTiledPixelBounds(Q){let K=this._map,W=K._animatingZoom?Math.max(K._animateToZoom,K.getZoom()):K.getZoom(),J=K.getZoomScale(W,this._tileZoom),U=K.project(Q,this._tileZoom).floor(),V=K.getSize().divideBy(J*2);return new P(U.subtract(V),U.add(V))}_update(Q){let K=this._map;if(!K)return;let W=this._clampZoom(K.getZoom());if(Q===void 0)Q=K.getCenter();if(this._tileZoom===void 0)return;let J=this._getTiledPixelBounds(Q),U=this._pxBoundsToTileRange(J),V=U.getCenter(),X=[],Y=this.options.keepBuffer,Z=new P(U.getBottomLeft().subtract([Y,-Y]),U.getTopRight().add([Y,-Y]));if(!(Number.isFinite(U.min.x)&&Number.isFinite(U.min.y)&&Number.isFinite(U.max.x)&&Number.isFinite(U.max.y)))throw Error("Attempted to load an infinite number of tiles");for(let H of Object.values(this._tiles)){let A=H.coords;if(A.z!==this._tileZoom||!Z.contains(new D(A.x,A.y)))H.current=!1}if(Math.abs(W-this._tileZoom)>1){this._setView(Q,W);return}for(let H=U.min.y;H<=U.max.y;H++)for(let A=U.min.x;A<=U.max.x;A++){let G=new D(A,H);if(G.z=this._tileZoom,!this._isValidTile(G))continue;let F=this._tiles[this._tileCoordsToKey(G)];if(F)F.current=!0;else X.push(G)}if(X.sort((H,A)=>H.distanceTo(V)-A.distanceTo(V)),X.length!==0){if(!this._loading)this._loading=!0,this.fire("loading");let H=document.createDocumentFragment();for(let A of X)this._addTile(A,H);this._level.el.appendChild(H)}}_isValidTile(Q){let K=this._map.options.crs;if(!K.infinite){let J=this._globalTileRange;if(!K.wrapLng&&(Q.x<J.min.x||Q.x>J.max.x)||!K.wrapLat&&(Q.y<J.min.y||Q.y>J.max.y))return!1}if(!this.options.bounds)return!0;let W=this._tileCoordsToBounds(Q);return new z(this.options.bounds).overlaps(W)}_keyToBounds(Q){return this._tileCoordsToBounds(this._keyToTileCoords(Q))}_tileCoordsToNwSe(Q){let K=this._map,W=this.getTileSize(),J=Q.scaleBy(W),U=J.add(W),V=K.unproject(J,Q.z),X=K.unproject(U,Q.z);return[V,X]}_tileCoordsToBounds(Q){let K=this._tileCoordsToNwSe(Q),W=new z(K[0],K[1]);if(!this.options.noWrap)W=this._map.wrapLatLngBounds(W);return W}_tileCoordsToKey(Q){return`${Q.x}:${Q.y}:${Q.z}`}_keyToTileCoords(Q){let K=Q.split(":"),W=new D(+K[0],+K[1]);return W.z=+K[2],W}_removeTile(Q){let K=this._tiles[Q];if(!K)return;K.el.remove(),delete this._tiles[Q],this.fire("tileunload",{tile:K.el,coords:this._keyToTileCoords(Q)})}_initTile(Q){Q.classList.add("tsmap-tile");let K=this.getTileSize();Q.style.width=`${K.x}px`,Q.style.height=`${K.y}px`,Q.onselectstart=M0,Q.onpointermove=M0}_addTile(Q,K){let W=this._getTilePos(Q),J=this._tileCoordsToKey(Q),U=this.createTile(this._wrapCoords(Q),this._tileReady.bind(this,Q));if(this._initTile(U),this.createTile.length<2)requestAnimationFrame(this._tileReady.bind(this,Q,null,U));K0(U,W),this._tiles[J]={el:U,coords:Q,current:!0},K.appendChild(U),this.fire("tileloadstart",{tile:U,coords:Q})}_tileReady(Q,K,W){if(K)this.fire("tileerror",{error:K,tile:W,coords:Q});let J=this._tileCoordsToKey(Q),U=this._tiles[J];if(!U)return;if(U.loaded=Date.now(),this._map._fadeAnimated){if(U.el.style.opacity="0",this._fadeFrame!==void 0)cancelAnimationFrame(this._fadeFrame);this._fadeFrame=requestAnimationFrame(this._updateOpacity.bind(this))}else U.active=!0,this._pruneTiles();if(!K)U.el.classList.add("tsmap-tile-loaded"),this.fire("tileload",{tile:U.el,coords:Q});if(this._noTilesToLoad())if(this._loading=!1,this.fire("load"),!this._map._fadeAnimated)requestAnimationFrame(this._pruneTiles.bind(this));else this._pruneTimeout=setTimeout(this._pruneTiles.bind(this),250)}_getTilePos(Q){return Q.scaleBy(this.getTileSize()).subtract(this._level.origin)}_wrapCoords(Q){let K=new D(this._wrapX?m$(Q.x,this._wrapX):Q.x,this._wrapY?m$(Q.y,this._wrapY):Q.y);return K.z=Q.z,K}_pxBoundsToTileRange(Q){let K=this.getTileSize();return new P(Q.min.unscaleBy(K).floor(),Q.max.unscaleBy(K).ceil().subtract([1,1]))}_noTilesToLoad(){return Object.values(this._tiles).every((Q)=>!!Q.loaded)}},T$.setDefaultOptions({tileSize:256,opacity:1,updateWhenIdle:X0.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2})}),DQ={};C0(DQ,{TileLayer:()=>V$});var V$,i$=k(()=>{e0(),f(),i(),P8(),oQ(),V$=class extends T${initialize(Q,K){if(super.initialize(K),this._url=Q,this.options.attribution===null){let J=new URL(Q,location.href).hostname;if(["tile.openstreetmap.org","tile.osm.org"].some((V)=>J.endsWith(V)))this.options.attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}if(this.options.detectRetina&&X0.retina&&this.options.maxZoom>0){if(this.options.tileSize=Math.floor(this.options.tileSize/2),!this.options.zoomReverse)this.options.zoomOffset++,this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom-1);else this.options.zoomOffset--,this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom+1);this.options.minZoom=Math.max(0,this.options.minZoom)}else if(!this.options.zoomReverse)this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom);else this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom);if(typeof this.options.subdomains==="string")this.options.subdomains=this.options.subdomains.split("");let W=this.options.offlineCache;if(W instanceof S8)this._offlineCache=W;else if(W===!0)this._offlineCache=j$();this._activeBlobUrls=new Set,this.on("tileunload",this._onTileRemove)}setUrl(Q,K){if(this._url===Q&&K===void 0)K=!0;if(this._url=Q,!K)this.redraw();return this}createTile(Q,K){let W=document.createElement("img");if(B(W,"load",this._tileOnLoad.bind(this,K,W)),B(W,"error",this._tileOnError.bind(this,K,W)),this.options.crossOrigin||this.options.crossOrigin==="")W.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;if(typeof this.options.referrerPolicy==="string")W.referrerPolicy=this.options.referrerPolicy;W.alt="";let J=this.getTileUrl(Q);if(this._offlineCache)this._resolveThroughCache(W,J);else W.src=J;return W}_resolveThroughCache(Q,K){let W=this._offlineCache??j$();PQ(K,{cache:W}).then((J)=>{let U=globalThis.URL;if(U&&typeof U.createObjectURL==="function"&&typeof globalThis.Blob==="function"){let V=new globalThis.Blob([J.data],{type:J.mime}),X=U.createObjectURL(V);this._activeBlobUrls.add(X),Q.src=X}else Q.src=K}).catch(()=>{Q.src=K})}getTileUrl(Q){let K=Object.create(this.options);if(Object.assign(K,{r:X0.retina?"@2x":"",s:this._getSubdomain(Q),x:Q.x,y:Q.y,z:this._getZoomForUrl()}),this._map&&!this._map.options.crs.infinite){let W=this._globalTileRange.max.y-Q.y;if(this.options.tms)K.y=W;K["-y"]=W}return zQ(this._url,K)}_tileOnLoad(Q,K){Q(null,K)}_tileOnError(Q,K,W){let J=this.options.errorTileUrl;if(J&&K.getAttribute("src")!==J)K.src=J;Q(W,K)}_onTileRemove(Q){Q.tile.onload=null}_getZoomForUrl(){let Q=this._tileZoom,K=this.options.maxZoom,W=this.options.zoomReverse,J=this.options.zoomOffset;if(W)Q=K-Q;return Q+J}_getSubdomain(Q){let K=Math.abs(Q.x+Q.y)%this.options.subdomains.length;return this.options.subdomains[K]}_abortLoading(){for(let Q of Object.keys(this._tiles))if(this._tiles[Q].coords.z!==this._tileZoom){let K=this._tiles[Q].el;if(K.onload=M0,K.onerror=M0,!K.complete){K.setAttribute("src","");let W=this._tiles[Q].coords;K.remove(),delete this._tiles[Q],this.fire("tileabort",{tile:K,coords:W})}}}_removeTile(Q){let K=this._tiles[Q];if(!K)return;let W=K.el,J=W.getAttribute("src")??"";if(J.startsWith("blob:")&&this._activeBlobUrls.has(J)){let U=globalThis.URL;if(U&&typeof U.revokeObjectURL==="function")U.revokeObjectURL(J);this._activeBlobUrls.delete(J)}W.setAttribute("src",""),super._removeTile(Q)}_tileReady(Q,K,W){if(!this._map||W&&W.getAttribute("src")==="")return;super._tileReady(Q,K,W)}_clampZoom(Q){return Math.round(super._clampZoom(Q))}},V$.setDefaultOptions({minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1})});class N9{buf;pos;type;length;_view;constructor($){if($ instanceof Uint8Array)this.buf=$;else if($ instanceof ArrayBuffer)this.buf=new Uint8Array($);else this.buf=new Uint8Array(0);this.pos=0,this.type=0,this.length=this.buf.length,this._view=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}readFields($,Q,K){let W=K===void 0?this.length:K;while(this.pos<W){let J=this.readVarint(),U=J>>3,V=this.pos;if(this.type=J&7,$(U,Q,this),this.pos===V)this.skip(J)}return Q}readMessage($,Q){return this.readFields($,Q,this.readVarint()+this.pos)}readFixed32(){let $=this._view.getUint32(this.pos,!0);return this.pos+=4,$}readSFixed32(){let $=this._view.getInt32(this.pos,!0);return this.pos+=4,$}readFixed64(){let $=this._view.getUint32(this.pos,!0),Q=this._view.getUint32(this.pos+4,!0);return this.pos+=8,Q*t0+$}readSFixed64(){let $=this._view.getUint32(this.pos,!0),Q=this._view.getInt32(this.pos+4,!0);return this.pos+=8,Q*t0+$}readFloat(){let $=this._view.getFloat32(this.pos,!0);return this.pos+=4,$}readDouble(){let $=this._view.getFloat64(this.pos,!0);return this.pos+=8,$}readVarint($){let Q=this.buf,K,W;if(W=Q[this.pos++],K=W&127,W<128)return K;if(W=Q[this.pos++],K|=(W&127)<<7,W<128)return K;if(W=Q[this.pos++],K|=(W&127)<<14,W<128)return K;if(W=Q[this.pos++],K|=(W&127)<<21,W<128)return K>>>0;return W=Q[this.pos],CW(K>>>0,$===!0,this)}readVarint64(){return this.readVarint(!0)}readSVarint(){let $=this.readVarint();return $%2===1?($+1)/-2:$/2}readBoolean(){return Boolean(this.readVarint())}readString(){let $=this.readVarint()+this.pos,Q=this.pos;if(this.pos=$,TQ!==null)return TQ.decode(this.buf.subarray(Q,$));return xW(this.buf,Q,$)}readBytes(){let $=this.readVarint()+this.pos,Q=this.buf.subarray(this.pos,$);return this.pos=$,new Uint8Array(Q)}readPackedVarint($,Q){return b0(this,$,(K)=>K.readVarint(Q))}readPackedSVarint($){return b0(this,$,(Q)=>Q.readSVarint())}readPackedBoolean($){return b0(this,$,(Q)=>Q.readBoolean())}readPackedFloat($){return b0(this,$,(Q)=>Q.readFloat())}readPackedDouble($){return b0(this,$,(Q)=>Q.readDouble())}readPackedFixed32($){return b0(this,$,(Q)=>Q.readFixed32())}readPackedSFixed32($){return b0(this,$,(Q)=>Q.readSFixed32())}readPackedFixed64($){return b0(this,$,(Q)=>Q.readFixed64())}readPackedSFixed64($){return b0(this,$,(Q)=>Q.readSFixed64())}skip($){let Q=$&7;if(Q===t8)while(this.buf[this.pos++]>=128);else if(Q===y$)this.pos=this.readVarint()+this.pos;else if(Q===q8)this.pos+=4;else if(Q===N8)this.pos+=8;else throw Error(`Unimplemented wire type: ${Q}`)}writeTag($,Q){this.writeVarint($<<3|Q)}realloc($){let Q=Math.max(this.length,16);while(Q<this.pos+$)Q*=2;if(Q!==this.buf.length){let K=new Uint8Array(Q);K.set(this.buf),this.buf=K,this._view=new DataView(K.buffer),this.length=Q}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}destroy(){this.buf=new Uint8Array(0),this._view=new DataView(this.buf.buffer),this.pos=0,this.length=0,this.type=0}writeVarint($){if($>268435455||$<0){BW($,this);return}this.realloc(4);let Q=$|0;if(this.buf[this.pos++]=Q&127|(Q>127?128:0),Q<=127)return;if(this.buf[this.pos++]=Q>>>7&127|(Q>16383?128:0),Q<=16383)return;if(this.buf[this.pos++]=Q>>>14&127|(Q>2097151?128:0),Q<=2097151)return;if(this.buf[this.pos++]=Q>>>21&127|(Q>268435455?128:0),Q<=268435455)return}writeSVarint($){this.writeVarint($<0?-$*2-1:$*2)}writeBoolean($){this.writeVarint($?1:0)}writeString($){let Q=CQ!==null?CQ.encode($):yW($);this.writeVarint(Q.length),this.realloc(Q.length),this.buf.set(Q,this.pos),this.pos+=Q.length}writeFloat($){this.realloc(4),this._view.setFloat32(this.pos,$,!0),this.pos+=4}writeDouble($){this.realloc(8),this._view.setFloat64(this.pos,$,!0),this.pos+=8}writeBytes($){this.writeVarint($.length),this.realloc($.length),this.buf.set($,this.pos),this.pos+=$.length}writeRawFixed32($){this.realloc(4),this._view.setUint32(this.pos,$>>>0,!0),this.pos+=4}writeRawSFixed32($){this.realloc(4),this._view.setInt32(this.pos,$|0,!0),this.pos+=4}writeRawFixed64($){this.realloc(8);let Q=$>>>0,K=Math.floor($*IQ)>>>0;this._view.setUint32(this.pos,Q,!0),this._view.setUint32(this.pos+4,K,!0),this.pos+=8}writeRawSFixed64($){this.realloc(8);let Q=$>>>0,K=Math.floor($*IQ)|0;this._view.setUint32(this.pos,Q,!0),this._view.setInt32(this.pos+4,K,!0),this.pos+=8}writeMessage($,Q,K){this.writeTag($,y$);let W=this.pos;this.pos++;let J=this.pos;Q(K,this);let U=this.pos-J;if(U>=128){let V=EW(U);this.realloc(V-1),this.buf.copyWithin(J+V-1,J,J+U),this.pos=W,this.writeVarint(U),this.pos=J+V-1+U}else this.buf[W]=U}writePackedVarint($,Q){if(Q.length>0)this.writeMessage($,_W,Q)}writePackedSVarint($,Q){if(Q.length>0)this.writeMessage($,SW,Q)}writePackedBoolean($,Q){if(Q.length>0)this.writeMessage($,PW,Q)}writePackedFloat($,Q){if(Q.length>0)this.writeMessage($,LW,Q)}writePackedDouble($,Q){if(Q.length>0)this.writeMessage($,zW,Q)}writePackedFixed32($,Q){if(Q.length>0)this.writeMessage($,vW,Q)}writePackedSFixed32($,Q){if(Q.length>0)this.writeMessage($,fW,Q)}writePackedFixed64($,Q){if(Q.length>0)this.writeMessage($,hW,Q)}writePackedSFixed64($,Q){if(Q.length>0)this.writeMessage($,bW,Q)}writeBytesField($,Q){this.writeTag($,y$),this.writeBytes(Q)}writeFixed32($,Q){this.writeTag($,q8),this.writeRawFixed32(Q)}writeSFixed32($,Q){this.writeTag($,q8),this.writeRawSFixed32(Q)}writeFixed64($,Q){this.writeTag($,N8),this.writeRawFixed64(Q)}writeSFixed64($,Q){this.writeTag($,N8),this.writeRawSFixed64(Q)}writeVarintField($,Q){this.writeTag($,t8),this.writeVarint(Q)}writeSVarintField($,Q){this.writeTag($,t8),this.writeSVarint(Q)}writeStringField($,Q){this.writeTag($,y$),this.writeString(Q)}writeFloatField($,Q){this.writeTag($,q8),this.writeFloat(Q)}writeDoubleField($,Q){this.writeTag($,N8),this.writeDouble(Q)}writeBooleanField($,Q){this.writeVarintField($,Q?1:0)}}function CW($,Q,K){let W=K.buf,J,U=0;if(J=W[K.pos++],$|=(J&15)<<28,U=(J&112)>>4,J<128)return q$($,U,Q);if(J=W[K.pos++],U|=(J&127)<<3,J<128)return q$($,U,Q);if(J=W[K.pos++],U|=(J&127)<<10,J<128)return q$($,U,Q);if(J=W[K.pos++],U|=(J&127)<<17,J<128)return q$($,U,Q);if(J=W[K.pos++],U|=(J&127)<<24,J<128)return q$($,U,Q);if(J=W[K.pos++],U|=(J&1)<<31,J<128)return q$($,U,Q);throw Error("Expected varint not more than 10 bytes")}function q$($,Q,K){if(K&&(Q&2147483648)!==0){let J=~$+1>>>0,U=~Q>>>0;if(J===0)U=U+1>>>0;let V=U*t0+J;if(V>jQ)throw Error("Varint exceeds safe integer range");return-V}let W=(Q>>>0)*t0+($>>>0);if(W>jQ)throw Error("Varint exceeds safe integer range");return W}function OW($){return $.readVarint()+$.pos}function b0($,Q,K){if($.type!==y$){if(Q===void 0)return[K($)];return Q.push(K($)),Q}let W=Q===void 0?[]:Q,J=OW($);while($.pos<J)W.push(K($));return W}function EW($){let Q=1;while($>=128)$=Math.floor($/128),Q++;return Q}function BW($,Q){let K,W;if($<0){let J=-$;if(K=~(J>>>0)+1>>>0,W=~Math.floor(J/t0)>>>0,K===0)W=W+1>>>0}else K=$>>>0,W=Math.floor($/t0)>>>0;Q.realloc(10);for(let J=0;J<10;J++){let U=J*7,V=kW(K,W,U),X=U+7<64?wW(K,W,U+7):!1;if(Q.buf[Q.pos++]=X?V|128:V,!X)break}}function kW($,Q,K){if(K>=32)return Q>>>K-32&127;if(K+7<=32)return $>>>K&127;return($>>>K|Q<<32-K)&127}function wW($,Q,K){if(K>=64)return!1;if(K>=32)return Q>>>K-32!==0;return $>>>K!==0||Q!==0}function _W($,Q){for(let K=0;K<$.length;K++)Q.writeVarint($[K])}function SW($,Q){for(let K=0;K<$.length;K++)Q.writeSVarint($[K])}function PW($,Q){for(let K=0;K<$.length;K++)Q.writeBoolean($[K])}function LW($,Q){for(let K=0;K<$.length;K++)Q.writeFloat($[K])}function zW($,Q){for(let K=0;K<$.length;K++)Q.writeDouble($[K])}function vW($,Q){for(let K=0;K<$.length;K++)Q.writeRawFixed32($[K])}function fW($,Q){for(let K=0;K<$.length;K++)Q.writeRawSFixed32($[K])}function hW($,Q){for(let K=0;K<$.length;K++)Q.writeRawFixed64($[K])}function bW($,Q){for(let K=0;K<$.length;K++)Q.writeRawSFixed64($[K])}function xW($,Q,K){let W="",J=Q;while(J<K){let U=$[J++];if(U<128)W+=String.fromCharCode(U);else if(U<224){let V=$[J++]&63;W+=String.fromCharCode((U&31)<<6|V)}else if(U<240){let V=$[J++]&63,X=$[J++]&63;W+=String.fromCharCode((U&15)<<12|V<<6|X)}else{let V=$[J++]&63,X=$[J++]&63,Y=$[J++]&63,Z=(U&7)<<18|V<<12|X<<6|Y;Z-=65536,W+=String.fromCharCode(55296|Z>>10),W+=String.fromCharCode(56320|Z&1023)}}return W}function yW($){let Q=[];for(let K=0;K<$.length;K++){let W=$.charCodeAt(K);if(W>=55296&&W<=56319&&K+1<$.length){let J=$.charCodeAt(K+1);if(J>=56320&&J<=57343)W=65536+((W&1023)<<10|J&1023),K++}if(W<128)Q.push(W);else if(W<2048)Q.push(192|W>>6,128|W&63);else if(W<65536)Q.push(224|W>>12,128|W>>6&63,128|W&63);else Q.push(240|W>>18,128|W>>12&63,128|W>>6&63,128|W&63)}return new Uint8Array(Q)}var t8=0,N8=1,y$=2,q8=5,t0,IQ,jQ,TQ,CQ,uW=k(()=>{t0=4294967296,IQ=1/t0,jQ=Number.MAX_SAFE_INTEGER,TQ=typeof TextDecoder<"u"?new TextDecoder("utf-8"):null,CQ=typeof TextEncoder<"u"?new TextEncoder:null});class q9{id;type;extent;properties;_pbf;_geometry;_geometryEnd;_keys;_values;constructor($,Q,K,W,J){this.id=void 0,this.type=mW,this.extent=K,this.properties={},this._pbf=$,this._geometry=-1,this._geometryEnd=-1,this._keys=W,this._values=J;let U=[];while($.pos<Q){let V=$.readVarint(),X=V>>3;if($.type=V&7,X===1)this.id=$.readVarint();else if(X===2)U=$.readPackedVarint(U);else if(X===3)this.type=$.readVarint();else if(X===4){this._geometry=$.pos;let Y=$.readVarint()+$.pos;this._geometryEnd=Y,$.pos=Y}else $.skip(V)}for(let V=0;V<U.length;V+=2){let X=W[U[V]],Y=J[U[V+1]];if(X!==void 0)this.properties[X]=Y??null}}loadGeometry(){if(this._geometry<0)return[];let $=this._pbf,Q=$.pos;$.pos=this._geometry;let K=$.readVarint()+$.pos,W=1,J=0,U=0,V=0,X=[],Y=null;while($.pos<K){if(J<=0){let Z=$.readVarint();W=Z&7,J=Z>>3}if(J--,W===e8||W===F7){let Z=$.readVarint(),H=$.readVarint();if(U+=Z>>1^-(Z&1),V+=H>>1^-(H&1),W===e8){if(Y!==null)X.push(Y);Y=[]}if(Y===null)Y=[];Y.push(new D(U,V))}else if(W===N7){if(Y!==null&&Y.length>0)Y.push(Y[0].clone())}else throw $.pos=Q,Error(`Unknown geometry command id: ${W}`)}if(Y!==null)X.push(Y);if(J>0)throw $.pos=Q,Error(`Truncated geometry: ${J} coordinate pair(s) missing`);return $.pos=Q,X}bbox(){if(this._geometry<0)return[0,0,0,0];let $=this._pbf,Q=$.pos;$.pos=this._geometry;let K=$.readVarint()+$.pos,W=1,J=0,U=0,V=0,X=1/0,Y=-1/0,Z=1/0,H=-1/0;while($.pos<K){if(J<=0){let A=$.readVarint();W=A&7,J=A>>3}if(J--,W===e8||W===F7){let A=$.readVarint(),G=$.readVarint();if(U+=A>>1^-(A&1),V+=G>>1^-(G&1),U<X)X=U;if(U>Y)Y=U;if(V<Z)Z=V;if(V>H)H=V}else if(W!==N7)throw $.pos=Q,Error(`Unknown geometry command id: ${W}`)}if(J>0)throw $.pos=Q,Error(`Truncated geometry: ${J} coordinate pair(s) missing`);return $.pos=Q,[X,Z,Y,H]}toGeoJSON($,Q,K){let W=this.extent*Math.pow(2,K),J=this.extent*$,U=this.extent*Q,V=this.loadGeometry(),X=(H)=>{let A=[];for(let G=0;G<H.length;G++){let F=H[G],N=F.x+J,q=F.y+U,R=N*360/W-180,I=180-q*360/W,C=360/Math.PI*Math.atan(Math.exp(I*Math.PI/180))-90;A.push([R,C])}return A},Y;if(this.type===dW){let H=[];for(let A=0;A<V.length;A++){let G=V[A];for(let F=0;F<G.length;F++){let N=X([G[F]]);H.push(N[0])}}if(H.length===1)Y={type:"Point",coordinates:H[0]};else Y={type:"MultiPoint",coordinates:H}}else if(this.type===cW){let H=[];for(let A=0;A<V.length;A++)H.push(X(V[A]));if(H.length===1)Y={type:"LineString",coordinates:H[0]};else Y={type:"MultiLineString",coordinates:H}}else if(this.type===lW){let H=[],A=null;for(let G=0;G<V.length;G++){let F=gW(V[G]);if(F===0)continue;let N=X(V[G]);if(F>0)A=[N],H.push(A);else if(A!==null)A.push(N)}if(H.length===1)Y={type:"Polygon",coordinates:H[0]};else Y={type:"MultiPolygon",coordinates:H}}else Y={type:"Point",coordinates:[0,0]};let Z={type:"Feature",geometry:Y,properties:this.properties};if(this.id!==void 0)Z.id=this.id;return Z}}function gW($){let Q=0;for(let K=0,W=$.length,J=W-1;K<W;J=K++){let U=$[K],V=$[J];Q+=(V.x-U.x)*(U.y+V.y)}return Q}var mW=0,dW=1,cW=2,lW=3,e8=1,F7=2,N7=7,pW=k(()=>{l()});class R9{version;name;extent;length;_pbf;_keys;_values;_features;constructor($,Q){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=$,this._keys=[],this._values=[],this._features=[];let K=Q===void 0?$.length:Q;while($.pos<K){let W=$.readVarint(),J=W>>3;if($.type=W&7,J===15)this.version=$.readVarint();else if(J===1)this.name=$.readString();else if(J===5)this.extent=$.readVarint();else if(J===2){this._features.push($.pos);let U=$.readVarint()+$.pos;$.pos=U}else if(J===3)this._keys.push($.readString());else if(J===4)this._values.push(iW($));else $.skip(W)}this.length=this._features.length}feature($){if($<0||$>=this._features.length)throw Error(`feature index out of bounds: ${$}`);let Q=this._pbf;Q.pos=this._features[$];let K=Q.readVarint()+Q.pos;return new q9(Q,K,this.extent,this._keys,this._values)}}function iW($){let Q=$.readVarint()+$.pos,K=null;while($.pos<Q){let W=$.readVarint(),J=W>>3;if($.type=W&7,J===1)K=$.readString();else if(J===2)K=$.readFloat();else if(J===3)K=$.readDouble();else if(J===4)K=$.readVarint(!0);else if(J===5)K=$.readVarint();else if(J===6)K=$.readSVarint();else if(J===7)K=$.readBoolean();else $.skip(W)}return K}var nW=k(()=>{pW()});class M9{layers;constructor($,Q){this.layers={};let K=Q===void 0?$.length:Q;while($.pos<K){let W=$.readVarint(),J=W>>3;if($.type=W&7,J===3){let U=$.readVarint()+$.pos,V=new R9($,U);if($.pos=U,V.name.length>0)this.layers[V.name]=V}else $.skip(W)}}}var sW=k(()=>{nW()});class D9{_cellSize;_cols;_rows;_cells;constructor($){this._cellSize=$?.cellSize??64;let Q=$?.width??1,K=$?.height??1;this._cols=Math.max(1,Math.ceil(Q/this._cellSize)),this._rows=Math.max(1,Math.ceil(K/this._cellSize)),this._cells=[];for(let W=0;W<this._cols*this._rows;W++)this._cells.push([])}tryInsert($){let Q=this._cellRange($);for(let K=Q.y0;K<=Q.y1;K++)for(let W=Q.x0;W<=Q.x1;W++){let J=this._cells[K*this._cols+W];for(let U of J){if(!rW($,U))continue;if(U.priority===void 0||$.priority===void 0)return!1;if(U.priority>=$.priority)return!1}}return this._insertBucketed($,Q),!0}insert($){this._insertBucketed($,this._cellRange($))}clear(){for(let $=0;$<this._cells.length;$++)this._cells[$]=[]}_cellRange($){let Q=this._cellSize,K=Math.floor($.minX/Q),W=Math.floor($.minY/Q),J=Math.floor($.maxX/Q),U=Math.floor($.maxY/Q);if(K<0)K=0;if(W<0)W=0;if(J>this._cols-1)J=this._cols-1;if(U>this._rows-1)U=this._rows-1;if(J<K)J=K;if(U<W)U=W;return{x0:K,y0:W,x1:J,y1:U}}_insertBucketed($,Q){for(let K=Q.y0;K<=Q.y1;K++)for(let W=Q.x0;W<=Q.x1;W++)this._cells[K*this._cols+W].push($)}}function rW($,Q){if($.maxX<Q.minX)return!1;if($.minX>Q.maxX)return!1;if($.maxY<Q.minY)return!1;if($.minY>Q.maxY)return!1;return!0}function aW($){if(!$)return"r";return`${$.italic?"i":"r"}${$.bold?"b":""}`}function $Q($){return`${$.codePoint}:${aW($)}`}class I9{canvas;_ctx;_fontFamily;_fontSize;_padding;_glyphs;_shelfY;_shelfX;_shelfH;constructor($){this._fontFamily=$?.fontFamily??"system-ui, -apple-system, Segoe UI, Roboto",this._fontSize=$?.fontSize??24,this._padding=$?.padding??4;let Q=$?.bucketSize??512;this.canvas=document.createElement("canvas"),this.canvas.width=Q,this.canvas.height=Q,this._ctx=this.canvas.getContext("2d"),this._glyphs=new Map,this._shelfX=0,this._shelfY=0,this._shelfH=0}getOrAddGlyph($,Q){let K={codePoint:$,italic:!!Q?.italic,bold:!!Q?.bold},W=this._glyphs.get($Q(K));if(W)return W;return this._rasterize(K)}measure($,Q){let K=0,W=0;for(let J of $){let U=J.codePointAt(0)??0,V=this.getOrAddGlyph(U,Q);if(K+=V.advance,V.height>W)W=V.height}return{width:K,height:W}}drawText($,Q,K,W,J){let U={italic:!!J.italic,bold:!!J.bold},V=J.size/this._fontSize;if(J.haloColor&&J.haloWidth&&J.haloWidth>0)$.save(),$.globalCompositeOperation="destination-over",$.fillStyle=J.haloColor,this._drawRun($,Q,K,W,V,U,J.haloWidth),$.restore();$.save(),$.fillStyle=J.color,this._drawRun($,Q,K,W,V,U,0),$.restore()}_buildSDF($){let{width:Q,height:K}=$,W=this._padding,J=1048576,U=new Int32Array(Q*K),V=new Int32Array(Q*K);for(let Y=0;Y<Q*K;Y++)if($.data[Y*4+3]>=128)V[Y]=1048576,U[Y]=0;else V[Y]=0,U[Y]=1048576;q7(V,Q,K),q7(U,Q,K);let X=oW(Q,K);for(let Y=0;Y<Q*K;Y++){let H=128-(V[Y]-U[Y])/3/W*128;if(H<0)H=0;else if(H>255)H=255;X.data[Y*4+0]=255,X.data[Y*4+1]=255,X.data[Y*4+2]=255,X.data[Y*4+3]=H|0}return X}_drawRun($,Q,K,W,J,U,V){let X=K;for(let Y of Q){let Z=Y.codePointAt(0)??0,H=this.getOrAddGlyph(Z,U);if(H.width>0&&H.height>0){let A=X+H.bearingX*J-V,G=W-H.bearingY*J-V,F=H.width*J+V*2,N=H.height*J+V*2;$.drawImage(this.canvas,H.x,H.y,H.width,H.height,A,G,F,N)}X+=H.advance*J}}_rasterize($){let Q=this._ctx;if(!Q){let R={codePoint:$.codePoint,x:0,y:0,width:0,height:0,advance:this._fontSize*0.6,bearingX:0,bearingY:0};return this._glyphs.set($Q($),R),R}let K=this._buildFontSpec($);Q.font=K;let W=String.fromCodePoint($.codePoint),J=Q.measureText(W),U=J.width&&J.width>0?J.width:this._fontSize*0.6,V=J.actualBoundingBoxAscent&&J.actualBoundingBoxAscent>0?J.actualBoundingBoxAscent:this._fontSize*0.8,X=J.actualBoundingBoxDescent&&J.actualBoundingBoxDescent>0?J.actualBoundingBoxDescent:this._fontSize*0.2,Y=this._padding,Z=Math.max(1,Math.ceil(U))+Y*2,H=Math.max(1,Math.ceil(V+X))+Y*2,A=document.createElement("canvas");A.width=Z,A.height=H;let G=A.getContext("2d");if(G){G.font=K,G.fillStyle="#000",G.textBaseline="alphabetic",G.fillText(W,Y,Y+V);try{let R=G.getImageData(0,0,Z,H),I=this._buildSDF(R);G.putImageData(I,0,0)}catch{}}if(this._shelfX+Z>this.canvas.width)this._shelfY+=this._shelfH,this._shelfX=0,this._shelfH=0;if(this._shelfY+H>this.canvas.height)this._growAtlas(Math.max(this.canvas.width*2,this._shelfY+H));if(this._shelfX+Z>this.canvas.width)this._growAtlas(Math.max(this.canvas.width*2,this._shelfX+Z));let F=this._shelfX,N=this._shelfY;if(Q.drawImage(A,F,N),this._shelfX+=Z,H>this._shelfH)this._shelfH=H;let q={codePoint:$.codePoint,x:F,y:N,width:Z,height:H,advance:U,bearingX:-Y,bearingY:V+Y};return this._glyphs.set($Q($),q),q}_buildFontSpec($){let Q=[];if($.italic)Q.push("italic");if($.bold)Q.push("bold");return Q.push(`${this._fontSize}px`),Q.push(this._fontFamily),Q.join(" ")}_growAtlas($){let Q=this.canvas,K=document.createElement("canvas");K.width=Math.max($,Q.width),K.height=Math.max($,Q.height);let W=K.getContext("2d");if(W)W.drawImage(Q,0,0);this.canvas=K,this._ctx=W}}function oW($,Q){let K=new Uint8ClampedArray($*Q*4),W=globalThis.ImageData;if(typeof W==="function")try{return new W(K,$,Q)}catch{}return{data:K,width:$,height:Q,colorSpace:"srgb"}}function q7($,Q,K){for(let W=0;W<K;W++)for(let J=0;J<Q;J++){let U=W*Q+J,V=$[U];if(W>0){if(J>0){let Y=$[U-Q-1]+4;if(Y<V)V=Y}let X=$[U-Q]+3;if(X<V)V=X;if(J<Q-1){let Y=$[U-Q+1]+4;if(Y<V)V=Y}}if(J>0){let X=$[U-1]+3;if(X<V)V=X}$[U]=V}for(let W=K-1;W>=0;W--)for(let J=Q-1;J>=0;J--){let U=W*Q+J,V=$[U];if(W<K-1){if(J<Q-1){let Y=$[U+Q+1]+4;if(Y<V)V=Y}let X=$[U+Q]+3;if(X<V)V=X;if(J>0){let Y=$[U+Q-1]+4;if(Y<V)V=Y}}if(J<Q-1){let X=$[U+1]+3;if(X<V)V=X}$[U]=V}}class j9{canvas;_ctx;_sprites;_cursorX;_cursorY;_rowH;constructor(){this.canvas=document.createElement("canvas"),this.canvas.width=512,this.canvas.height=512,this._ctx=this.canvas.getContext("2d"),this._sprites=new Map,this._cursorX=0,this._cursorY=0,this._rowH=0}addSprite($,Q){let{width:K,height:W}=$;if(this._cursorX+K>this.canvas.width)this._cursorY+=this._rowH,this._cursorX=0,this._rowH=0;if(this._cursorY+W>this.canvas.height)this._grow(Math.max(this.canvas.width*2,this._cursorY+W));let J=this._cursorX,U=this._cursorY,V=this._ctx;if(V)if(tW(Q)){let Y=document.createElement("canvas");Y.width=Q.width,Y.height=Q.height;let Z=Y.getContext("2d");if(Z)Z.putImageData(Q,0,0),V.drawImage(Y,$.x,$.y,K,W,J,U,K,W)}else V.drawImage(Q,$.x,$.y,K,W,J,U,K,W);let X={id:$.id,x:J,y:U,width:K,height:W,pixelRatio:$.pixelRatio??1};if(this._sprites.set($.id,X),this._cursorX+=K,W>this._rowH)this._rowH=W}get($){return this._sprites.get($)}drawIcon($,Q,K,W,J){let U=this._sprites.get(Q);if(!U)return;let X=(J?.size??U.width)/U.width,Y=U.width*X,Z=U.height*X;if(J?.rotation)$.save(),$.translate(K,W),$.rotate(J.rotation),$.drawImage(this.canvas,U.x,U.y,U.width,U.height,-Y/2,-Z/2,Y,Z),$.restore();else $.drawImage(this.canvas,U.x,U.y,U.width,U.height,K-Y/2,W-Z/2,Y,Z)}_grow($){let Q=this.canvas,K=document.createElement("canvas");K.width=Math.max($,Q.width),K.height=Math.max($,Q.height);let W=K.getContext("2d");if(W)W.drawImage(Q,0,0);this.canvas=K,this._ctx=W}}function tW($){if(!$||typeof $!=="object")return!1;let Q=$;return typeof Q.width==="number"&&typeof Q.height==="number"&&(Q.data instanceof Uint8ClampedArray||Q.data instanceof Uint8Array)}function R7($,Q,K,W,J,U,V){let X=V??new Float32Array(16),Y=1/($-Q),Z=1/(K-W),H=1/(J-U);return X[0]=-2*Y,X[1]=0,X[2]=0,X[3]=0,X[4]=0,X[5]=-2*Z,X[6]=0,X[7]=0,X[8]=0,X[9]=0,X[10]=2*H,X[11]=0,X[12]=($+Q)*Y,X[13]=(W+K)*Z,X[14]=(U+J)*H,X[15]=1,X}function eW($,Q){let K=typeof Q==="string"?Q.split(""):Q;if(!K||K.length===0)return"";let W=Math.abs($.x+$.y)%K.length;return K[W]}function $4($,Q){return zQ($,Q)}var Q4=k(()=>{f()}),T9={};C0(T9,{VectorTileMapLayer:()=>s$});function m($,Q,K,W){if(!K9($))return $;try{let J=$8($,"value"),U={zoom:Q,feature:K?{type:K.type,id:K.id,properties:K.properties}:void 0,featureState:W};return J.evaluate(U)}catch{return}}function M7($,Q,K,W,J,U,V){if(Q.length===0)return;let X=m(W?.["fill-color"],J,U,V)??"#000",Y=m(W?.["fill-opacity"],J,U,V),Z=m(W?.["fill-outline-color"],J,U,V);$.beginPath();for(let H of Q){if(H.length===0)continue;$.moveTo(H[0].x*K,H[0].y*K);for(let A=1;A<H.length;A++)$.lineTo(H[A].x*K,H[A].y*K)}if($.save(),Y!==void 0)$.globalAlpha=Y;if($.fillStyle=X,$.fill("evenodd"),$.restore(),Z)$.save(),$.strokeStyle=Z,$.lineWidth=1,$.stroke(),$.restore()}function K4($,Q,K,W,J,U,V){if(Q.length<2)return null;let X=Q[0],Y=Q[Q.length-1],Z=$.createLinearGradient(X.x*K,X.y*K,Y.x*K,Y.y*K),H={zoom:J,feature:{type:U.type,id:U.id,properties:U.properties},featureState:V,lineProgress:0};for(let A of O9){H.lineProgress=A;try{let G=W.evaluate(H);if(typeof G==="string")Z.addColorStop(A,G)}catch{}}return Z}function W4($,Q,K,W,J,U,V,X,Y){if(Q.length===0)return;let Z=m(W?.["line-color"],J,U,V)??"#000",H=m(W?.["line-width"],J,U,V)??1,A=m(W?.["line-opacity"],J,U,V),G=W?.["line-cap"],F=W?.["line-join"];if($.save(),Y){let N=K4($,Q[0],K,Y,J,U,V);$.strokeStyle=N??Z}else $.strokeStyle=Z;if($.lineWidth=H,A!==void 0)$.globalAlpha=A;if(X&&Array.isArray(X))$.setLineDash(X);if(G)$.lineCap=G;if(F)$.lineJoin=F;$.beginPath();for(let N of Q){if(N.length===0)continue;$.moveTo(N[0].x*K,N[0].y*K);for(let q=1;q<N.length;q++)$.lineTo(N[q].x*K,N[q].y*K)}$.stroke(),$.restore()}function J4($,Q,K,W,J,U,V){if(Q.length===0)return;let X=m(W?.["circle-color"],J,U,V)??"#000",Y=m(W?.["circle-radius"],J,U,V)??4,Z=m(W?.["circle-opacity"],J,U,V),H=m(W?.["circle-stroke-color"],J,U,V),A=m(W?.["circle-stroke-width"],J,U,V);if($.save(),Z!==void 0)$.globalAlpha=Z;for(let G of Q)for(let F of G)if($.beginPath(),$.arc(F.x*K,F.y*K,Y,0,Math.PI*2),$.fillStyle=X,$.fill(),H&&A)$.strokeStyle=H,$.lineWidth=A,$.stroke();$.restore()}function E0($,Q,K,W){return m($,Q,K,W)}function D7($){if($===void 0||$===null)return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);if(typeof $==="boolean")return $?"true":"false";return""}function U4($,Q,K,W,J,U,V,X,Y,Z){if(J.type!==1)return;if(Q.length===0||Q[0].length===0)return;let{layout:H,paint:A}=W;for(let G of Q)for(let F of G){let N=F.x*K,q=F.y*K,R=E0(H?.["text-field"],U,J,V),I=D7(R),C=E0(H?.["text-size"],U,J,V)??16,M=!!E0(H?.["text-italic"],U,J,V),j=!!E0(H?.["text-bold"],U,J,V),E=E0(A?.["text-color"],U,J,V)??"#000",_=E0(A?.["text-halo-color"],U,J,V),x=E0(A?.["text-halo-width"],U,J,V),n=D7(E0(H?.["icon-image"],U,J,V)),p=E0(H?.["icon-size"],U,J,V),J0=E0(H?.["icon-rotate"],U,J,V),a=n&&Y?Y.get(n):void 0,y=H?.["symbol-priority"],o=N,U0=q,b=N,G0=q,F0=null;if(I){F0=X.measure(I,{italic:M,bold:j});let e=C/24,V0=F0.width*e,Z0=F0.height*e,f0=N-V0/2,G$=q-Z0;if(f0<o)o=f0;if(G$<U0)U0=G$;if(f0+V0>b)b=f0+V0;if(G$+Z0>G0)G0=G$+Z0}if(a){let e=p??a.width,V0=N-e/2,Z0=q-e/2;if(V0<o)o=V0;if(Z0<U0)U0=Z0;if(V0+e>b)b=V0+e;if(Z0+e>G0)G0=Z0+e}if(!I&&!a)continue;if(!Z.tryInsert({minX:o,minY:U0,maxX:b,maxY:G0,priority:y}))continue;if(a&&Y)Y.drawIcon($,n,N,q,{size:p??a.width,rotation:J0});if(I&&F0){let e=C/24,V0=F0.width*e;X.drawText($,I,N-V0/2,q,{color:E,haloColor:_,haloWidth:x,size:C,italic:M,bold:j})}}}function R8($,Q,K){let W=$.filter;if(!W)return!0;if(!Array.isArray(W))return!0;let J=W[0];if(typeof J==="string"&&E9.has(J)&&C9(W))return C8(W,Q);if($._compiledFilter===void 0)try{$._compiledFilter=$8(W,"boolean")}catch{$._compiledFilter=!1}let U=$._compiledFilter;if(!U)return!0;try{let V=U.evaluate({zoom:K,feature:{type:Q.type,id:Q.id,properties:Q.properties}});return Boolean(V)}catch{return!0}}function C9($){let Q=$[0];if(Q==="all"||Q==="any"||Q==="none")return $.slice(1).every((K)=>Array.isArray(K)&&C9(K));for(let K=1;K<$.length;K++){let W=$[K];if(Array.isArray(W)){let J=W[0];if(J!=="get"&&J!=="geometry-type"&&J!=="$type")return!1}}return!0}function C8($,Q){let[K,...W]=$;if(K==="all")return W.every((U)=>C8(U,Q));if(K==="any")return W.some((U)=>C8(U,Q));if(K==="none")return W.every((U)=>!C8(U,Q));if(K==="has"){let U=W[0];return typeof U==="string"&&U in Q.properties}if(K==="!has"){let U=W[0];return typeof U==="string"&&!(U in Q.properties)}let J=h$(W[0],Q);if(K==="=="||K==="!="){let U=h$(W[1],Q);return K==="=="?J===U:J!==U}if(K==="<"||K==="<="||K===">"||K===">="){let U=h$(W[1],Q);if(typeof J!=="number"||typeof U!=="number")return!1;return K==="<"?J<U:K==="<="?J<=U:K===">"?J>U:J>=U}if(K==="in")return W.slice(1).map((V)=>h$(V,Q)).includes(J);if(K==="!in")return!W.slice(1).map((V)=>h$(V,Q)).includes(J);return!0}function h$($,Q){if(Array.isArray($)){if($[0]==="get"&&typeof $[1]==="string")return Q.properties[$[1]]??null;if($[0]==="geometry-type"){let K=Q.type;return K===1?"Point":K===2?"LineString":K===3?"Polygon":"Unknown"}}return $}function V4($){let Q=[];for(let W of Object.keys($.layers)){let J=$.layers[W];for(let U=0;U<J.length;U++){let X=J.feature(U).bbox(),Y=[X[0],X[1],X[2],X[3]];Q.push({bbox:Y,data:{featureIndex:U,sourceLayerName:W,bbox:Y}})}}let K=new v7;return K.load(Q),K}function X4($,Q,K,W,J){if(!W)return null;if(Q){let[[U,V],[X,Y]]=Q,Z=W.containerPointToLayerPoint?.({x:U,y:V})??{x:U,y:V},H=W.containerPointToLayerPoint?.({x:X,y:Y})??{x:X,y:Y},A=Math.min(Z.x,H.x)-K.x*J,G=Math.min(Z.y,H.y)-K.y*J,F=Math.max(Z.x,H.x)-K.x*J,N=Math.max(Z.y,H.y)-K.y*J;if(F<0||N<0||A>J||G>J)return null;let R=4096/J;return{kind:"bbox",px:(A+F)*0.5*R,py:(G+N)*0.5*R,bbox:[A*R,G*R,F*R,N*R],scale:R}}if($){let U=W.containerPointToLayerPoint?.($)??$,V=U.x-K.x*J,X=U.y-K.y*J;if(V<0||X<0||V>J||X>J)return null;let Z=4096/J,H=V*Z,A=X*Z,G=8*Z;return{kind:"point",px:H,py:A,bbox:[H-G,A-G,H+G,A+G],scale:Z}}return null}function Y4($,Q){if($.index)return(Q.kind==="point"?$.index.search(Q.bbox):$.index.search(Q.bbox)).map((J)=>J.data);if(!$.tile)return[];let K=[];for(let W of Object.keys($.tile.layers)){let J=$.tile.layers[W];for(let U=0;U<J.length;U++){let X=J.feature(U).bbox();K.push({featureIndex:U,sourceLayerName:W,bbox:[X[0],X[1],X[2],X[3]]})}}return K}function Z4($,Q,K,W){let J=$.extent/W,U=Q.px*(J/Q.scale),V=Q.py*(J/Q.scale),X=[Q.bbox[0]*(J/Q.scale),Q.bbox[1]*(J/Q.scale),Q.bbox[2]*(J/Q.scale),Q.bbox[3]*(J/Q.scale)],Y=$.loadGeometry();if(Q.kind==="bbox"){if($.type===3){if(I7({x:U,y:V},Y))return!0}for(let Z of Y)for(let H of Z)if(H.x>=X[0]&&H.x<=X[2]&&H.y>=X[1]&&H.y<=X[3])return!0;return!1}if($.type===3)return I7({x:U,y:V},Y);if($.type===2){let H=((K.paint?.["line-width"]??1)/2+4)*J,A=H*H;for(let G of Y)for(let F=1;F<G.length;F++)if(N4({x:U,y:V},G[F-1],G[F])<=A)return!0;return!1}if($.type===1){let H=((K.paint?.["circle-radius"]??4)+2)*J,A=H*H;for(let G of Y)for(let F of G){let N=F.x-U,q=F.y-V;if(N*N+q*q<=A)return!0}return!1}return!1}function I7($,Q){let K=!1;for(let W of Q)for(let J=0,U=W.length-1;J<W.length;U=J++){let V=W[J].x,X=W[J].y,Y=W[U].x,Z=W[U].y;if(X>$.y!==Z>$.y&&$.x<(Y-V)*($.y-X)/(Z-X||1)+V)K=!K}return K}function H4($,Q,K,W,J,U,V){if(Q.length===0)return;let X=m(W?.["fill-color"],J,U,V)??"#000",Y=m(W?.["fill-opacity"],J,U,V)??1,Z=n$(X,Y),H=Q.map((q)=>q.map((R)=>({x:R.x*K,y:R.y*K}))),{vertices:A,holes:G}=Z9(H),F=Y9(A,G,2);if(F.length===0)return;let N=new Float32Array(F.length*2);for(let q=0;q<F.length;q++)N[q*2]=A[F[q]*2],N[q*2+1]=A[F[q]*2+1];$.drawFill(N,Z)}function A4($,Q,K,W,J,U,V){if(Q.length===0)return;let X=m(W?.["fill-extrusion-color"],J,U,V)??"#000",Y=m(W?.["fill-extrusion-opacity"],J,U,V)??1,Z=m(W?.["fill-extrusion-height"],J,U,V)??0,H=m(W?.["fill-extrusion-base"],J,U,V)??0;if(Z<=H)return;let A=n$(X,1),G=Q.map((F)=>F.map((N)=>({x:N.x*K,y:N.y*K})));$.drawFillExtrusion([{rings:G}],[Z*K],[H*K],A,Y)}function G4($,Q,K,W,J,U,V){if(Q.length===0)return;let X=m(W?.["line-color"],J,U,V)??"#000",Y=m(W?.["line-width"],J,U,V)??1,Z=m(W?.["line-opacity"],J,U,V)??1,H=n$(X,Z);for(let A of Q){if(A.length<2)continue;let G=new Float32Array(A.length*2);for(let F=0;F<A.length;F++)G[F*2]=A[F].x*K,G[F*2+1]=A[F].y*K;$.drawLine(G,{width:Y,color:H,cap:W?.["line-cap"],join:W?.["line-join"]})}}function F4($,Q,K,W,J,U,V){if(Q.length===0)return;let X=m(W?.["circle-color"],J,U,V)??"#000",Y=m(W?.["circle-radius"],J,U,V)??4,Z=m(W?.["circle-opacity"],J,U,V)??1,H=m(W?.["circle-stroke-color"],J,U,V),A=m(W?.["circle-stroke-width"],J,U,V)??0,G=n$(X,Z),F=H?n$(H,Z):void 0,N=0;for(let I of Q)N+=I.length;if(N===0)return;let q=new Float32Array(N*2),R=0;for(let I of Q)for(let C of I)q[R++]=C.x*K,q[R++]=C.y*K;$.drawCircles(q,{radius:Y,color:G,strokeColor:F,strokeWidth:A})}function n$($,Q){let K=$.trim();if(K.charAt(0)==="#"){let J=K.slice(1);if(J.length===3){let U=Number.parseInt(J[0]+J[0],16)/255,V=Number.parseInt(J[1]+J[1],16)/255,X=Number.parseInt(J[2]+J[2],16)/255;return[U,V,X,Q]}if(J.length===4){let U=Number.parseInt(J[0]+J[0],16)/255,V=Number.parseInt(J[1]+J[1],16)/255,X=Number.parseInt(J[2]+J[2],16)/255,Y=Number.parseInt(J[3]+J[3],16)/255;return[U,V,X,Y*Q]}if(J.length===6){let U=Number.parseInt(J.slice(0,2),16)/255,V=Number.parseInt(J.slice(2,4),16)/255,X=Number.parseInt(J.slice(4,6),16)/255;return[U,V,X,Q]}if(J.length===8){let U=Number.parseInt(J.slice(0,2),16)/255,V=Number.parseInt(J.slice(2,4),16)/255,X=Number.parseInt(J.slice(4,6),16)/255,Y=Number.parseInt(J.slice(6,8),16)/255;return[U,V,X,Y*Q]}}let W=/^rgba?\(([^)]+)\)/i.exec(K);if(W){let J=W[1].split(",").map((Z)=>Z.trim()),U=Number.parseFloat(J[0]??"0")/255,V=Number.parseFloat(J[1]??"0")/255,X=Number.parseFloat(J[2]??"0")/255,Y=J.length>3?Number.parseFloat(J[3]??"1"):1;return[U,V,X,Y*Q]}return[0,0,0,Q]}function N4($,Q,K){let W=K.x-Q.x,J=K.y-Q.y,U=0;if(W!==0||J!==0){if(U=(($.x-Q.x)*W+($.y-Q.y)*J)/(W*W+J*J),U>1)U=1;else if(U<0)U=0}let V=Q.x+U*W-$.x,X=Q.y+U*J-$.y;return V*V+X*X}var s$,O9,E9,B9=k(()=>{W9(),uW(),sW(),P8(),sQ(),aQ(),oQ(),Q4(),s$=class extends T${initialize(Q){super.initialize(Q),this._styleLayers=this.options.layers??[],this._decodedTiles=new Map,this._glyphAtlas=this.options.glyphAtlas,this._iconAtlas=this.options.iconAtlas;let K=this.options.offlineCache;if(K instanceof S8)this._offlineCache=K;else if(K===!0)this._offlineCache=j$();if(typeof this.options.subdomains==="string")this.options.subdomains=this.options.subdomains.split("")}getGlyphAtlas(){if(!this._glyphAtlas)this._glyphAtlas=new I9;return this._glyphAtlas}getIconAtlas(){if(!this._iconAtlas)this._iconAtlas=new j9;return this._iconAtlas}setFeatureStateLookup(Q){return this._featureStateLookup=Q,this}setSourceId(Q){return this._sourceId=Q,this}_repaintDecodedTiles(){for(let Q of this._decodedTiles.values()){if(!Q.tile)continue;if(Q.gl)Q.gl.clear();else{let K=Q.canvas.getContext("2d");if(!K)continue;K.clearRect(0,0,Q.canvas.width,Q.canvas.height)}try{this._drawTile(Q.canvas,Q.tile,{x:Q.coords.x,y:Q.coords.y,z:Q.coords.z})}catch{}}}setStyleLayers(Q){return this._styleLayers=Q,this.redraw(),this}getStyleLayer(Q){for(let K of this._styleLayers)if(K.id===Q)return K;return}queryRenderedFeatures(Q,K){let W,J,U;if(Q&&typeof Q.x==="number"&&typeof Q.y==="number")W=Q,U=K;else if(U=Q,U?.bbox)J=U.bbox;else if(U?.point){let H=U.point;W=Array.isArray(H)?{x:H[0],y:H[1]}:H}let V=U?.layers,X=[],Y=this.getTileSize().x,Z=this._map?.getZoom?.()??0;for(let H of this._decodedTiles.values()){if(!H.tile)continue;if(W===void 0&&J===void 0){for(let F of this._styleLayers){if(V&&!V.includes(F.id))continue;if(F.layout?.visibility==="none")continue;let N=H.tile.layers[F.sourceLayer];if(!N)continue;for(let q=0;q<N.length;q++){let R=N.feature(q);if(!R8(F,R,Z))continue;X.push({feature:R,layer:F,tile:H.coords})}}continue}let A=X4(W,J,H.coords,this._map,Y);if(!A)continue;let G=Y4(H,A);if(G.length===0)continue;for(let F of this._styleLayers){if(V&&!V.includes(F.id))continue;if(F.layout?.visibility==="none")continue;let N=H.tile.layers[F.sourceLayer];if(!N)continue;let q=new Set;for(let R of G){if(R.sourceLayerName!==F.sourceLayer)continue;if(q.has(R.featureIndex))continue;q.add(R.featureIndex);let I=N.feature(R.featureIndex);if(!R8(F,I,Z))continue;if(Z4(I,A,F,Y))X.push({feature:I,layer:F,tile:H.coords})}}}return X}querySourceFeatures(Q={}){let K=[],W=Q.sourceLayer,J=this._map?.getZoom?.()??0,U=Q.filter===void 0?null:{id:"_query",type:"fill",sourceLayer:"",filter:Q.filter},V=new Set;for(let X of this._decodedTiles.values()){if(!X.tile)continue;for(let[Y,Z]of Object.entries(X.tile.layers)){if(W&&Y!==W)continue;for(let H=0;H<Z.length;H++){let A=Z.feature(H);if(U&&!R8(U,A,J))continue;let G=A.id;if(G!==void 0){let F=`${Y}|${typeof G}|${G}`;if(V.has(F))continue;V.add(F)}K.push({feature:A,sourceLayer:Y,tile:X.coords})}}}return K}createTile(Q,K){let W=this.getTileSize(),J=document.createElement("canvas");J.width=W.x,J.height=W.y,J.setAttribute("role","presentation");let U=new AbortController,V={canvas:J,tile:null,coords:{x:Q.x,y:Q.y,z:Q.z},abort:U,index:null,gl:null};this._decodedTiles.set(J,V);let X=this.getTileUrl(Q);return this._fetchAndDraw(X,J,V,Q,K).catch((Y)=>{K(Y,J)}),J}onRemove(Q){for(let K of this._decodedTiles.values())K.abort.abort(),K.gl?.destroy();this._decodedTiles.clear(),super.onRemove(Q)}_removeTile(Q){let K=this._tiles?.[Q];if(K){let W=this._decodedTiles.get(K.el);if(W)W.abort.abort(),W.gl?.destroy(),this._decodedTiles.delete(K.el)}super._removeTile(Q)}getTileUrl(Q){let K=Object.create(this.options);return K.s=eW(Q,this.options.subdomains??"abc"),K.x=Q.x,K.y=Q.y,K.z=this._getZoomForUrl(Q.z),K.r="",$4(this.options.url,K)}_getZoomForUrl(Q){return Q}async _fetchAndDraw(Q,K,W,J,U){let V;try{V=await this._fetchTileBytes(Q,W)}catch(Y){U(Y,K);return}if(W.abort.signal.aborted){U(new DOMException("aborted","AbortError"),K);return}let X;try{let Y=new N9(V);X=new M9(Y)}catch(Y){U(Y,K);return}W.tile=X,W.index=V4(X);try{this._drawTile(K,X,J)}catch(Y){U(Y,K);return}U(null,K)}async _fetchTileBytes(Q,K){if(this._offlineCache)return(await PQ(Q,{cache:this._offlineCache,signal:K.abort.signal})).data;let W={signal:K.abort.signal};if(this.options.crossOrigin===!0)W.credentials="same-origin";else if(typeof this.options.crossOrigin==="string")W.credentials="include";let J=await fetch(Q,W);if(!J.ok)throw Error(`HTTP ${J.status} fetching ${Q}`);return new Uint8Array(await J.arrayBuffer())}_drawTile(Q,K,W){let J=this.getTileSize().x,U=this._map?.getZoom?.()??W.z,V=this._sourceId??"",X=this._featureStateLookup,Y=this.options.renderer==="webgl",Z=this._decodedTiles.get(Q),H=Z?.gl??null;if(Y&&Z&&!H)try{H=new rQ(Q),Z.gl=H;let F=R7(0,J,J,0,-1,1);H.setProjectionMatrix(F)}catch(F){if(H=null,F instanceof nQ){if(!this._webglFallbackWarned)this._webglFallbackWarned=!0,console.warn("[ts-maps] WebGL2 unavailable; VectorTileMapLayer falling back to Canvas2D.")}else if(!this._webglFallbackWarned)this._webglFallbackWarned=!0,console.warn("[ts-maps] WebGL initialization failed; falling back to Canvas2D.",F)}let A=H?null:Q.getContext("2d");if(!H&&!A)return;if(H)H.clear();let G=null;for(let F of this._styleLayers){if(F.layout?.visibility==="none")continue;if(F.minzoom!==void 0&&U<F.minzoom)continue;if(F.maxzoom!==void 0&&U>F.maxzoom)continue;let N=K.layers[F.sourceLayer];if(!N)continue;let q=F.paint,R=q&&q["line-dasharray"]?m(q["line-dasharray"],U,void 0,void 0):void 0,I=null;if(F.type==="line"&&q&&q["line-gradient"]!==void 0)try{I=$8(q["line-gradient"],"color")}catch{I=null}for(let C=0;C<N.length;C++){let M=N.feature(C);if(!R8(F,M,U))continue;let j=M.loadGeometry(),E=J/M.extent,_;if(X&&M.id!==void 0)_=X(V,F.sourceLayer,M.id);if(F.type==="fill"){if(H)H4(H,j,E,q,U,M,_);else if(A)M7(A,j,E,q,U,M,_)}else if(F.type==="fill-extrusion"){if(H)A4(H,j,E,q,U,M,_);else if(A)M7(A,j,E,q,U,M,_)}else if(F.type==="line"){if(H)G4(H,j,E,q,U,M,_);else if(A)W4(A,j,E,q,U,M,_,R,I)}else if(F.type==="circle"){if(H)F4(H,j,E,q,U,M,_);else if(A)J4(A,j,E,q,U,M,_)}else if(F.type==="symbol"){if(!A)continue;if(!G)G=new D9({width:J,height:J});U4(A,j,E,F,M,U,_,this.getGlyphAtlas(),this._iconAtlas,G)}}}if(H&&this._map){let F=R7(0,J,J,0,-1,1),N=this._map;if(typeof N._drawTerrainForTile==="function")N._drawTerrainForTile(H,W,J,F);if(typeof N._invokeCustomLayerRender==="function")N._invokeCustomLayerRender(H.ctx.gl,F)}}},s$.setDefaultOptions({url:"",tileSize:512,subdomains:"abc",minZoom:0,maxZoom:22,crossOrigin:!1,layers:[],sources:void 0}),O9=[0,0.25,0.5,0.75,1],E9=new Set(["all","any","none","has","!has","in","!in","==","!=","<","<=",">",">="])});function k9($,Q){return new L($,Q)}async function q4($,Q){if(typeof fetch!=="function"||typeof Image!=="function"||typeof document?.createElement!=="function")return null;try{let K=await fetch($);if(!K.ok)return null;let W=await K.blob(),J=await new Promise((Y,Z)=>{let H=new Image;H.crossOrigin="anonymous",H.onload=()=>Y(H),H.onerror=Z,H.src=URL.createObjectURL(W)}),U=document.createElement("canvas");U.width=Q,U.height=Q;let V=U.getContext("2d");if(!V)return null;V.drawImage(J,0,0,Q,Q);let X=V.getImageData(0,0,Q,Q).data;return new Uint8Array(X.buffer,X.byteOffset,X.byteLength)}catch{return null}}var L,R4,$0=k(()=>{e0(),f(),i(),Z$(),r(),B$(),t7(),e7(),g7(),Y0(),A0(),W0(),l(),n5(),P8(),x7(),u7(),aQ(),L=class $ extends R0{static _pointerEvents=["click","dblclick","pointerover","pointerout","contextmenu"];_sizeChanged=!0;_initControlPos;_clearControlPos;_addLayers;initialize(Q,K){if(K=t(this,K),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._bearing=typeof K.bearing==="number"?(K.bearing%360+360)%360:0,this._pitch=typeof K.pitch==="number"?this._clampPitch(K.pitch):0,this._initContainer(Q),this._initLayout(),this._initEvents(),this._wireTerrainCameraHooks(),K.maxBounds)this.setMaxBounds(K.maxBounds);if(K.zoom!==void 0)this._zoom=this._limitZoom(K.zoom);if(K.center&&K.zoom!==void 0)this.setView(new O(K.center),K.zoom,{reset:!0});if(this._bearing||this._pitch)this._applyCameraTransform();if(this.callInitHooks(),this._zoomAnimated=this.options.zoomAnimation,this._zoomAnimated)this._createAnimProxy();this._addLayers?.(this.options.layers)}setView(Q,K,W){if(K=K===void 0?this._zoom:this._limitZoom(K),Q=this._limitCenter(new O(Q),K,this.options.maxBounds),W??={},this._stop(),this._loaded&&!W.reset&&W!==!0){if(W.animate!==void 0)W.zoom={animate:W.animate,...W.zoom},W.pan={animate:W.animate,duration:W.duration,...W.pan};if(this._zoom!==K?this._tryAnimatedZoom&&this._tryAnimatedZoom(Q,K,W.zoom):this._tryAnimatedPan(Q,W.pan))return clearTimeout(this._sizeTimer),this}return this._resetView(Q,K,W.pan?.noMoveStart),this}setZoom(Q,K){if(!this._loaded)return this._zoom=Q,this;return this.setView(this.getCenter(),Q,{zoom:K})}zoomIn(Q,K){return Q??=this.options.zoomDelta,this.setZoom(this._zoom+Q,K)}zoomOut(Q,K){return Q??=this.options.zoomDelta,this.setZoom(this._zoom-Q,K)}setZoomAround(Q,K,W){let J=this.getZoomScale(K),U=this.getSize().divideBy(2),X=(Q instanceof D?Q:this.latLngToContainerPoint(Q)).subtract(U).multiplyBy(1-1/J),Y=this.containerPointToLatLng(U.add(X));return this.setView(Y,K,{zoom:W})}_getBoundsCenterZoom(Q,K){K??={},Q=Q.getBounds?Q.getBounds():new z(Q);let W=new D(K.paddingTopLeft||K.padding||[0,0]),J=new D(K.paddingBottomRight||K.padding||[0,0]),U=this.getBoundsZoom(Q,!1,W.add(J));if(U=typeof K.maxZoom==="number"?Math.min(K.maxZoom,U):U,U===1/0)return{center:Q.getCenter(),zoom:U};let V=J.subtract(W).divideBy(2),X=this.project(Q.getSouthWest(),U),Y=this.project(Q.getNorthEast(),U);return{center:this.unproject(X.add(Y).divideBy(2).add(V),U),zoom:U}}fitBounds(Q,K){let W=new z(Q);if(!W.isValid())throw Error("Bounds are not valid.");let J=this._getBoundsCenterZoom(W,K);return this.setView(J.center,J.zoom,K)}fitWorld(Q){return this.fitBounds([[-90,-180],[90,180]],Q)}panTo(Q,K){return this.setView(Q,this._zoom,{pan:K})}panBy(Q,K){if(Q=new D(Q).round(),K??={},!Q.x&&!Q.y)return this.fire("moveend");if(K.animate!==!0&&!this.getSize().contains(Q))return this._resetView(this.unproject(this.project(this.getCenter()).add(Q)),this.getZoom()),this;if(!this._panAnim)this._panAnim=new iQ,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this);if(!K.noMoveStart)this.fire("movestart");if(K.animate!==!1){this._mapPane.classList.add("tsmap-pan-anim");let W=this._getMapPanePos().subtract(Q).round();this._panAnim.run(this._mapPane,W,K.duration||0.25,K.easeLinearity)}else this._rawPanBy(Q),this.fire("move").fire("moveend");return this}flyTo(Q,K,W){if(W??={},W.animate===!1)return this.setView(Q,K,W);this._stop();let J=this.project(this.getCenter()),U=this.project(Q),V=this.getSize(),X=this._zoom,Y=this._bearing,Z=this._pitch;Q=new O(Q);let H=K===void 0?X:this._limitZoom(K),A=typeof W.bearing==="number"?(W.bearing%360+360)%360:Y,G=typeof W.pitch==="number"?this._clampPitch(W.pitch):Z,F=Math.max(V.x,V.y),N=F*this.getZoomScale(X,H),q=U.distanceTo(J)||1,R=1.42,I=R*R;function C(b){let G0=b?-1:1,F0=b?N:F,e=N*N-F*F+G0*I*I*q*q,V0=2*F0*I*q,Z0=e/V0,f0=Math.sqrt(Z0*Z0+1)-Z0;return f0<0.000000015?-18:Math.log(f0)}function M(b){return(Math.exp(b)-Math.exp(-b))/2}function j(b){return(Math.exp(b)+Math.exp(-b))/2}function E(b){return M(b)/j(b)}let _=C(0);function x(b){return F*(j(_)/j(_+R*b))}function n(b){return F*(j(_)*E(_+R*b)-M(_))/I}let p=(C(1)-_)/R,J0=W.duration?W.duration:1000*p*0.8,a=this._getCamAnim(),y=Math.abs((A-Y+540)%360-180)>0.000001,o=Math.abs(G-Z)>0.000001,U0=Math.abs(H-X)>0.000001;if(this._moveStart(!0,W.noMoveStart),y)this.fire("rotatestart",{bearing:Y});if(o)this.fire("pitchstart",{pitch:Z});return a.run({duration:J0,easing:(b)=>1-(1-b)**1.5,onFrame:({t:b})=>{let G0=b*p,F0=this.unproject(J.add(U.subtract(J).multiplyBy(n(G0)/q)),X),e=this.getScaleZoom(F/x(G0),X);if(y)this._bearing=$._lerpBearing(Y,A,b);if(o)this._pitch=Z+(G-Z)*b;if(this._move(F0,e,{flyTo:!0}),y||o)this._applyCameraTransform();if(y)this.fire("rotate",{bearing:this._bearing});if(o)this.fire("pitch",{pitch:this._pitch})},onEnd:(b)=>{if(b){if(y)this._bearing=A;if(o)this._pitch=G;if(this._move(Q,H),y||o)this._applyCameraTransform();if(this._moveEnd(U0),y)this.fire("rotateend",{bearing:A});if(o)this.fire("pitchend",{pitch:G})}else{if(this._moveEnd(U0),y)this.fire("rotateend",{bearing:this._bearing});if(o)this.fire("pitchend",{pitch:this._pitch})}}}),this}flyToBounds(Q,K){let W=this._getBoundsCenterZoom(Q,K);return this.flyTo(W.center,W.zoom,K)}setMaxBounds(Q){let K=new z(Q);if(this.listens("moveend",this._panInsideMaxBounds))this.off("moveend",this._panInsideMaxBounds);if(!K.isValid())return this.options.maxBounds=null,this;if(this.options.maxBounds=K,this._loaded)this._panInsideMaxBounds();return this.on("moveend",this._panInsideMaxBounds,this)}setMinZoom(Q){let K=this.options.minZoom;if(this.options.minZoom=Q,this._loaded&&K!==Q){if(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)return this.setZoom(Q)}return this}setMaxZoom(Q){let K=this.options.maxZoom;if(this.options.maxZoom=Q,this._loaded&&K!==Q){if(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)return this.setZoom(Q)}return this}panInsideBounds(Q,K){this._enforcingBounds=!0;let W=this.getCenter(),J=this._limitCenter(W,this._zoom,new z(Q));if(!W.equals(J))this.panTo(J,K);return this._enforcingBounds=!1,this}panInside(Q,K){K??={};let W=new D(K.paddingTopLeft||K.padding||[0,0]),J=new D(K.paddingBottomRight||K.padding||[0,0]),U=this.project(this.getCenter()),V=this.project(Q),X=this.getPixelBounds(),Y=new P([X.min.add(W),X.max.subtract(J)]),Z=Y.getSize();if(!Y.contains(V)){this._enforcingBounds=!0;let H=V.subtract(Y.getCenter()),A=Y.extend(V).getSize().subtract(Z);U.x+=H.x<0?-A.x:A.x,U.y+=H.y<0?-A.y:A.y,this.panTo(this.unproject(U),K),this._enforcingBounds=!1}return this}invalidateSize(Q){if(!this._loaded)return this;Q={animate:!1,pan:!0,...Q===!0?{animate:!0}:Q};let K=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let W=this.getSize(),J=K.divideBy(2).round(),U=W.divideBy(2).round(),V=J.subtract(U);if(!V.x&&!V.y)return this;if(Q.animate&&Q.pan)this.panBy(V);else{if(Q.pan)this._rawPanBy(V);if(this.fire("move"),Q.debounceMoveend)clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,"moveend"),200);else this.fire("moveend")}if(this._bearing||this._pitch)this._applyCameraTransform();return this.fire("resize",{oldSize:K,newSize:W})}stop(){if(this.setZoom(this._limitZoom(this._zoom)),!this.options.zoomSnap)this.fire("viewreset");return this._stop()}locate(Q){let K=this._locateOptions={timeout:1e4,watch:!1,...Q};if(!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;let W=this._handleGeolocationResponse.bind(this),J=this._handleGeolocationError.bind(this);if(K.watch){if(this._locationWatchId!==void 0)navigator.geolocation.clearWatch(this._locationWatchId);this._locationWatchId=navigator.geolocation.watchPosition(W,J,K)}else navigator.geolocation.getCurrentPosition(W,J,K);return this}stopLocate(){if(navigator.geolocation?.clearWatch?.(this._locationWatchId),this._locateOptions)this._locateOptions.setView=!1;return this}_handleGeolocationError(Q){if(!this._container._tsmap_id)return;let K=Q.code,W=Q.message||(K===1?"permission denied":K===2?"position unavailable":"timeout");if(this._locateOptions.setView&&!this._loaded)this.fitWorld();this.fire("locationerror",{code:K,message:`Geolocation error: ${W}.`})}_handleGeolocationResponse(Q){if(!this._container._tsmap_id)return;let K=Q.coords.latitude,W=Q.coords.longitude,J=new O(K,W),U=J.toBounds(Q.coords.accuracy*2),V=this._locateOptions;if(V.setView){let Y=this.getBoundsZoom(U);this.setView(J,V.maxZoom?Math.min(Y,V.maxZoom):Y)}let X={latlng:J,bounds:U,timestamp:Q.timestamp};for(let Y in Q.coords)if(typeof Q.coords[Y]==="number")X[Y]=Q.coords[Y];this.fire("locationfound",X)}addHandler(Q,K){if(!K)return this;let W=this[Q]=new K(this);if(this._handlers.push(W),this.options[Q])W.enable();return this}remove(){if(this._initEvents(!0),this.options.maxBounds)this.off("moveend",this._panInsideMaxBounds);if(this._containerId!==this._container._tsmap_id)throw Error("Map container is being reused by another instance");if(delete this._container._tsmap_id,delete this._containerId,this._locationWatchId!==void 0)this.stopLocate();if(this._stop(),c7(this._container),this._mapPane.remove(),this._clearControlPos)this._clearControlPos();if(this._resizeRequest)cancelAnimationFrame(this._resizeRequest),this._resizeRequest=null;if(this._clearHandlers(),clearTimeout(this._transitionEndTimer),clearTimeout(this._sizeTimer),this._loaded)this.fire("unload");this._destroyAnimProxy();for(let Q of Object.values(this._layers))Q.remove();for(let Q of Object.values(this._panes))Q.remove();if(this._layers={},this._panes={},delete this._mapPane,delete this._renderer,this._destroyTerrainOverlay(),this._atmosphereOverlay&&this._atmosphereOverlay.parentNode)this._atmosphereOverlay.parentNode.removeChild(this._atmosphereOverlay);if(this._atmosphereOverlay=void 0,this._terrainSource?.clear(),this._terrainFetchInFlight?.clear(),this._offlineApi)delete this._offlineApi;return this}createPane(Q,K){let W=`tsmap-pane${Q?` tsmap-${Q.replace("Pane","")}-pane`:""}`,J=v("div",W,K||this._mapPane);if(Q)this._panes[Q]=J;return J}getCenter(){if(this._checkIfLoaded(),this._lastCenter&&!this._moved())return this._lastCenter.clone();return this.layerPointToLatLng(this._getCenterLayerPoint())}getZoom(){return this._zoom}getBearing(){return this._bearing}setBearing(Q){let K=(Q%360+360)%360;if(K===this._bearing)return this;return this.fire("rotatestart",{bearing:this._bearing}),this._bearing=K,this._applyCameraTransform(),this.fire("rotate",{bearing:K}),this.fire("rotateend",{bearing:K}),this}rotateTo(Q,K){if(!K?.animate)return this.setBearing(Q);return this.easeTo({bearing:Q,duration:K.duration??300,easing:K.easing})}getPitch(){return this._pitch}setPitch(Q){let K=this._clampPitch(Q);if(K===this._pitch)return this;if(this.fire("pitchstart",{pitch:this._pitch}),this._pitch=K,this._applyCameraTransform(),this._atmosphereOverlay)this._updateAtmosphereOverlay();return this.fire("pitch",{pitch:K}),this.fire("pitchend",{pitch:K}),this}pitchTo(Q,K){if(!K?.animate)return this.setPitch(Q);return this.easeTo({pitch:Q,duration:K.duration??300,easing:K.easing})}_clampPitch(Q){let K=this.options.minPitch??0,W=this.options.maxPitch??60;return Math.max(K,Math.min(W,Q))}easeTo(Q={}){this._stop();let K=this.getCenter(),W=this._zoom,J=this._bearing,U=this._pitch,V=Q.center!==void 0?new O(Q.center):K,X=Q.zoom!==void 0?this._limitZoom(Q.zoom):W,Y=typeof Q.bearing==="number"?(Q.bearing%360+360)%360:J,Z=typeof Q.pitch==="number"?this._clampPitch(Q.pitch):U,H=Q.duration??300,A=!K.equals(V),G=Math.abs(X-W)>0.000000001,F=(Y-J+540)%360-180,N=Math.abs(F)>0.000000001,q=Math.abs(Z-U)>0.000000001;if(!A&&!G&&!N&&!q){if(!Q.noMoveStart)this.fire("movestart");return this.fire("moveend"),this}let R=this.project(K,W),I=this.project(V,W);if(H<=0){if(!Q.noMoveStart)this._moveStart(G,!1);if(N)this.fire("rotatestart",{bearing:J});if(q)this.fire("pitchstart",{pitch:U});if(this._bearing=Y,this._pitch=Z,this._move(V,X),N||q)this._applyCameraTransform();if(this._moveEnd(G),N)this.fire("rotate",{bearing:Y}),this.fire("rotateend",{bearing:Y});if(q)this.fire("pitch",{pitch:Z}),this.fire("pitchend",{pitch:Z});return this}let C=this._getCamAnim();if(!Q.noMoveStart)this._moveStart(G,!1);if(N)this.fire("rotatestart",{bearing:J});if(q)this.fire("pitchstart",{pitch:U});return C.run({duration:H,easing:Q.easing,onFrame:({t:M})=>{let j=W+(X-W)*M,E=R.add(I.subtract(R).multiplyBy(M)),_=this.unproject(E,W);if(N)this._bearing=$._lerpBearing(J,Y,M);if(q)this._pitch=U+(Z-U)*M;if(this._move(_,j,{easeTo:!0}),N||q)this._applyCameraTransform();if(N)this.fire("rotate",{bearing:this._bearing});if(q)this.fire("pitch",{pitch:this._pitch})},onEnd:(M)=>{if(M){if(N)this._bearing=Y;if(q)this._pitch=Z;if(this._move(V,X),N||q)this._applyCameraTransform();if(this._moveEnd(G),N)this.fire("rotateend",{bearing:Y});if(q)this.fire("pitchend",{pitch:Z})}else{if(this._moveEnd(G),N)this.fire("rotateend",{bearing:this._bearing});if(q)this.fire("pitchend",{pitch:this._pitch})}}}),this}isEasing(){return!!this._camAnim?.isRunning()}getCamera(){return{center:this.getCenter(),zoom:this.getZoom(),bearing:this.getBearing(),pitch:this.getPitch()}}jumpTo(Q={}){this._stop();let K=this.getCenter(),W=this._zoom,J=this._bearing,U=this._pitch;if(Q.bearing!==void 0){let V=(Q.bearing%360+360)%360;if(V!==J)this._bearing=V,this.fire("rotate")}if(Q.pitch!==void 0){let V=this._clampPitch(Q.pitch);if(V!==U)this._pitch=V,this.fire("pitch")}if(Q.center!==void 0||Q.zoom!==void 0){let V=Q.center!==void 0?new O(Q.center):K,X=Q.zoom!==void 0?this._limitZoom(Q.zoom):W;if(!V.equals(K)||X!==W)this._move(V,X)}return this._applyCameraTransform(),this}_getCamAnim(){if(!this._camAnim)this._camAnim=new pQ;return this._camAnim}static _lerpBearing(Q,K,W){let J=(K-Q+540)%360-180;return((Q+J*W)%360+360)%360}getBounds(){let Q=this.getPixelBounds(),K=this.unproject(Q.getBottomLeft()),W=this.unproject(Q.getTopRight());return new z(K,W)}getMinZoom(){return this.options.minZoom??this._layersMinZoom??0}getMaxZoom(){return this.options.maxZoom??this._layersMaxZoom??1/0}getBoundsZoom(Q,K,W){let J=new z(Q),U=new D(W??[0,0]),V=this.getZoom()??0,X=this.getMinZoom(),Y=this.getMaxZoom(),Z=J.getNorthWest(),H=J.getSouthEast(),A=this.getSize().subtract(U),G=new P(this.project(H,V),this.project(Z,V)).getSize(),F=this.options.zoomSnap,N=A.x/G.x,q=A.y/G.y,R=K?Math.max(N,q):Math.min(N,q);if(V=this.getScaleZoom(R,V),F)V=Math.round(V/(F/100))*(F/100),V=K?Math.ceil(V/F)*F:Math.floor(V/F)*F;return Math.max(X,Math.min(Y,V))}getSize(){if(!this._size||this._sizeChanged)this._size=new D(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1;return this._size.clone()}getPixelBounds(Q,K){let W=this._getTopLeftPoint(Q,K);return new P(W,W.add(this.getSize()))}getPixelOrigin(){return this._checkIfLoaded(),this._pixelOrigin}getPixelWorldBounds(Q){return this.options.crs.getProjectedBounds(Q??this.getZoom())}getPane(Q){return typeof Q==="string"?this._panes[Q]:Q}getPanes(){return this._panes}getContainer(){return this._container}getZoomScale(Q,K){let W=this.options.crs;return K??=this._zoom,W.scale(Q)/W.scale(K)}getScaleZoom(Q,K){let W=this.options.crs;K??=this._zoom;let J=W.zoom(Q*W.scale(K));return Number.isNaN(J)?1/0:J}project(Q,K){return K??=this._zoom,this.options.crs.latLngToPoint(new O(Q),K)}unproject(Q,K){return K??=this._zoom,this.options.crs.pointToLatLng(new D(Q),K)}layerPointToLatLng(Q){let K=new D(Q).add(this.getPixelOrigin());return this.unproject(K)}latLngToLayerPoint(Q){return this.project(new O(Q))._round()._subtract(this.getPixelOrigin())}wrapLatLng(Q){return this.options.crs.wrapLatLng(new O(Q))}wrapLatLngBounds(Q){return this.options.crs.wrapLatLngBounds(new z(Q))}distance(Q,K){return this.options.crs.distance(new O(Q),new O(K))}containerPointToLayerPoint(Q){let K=new D(Q);if(!this._bearing&&!this._pitch)return K.subtract(this._getMapPanePos());let W=this.getSize()._divideBy(2),J=K.subtract(this._getMapPanePos())._subtract(W);if(this._pitch)J=this._unpitchPoint(J);if(this._bearing)J=this._rotatePoint(J,-this._bearing,new D(0,0));return J._add(W)}layerPointToContainerPoint(Q){let K=new D(Q);if(!this._bearing&&!this._pitch)return K.add(this._getMapPanePos());let W=this.getSize()._divideBy(2),J=K.subtract(W);if(this._bearing)J=this._rotatePoint(J,this._bearing,new D(0,0));if(this._pitch)J=this._pitchPoint(J);return J._add(W)._add(this._getMapPanePos())}containerPointToLatLng(Q){let K=this.containerPointToLayerPoint(new D(Q));return this.layerPointToLatLng(K)}latLngToContainerPoint(Q){return this.layerPointToContainerPoint(this.latLngToLayerPoint(new O(Q)))}pointerEventToContainerPoint(Q){return r7(Q,this._container)}pointerEventToLayerPoint(Q){return this.containerPointToLayerPoint(this.pointerEventToContainerPoint(Q))}pointerEventToLatLng(Q){return this.layerPointToLatLng(this.pointerEventToLayerPoint(Q))}_initContainer(Q){let K=this._container=i7(Q);if(!K)throw Error("Map container not found.");else if(K._tsmap_id)throw Error("Map container is already initialized.");d7(K),B(K,"scroll",this._onScroll,this),this._containerId=u(K)}_initLayout(){let Q=this._container;this._fadeAnimated=this.options.fadeAnimation;let K=["tsmap-container","tsmap-touch"];if(X0.retina)K.push("tsmap-retina");if(X0.safari)K.push("tsmap-safari");if(this._fadeAnimated)K.push("tsmap-fade-anim");Q.classList.add(...K);let{position:W}=getComputedStyle(Q);if(W!=="absolute"&&W!=="relative"&&W!=="fixed"&&W!=="sticky")Q.style.position="relative";if(this._initPanes(),this._initControlPos)this._initControlPos()}_initPanes(){let Q=this._panes={};if(this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),K0(this._mapPane,new D(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),!this.options.markerZoomAnimation)Q.markerPane.classList.add("tsmap-zoom-hide"),Q.shadowPane.classList.add("tsmap-zoom-hide")}_resetView(Q,K,W){K0(this._mapPane,new D(0,0));let J=!this._loaded;this._loaded=!0,K=this._limitZoom(K),this.fire("viewprereset");let U=this._zoom!==K;if(this._moveStart(U,W)._move(Q,K)._moveEnd(U),this.fire("viewreset"),J)this.fire("load")}_moveStart(Q,K){if(Q)this.fire("zoomstart");if(!K)this.fire("movestart");return this}_move(Q,K,W,J){if(K===void 0)K=this._zoom;let U=this._zoom!==K;if(this._zoom=K,this._lastCenter=Q,this._pixelOrigin=this._getNewPixelOrigin(Q),!J){if(U||W?.pinch)this.fire("zoom",W);this.fire("move",W)}else if(W?.pinch)this.fire("zoom",W);return this}_moveEnd(Q){if(Q)this.fire("zoomend");return this.fire("moveend")}_stop(){if(this._flyToFrame!==void 0)cancelAnimationFrame(this._flyToFrame);return this._panAnim?.stop(),this._camAnim?.stop(),this}_rawPanBy(Q){K0(this._mapPane,this._getMapPanePos().subtract(Q))}_getZoomSpan(){return this.getMaxZoom()-this.getMinZoom()}_panInsideMaxBounds(){if(!this._enforcingBounds)this.panInsideBounds(this.options.maxBounds)}_checkIfLoaded(){if(!this._loaded)throw Error("Set map center and zoom first.")}_initEvents(Q){if(this._targets={},this._targets[u(this._container)]=this,(Q?h:B)(this._container,"click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize)if(!Q){if(!this._resizeObserver)this._resizeObserver=new ResizeObserver(this._onResize.bind(this));this._resizeObserver.observe(this._container)}else this._resizeObserver?.disconnect();if(this.options.transform3DLimit)(Q?this.off:this.on).call(this,"moveend",this._onMoveEnd)}_onResize(){if(this._resizeRequest!==void 0&&this._resizeRequest!==null)cancelAnimationFrame(this._resizeRequest);this._resizeRequest=requestAnimationFrame(()=>{this.invalidateSize({debounceMoveend:!0})})}_onScroll(){this._container.scrollTop=0,this._container.scrollLeft=0}_onMoveEnd(){let Q=this._getMapPanePos();if(Math.max(Math.abs(Q.x),Math.abs(Q.y))>=this.options.transform3DLimit)this._resetView(this.getCenter(),this.getZoom())}_findEventTargets(Q,K){let W=[],J,U=Q.target||Q.srcElement,V=!1,X=K==="pointerout"||K==="pointerover";while(U){if(J=this._targets[u(U)],J&&(K==="click"||K==="preclick")&&this._draggableMoved(J)){V=!0;break}if(J&&J.listens(K,!0)){if(X&&!lQ(U,Q))break;if(W.push(J),X)break}if(U===this._container)break;U=U.parentNode}if(!W.length&&!V&&!X&&this.listens(K,!0))W=[this];return W}_isClickDisabled(Q){while(Q&&Q!==this._container){if(Q._tsmap_disable_click||!Q.parentNode)return!0;Q=Q.parentNode}}_handleDOMEvent(Q){let K=Q.target??Q.srcElement;if(!this._loaded||K._tsmap_disable_events||Q.type==="click"&&this._isClickDisabled(K))return;let W=Q.type;if(W==="pointerdown")gQ(K);this._fireDOMEvent(Q,W)}_fireDOMEvent(Q,K,W){if(K==="click")this._fireDOMEvent(Q,"preclick",W);let J=this._findEventTargets(Q,K);if(W)J=W.filter((Y)=>Y.listens(K,!0)).concat(J);if(!J.length)return;if(K==="contextmenu")Q.preventDefault();let U=J[0],V={originalEvent:Q};if(Q.type!=="keypress"&&Q.type!=="keydown"&&Q.type!=="keyup"){let X=U.getLatLng&&(!U._pxRadius||U._pxRadius<=10);V.containerPoint=X?this.latLngToContainerPoint(U.getLatLng()):this.pointerEventToContainerPoint(Q),V.layerPoint=this.containerPointToLayerPoint(V.containerPoint),V.latlng=X?U.getLatLng():this.layerPointToLatLng(V.layerPoint)}for(let X of J)if(X.fire(K,V,!0),V.originalEvent._stopped||X.options?.bubblingPointerEvents===!1&&$._pointerEvents.includes(K))return}_draggableMoved(Q){return Q=Q.dragging?.enabled()?Q:this,Q.dragging?.moved()||this.boxZoom?.moved()}_clearHandlers(){for(let Q of this._handlers)Q.disable()}whenReady(Q,K){if(this._loaded)Q.call(K||this,{target:this});else this.on("load",Q,K);return this}_getMapPanePos(){return J$(this._mapPane)}_rotatePoint(Q,K,W){if(!K)return Q.clone();let J=K*Math.PI/180,U=Math.cos(J),V=Math.sin(J),X=Q.x-W.x,Y=Q.y-W.y;return new D(W.x+X*U-Y*V,W.y+X*V+Y*U)}_applyCameraTransform(){if(!this._mapPane)return;let Q=this.getSize()._divideBy(2),K=`${Q.x}px ${Q.y}px`;this._mapPane.style.transformOrigin=K;let W=this._getMapPanePos();K0(this._mapPane,W,this._bearing,this._pitch);let J=["markerPane","popupPane","tooltipPane"],U=!!this._bearing||!!this._pitch;for(let V of J){let X=this._panes?.[V];if(!X)continue;if(U)X.classList.add("tsmap-upright"),X.style.transformOrigin=K,X.style.transform=`rotateX(${-this._pitch}deg) rotate(${-this._bearing}deg) translateZ(0)`;else X.classList.remove("tsmap-upright"),X.style.transform="",X.style.transformOrigin=""}}_pitchPoint(Q){let K=this._pitch*Math.PI/180;if(!K)return Q.clone();let J=this.getSize().y/2/Math.tan(36.87*Math.PI/180/2),U=Math.sin(K),V=Math.cos(K),X=J-Q.y*U;if(Math.abs(X)<0.000001)return Q.clone();let Y=J*Q.x/X,Z=J*Q.y*V/X;return new D(Y,Z)}_unpitchPoint(Q){let K=this._pitch*Math.PI/180;if(!K)return Q.clone();let J=this.getSize().y/2/Math.tan(36.87*Math.PI/180/2),U=Math.sin(K),V=Math.cos(K),X=J*V+Q.y*U;if(Math.abs(X)<0.000001)return Q.clone();let Y=Q.y*J/X,Z=Q.x*J*V/X;return new D(Z,Y)}_moved(){let Q=this._getMapPanePos();return!!Q&&!Q.equals([0,0])}_getTopLeftPoint(Q,K){return(Q&&K!==void 0?this._getNewPixelOrigin(Q,K):this.getPixelOrigin()).subtract(this._getMapPanePos())}_getNewPixelOrigin(Q,K){let W=this.getSize()._divideBy(2);return this.project(Q,K)._subtract(W)._add(this._getMapPanePos())._round()}_latLngToNewLayerPoint(Q,K,W){let J=this._getNewPixelOrigin(W,K);return this.project(Q,K)._subtract(J)}_latLngBoundsToNewLayerBounds(Q,K,W){let J=this._getNewPixelOrigin(W,K);return new P([this.project(Q.getSouthWest(),K)._subtract(J),this.project(Q.getNorthWest(),K)._subtract(J),this.project(Q.getSouthEast(),K)._subtract(J),this.project(Q.getNorthEast(),K)._subtract(J)])}_getCenterLayerPoint(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))}_getCenterOffset(Q){return this.latLngToLayerPoint(Q).subtract(this._getCenterLayerPoint())}_limitCenter(Q,K,W){if(!W)return Q;let J=this.project(Q,K),U=this.getSize().divideBy(2),V=new P(J.subtract(U),J.add(U)),X=this._getBoundsOffset(V,W,K);if(Math.abs(X.x)<=1&&Math.abs(X.y)<=1)return Q;return this.unproject(J.add(X),K)}_limitOffset(Q,K){if(!K)return Q;let W=this.getPixelBounds(),J=new P(W.min.add(Q),W.max.add(Q));return Q.add(this._getBoundsOffset(J,K))}_getBoundsOffset(Q,K,W){let J=new P(this.project(K.getNorthEast(),W),this.project(K.getSouthWest(),W)),U=J.min.subtract(Q.min),V=J.max.subtract(Q.max),X=this._rebound(U.x,-V.x),Y=this._rebound(U.y,-V.y);return new D(X,Y)}_rebound(Q,K){return Q+K>0?Math.round(Q-K)/2:Math.max(0,Math.ceil(Q))-Math.max(0,Math.floor(K))}_limitZoom(Q){let K=this.getMinZoom(),W=this.getMaxZoom(),J=this.options.zoomSnap;if(J)Q=Math.round(Q/J)*J;return Math.max(K,Math.min(W,Q))}_onPanTransitionStep(){this.fire("move")}_onPanTransitionEnd(){this._mapPane.classList.remove("tsmap-pan-anim"),this.fire("moveend")}_tryAnimatedPan(Q,K){let W=this._getCenterOffset(Q)._trunc();if(K?.animate!==!0&&!this.getSize().contains(W))return!1;return this.panBy(W,K),!0}_createAnimProxy(){this._proxy=v("div","tsmap-proxy tsmap-zoom-animated"),this._panes.mapPane?.appendChild(this._proxy),this.on("zoomanim",this._animateProxyZoom,this),this.on("load moveend",this._animMoveEnd,this),B(this._proxy,"transitionend",this._catchTransitionEnd,this)}_animateProxyZoom(Q){let K=this._proxy.style.transform;if(W$(this._proxy,this.project(Q.center,Q.zoom),this.getZoomScale(Q.zoom,1)),K===this._proxy.style.transform&&this._animatingZoom)this._onZoomTransitionEnd()}_animMoveEnd(){let Q=this.getCenter(),K=this.getZoom();W$(this._proxy,this.project(Q,K),this.getZoomScale(K,1))}_destroyAnimProxy(){if(this._proxy)h(this._proxy,"transitionend",this._catchTransitionEnd,this),this._proxy.remove(),this.off("zoomanim",this._animateProxyZoom,this),this.off("load moveend",this._animMoveEnd,this),delete this._proxy}_catchTransitionEnd(Q){if(this._animatingZoom&&Q.propertyName.includes("transform"))this._onZoomTransitionEnd()}_nothingToAnimate(){return!this._container.getElementsByClassName("tsmap-zoom-animated").length}_tryAnimatedZoom(Q,K,W){if(this._animatingZoom)return!0;if(W??={},!this._zoomAnimated||W.animate===!1||this._nothingToAnimate()||Math.abs(K-this._zoom)>this.options.zoomAnimationThreshold)return!1;let J=this.getZoomScale(K),U=this._getCenterOffset(Q)._divideBy(1-1/J);if(W.animate!==!0&&!this.getSize().contains(U))return!1;return requestAnimationFrame(()=>{this._moveStart(!0,W.noMoveStart??!1)._animateZoom(Q,K,!0)}),!0}_animateZoom(Q,K,W,J){if(!this._mapPane)return;if(W)this._animatingZoom=!0,this._animateToCenter=Q,this._animateToZoom=K,this._mapPane.classList.add("tsmap-zoom-anim");if(this.fire("zoomanim",{center:Q,zoom:K,noUpdate:J}),!this._tempFireZoomEvent)this._tempFireZoomEvent=this._zoom!==this._animateToZoom;this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._transitionEndTimer=setTimeout(this._onZoomTransitionEnd.bind(this),250)}_onZoomTransitionEnd(){if(!this._animatingZoom)return;if(this._mapPane?.classList.remove("tsmap-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent)this.fire("zoom");delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0)}setStyle(Q,K){let W=K?.diff!==!1,J=K?.validate!==!1;if(W&&this._style){let U=a5(this._style.spec,Q);if(!U.commands.find((X)=>X.command==="setStyle")){for(let X of U.commands)this._applyStyleCommand(X);return this.fire("styledata"),this}}if(this._style)for(let U of this._style.sourceLayers.values())this.removeLayer(U);this._style=new T8(Q,{validate:J});for(let[U,V]of Object.entries(this._style.spec.sources)){let X=this._makeSourceLayer(U,V);this._installFeatureStateLookup(U,X),this.addLayer(X)}return this.fire("styledata"),this}getStyle(){return this._style?.serialize()}isStyleLoaded(){return!!this._style}addSource(Q,K){if(!this._style)this._style=new T8({version:8,sources:{[Q]:K},layers:[]});else this._style.spec.sources[Q]=K;let W=this._makeSourceLayer(Q,K);return this._installFeatureStateLookup(Q,W),this.addLayer(W),this.fire("styledata"),this}getSource(Q){return this._style?.spec.sources[Q]}removeSource(Q){if(!this._style)return this;let K=this._style.sourceLayers.get(Q);if(K)this.removeLayer(K),this._style.sourceLayers.delete(Q);return delete this._style.spec.sources[Q],this.fire("styledata"),this}_makeSourceLayer(Q,K){if(K.type==="raster"){let{TileLayer:W}=(i$(),l8(DQ)),U=(K.tiles??[])[0];if(!U)throw Error(`source "${Q}" has no tiles URL`);let V=new W(U,{tileSize:K.tileSize??256,minZoom:K.minzoom,maxZoom:K.maxzoom,attribution:K.attribution});return this._style.sourceLayers.set(Q,V),V}if(K.type==="vector"){let{VectorTileMapLayer:W}=(B9(),l8(T9)),U=(K.tiles??[])[0];if(!U)throw Error(`source "${Q}" has no tiles URL`);let V=this._style.spec.layers.filter((Y)=>Y.type!=="background"&&Y.type!=="raster"&&Y.source===Q).map((Y)=>this._style.toVectorStyleLayer(Y)),X=new W({url:U,tileSize:K.tileSize??512,minZoom:K.minzoom,maxZoom:K.maxzoom,attribution:K.attribution,layers:V});return this._style.sourceLayers.set(Q,X),X}if(K.type==="raster-dem"){let{TileLayer:W}=(i$(),l8(DQ)),U=(K.tiles??[])[0];if(!U)throw Error(`source "${Q}" (raster-dem) has no tiles URL`);let V=new W(U,{tileSize:K.tileSize??512,minZoom:K.minzoom,maxZoom:K.maxzoom,attribution:K.attribution});return this._style.sourceLayers.set(Q,V),V}throw Error(`source type "${K.type}" is not supported in setStyle yet`)}addStyleLayer(Q,K){if(!this._style)throw Error("addStyleLayer requires a loaded style");let W=this._style.spec.layers;if(K){let J=W.findIndex((U)=>U.id===K);if(J>=0)W.splice(J,0,Q);else W.push(Q)}else W.push(Q);if(this._style.layerSpecs.set(Q.id,Q),Q.source){let J=this._style.sourceLayers.get(Q.source);if(typeof J?.setStyleLayers==="function"){let U=W.filter((X)=>X.type!=="background"&&X.type!=="raster"&&X.source===Q.source).map((X)=>this._style.toVectorStyleLayer(X)),V=J;V.setStyleLayers(U),V.redraw?.()}}return this.fire("styledata"),this}removeStyleLayer(Q){if(!this._style)return this;let K=this._style.spec.layers.findIndex((J)=>J.id===Q);if(K<0)return this;let W=this._style.spec.layers.splice(K,1)[0];if(this._style.layerSpecs.delete(Q),W.source){let J=this._style.sourceLayers.get(W.source);if(typeof J?.setStyleLayers==="function"){let U=this._style.spec.layers.filter((X)=>X.type!=="background"&&X.type!=="raster"&&X.source===W.source).map((X)=>this._style.toVectorStyleLayer(X)),V=J;V.setStyleLayers(U),V.redraw?.()}}return this.fire("styledata"),this}getStyleLayer(Q){return this._style?.layerSpecs.get(Q)}setPaintProperty(Q,K,W){return this._style?.setPaintProperty(Q,K,W),this.fire("styledata"),this}setLayoutProperty(Q,K,W){return this._style?.setLayoutProperty(Q,K,W),this.fire("styledata"),this}setFilter(Q,K){return this._style?.setFilter(Q,K),this.fire("styledata"),this}on(Q,K,W,J){if(typeof K==="string"&&typeof Q==="string"&&typeof W==="function"){let U=K,V=W,X=J,Y=(H)=>{if(!H||!H.containerPoint)return;let A=this.queryRenderedFeatures(H.containerPoint,{layers:[U]});if(!A.length)return;V.call(X??this,Object.assign({},H,{features:A}))};if(!this._layerHandlers)this._layerHandlers=new globalThis.Map;let Z=this._layerHandlers.get(Q)??[];return Z.push({layerId:U,listener:V,wrapped:Y,context:X}),this._layerHandlers.set(Q,Z),R0.prototype.on.call(this,Q,Y,this)}return R0.prototype.on.call(this,Q,K,W)}off(Q,K,W,J){if(typeof K==="string"&&typeof Q==="string"&&typeof W==="function"){let U=K,V=W,X=this._layerHandlers?.get(Q);if(X){let Y=X.findIndex((Z)=>Z.layerId===U&&Z.listener===V);if(Y>=0){let[Z]=X.splice(Y,1);if(R0.prototype.off.call(this,Q,Z.wrapped,this),X.length===0)this._layerHandlers.delete(Q);return this}}return this}return R0.prototype.off.call(this,Q,K,W,J)}once(Q,K,W,J){if(typeof K==="string"&&typeof Q==="string"&&typeof W==="function"){let U=K,V=W,X=J,Y=this,Z=function(A){Y.off(Q,U,Z),V.call(X??Y,A)};return Y.on(Q,U,Z),this}return R0.prototype.once.call(this,Q,K,W)}queryRenderedFeatures(Q,K){if(!this._style)return[];let W=[];for(let J of this._style.sourceLayers.values()){let U=J;if(typeof U.queryRenderedFeatures==="function"){let V=Q===void 0?U.queryRenderedFeatures():U.queryRenderedFeatures(Q,K);for(let X of V)W.push(X)}}return W}querySourceFeatures(Q,K){if(!this._style)return[];let W=this._style.sourceLayers.get(Q);if(!W)return[];if(typeof W.querySourceFeatures!=="function")return[];return W.querySourceFeatures(K??{})}_featureStateKey(Q){let K=typeof Q.id==="number"?`n:${Q.id}`:`s:${Q.id}`;return`${Q.source}|${Q.sourceLayer??""}|${K}`}_ensureFeatureStateMap(){if(!this._featureState)this._featureState=new globalThis.Map;return this._featureState}_repaintSource(Q){let K=this._style?.sourceLayers.get(Q);if(!K)return;if(typeof K._repaintDecodedTiles==="function")K._repaintDecodedTiles()}setFeatureState(Q,K){let W=this._ensureFeatureStateMap(),J=this._featureStateKey(Q),U=W.get(J);if(U)Object.assign(U,K);else W.set(J,{...K});return this._repaintSource(Q.source),this}getFeatureState(Q){let K=this._featureState;if(!K)return{};let W=this._featureStateKey(Q);return K.get(W)??{}}removeFeatureState(Q,K){let W=this._featureState;if(!W)return this;let J=this._featureStateKey(Q);if(K===void 0)W.delete(J);else{let U=W.get(J);if(U){if(delete U[K],Object.keys(U).length===0)W.delete(J)}}return this._repaintSource(Q.source),this}_installFeatureStateLookup(Q,K){if(typeof K?.setFeatureStateLookup!=="function")return;if(K.setFeatureStateLookup((W,J,U)=>{let V=this._featureState;if(!V)return{};let X=typeof U==="number"?`n:${U}`:`s:${U}`;return V.get(`${W}|${J}|${X}`)??{}}),typeof K.setSourceId==="function")K.setSourceId(Q)}_applyStyleCommand(Q){switch(Q.command){case"addSource":{let[K,W]=Q.args;if(!this._style)this._style=new T8({version:8,sources:{},layers:[]},{validate:!1});this._style.spec.sources[K]=W;let J=this._makeSourceLayer(K,W);this._installFeatureStateLookup(K,J),this.addLayer(J);break}case"removeSource":{let[K]=Q.args;this.removeSource(K);break}case"addLayer":{let[K,W]=Q.args;this.addStyleLayer(K,W);break}case"removeLayer":{let[K]=Q.args;this.removeStyleLayer(K);break}case"setPaintProperty":{let[K,W,J]=Q.args;this._style?.setPaintProperty(K,W,J);break}case"setLayoutProperty":{let[K,W,J]=Q.args;this._style?.setLayoutProperty(K,W,J);break}case"setFilter":{let[K,W]=Q.args;this._style?.setFilter(K,W);break}case"setLayerZoomRange":{let[K,W,J]=Q.args;this._style?.setLayerZoomRange(K,W,J);break}}}setFog(Q){if(Q!==null){if(Q.range!==void 0){let[K,W]=Q.range;if(!(K<W))throw RangeError(`setFog: range[0] (${K}) must be < range[1] (${W}).`)}if(Q["star-intensity"]!==void 0&&Q["star-intensity"]<0)throw RangeError(`setFog: star-intensity must be >= 0 (got ${Q["star-intensity"]}).`)}return this._fog=Q===null?null:{...Q},this._updateAtmosphereOverlay(),this.fire("fogchange",{fog:this._fog}),this}getFog(){return this._fog??null}setSky(Q){if(Q!==null){let K=["fog-ground-blend","sun-intensity"];for(let J of K){let U=Q[J];if(U!==void 0&&Number.isNaN(U))throw RangeError(`setSky: ${J} is NaN.`)}if(Q["sun-position"]!==void 0){let[J,U]=Q["sun-position"];if(Number.isNaN(J)||Number.isNaN(U))throw RangeError("setSky: sun-position contains NaN.")}let W={...Q};if(W["fog-ground-blend"]!==void 0)W["fog-ground-blend"]=Math.max(0,Math.min(1,W["fog-ground-blend"]));if(W["sun-intensity"]!==void 0)W["sun-intensity"]=Math.max(0,Math.min(1,W["sun-intensity"]));this._sky=W}else this._sky=null;return this._updateAtmosphereOverlay(),this.fire("skychange",{sky:this._sky}),this}getSky(){return this._sky??null}setTerrain(Q){if(Q!==null){if(typeof Q.source!=="string"||Q.source.length===0)throw TypeError("setTerrain: `source` must be a non-empty string.");if(Q.exaggeration!==void 0&&!Number.isFinite(Q.exaggeration))throw RangeError(`setTerrain: exaggeration must be a finite number (got ${Q.exaggeration}).`);if(Q.exaggeration!==void 0&&Q.exaggeration<0)throw RangeError(`setTerrain: exaggeration must be >= 0 (got ${Q.exaggeration}).`);this._terrain={source:Q.source,exaggeration:Q.exaggeration??1};let K=this._style?.spec.sources?.[Q.source],W=K?.encoding==="terrarium"?"terrarium":"mapbox",J=K?.tileSize??256;if(!this._terrainSource)this._terrainSource=new y7({demSize:J,encoding:W,exaggeration:this._terrain.exaggeration});else this._terrainSource.setExaggeration(this._terrain.exaggeration??1)}else this._terrain=null,this._terrainSource?.clear();if(this._terrain)this._ensureTerrainOverlay();else this._destroyTerrainOverlay();return this.fire("terrainchange",{terrain:this._terrain}),this._renderTerrainOverlay(),this}_ensureTerrainOverlay(){if(this._terrainOverlayCanvas)return;let Q=this._container;if(!Q||typeof Q.appendChild!=="function")return;let W=(Q.ownerDocument??document).createElement("canvas");W.className="ts-maps-terrain-overlay";let J=this.getSize?.()??new D(Q.clientWidth||300,Q.clientHeight||150);if(W.width=Math.max(1,J.x),W.height=Math.max(1,J.y),W.style)W.style.position="absolute",W.style.inset="0",W.style.pointerEvents="none",W.style.zIndex="390";Q.appendChild(W),this._terrainOverlayCanvas=W}_destroyTerrainOverlay(){if(this._terrainOverlayRenderer){try{this._terrainOverlayRenderer.destroy()}catch{}this._terrainOverlayRenderer=void 0}if(this._terrainOverlayCanvas&&this._terrainOverlayCanvas.parentNode)this._terrainOverlayCanvas.parentNode.removeChild(this._terrainOverlayCanvas);this._terrainOverlayCanvas=void 0}_renderTerrainOverlay(){if(!this._terrain||!this._terrainSource)return;let Q=this._terrainOverlayCanvas;if(!Q)return;let K=this.getSize?.();if(K){if(Q.width!==K.x)Q.width=Math.max(1,K.x);if(Q.height!==K.y)Q.height=Math.max(1,K.y)}if(!this._terrainOverlayRenderer)try{this._terrainOverlayRenderer=new rQ(Q)}catch{return}let W=this._terrainOverlayRenderer;W.clear();let J=Math.max(0,Math.floor(this.getZoom?.()??0)),U=this.getBounds?.();if(!U||!U.isValid||!U.isValid())return;let V=U.getSouthWest(),X=U.getNorthEast(),Y=256,Z=2**J,H=(C)=>Math.floor((C+180)/360*Z),A=(C)=>{let M=Math.max(-85.05112878,Math.min(85.05112878,C))*Math.PI/180;return Math.floor((1-Math.log(Math.tan(M)+1/Math.cos(M))/Math.PI)/2*Z)},G=Math.max(0,H(V.lng)),F=Math.min(Z-1,H(X.lng)),N=Math.max(0,A(X.lat)),q=Math.min(Z-1,A(V.lat)),R=Q.width,I=Q.height;for(let C=G;C<=F;C++)for(let M=N;M<=q;M++){let j={z:J,x:C,y:M};if(!this._terrainSource.hasTile(j)){this._maybeFetchTerrainTile(j);continue}let E=180/Math.PI*Math.atan(Math.sinh(Math.PI*(1-2*M/Z))),_=C/Z*360-180,x=this.latLngToContainerPoint?.({lat:E,lng:_});if(!x)continue;let n=x.x/R*2-1,p=1-x.y/I*2,J0=Y/R*2,a=-(Y/I)*2,y=new Float32Array(16);y[0]=J0,y[5]=a,y[10]=1,y[15]=1,y[12]=n,y[13]=p,this._drawTerrainForTile(W,j,Y,y)}}getTerrain(){return this._terrain??null}getTerrainSource(){return this._terrainSource}setRenderer(Q){let K=this.options;if(K.preferredRenderer=Q,this._style)for(let W of this._style.sourceLayers.values()){let J=W;if(typeof J.setRenderer==="function")try{J.setRenderer(Q)}catch{}if(typeof J.redraw==="function")try{J.redraw()}catch{}}return this.fire("rendererchange",{renderer:Q}),this}getPreferredRenderer(){return this.options.preferredRenderer??"canvas2d"}queryTerrainElevation(Q){if(!this._terrain||!this._terrainSource)return null;let K=Math.max(0,Math.floor(this.getZoom?.()??0));return this._terrainSource.queryElevation(Q.lng,Q.lat,K)}toCanvas(){let Q=this._container,K=Q.ownerDocument??document,W=this.getSize(),J=globalThis.devicePixelRatio??1,U=K.createElement("canvas"),V=Math.max(1,Math.round(W.x)),X=Math.max(1,Math.round(W.y));if(U.width=Math.round(V*J),U.height=Math.round(X*J),U.style)U.style.width=`${V}px`,U.style.height=`${X}px`;let Y=U.getContext("2d");if(!Y)return U;Y.scale(J,J);let Z=Q.getBoundingClientRect(),H=K.createTreeWalker(Q,1),A=H.nextNode();while(A){if(A.tagName==="CANVAS"||A.tagName==="IMG"){let G=A.getBoundingClientRect?.();if(G&&G.width>0&&G.height>0)try{Y.drawImage(A,G.left-Z.left,G.top-Z.top,G.width,G.height)}catch{}}A=H.nextNode()}return U}toDataURL(Q="image/png",K){return this._requestExportFrame(),this.toCanvas().toDataURL(Q,K)}toBlob(Q="image/png",K){return this._requestExportFrame(),new Promise((W)=>{let J=this.toCanvas();if(typeof J.toBlob==="function")J.toBlob((U)=>W(U),Q,K);else try{let U=J.toDataURL(Q,K),V=U.indexOf(","),X=U.slice(V+1),Y=atob(X),Z=new Uint8Array(Y.length);for(let H=0;H<Y.length;H++)Z[H]=Y.charCodeAt(H);W(new Blob([Z],{type:Q}))}catch{W(null)}})}_requestExportFrame(){if(!this._style)return;for(let Q of this._style.sourceLayers.values()){let K=Q.redraw;if(typeof K==="function")try{K.call(Q)}catch{}}}_isGlobeProjection(){let Q=this.options??{};if(Q.projection==="globe")return!0;return typeof Q.crs?.projection?.globeToMercatorMix==="function"}_globeAtmosphereMix(){let K=(this.options??{}).crs?.projection,W=this.getZoom?.()??0;if(typeof K?.globeToMercatorMix==="function")return K.globeToMercatorMix(W);let J=5.5,U=6;if(W<=J)return 1;if(W>=U)return 0;let V=(W-J)/(U-J);return 1-V*V*(3-2*V)}_updateAtmosphereOverlay(){let Q=this._container;if(!Q||typeof Q.appendChild!=="function")return;let K=this._sky!==null&&this._sky!==void 0,W=this._fog!==null&&this._fog!==void 0,J=this._isGlobeProjection()?this._globeAtmosphereMix():0,U=J>0;if(!K&&!W&&!U){if(this._atmosphereOverlay&&this._atmosphereOverlay.parentNode)this._atmosphereOverlay.parentNode.removeChild(this._atmosphereOverlay);this._atmosphereOverlay=void 0;return}if(!this._atmosphereOverlay){let R=(Q.ownerDocument??document).createElement("div");if(R.className="ts-maps-atmosphere",R.style)R.style.position="absolute",R.style.inset="0",R.style.pointerEvents="none",R.style.zIndex="400";Q.appendChild(R),this._atmosphereOverlay=R}let V=this.getPitch?.()??0,X=Math.max(0,Math.min(1,(V-5)/55)),Y=this._sky?.["sky-color"]??"#87ceeb",Z=this._sky?.["horizon-color"]??"#ffffff",H=this._fog?.color??"rgb(245, 247, 250)",A=this._fog?.["horizon-blend"]??0.1,G=[];if(U){let R=this._sky?.["sky-color"]??H;G.push(`radial-gradient(circle at 50% 50%, transparent 36%, ${R} 46%, transparent 62%)`)}if(K)G.push(`linear-gradient(to bottom, ${Y} 0%, ${Z} 40%, transparent 60%)`);if(W){let R=Math.max(0.05,Math.min(0.4,A*2)),I=0.45,C=Math.max(0,0.45-R/2),M=Math.min(1,0.45+R/2);G.push(`linear-gradient(to bottom, transparent ${(C*100).toFixed(1)}%, ${H} ${45 .toFixed(1)}%, transparent ${(M*100).toFixed(1)}%)`)}let F=this._atmosphereOverlay.style;if(!F)return;F.background=G.join(", ");let q=Math.max(K||W?X:0,U?J*0.9:0);F.opacity=String(q.toFixed(3)),F.display=q<=0?"none":"block"}_getCustomLayerGL(){let Q=this._container;if(!Q||typeof Q.querySelector!=="function")return null;let K=Q.querySelector("canvas");if(!K||typeof K.getContext!=="function")return null;try{return K.getContext("webgl2")??null}catch{return null}}addCustomLayer(Q){if(!this._customLayers)this._customLayers=new globalThis.Map;if(this._customLayers.has(Q.id))throw Error(`addCustomLayer: a custom layer with id "${Q.id}" is already registered.`);this._customLayers.set(Q.id,Q);let K=this._getCustomLayerGL();if(K&&typeof Q.onAdd==="function")Q.onAdd(this,K);return this.fire("customlayer:add",{id:Q.id,layer:Q}),this}addTerrainTile(Q,K){if(!this._terrain||!this._terrainSource)return;this._terrainSource.addTilePixels(Q,K)}_drawTerrainForTile(Q,K,W,J){if(!this._terrain||!this._terrainSource)return;let U=this._terrainSource;if(!U.hasTile(K)){this._maybeFetchTerrainTile(K);return}let V=U.getTile(K);if(!V)return;let X=yK({elevation:V,demSize:U.demSize,tileSize:W,resolution:U.meshResolution,exaggeration:U.exaggeration,unitsPerMeter:0.001});Q.drawTerrain(X.positions,X.indices,[0.78,0.8,0.75,1],1,J)}_maybeFetchTerrainTile(Q){if(!this._terrain||!this._terrainSource||!this._style)return;let K=this._style.spec.sources?.[this._terrain.source];if(!K||K.type!=="raster-dem")return;let W=Array.isArray(K.tiles)?K.tiles[0]:void 0;if(!W||typeof W!=="string")return;let J=W.replace(/\{z\}/g,String(Q.z)).replace(/\{x\}/g,String(Q.x)).replace(/\{y\}/g,String(Q.y));if(!this._terrainFetchInFlight)this._terrainFetchInFlight=new globalThis.Map;if(this._terrainFetchInFlight.has(J))return;let U=q4(J,this._terrainSource.demSize).then((V)=>{if(V&&this._terrainSource&&this._terrain)this._terrainSource.addTilePixels(Q,V);this.fire("terrainload",{coord:Q})}).catch(()=>{}).finally(()=>{this._terrainFetchInFlight?.delete(J)});this._terrainFetchInFlight.set(J,U)}_wireTerrainCameraHooks(){let Q=()=>this._renderTerrainOverlay();this.on("moveend",Q),this.on("zoomend",Q),this.on("rotate",Q),this.on("pitch",Q),this.on("resize",Q),this.on("terrainload",Q)}_invokeCustomLayerRender(Q,K){if(!this._customLayers||this._customLayers.size===0)return;for(let W of this._customLayers.values())try{W.render(Q,K)}catch(J){console.warn(`[ts-maps] custom layer "${W.id}" threw during render:`,J)}}removeCustomLayer(Q){let K=this._customLayers?.get(Q);if(!K)return this;let W=this._getCustomLayerGL();if(W&&typeof K.onRemove==="function")K.onRemove(this,W);return this._customLayers.delete(Q),this.fire("customlayer:remove",{id:Q,layer:K}),this}getCustomLayer(Q){return this._customLayers?.get(Q)}getCustomLayers(){return this._customLayers?Array.from(this._customLayers.values()):[]}get offline(){if(!this._offlineApi){let Q=this;this._offlineApi={save(K){return EK(K,Q)},async size(){return j$().size()},async clear(){await j$().clear()}}}return this._offlineApi}},L.setDefaultOptions({crs:O8,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:0,zoomDelta:1,trackResize:!0,bearing:0,pitch:0,maxPitch:60,minPitch:0}),R4=L});W0();l();a$();Y0();A0();l();var w9={};C0(w9,{_getBitCode:()=>Q$,_getEdgeIntersection:()=>_8,_sqClosestPointOnSegment:()=>Q8,clipSegment:()=>v9,closestPointOnSegment:()=>M4,isFlat:()=>T0,pointToSegmentDistance:()=>z9,polylineCenter:()=>f9,simplify:()=>L9});var _9={};C0(_9,{centroid:()=>tQ,clipPolygon:()=>S9,polygonCenter:()=>P9});Y0();A0();l();function S9($,Q,K){let W,J=[1,4,2,8];for(let U=0,V=$.length;U<V;U++)$[U]._code=Q$($[U],Q);for(let U=0;U<4;U++){let V=J[U];W=[];for(let X=0,Y=$.length,Z=Y-1;X<Y;Z=X++){let H=$[X],A=$[Z];if(!(H._code&V)){if(A._code&V){let G=_8(A,H,V,Q,K);G._code=Q$(G,Q),W.push(G)}W.push(H)}else if(!(A._code&V)){let G=_8(A,H,V,Q,K);G._code=Q$(G,Q),W.push(G)}}$=W}return $}function P9($,Q){if(!$||$.length===0)throw Error("latlngs not passed");if(!T0($))console.warn("latlngs are not flat! Only the first ring will be used"),$=$[0];let K=new O(0,0),W=new z($);if(W.getNorthWest().distanceTo(W.getSouthWest())*W.getNorthEast().distanceTo(W.getNorthWest())<1700)K=tQ($);let U=$.length,V=[];for(let G=0;G<U;G++){let F=new O($[G]);V.push(Q.project(new O(F.lat-K.lat,F.lng-K.lng)))}let X=0,Y=0,Z=0,H;for(let G=0,F=U-1;G<U;F=G++){let N=V[G],q=V[F],R=N.y*q.x-q.y*N.x;Y+=(N.x+q.x)*R,Z+=(N.y+q.y)*R,X+=R*3}if(X===0)H=V[0];else H=[Y/X,Z/X];let A=Q.unproject(new D(H));return new O(A.lat+K.lat,A.lng+K.lng)}function tQ($){let Q=0,K=0,W=0;for(let J of $){let U=new O(J);Q+=U.lat,K+=U.lng,W++}return new O(Q/W,K/W)}function L9($,Q){if(!Q||!$.length)return $.slice();let K=Q*Q;return $=I4($,K),$=D4($,K),$}function z9($,Q,K){return Math.sqrt(Q8($,Q,K,!0))}function M4($,Q,K){return Q8($,Q,K)}function D4($,Q){let K=$.length,W=new Uint8Array(K);W[0]=W[K-1]=1,OQ($,W,Q,0,K-1);let J=[];for(let U=0;U<K;U++)if(W[U])J.push($[U]);return J}function OQ($,Q,K,W,J){let U=0,V=0;for(let X=W+1;X<=J-1;X++){let Y=Q8($[X],$[W],$[J],!0);if(Y>U)V=X,U=Y}if(U>K)Q[V]=1,OQ($,Q,K,W,V),OQ($,Q,K,V,J)}function I4($,Q){let K=[$[0]],W=0;for(let J=1;J<$.length;J++)if(j4($[J],$[W])>Q)K.push($[J]),W=J;if(W<$.length-1)K.push($[$.length-1]);return K}var j7;function v9($,Q,K,W,J){let U=W?j7:Q$($,K),V=Q$(Q,K);j7=V;while(!0){if(!(U|V))return[$,Q];if(U&V)return!1;let X=U||V,Y=_8($,Q,X,K,J),Z=Q$(Y,K);if(X===U)$=Y,U=Z;else Q=Y,V=Z}}function _8($,Q,K,W,J){let U=Q.x-$.x,V=Q.y-$.y,X=W.min,Y=W.max,Z=0,H=0;if(K&8)Z=$.x+U*(Y.y-$.y)/V,H=Y.y;else if(K&4)Z=$.x+U*(X.y-$.y)/V,H=X.y;else if(K&2)Z=Y.x,H=$.y+V*(Y.x-$.x)/U;else if(K&1)Z=X.x,H=$.y+V*(X.x-$.x)/U;return new D(Z,H,J)}function Q$($,Q){let K=0;if($.x<Q.min.x)K|=1;else if($.x>Q.max.x)K|=2;if($.y<Q.min.y)K|=4;else if($.y>Q.max.y)K|=8;return K}function j4($,Q){let K=Q.x-$.x,W=Q.y-$.y;return K*K+W*W}function Q8($,Q,K,W){let{x:J,y:U}=Q,V=K.x-J,X=K.y-U,Y=V*V+X*X,Z;if(Y>0){if(Z=(($.x-J)*V+($.y-U)*X)/Y,Z>1)J=K.x,U=K.y;else if(Z>0)J+=V*Z,U+=X*Z}return V=$.x-J,X=$.y-U,W?V*V+X*X:new D(J,U)}function T0($){return!Array.isArray($[0])||typeof $[0][0]!=="object"&&typeof $[0][0]<"u"}function f9($,Q){if(!$||$.length===0)throw Error("latlngs not passed");if(!T0($))console.warn("latlngs are not flat! Only the first ring will be used"),$=$[0];let K=new O(0,0),W=new z($);if(W.getNorthWest().distanceTo(W.getSouthWest())*W.getNorthEast().distanceTo(W.getNorthWest())<1700)K=tQ($);let U=$.length,V=[];for(let H=0;H<U;H++){let A=new O($[H]);V.push(Q.project(new O(A.lat-K.lat,A.lng-K.lng)))}let X=0;for(let H=0;H<U-1;H++)X+=V[H].distanceTo(V[H+1])/2;let Y;if(X===0)Y=V[0];else{let H=0;Y=V[0];for(let A=0;A<U-1;A++){let G=V[A],F=V[A+1],N=G.distanceTo(F);if(H+=N,H>X){let q=(H-X)/N;Y=[F.x-q*(F.x-G.x),F.y-q*(F.y-G.y)];break}}}let Z=Q.unproject(new D(Y));return new O(Z.lat+K.lat,Z.lng+K.lng)}Y0();A0();x7();u7();var h9={};C0(h9,{Globe:()=>B4,LonLat:()=>eQ,Mercator:()=>EQ,SphericalMercator:()=>p0});Y0();hQ();var T4=p0.R;function C4($){let Q=new O($),K=Q.lat*Math.PI/180,W=Q.lng*Math.PI/180,J=Math.cos(K);return{x:J*Math.sin(W),y:Math.sin(K),z:J*Math.cos(W)}}function O4($){let Q=Math.hypot($.x,$.y,$.z)||1,K=Math.asin(Math.max(-1,Math.min(1,$.y/Q))),W=Math.atan2($.x,$.z);return new O(K*180/Math.PI,W*180/Math.PI)}function E4($,Q,K){if($<=Q)return 1;if($>=K)return 0;let W=($-Q)/(K-Q);return 1-W*W*(3-2*W)}var B4={R:T4,GLOBE_START_ZOOM:5.5,GLOBE_END_ZOOM:6,project($){return p0.project($)},unproject($){return p0.unproject($)},bounds:p0.bounds,toSphere:C4,fromSphere:O4,globeToMercatorMix($){return E4($,this.GLOBE_START_ZOOM,this.GLOBE_END_ZOOM)}};W0();l();Y0();var eQ={project($){let Q=new O($);return new D(Q.lng,Q.lat)},unproject($){let Q=new D($);return new O(Q.y,Q.x)},bounds:new P([-180,-90],[180,90])};W0();l();Y0();var k4=6378137,EQ={R:k4,R_MINOR:6356752.314245179,bounds:new P([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project($){let Q=new O($),K=Math.PI/180,W=this.R,J=this.R_MINOR/W,U=Math.sqrt(1-J*J),V=Q.lat*K,X=U*Math.sin(V),Y=Math.tan(Math.PI/4-V/2)/((1-X)/(1+X))**(U/2);return V=-W*Math.log(Math.max(Y,0.0000000001)),new D(Q.lng*K*W,V)},unproject($){let Q=new D($),K=180/Math.PI,W=this.R,J=this.R_MINOR/W,U=Math.sqrt(1-J*J),V=Math.exp(-Q.y/W),X=Math.PI/2-2*Math.atan(V),Y=0.1;for(let Z=0;Z<15&&Math.abs(Y)>0.0000001;Z++){let H=U*Math.sin(X);H=((1-H)/(1+H))**(U/2),Y=Math.PI/2-2*Math.atan(V*H)-X,X+=Y}return new O(X*K,Q.x*K/W)}};hQ();fQ();C$();a$();C$();class b9 extends s0{static code="EPSG:3395";static projection=EQ;static transformation=(()=>{let $=0.5/(Math.PI*EQ.R);return new Y$($,0.5,-$,0.5)})()}g7();a$();C$();class $6 extends s0{static code="EPSG:4326";static projection=eQ;static transformation=new Y$(0.005555555555555556,1,-0.005555555555555556,0.5)}a$();fQ();class x9 extends L8{static projection=eQ;static transformation=new Y$(1,0,-1,0);static infinite=!0;static scale($){return 2**$}static zoom($){return Math.log($)/Math.LN2}static distance($,Q){let K=Q.lng-$.lng,W=Q.lat-$.lat;return Math.sqrt(K*K+W*W)}}var y9={};C0(y9,{GoogleDirections:()=>c9,GoogleGeocoder:()=>d9,MapboxDirections:()=>i9,MapboxGeocoder:()=>p9,MapboxIsochrone:()=>n9,MapboxMatrix:()=>s9,MaptilerGeocoder:()=>r9,NominatimGeocoder:()=>Q6,OSRMDirections:()=>K6,OSRMMatrix:()=>W6,PhotonGeocoder:()=>e9,ValhallaDirections:()=>Y6,ValhallaIsochrone:()=>Z6,ValhallaMatrix:()=>H6,defaultDirections:()=>s4,defaultGeocoder:()=>n4,defaultIsochrone:()=>r4,defaultMatrix:()=>a4,valhallaDirections:()=>t4,valhallaMatrix:()=>o4});var u9="https://maps.googleapis.com/maps/api";function g9($){if(!$)throw Error("Google provider requires an apiKey");return $}var w4={driving:"driving",walking:"walking",cycling:"bicycling"};function m9($,Q=5){let K=10**Q,W=$.length,J=0,U=0,V=0,X=[];while(J<W){let Y=0,Z=0,H;do H=$.charCodeAt(J++)-63,Z|=(H&31)<<Y,Y+=5;while(H>=32);let A=Z&1?~(Z>>1):Z>>1;U+=A,Y=0,Z=0;do H=$.charCodeAt(J++)-63,Z|=(H&31)<<Y,Y+=5;while(H>=32);let G=Z&1?~(Z>>1):Z>>1;V+=G,X.push({lat:U/K,lng:V/K})}return X}async function BQ($,Q){let K=await fetch($,{signal:Q});if(!K.ok)throw Error(`Google request failed: ${K.status} ${K.statusText}`);return K.json()}function _4($){if(!$)return;if($.includes("country"))return"country";if($.includes("administrative_area_level_1"))return"region";if($.includes("administrative_area_level_2"))return"district";if($.includes("postal_code"))return"postcode";if($.includes("locality")||$.includes("sublocality"))return"place";if($.includes("street_address")||$.includes("route")||$.includes("premise"))return"address";if($.includes("point_of_interest")||$.includes("establishment"))return"poi";return}function T7($){let Q={text:$.formatted_address,center:{lat:$.geometry.location.lat,lng:$.geometry.location.lng},properties:{place_id:$.place_id,types:$.types,address_components:$.address_components}},K=$.geometry.bounds??$.geometry.viewport;if(K)Q.bbox=[K.southwest.lng,K.southwest.lat,K.northeast.lng,K.northeast.lat];let W=_4($.types);if(W)Q.placeType=W;return Q}class d9{name="google";apiKey;baseUrl;constructor($){this.apiKey=g9($.apiKey),this.baseUrl=($.baseUrl??u9).replace(/\/$/,"")}async search($,Q){let K=new URLSearchParams;if(K.set("address",$),K.set("key",this.apiKey),Q?.language)K.set("language",Q.language);if(Q?.bbox){let[V,X,Y,Z]=Q.bbox;K.set("bounds",`${X},${V}|${Z},${Y}`)}if(Q?.countries&&Q.countries.length>0)K.set("components",Q.countries.map((V)=>`country:${V}`).join("|"));let W=`${this.baseUrl}/geocode/json?${K.toString()}`,J=await BQ(W,Q?.signal);if(J.status!=="OK"&&J.status!=="ZERO_RESULTS")throw Error(`Google geocoding error: ${J.status}${J.error_message?` — ${J.error_message}`:""}`);let U=(J.results??[]).map(T7);return typeof Q?.limit==="number"?U.slice(0,Q.limit):U}async reverse($,Q){let K=new URLSearchParams;if(K.set("latlng",`${$.lat},${$.lng}`),K.set("key",this.apiKey),Q?.language)K.set("language",Q.language);let W=`${this.baseUrl}/geocode/json?${K.toString()}`,J=await BQ(W,Q?.signal);if(J.status!=="OK"&&J.status!=="ZERO_RESULTS")throw Error(`Google reverse-geocoding error: ${J.status}${J.error_message?` — ${J.error_message}`:""}`);let U=(J.results??[]).map(T7);return typeof Q?.limit==="number"?U.slice(0,Q.limit):U}}function S4($){return $?$.replace(/<[^>]+>/g,""):""}function P4($){let Q={distance:$.distance?.value??0,duration:$.duration?.value??0,instruction:S4($.html_instructions),geometry:$.polyline?m9($.polyline.points):[]};if($.maneuver)Q.maneuver=$.maneuver;return Q}function L4($){let Q=$.legs??[],K=Q.flatMap((V)=>(V.steps??[]).map(P4)),W=Q.reduce((V,X)=>V+(X.distance?.value??0),0),J=Q.reduce((V,X)=>V+(X.duration?.value??0),0),U=$.overview_polyline?m9($.overview_polyline.points):K.flatMap((V)=>V.geometry);return{distance:W,duration:J,geometry:U,steps:K}}class c9{name="google";apiKey;baseUrl;constructor($){this.apiKey=g9($.apiKey),this.baseUrl=($.baseUrl??u9).replace(/\/$/,"")}async getDirections($,Q){if($.length<2)throw Error("Google directions requires at least two waypoints");let K=new URLSearchParams;K.set("key",this.apiKey),K.set("mode",w4[Q?.profile??"driving"]);let W=$[0],J=$[$.length-1];if(K.set("origin",`${W.lat},${W.lng}`),K.set("destination",`${J.lat},${J.lng}`),$.length>2){let X=$.slice(1,-1).map((Y)=>`${Y.lat},${Y.lng}`).join("|");K.set("waypoints",X)}if(Q?.alternatives)K.set("alternatives","true");if(Q?.language)K.set("language",Q.language);let U=`${this.baseUrl}/directions/json?${K.toString()}`,V=await BQ(U,Q?.signal);if(V.status!=="OK"&&V.status!=="ZERO_RESULTS")throw Error(`Google directions error: ${V.status}${V.error_message?` — ${V.error_message}`:""}`);return(V.routes??[]).map(L4)}}var b8="https://api.mapbox.com";function x8($){if(!$)throw Error("Mapbox provider requires an accessToken");return $}var l9={driving:"mapbox/driving",walking:"mapbox/walking",cycling:"mapbox/cycling"},z4={driving:"mapbox/driving",walking:"mapbox/walking",cycling:"mapbox/cycling"};async function r$($,Q){let K=await fetch($,{signal:Q});if(!K.ok)throw Error(`Mapbox request failed: ${K.status} ${K.statusText}`);return K.json()}function v4($){switch($){case"country":case"region":case"district":case"postcode":case"place":case"address":case"poi":return $;default:return}}function C7($){let Q=$.geometry?.coordinates??[0,0],K={text:$.properties?.full_address??$.properties?.name??"",center:{lat:Q[1],lng:Q[0]},properties:$.properties};if($.properties?.bbox)K.bbox=$.properties.bbox;let W=v4($.properties?.feature_type);if(W)K.placeType=W;if(typeof $.relevance==="number")K.relevance=$.relevance;return K}class p9{name="mapbox";accessToken;baseUrl;constructor($){this.accessToken=x8($.accessToken),this.baseUrl=($.baseUrl??b8).replace(/\/$/,"")}async search($,Q){let K=new URLSearchParams;if(K.set("q",$),K.set("access_token",this.accessToken),K.set("limit",String(Q?.limit??5)),Q?.language)K.set("language",Q.language);if(Q?.proximity)K.set("proximity",`${Q.proximity.lng},${Q.proximity.lat}`);if(Q?.bbox)K.set("bbox",Q.bbox.join(","));if(Q?.countries&&Q.countries.length>0)K.set("country",Q.countries.join(","));let W=`${this.baseUrl}/search/geocode/v6/forward?${K.toString()}`;return((await r$(W,Q?.signal)).features??[]).map(C7)}async reverse($,Q){let K=new URLSearchParams;if(K.set("longitude",String($.lng)),K.set("latitude",String($.lat)),K.set("access_token",this.accessToken),K.set("limit",String(Q?.limit??1)),Q?.language)K.set("language",Q.language);let W=`${this.baseUrl}/search/geocode/v6/reverse?${K.toString()}`;return((await r$(W,Q?.signal)).features??[]).map(C7)}}function u$($){return $.map(([Q,K])=>({lat:K,lng:Q}))}function f4($){let Q={distance:$.distance,duration:$.duration,instruction:$.maneuver?.instruction??$.name??"",geometry:u$($.geometry?.coordinates??[])};if($.maneuver?.type)Q.maneuver=$.maneuver.modifier?`${$.maneuver.type}-${$.maneuver.modifier}`.replace(/\s+/g,"-"):$.maneuver.type;return Q}function h4($){let Q=($.legs??[]).flatMap((K)=>(K.steps??[]).map(f4));return{distance:$.distance,duration:$.duration,geometry:u$($.geometry?.coordinates??[]),steps:Q}}class i9{name="mapbox";accessToken;baseUrl;constructor($){this.accessToken=x8($.accessToken),this.baseUrl=($.baseUrl??b8).replace(/\/$/,"")}async getDirections($,Q){if($.length<2)throw Error("Mapbox directions requires at least two waypoints");let K=l9[Q?.profile??"driving"],W=$.map((X)=>`${X.lng},${X.lat}`).join(";"),J=new URLSearchParams;if(J.set("access_token",this.accessToken),J.set("geometries","geojson"),J.set("overview","full"),J.set("steps","true"),J.set("alternatives",Q?.alternatives?"true":"false"),Q?.language)J.set("language",Q.language);let U=`${this.baseUrl}/directions/v5/${K}/${W}?${J.toString()}`,V=await r$(U,Q?.signal);if(V.code!=="Ok")throw Error(`Mapbox directions error: ${V.code}${V.message?` — ${V.message}`:""}`);return(V.routes??[]).map(h4)}}class n9{name="mapbox";accessToken;baseUrl;constructor($){this.accessToken=x8($.accessToken),this.baseUrl=($.baseUrl??b8).replace(/\/$/,"")}async getIsochrones($,Q){let K=z4[Q.profile??"driving"],W=Q.contourMetric??"time",J=new URLSearchParams;if(J.set("access_token",this.accessToken),W==="distance")J.set("contours_meters",Q.contours.join(","));else J.set("contours_minutes",Q.contours.join(","));if(J.set("polygons","true"),typeof Q.denoise==="number")J.set("denoise",String(Q.denoise));if(typeof Q.generalize==="number")J.set("generalize",String(Q.generalize));let U=`${this.baseUrl}/isochrone/v1/${K}/${$.lng},${$.lat}?${J.toString()}`,V=await r$(U,Q.signal),X=[];for(let Y of V.features??[]){let Z=Y.properties?.contour??0;if(Y.geometry.type==="Polygon"){let H=Y.geometry.coordinates;if(H.length===0)continue;let A={geometry:u$(H[0]),contour:Z};if(H.length>1)A.holes=H.slice(1).map((G)=>u$(G));X.push(A)}else if(Y.geometry.type==="LineString")X.push({geometry:u$(Y.geometry.coordinates),contour:Z})}return X}}class s9{name="mapbox";accessToken;baseUrl;constructor($){this.accessToken=x8($.accessToken),this.baseUrl=($.baseUrl??b8).replace(/\/$/,"")}async getMatrix($,Q,K){let W=l9[K?.profile??"driving"],U=[...$,...Q].map((N)=>`${N.lng},${N.lat}`).join(";"),V=$.map((N,q)=>q).join(";"),X=Q.map((N,q)=>q+$.length).join(";"),Y=new URLSearchParams;Y.set("access_token",this.accessToken),Y.set("sources",V),Y.set("destinations",X);let Z=[],H=K?.metric??"time";if(H==="distance"||H==="time")Z.push("duration","distance");Y.set("annotations",Z.join(","));let A=`${this.baseUrl}/directions-matrix/v1/${W}/${U}?${Y.toString()}`,G=await r$(A,K?.signal);if(G.code!=="Ok")throw Error(`Mapbox matrix error: ${G.code}${G.message?` — ${G.message}`:""}`);let F={};if(G.durations)F.durations=G.durations;if(G.distances)F.distances=G.distances;return F}}var b4="https://api.maptiler.com";function x4($){if(!$||$.length===0)return;let Q=$[0];switch(Q){case"country":case"region":case"district":case"postcode":case"place":case"address":case"poi":return Q;default:return}}function O7($){let Q=$.center??[0,0],K={text:$.place_name??$.text??"",center:{lat:Q[1],lng:Q[0]},properties:$.properties};if($.bbox)K.bbox=$.bbox;let W=x4($.place_type);if(W)K.placeType=W;if(typeof $.relevance==="number")K.relevance=$.relevance;return K}class r9{name="maptiler";apiKey;baseUrl;constructor($){if(!$.apiKey)throw Error("Maptiler provider requires an apiKey");this.apiKey=$.apiKey,this.baseUrl=($.baseUrl??b4).replace(/\/$/,"")}buildParams($){let Q=new URLSearchParams;if(Q.set("key",this.apiKey),$?.limit)Q.set("limit",String($.limit));if($?.language)Q.set("language",$.language);if($?.proximity)Q.set("proximity",`${$.proximity.lng},${$.proximity.lat}`);if($?.bbox)Q.set("bbox",$.bbox.join(","));if($?.countries&&$.countries.length>0)Q.set("country",$.countries.join(","));return Q}async fetch($,Q){let K=await fetch($,{signal:Q});if(!K.ok)throw Error(`Maptiler request failed: ${K.status} ${K.statusText}`);return await K.json()}async search($,Q){let K=this.buildParams(Q),W=`${this.baseUrl}/geocoding/${encodeURIComponent($)}.json?${K.toString()}`;return((await this.fetch(W,Q?.signal)).features??[]).map(O7)}async reverse($,Q){let K=this.buildParams(Q),W=`${this.baseUrl}/geocoding/${$.lng},${$.lat}.json?${K.toString()}`;return((await this.fetch(W,Q?.signal)).features??[]).map(O7)}}f();function y4($,Q){if($==="boundary"&&Q==="administrative")return"region";if(Q==="country")return"country";if(Q==="state"||Q==="province")return"region";if(Q==="city"||Q==="town"||Q==="village")return"place";if(Q==="postcode")return"postcode";if(Q==="administrative")return"district";if($==="highway"||$==="place"&&Q==="house")return"address";if($==="amenity"||$==="shop"||$==="tourism")return"poi";return}function E7($){let Q=Number.parseFloat($.lat),K=Number.parseFloat($.lon),W={text:$.display_name,center:{lat:Q,lng:K},properties:{...$.address,osm_id:$.osm_id,osm_type:$.osm_type,class:$.class,type:$.type}};if($.boundingbox){let[U,V,X,Y]=$.boundingbox.map(Number.parseFloat);W.bbox=[X,U,Y,V]}let J=y4($.class,$.type);if(J)W.placeType=J;if(typeof $.importance==="number")W.relevance=Math.max(0,Math.min(1,$.importance));return W}class Q6{name="nominatim";baseUrl;userAgent;scheduleRequest;constructor($={}){this.baseUrl=($.baseUrl??"https://nominatim.openstreetmap.org").replace(/\/$/,""),this.userAgent=$.userAgent??"ts-maps",this.scheduleRequest=LQ((Q)=>Q(),250)}gate($){return new Promise((Q,K)=>{this.scheduleRequest(()=>{$().then(Q,K)})})}buildSearchUrl($,Q){let K=new URLSearchParams;if(K.set("q",$),K.set("format","json"),K.set("addressdetails","1"),K.set("limit",String(Q?.limit??5)),Q?.language)K.set("accept-language",Q.language);if(Q?.countries&&Q.countries.length>0)K.set("countrycodes",Q.countries.join(","));if(Q?.bbox){let[W,J,U,V]=Q.bbox;K.set("viewbox",`${W},${V},${U},${J}`),K.set("bounded","1")}return`${this.baseUrl}/search?${K.toString()}`}buildReverseUrl($,Q){let K=new URLSearchParams;if(K.set("lat",String($.lat)),K.set("lon",String($.lng)),K.set("format","json"),K.set("addressdetails","1"),Q?.language)K.set("accept-language",Q.language);return`${this.baseUrl}/reverse?${K.toString()}`}async fetch($,Q){let K=await fetch($,{headers:{"User-Agent":this.userAgent,Accept:"application/json"},signal:Q});if(!K.ok)throw Error(`Nominatim request failed: ${K.status} ${K.statusText}`);return K.json()}async search($,Q){if(!$)return[];let K=this.buildSearchUrl($,Q);return this.gate(async()=>{let W=await this.fetch(K,Q?.signal);return Array.isArray(W)?W.map(E7):[]})}async reverse($,Q){let K=this.buildReverseUrl($,Q);return this.gate(async()=>{let W=await this.fetch(K,Q?.signal);if(!W||W.error)return[];return[E7(W)]})}}var a9={driving:"driving",walking:"foot",cycling:"bike"};function o9($){return $.map(([Q,K])=>({lat:K,lng:Q}))}function u4($){if($.maneuver?.instruction)return $.maneuver.instruction;let Q=[];if($.maneuver?.type)Q.push($.maneuver.type);if($.maneuver?.modifier)Q.push($.maneuver.modifier);if($.name)Q.push(`onto ${$.name}`);return Q.join(" ").trim()||"continue"}function g4($){if(!$.maneuver?.type)return;if($.maneuver.modifier)return`${$.maneuver.type}-${$.maneuver.modifier}`.replace(/\s+/g,"-");return $.maneuver.type}function t9($){let Q={distance:$.distance,duration:$.duration,instruction:u4($),geometry:o9($.geometry?.coordinates??[])},K=g4($);if(K)Q.maneuver=K;return Q}function m4($){let Q=($.steps??[]).map(t9),K=Q.flatMap((W)=>W.geometry);return{distance:$.distance,duration:$.duration,geometry:K,steps:Q}}function d4($){let Q=($.legs??[]).flatMap((K)=>(K.steps??[]).map(t9));return{distance:$.distance,duration:$.duration,geometry:o9($.geometry?.coordinates??[]),steps:Q,legs:($.legs??[]).map(m4)}}class K6{name="osrm";baseUrl;constructor($={}){this.baseUrl=($.baseUrl??"https://router.project-osrm.org").replace(/\/$/,"")}async getDirections($,Q){if($.length<2)throw Error("OSRM requires at least two waypoints");let K=a9[Q?.profile??"driving"]??"driving",W=$.map((Y)=>`${Y.lng},${Y.lat}`).join(";"),J=new URLSearchParams;J.set("overview","full"),J.set("geometries","geojson"),J.set("steps","true"),J.set("alternatives",Q?.alternatives?"true":"false");let U=`${this.baseUrl}/route/v1/${K}/${W}?${J.toString()}`,V=await fetch(U,{signal:Q?.signal});if(!V.ok)throw Error(`OSRM request failed: ${V.status} ${V.statusText}`);let X=await V.json();if(X.code!=="Ok")throw Error(`OSRM error: ${X.code}${X.message?` — ${X.message}`:""}`);return(X.routes??[]).map(d4)}}class W6{name="osrm";baseUrl;constructor($={}){this.baseUrl=($.baseUrl??"https://router.project-osrm.org").replace(/\/$/,"")}async getMatrix($,Q,K){if($.length===0||Q.length===0)throw Error("OSRM matrix requires at least one origin and one destination");let W=a9[K?.profile??"driving"]??"driving",U=[...$,...Q].map((N)=>`${N.lng},${N.lat}`).join(";"),V=$.map((N,q)=>q).join(";"),X=Q.map((N,q)=>$.length+q).join(";"),Y=K?.metric==="distance"?"distance":"duration",Z=new URLSearchParams;Z.set("sources",V),Z.set("destinations",X),Z.set("annotations",Y);let H=`${this.baseUrl}/table/v1/${W}/${U}?${Z.toString()}`,A=await fetch(H,{signal:K?.signal});if(!A.ok)throw Error(`OSRM matrix request failed: ${A.status} ${A.statusText}`);let G=await A.json();if(G.code!=="Ok")throw Error(`OSRM matrix error: ${G.code}${G.message?` — ${G.message}`:""}`);let F={};if(G.durations)F.durations=G.durations.map((N)=>N.map((q)=>q??Number.POSITIVE_INFINITY));if(G.distances)F.distances=G.distances.map((N)=>N.map((q)=>q??Number.POSITIVE_INFINITY));return F}}function c4($){if(!$)return;if($.osm_value==="country"||$.type==="country")return"country";if($.osm_value==="state"||$.type==="state")return"region";if($.type==="county")return"district";if($.osm_key==="place"&&($.osm_value==="city"||$.osm_value==="town"||$.osm_value==="village"))return"place";if($.osm_key==="highway"||$.housenumber)return"address";if($.postcode&&$.type==="postcode")return"postcode";if($.osm_key==="amenity"||$.osm_key==="shop"||$.osm_key==="tourism")return"poi";return}function l4($){if(!$)return"";let Q=[];if($.name)Q.push($.name);if($.street){let K=$.housenumber?`${$.street} ${$.housenumber}`:$.street;if(!Q.length||Q[0]!==K)Q.push(K)}if($.postcode||$.city)Q.push([$.postcode,$.city].filter(Boolean).join(" "));if($.country)Q.push($.country);return Q.filter(Boolean).join(", ")}function B7($){let Q=$.geometry?.coordinates??[0,0],K={text:l4($.properties),center:{lat:Q[1],lng:Q[0]},properties:$.properties};if($.properties?.extent){let[J,U,V,X]=$.properties.extent;K.bbox=[J,X,V,U]}let W=c4($.properties);if(W)K.placeType=W;return K}class e9{name="photon";baseUrl;constructor($={}){this.baseUrl=($.baseUrl??"https://photon.komoot.io").replace(/\/$/,"")}async search($,Q){if(!$)return[];let K=new URLSearchParams;if(K.set("q",$),K.set("limit",String(Q?.limit??5)),Q?.language)K.set("lang",Q.language);if(Q?.proximity)K.set("lat",String(Q.proximity.lat)),K.set("lon",String(Q.proximity.lng));if(Q?.bbox)K.set("bbox",Q.bbox.join(","));let W=`${this.baseUrl}/api?${K.toString()}`,J=await fetch(W,{signal:Q?.signal});if(!J.ok)throw Error(`Photon request failed: ${J.status} ${J.statusText}`);return((await J.json()).features??[]).map(B7)}async reverse($,Q){let K=new URLSearchParams;if(K.set("lat",String($.lat)),K.set("lon",String($.lng)),Q?.limit)K.set("limit",String(Q.limit));if(Q?.language)K.set("lang",Q.language);let W=`${this.baseUrl}/reverse?${K.toString()}`,J=await fetch(W,{signal:Q?.signal});if(!J.ok)throw Error(`Photon reverse request failed: ${J.status} ${J.statusText}`);return((await J.json()).features??[]).map(B7)}}var J6="https://valhalla1.openstreetmap.de",U6={driving:"auto",walking:"pedestrian",cycling:"bicycle"};function p4($,Q=6){let K=10**Q,W=$.length,J=0,U=0,V=0,X=[];while(J<W){let Y=0,Z=0,H;do H=$.charCodeAt(J++)-63,Z|=(H&31)<<Y,Y+=5;while(H>=32);let A=Z&1?~(Z>>1):Z>>1;U+=A,Y=0,Z=0;do H=$.charCodeAt(J++)-63,Z|=(H&31)<<Y,Y+=5;while(H>=32);let G=Z&1?~(Z>>1):Z>>1;V+=G,X.push({lat:U/K,lng:V/K})}return X}function i4($){let Q=$.shape?p4($.shape):[],K=($.maneuvers??[]).map((W)=>{let J=W.begin_shape_index??0,U=W.end_shape_index??J;return{distance:(W.length??0)*1000,duration:W.time??0,instruction:W.instruction??"",geometry:Q.slice(J,U+1)}});return{distance:($.summary?.length??0)*1000,duration:$.summary?.time??0,geometry:Q,steps:K}}function k7($){let Q=($.legs??[]).map(i4),K=Q.flatMap((J)=>J.geometry),W=Q.flatMap((J)=>J.steps);return{distance:($.summary?.length??0)*1000,duration:$.summary?.time??0,geometry:K,steps:W,legs:Q}}async function V6($,Q,K){let W=await fetch($,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(Q),signal:K});if(!W.ok)throw Error(`Valhalla request failed: ${W.status} ${W.statusText}`);return W.json()}function X6($,Q,K){let W=$.replace(/\/$/,""),J=K?`?api_key=${encodeURIComponent(K)}`:"";return`${W}${Q}${J}`}class Y6{name="valhalla";baseUrl;apiKey;constructor($={}){this.baseUrl=$.baseUrl??J6,this.apiKey=$.apiKey}async getDirections($,Q){if($.length<2)throw Error("Valhalla requires at least two waypoints");let K={locations:$.map((V)=>({lat:V.lat,lon:V.lng})),costing:U6[Q?.profile??"driving"]??"auto",directions_options:{language:Q?.language??"en-US"}};if(Q?.alternatives)K.alternates=1;let W=X6(this.baseUrl,"/route",this.apiKey),J=await V6(W,K,Q?.signal),U=[];if(J.trip)U.push(k7(J.trip));if(J.alternates){for(let V of J.alternates)if(V.trip)U.push(k7(V.trip))}return U}}function b$($){return $.map(([Q,K])=>({lat:K,lng:Q}))}class Z6{name="valhalla";baseUrl;apiKey;constructor($={}){this.baseUrl=$.baseUrl??J6,this.apiKey=$.apiKey}async getIsochrones($,Q){let K=Q.contourMetric??"time",W={locations:[{lat:$.lat,lon:$.lng}],costing:U6[Q.profile??"driving"]??"auto",contours:Q.contours.map((X)=>K==="distance"?{distance:X}:{time:X}),polygons:!0};if(typeof Q.denoise==="number")W.denoise=Q.denoise;if(typeof Q.generalize==="number")W.generalize=Q.generalize;let J=X6(this.baseUrl,"/isochrone",this.apiKey),U=await V6(J,W,Q.signal),V=[];for(let X of U.features??[]){let Y=X.properties?.contour??0,{geometry:Z}=X;if(Z.type==="Polygon"){let H=Z.coordinates;if(H.length===0)continue;let A={geometry:b$(H[0]),contour:Y};if(H.length>1)A.holes=H.slice(1).map(b$);V.push(A)}else if(Z.type==="MultiPolygon"){let H=Z.coordinates;for(let A of H){if(A.length===0)continue;let G={geometry:b$(A[0]),contour:Y};if(A.length>1)G.holes=A.slice(1).map(b$);V.push(G)}}else if(Z.type==="LineString")V.push({geometry:b$(Z.coordinates),contour:Y})}return V}}class H6{name="valhalla";baseUrl;apiKey;constructor($={}){this.baseUrl=$.baseUrl??J6,this.apiKey=$.apiKey}async getMatrix($,Q,K){let W={sources:$.map((H)=>({lat:H.lat,lon:H.lng})),targets:Q.map((H)=>({lat:H.lat,lon:H.lng})),costing:U6[K?.profile??"driving"]??"auto"},J=X6(this.baseUrl,"/sources_to_targets",this.apiKey),U=await V6(J,W,K?.signal),V=[],X=[];for(let H of U.sources_to_targets??[]){let A=[],G=[];for(let F of H)A.push(F.time??0),G.push((F.distance??0)*1000);V.push(A),X.push(G)}let Y=K?.metric??"time",Z={};if(Y==="time"||Y==="distance")Z.durations=V,Z.distances=X;return Z}}var n4=()=>new Q6,s4=()=>new K6,r4=()=>new Z6,a4=()=>new W6,o4=()=>new H6,t4=()=>new Y6;i();r();$0();f();r();e$();$0();class y0 extends E${_map;onAdd($){return document.createElement("div")}onRemove($){}initialize(...$){t(this,$[0])}getPosition(){return this.options.position}setPosition($){let Q=this._map;return Q?.removeControl(this),this.options.position=$,Q?.addControl(this),this}getContainer(){return this._container}addTo($){this.remove(),this._map=$;let Q=this._container=this.onAdd($),K=this.getPosition(),W=$._controlCorners[K];if(Q.classList.add("tsmap-control"),K.includes("bottom"))W.insertBefore(Q,W.firstChild);else W.appendChild(Q);return this._map.on("unload",this.remove,this),this}remove(){if(!this._map)return this;return this._container?.remove(),this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this}_refocusOnMap($){if(this._map&&$&&!($.screenX===0&&$.screenY===0))this._map.getContainer().focus()}}y0.setDefaultOptions({position:"topright"});L.include({addControl($){return $.addTo(this),this},removeControl($){return $.remove(),this},_initControlPos(){let $=this._controlCorners={},Q="tsmap-",K=this._controlContainer=v("div","tsmap-control-container",this._container);function W(J,U){let V=`${"tsmap-"+J} tsmap-${U}`;$[J+U]=v("div",V,K)}W("top","left"),W("top","right"),W("bottom","left"),W("bottom","right")},_clearControlPos(){for(let $ of Object.values(this._controlCorners))$.remove();this._controlContainer?.remove(),delete this._controlCorners,delete this._controlContainer}});var e4='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="tsmap-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>';class K8 extends y0{initialize($){super.initialize($),this._attributions={}}onAdd($){$.attributionControl=this,this._container=v("div","tsmap-control-attribution"),O$(this._container);for(let Q of Object.values($._layers))if(Q.getAttribution)this.addAttribution(Q.getAttribution());return this._update(),$.on("layeradd",this._addAttribution,this),this._container}onRemove($){$.off("layeradd",this._addAttribution,this)}_addAttribution($){if($.layer.getAttribution)this.addAttribution($.layer.getAttribution()),$.layer.once("remove",()=>this.removeAttribution($.layer.getAttribution()))}setPrefix($){return this.options.prefix=$,this._update(),this}addAttribution($){if(!$)return this;if(!this._attributions[$])this._attributions[$]=0;return this._attributions[$]++,this._update(),this}removeAttribution($){if(!$)return this;if(this._attributions[$])this._attributions[$]--,this._update();return this}_update(){if(!this._map)return;let $=Object.keys(this._attributions).filter((K)=>this._attributions[K]),Q=[];if(this.options.prefix)Q.push(this.options.prefix);if($.length)Q.push($.join(", "));this._container.innerHTML=Q.join(' <span aria-hidden="true">|</span> ')}}K8.setDefaultOptions({position:"bottomright",prefix:`<a target="_blank" href="https://github.com/stacksjs/ts-maps" title="ts-maps">${e4}ts-maps</a>`});L.mergeOptions({attributionControl:!0});L.addInitHook(function(){if(this.options.attributionControl)new K8().addTo(this)});f();i();r();class y8 extends y0{_lastZIndex=0;_handlingClick=!1;_preventClick=!1;initialize($,Q,K){super.initialize(K),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(let[W,J]of Object.entries($??{}))this._addLayer(J,W);for(let[W,J]of Object.entries(Q??{}))this._addLayer(J,W,!0)}onAdd($){this._initLayout(),this._update(),this._map=$,$.on("zoomend",this._checkDisabledLayers,this);for(let Q of this._layers)Q.layer.on("add remove",this._onLayerChange,this);if(!this.options.collapsed)$.on("resize",this._expandIfNotCollapsed,this);return this._container}addTo($){return super.addTo($),this._expandIfNotCollapsed()}onRemove(){this._map.off("zoomend",this._checkDisabledLayers,this);for(let $ of this._layers)$.layer.off("add remove",this._onLayerChange,this);this._map.off("resize",this._expandIfNotCollapsed,this)}addBaseLayer($,Q){return this._addLayer($,Q),this._map?this._update():this}addOverlay($,Q){return this._addLayer($,Q,!0),this._map?this._update():this}removeLayer($){$.off("add remove",this._onLayerChange,this);let Q=this._getLayer(u($));if(Q)this._layers.splice(this._layers.indexOf(Q),1);return this._map?this._update():this}expand(){clearTimeout(this._collapseDelayTimeout),this._container.classList.add("tsmap-control-layers-expanded"),this._section.style.height="";let $=this._map.getSize().y-(this._container.offsetTop+50);if($<this._section.clientHeight)this._section.classList.add("tsmap-control-layers-scrollbar"),this._section.style.height=`${$}px`;else this._section.classList.remove("tsmap-control-layers-scrollbar");return this._checkDisabledLayers(),this}collapse($){if(!$||!(($.type==="pointerleave"||$.type==="pointerout")&&$.pointerType==="touch")){if(this.options.collapseDelay>0)return this._collapseDelayTimeout=setTimeout(()=>{this._container.classList.remove("tsmap-control-layers-expanded")},this.options.collapseDelay),this;this._container.classList.remove("tsmap-control-layers-expanded")}return this}_initLayout(){let Q=this._container=v("div","tsmap-control-layers"),K=this.options.collapsed;O$(Q),cQ(Q);let W=this._section=v("fieldset","tsmap-control-layers-list");if(K)this._map.on("click",this.collapse,this),B(Q,{pointerenter:this._expandSafely,pointerleave:this.collapse},this);let J=this._layersLink=v("a","tsmap-control-layers-toggle",Q);if(J.href="#",J.title="Layers",J.setAttribute("role","button"),B(J,{keydown(U){if(U.code==="Enter")this._expandSafely()},click(U){U.preventDefault(),this._expandSafely()}},this),!K)this.expand();this._baseLayersList=v("div","tsmap-control-layers-base",W),this._separator=v("div","tsmap-control-layers-separator",W),this._overlaysList=v("div","tsmap-control-layers-overlays",W),Q.appendChild(W)}_getLayer($){for(let Q of this._layers)if(Q&&u(Q.layer)===$)return Q}_addLayer($,Q,K){if(this._map)$.on("add remove",this._onLayerChange,this);if(this._layers.push({layer:$,name:Q,overlay:K}),this.options.sortLayers)this._layers.sort((W,J)=>this.options.sortFunction(W.layer,J.layer,W.name,J.name));if(this.options.autoZIndex&&$.setZIndex)this._lastZIndex++,$.setZIndex(this._lastZIndex);this._expandIfNotCollapsed()}_update(){if(!this._container)return this;this._baseLayersList.replaceChildren(),this._overlaysList.replaceChildren(),this._layerControlInputs=[];for(let W of this._layers)this._addItem(W);let $=this._layers.some((W)=>!!W.overlay),Q=this._layers.filter((W)=>!W.overlay).length,K=Q>0;if(this.options.hideSingleBase)K=K&&Q>1,this._baseLayersList.style.display=K?"":"none";return this._separator.style.display=$&&K?"":"none",this}_onLayerChange($){if(!this._handlingClick)this._update();let Q=this._getLayer(u($.target)),K=Q.overlay?$.type==="add"?"overlayadd":"overlayremove":$.type==="add"?"baselayerchange":null;if(K)this._map.fire(K,Q)}_addItem($){let Q=document.createElement("label"),K=this._map.hasLayer($.layer),W=document.createElement("input");if(W.type=$.overlay?"checkbox":"radio",W.className="tsmap-control-layers-selector",W.defaultChecked=K,!$.overlay)W.name=`tsmap-base-layers_${u(this)}`;this._layerControlInputs.push(W),W.layerId=u($.layer),B(W,"click",this._onInputClick,this);let J=document.createElement("span");J.innerHTML=` ${$.name}`;let U=document.createElement("span");return Q.appendChild(U),U.appendChild(W),U.appendChild(J),($.overlay?this._overlaysList:this._baseLayersList).appendChild(Q),this._checkDisabledLayers(),Q}_onInputClick($){if(this._preventClick)return;let Q=this._layerControlInputs,K=[],W=[];this._handlingClick=!0;for(let J of Q){let U=this._getLayer(J.layerId).layer;if(J.checked)K.push(U);else W.push(U)}for(let J of W)if(this._map.hasLayer(J))this._map.removeLayer(J);for(let J of K)if(!this._map.hasLayer(J))this._map.addLayer(J);this._handlingClick=!1,this._refocusOnMap($)}_checkDisabledLayers(){let $=this._layerControlInputs,Q=this._map.getZoom();for(let K of $){let W=this._getLayer(K.layerId).layer;K.disabled=W.options.minZoom!==void 0&&Q<W.options.minZoom||W.options.maxZoom!==void 0&&Q>W.options.maxZoom}}_expandIfNotCollapsed(){if(this._map&&!this.options.collapsed)this.expand();return this}_expandSafely(){let $=this._section;this._preventClick=!0,B($,"click",a0),this.expand(),setTimeout(()=>{h($,"click",a0),this._preventClick=!1})}}y8.setDefaultOptions({collapsed:!0,collapseDelay:0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction($,Q,K,W){return K<W?-1:W<K?1:0}});i();r();var M8="tsmap-control-locate";class A6 extends y0{onAdd($){let Q=this.options,K=v("div",`${M8} tsmap-bar`),W=v("a",`${M8}-button`,K);return W.href="#",W.title=Q.title??"Show your location",W.setAttribute("role","button"),W.setAttribute("aria-label",W.title),W.innerHTML='<span class="tsmap-locate-icon" aria-hidden="true"></span>',O$(W),B(W,"click",o0),B(W,"click",this._onClick,this),this._button=W,this._setState("idle"),$.on("dragstart zoomstart",this._stopFollowing,this),K}onRemove($){$.off("dragstart zoomstart",this._stopFollowing,this),this._clearWatch(),this._clearMarker()}start(){return this._locate(),this}stop(){return this._clearWatch(),this._clearMarker(),this._setState("idle"),this}_onClick(){if(this._following){this.stop();return}this._locate()}_locate(){let $=typeof navigator<"u"?navigator:void 0;if(!$?.geolocation){this._setState("denied"),this._map?.fire?.("locateerror",{message:"Geolocation is not available in this browser"});return}let Q=this.options;this._setState("locating");let K={enableHighAccuracy:Q.enableHighAccuracy??!0,timeout:Q.timeout??1e4,maximumAge:Q.maximumAge??60000},W=(J)=>{this._clearWatch(),this._setState("denied"),this._map?.fire?.("locateerror",{code:J.code,message:J.message})};if(Q.follow===!1){$.geolocation.getCurrentPosition((J)=>this._onPosition(J,!0),W,K);return}this._following=!0,this._watchId=$.geolocation.watchPosition((J)=>this._onPosition(J,!0),W,K)}_onPosition($,Q){let K=this.options,{latitude:W,longitude:J,accuracy:U}=$.coords,V=[W,J];if(this._setState(this._following?"active":"idle"),Q&&this._map){let X=K.zoom===null?this._map.getZoom():K.zoom??16;this._map.setView(V,X)}if(K.showMarker!==!1)this._updateMarker(V,U);this._map?.fire?.("locatefound",{latlng:V,accuracy:U,position:$})}_updateMarker($,Q){let K=this._map;if(!K)return;let W=K.circle??globalThis.tsmapCircle;if(typeof W!=="function")return;if(this._accuracyCircle){this._accuracyCircle.setLatLng?.($),this._accuracyCircle.setRadius?.(Q);return}this._accuracyCircle=W.call(K,$,{radius:Q,className:"tsmap-locate-accuracy",interactive:!1}),this._accuracyCircle?.addTo?.(K)}_clearMarker(){this._accuracyCircle?.remove?.(),this._accuracyCircle=void 0,this._marker?.remove?.(),this._marker=void 0}_stopFollowing(){if(!this._following)return;this._following=!1,this._clearWatch(),this._setState("idle")}_clearWatch(){if(this._watchId!==void 0&&typeof navigator<"u")navigator.geolocation?.clearWatch(this._watchId);this._watchId=void 0,this._following=!1}_setState($){let Q=this._button;if(!Q)return;let K=this.options;for(let J of["idle","locating","active","denied"])Q.classList.remove(`${M8}-${J}`);Q.classList.add(`${M8}-${$}`);let W=$==="locating"?K.titleLocating??"Finding your location…":$==="active"?K.titleActive??"Following your location":$==="denied"?K.titleDenied??"Location unavailable — check browser permissions":K.title??"Show your location";Q.title=W,Q.setAttribute("aria-label",W),Q.setAttribute("aria-pressed",String($==="active")),Q.setAttribute("data-state",$)}}A6.setDefaultOptions({position:"topright",zoom:16,follow:!0,enableHighAccuracy:!0,timeout:1e4,maximumAge:60000,showMarker:!0});r();class u8 extends y0{onAdd($){let K=v("div","tsmap-control-scale"),W=this.options;return this._addScales(W,"tsmap-control-scale-line",K),$.on(W.updateWhenIdle?"moveend":"move",this._update,this),$.whenReady(this._update,this),K}onRemove($){$.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)}_addScales($,Q,K){if($.metric)this._mScale=v("div",Q,K);if($.imperial)this._iScale=v("div",Q,K)}_update(){let $=this._map,Q=$.getSize().y/2,K=$.distance($.containerPointToLatLng([0,Q]),$.containerPointToLatLng([this.options.maxWidth,Q]));this._updateScales(K)}_updateScales($){if(this.options.metric&&$)this._updateMetric($);if(this.options.imperial&&$)this._updateImperial($)}_updateMetric($){let Q=this._getRoundNum($),K=Q<1000?`${Q} m`:`${Q/1000} km`;this._updateScale(this._mScale,K,Q/$)}_updateImperial($){let Q=$*3.2808399;if(Q>5280){let K=Q/5280,W=this._getRoundNum(K);this._updateScale(this._iScale,`${W} mi`,W/K)}else{let K=this._getRoundNum(Q);this._updateScale(this._iScale,`${K} ft`,K/Q)}}_updateScale($,Q,K){$.style.width=`${Math.round(this.options.maxWidth*K)}px`,$.innerHTML=Q}_getRoundNum($){let Q=10**(String(Math.floor($)).length-1),K=$/Q;return K=K>=10?10:K>=5?5:K>=3?3:K>=2?2:1,Q*K}}u8.setDefaultOptions({position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1});i();r();$0();class W8 extends y0{onAdd($){let K=v("div","tsmap-control-zoom tsmap-bar"),W=this.options;return this._zoomInButton=this._createButton(W.zoomInText,W.zoomInTitle,"tsmap-control-zoom-in",K,this._zoomIn),this._zoomOutButton=this._createButton(W.zoomOutText,W.zoomOutTitle,"tsmap-control-zoom-out",K,this._zoomOut),this._updateDisabled(),$.on("zoomend zoomlevelschange",this._updateDisabled,this),K}onRemove($){$.off("zoomend zoomlevelschange",this._updateDisabled,this)}disable(){return this._disabled=!0,this._updateDisabled(),this}enable(){return this._disabled=!1,this._updateDisabled(),this}_zoomIn($){if(!this._disabled&&this._map._zoom<this._map.getMaxZoom())this._map.zoomIn(this._map.options.zoomDelta*($.shiftKey?3:1))}_zoomOut($){if(!this._disabled&&this._map._zoom>this._map.getMinZoom())this._map.zoomOut(this._map.options.zoomDelta*($.shiftKey?3:1))}_createButton($,Q,K,W,J){let U=v("a",K,W);return U.innerHTML=$,U.href="#",U.title=Q,U.setAttribute("role","button"),U.setAttribute("aria-label",Q),O$(U),B(U,"click",o0),B(U,"click",J,this),B(U,"click",this._refocusOnMap,this),U}_updateDisabled(){let $=this._map,Q="tsmap-disabled";if(this._zoomInButton?.classList.remove("tsmap-disabled"),this._zoomOutButton?.classList.remove("tsmap-disabled"),this._zoomInButton?.setAttribute("aria-disabled","false"),this._zoomOutButton?.setAttribute("aria-disabled","false"),this._disabled||$._zoom===$.getMinZoom())this._zoomOutButton?.classList.add("tsmap-disabled"),this._zoomOutButton?.setAttribute("aria-disabled","true");if(this._disabled||$._zoom===$.getMaxZoom())this._zoomInButton?.classList.add("tsmap-disabled"),this._zoomInButton?.setAttribute("aria-disabled","true")}}W8.setDefaultOptions({position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">−</span>',zoomOutTitle:"Zoom out"});L.mergeOptions({zoomControl:!0});L.addInitHook(function(){if(this.options.zoomControl)this.zoomControl=new W8,this.addControl(this.zoomControl)});e0();e$();B$();e$();class D0 extends E${_enabled=!1;static addTo($,Q){return $.addHandler(Q,this),this}initialize(...$){this._map=$[0]}enable(){if(this._enabled)return this;return this._enabled=!0,this.addHooks(),this}disable(){if(!this._enabled)return this;return this._enabled=!1,this.removeHooks(),this}enabled(){return!!this._enabled}addHooks(){}removeHooks(){}}f();e7();t7();i();r();f();i();Z$();r();B$();l();class S0 extends R0{static _dragging=!1;initialize($,Q,K,W){t(this,W),this._element=$,this._dragStartTarget=Q??$,this._preventOutline=K}enable(){if(this._enabled)return this;return B(this._dragStartTarget,"pointerdown",this._onDown,this),this._enabled=!0,this}disable(){if(!this._enabled)return this;if(S0._dragging===this)this.finishDrag(!0);return h(this._dragStartTarget,"pointerdown",this._onDown,this),this._enabled=!1,this._moved=!1,this}_onDown($){if(this._moved=!1,this._element.classList.contains("tsmap-zoom-anim"))return;if(z0().length!==1){if(S0._dragging===this)this.finishDrag();return}if(S0._dragging||$.shiftKey||$.button!==0&&$.pointerType!=="touch")return;if(S0._dragging=this,this._preventOutline)gQ(this._element);if(yQ(),bQ(),this._moving)return;this.fire("down");let Q=n7(this._element);this._startPoint=new D($.clientX,$.clientY),this._startPos=J$(this._element),this._parentScale=mQ(Q),B(this._dragStartTarget,"pointermove",this._onMove,this),B(this._dragStartTarget,"pointerup pointercancel",this._onUp,this)}_onMove($){if(z0().length>1){this._moved=!0;return}let Q=new D($.clientX,$.clientY)._subtract(this._startPoint);if(!Q.x&&!Q.y)return;if(Math.abs(Q.x)+Math.abs(Q.y)<this.options.clickTolerance)return;if(Q.x/=this._parentScale.x,Q.y/=this._parentScale.y,$.cancelable)$.preventDefault();if(!this._moved)this.fire("dragstart"),this._moved=!0,this._element.ownerDocument.body.classList.add("tsmap-dragging"),this._lastTarget=$.target??$.srcElement,this._lastTarget.classList.add("tsmap-drag-target");this._newPos=this._startPos.add(Q),this._moving=!0,this._lastEvent=$,this._updatePosition()}_updatePosition(){let $={originalEvent:this._lastEvent};this.fire("predrag",$),K0(this._element,this._newPos),this.fire("drag",$)}_onUp(){this.finishDrag()}finishDrag($){if(this._element.ownerDocument.body.classList.remove("tsmap-dragging"),this._lastTarget)this._lastTarget.classList.remove("tsmap-drag-target"),this._lastTarget=null;h(this._dragStartTarget,"pointermove",this._onMove,this),h(this._dragStartTarget,"pointerup pointercancel",this._onUp,this),uQ(),xQ();let Q=this._moved&&this._moving;if(this._moving=!1,S0._dragging=!1,Q)this.fire("dragend",{noInertia:$,distance:this._newPos.distanceTo(this._startPos)})}}S0.setDefaultOptions({clickTolerance:3});f();i();r();W0();O0();class G6 extends H0{initialize($){t(this,$)}onAdd($){if(!this._container)this._initContainer(),this._container.classList.add("tsmap-zoom-animated");this.getPane().appendChild(this._container),this._resizeContainer(),this._onMoveEnd()}onRemove($){this._destroyContainer()}getEvents(){let $={viewreset:this._reset,zoom:this._onZoom,moveend:this._onMoveEnd,resize:this._resizeContainer,zoomend:this._onZoomEnd};if(this._zoomAnimated)$.zoomanim=this._onAnimZoom;if(this.options.continuous)$.move=this._onMoveEnd;return $}_onAnimZoom($){this._updateTransform($.center,$.zoom)}_onZoom(){this._updateTransform(this._map.getCenter(),this._map.getZoom())}_updateTransform($,Q){let K=this._map.getZoomScale(Q,this._zoom),W=this._map.getSize().multiplyBy(0.5+this.options.padding),J=this._map.project(this._center,Q),U=W.multiplyBy(-K)._add(J)._subtract(this._map._getNewPixelOrigin($,Q))._round();W$(this._container,U,K)}_onMoveEnd($){let Q=this.options.padding,K=this._map.getSize(),W=this._map.containerPointToLayerPoint(K.multiplyBy(-Q)).round();this._bounds=new P(W,W.add(K.multiplyBy(1+Q*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled($)}_reset(){this._onSettled(),this._updateTransform(this._center,this._zoom),this._onViewReset()}_initContainer(){this._container=v("div")}_destroyContainer(){h(this._container),this._container.remove(),delete this._container}_resizeContainer(){let $=this.options.padding,Q=this._map.getSize().multiplyBy(1+$*2).round();return this._container.style.width=`${Q.x}px`,this._container.style.height=`${Q.y}px`,Q}_onZoomEnd(){}_onViewReset(){}_onSettled($){}}G6.setDefaultOptions({padding:0.1,continuous:!1});f();r();Y0();l();$0();A0();f();O0();class J8 extends H0{initialize($,Q){t(this,Q),this._layers={};for(let K of $??[])this.addLayer(K)}addLayer($){let Q=this.getLayerId($);return this._layers[Q]=$,this._map?.addLayer($),this}removeLayer($){let Q=typeof $==="number"?$:this.getLayerId($);if(this._map&&this._layers[Q])this._map.removeLayer(this._layers[Q]);return delete this._layers[Q],this}hasLayer($){return(typeof $==="number"?$:this.getLayerId($))in this._layers}clearLayers(){return this.eachLayer(this.removeLayer,this)}onAdd($){this.eachLayer($.addLayer,$)}onRemove($){this.eachLayer($.removeLayer,$)}eachLayer($,Q){for(let K of Object.values(this._layers))$.call(Q,K);return this}getLayer($){return this._layers[$]}getLayers(){let $=[];return this.eachLayer((Q)=>$.push(Q)),$}setZIndex($){return this.eachLayer((Q)=>Q.setZIndex?.($))}getLayerId($){return u($)}}class P0 extends J8{addLayer($){if(this.hasLayer($))return this;return $.addEventParent(this),super.addLayer($),this.fire("layeradd",{layer:$})}removeLayer($){if(!this.hasLayer($))return this;let Q=typeof $==="number"?this._layers[$]:$;return Q.removeEventParent(this),super.removeLayer(Q),this.fire("layerremove",{layer:Q})}setStyle($){return this.eachLayer((Q)=>Q.setStyle?.($))}bringToFront(){return this.eachLayer(($)=>$.bringToFront?.())}bringToBack(){return this.eachLayer(($)=>$.bringToBack?.())}getBounds(){let $=new z;for(let Q of Object.values(this._layers))$.extend(Q.getBounds?Q.getBounds():Q.getLatLng());return $}}O0();class g8 extends H0{initialize($,Q){if($ instanceof O||Array.isArray($))this._latlng=new O($),t(this,Q);else t(this,$),this._source=Q;if(this.options.content)this._content=this.options.content}openOn($){let Q=arguments.length?$:this._source._map;if(!Q.hasLayer(this))Q.addLayer(this);return this}close(){return this._map?.removeLayer(this),this}toggle($){if(this._map)this.close();else{if(arguments.length)this._source=$;else $=this._source;this._prepareOpen(),this.openOn($._map)}return this}onAdd($){if(this._zoomAnimated=$._zoomAnimated,!this._container)this._initLayout();if($._fadeAnimated)this._container.style.opacity="0";if(clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),$._fadeAnimated)this._container.style.opacity="1";if(this.bringToFront(),this.options.interactive)this._container.classList.add("tsmap-interactive"),this.addInteractiveTarget(this._container)}onRemove($){if($._fadeAnimated)this._container.style.opacity="0",this._removeTimeout=setTimeout(()=>this._container.remove(),200);else this._container.remove();if(this.options.interactive)this._container.classList.remove("tsmap-interactive"),this.removeInteractiveTarget(this._container)}getLatLng(){return this._latlng}setLatLng($){if(this._latlng=new O($),this._map)this._updatePosition(),this._adjustPan();return this}getContent(){return this._content}setContent($){return this._content=$,this.update(),this}getElement(){return this._container}update(){if(!this._map)return;this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan()}getEvents(){let $={zoom:this._updatePosition,viewreset:this._updatePosition};if(this._zoomAnimated)$.zoomanim=this._animateZoom;return $}isOpen(){return!!this._map&&this._map.hasLayer(this)}bringToFront(){if(this._map)o$(this._container);return this}bringToBack(){if(this._map)t$(this._container);return this}_prepareOpen($){let Q=this._source;if(!Q._map)return!1;if(Q instanceof P0){Q=null;for(let K of Object.values(this._source._layers))if(K._map){Q=K;break}if(!Q)return!1;this._source=Q}if(!$)if(Q.getCenter)$=Q.getCenter();else if(Q.getLatLng)$=Q.getLatLng();else if(Q.getBounds)$=Q.getBounds().getCenter();else throw Error("Unable to get source layer LatLng.");if(this.setLatLng($),this._map)this.update();return!0}_updateContent(){if(!this._content)return;let $=this._contentNode,Q=typeof this._content==="function"?this._content(this._source??this):this._content;if(typeof Q==="string")$.innerHTML=Q;else{while($.hasChildNodes())$.removeChild($.firstChild);$.appendChild(Q)}this.fire("contentupdate")}_updatePosition(){if(!this._map)return;let $=this._map.latLngToLayerPoint(this._latlng),Q=this._getAnchor(),K=new D(this.options.offset);if(this._zoomAnimated)K0(this._container,$.add(Q));else K=K.add($).add(Q);let W=this._containerBottom=-K.y,J=this._containerLeft=-Math.round(this._containerWidth/2)+K.x;this._container.style.bottom=`${W}px`,this._container.style.left=`${J}px`}_getAnchor(){return[0,0]}_initLayout(){}_updateLayout(){}_adjustPan(){}_animateZoom($){}}g8.setDefaultOptions({interactive:!1,offset:[0,0],className:"",pane:void 0,content:""});L.include({_initOverlay($,Q,K,W){let J=Q;if(!(J instanceof $))J=new $(W).setContent(Q);if(K)J.setLatLng(K);return J}});H0.include({_initOverlay($,Q,K,W){let J=K;if(J instanceof $)t(J,W),J._source=this;else J=Q&&!W?Q:new $(W,this),J.setContent(K);return J}});f();Y0();f();i();r();Y0();l();O0();var w7="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="25" height="41" viewBox="0 0 25 41"><path fill="#2b83f6" stroke="#1e5fad" stroke-width="1" d="M12.5 0C5.6 0 0 5.6 0 12.5c0 9.4 12.5 28.5 12.5 28.5S25 21.9 25 12.5C25 5.6 19.4 0 12.5 0z"/><circle cx="12.5" cy="12.5" r="5" fill="#fff"/></svg>'),$J="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="41" height="41" viewBox="0 0 41 41"><ellipse cx="20.5" cy="31" rx="14" ry="6" fill="#000" opacity="0.28"/></svg>'),PJ="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36"><rect x="4" y="4" width="14" height="14" fill="#fff" stroke="#666" stroke-width="1.5"/><rect x="10" y="10" width="14" height="14" fill="#e8e8e8" stroke="#666" stroke-width="1.5"/><rect x="16" y="16" width="14" height="14" fill="#d0d0d0" stroke="#666" stroke-width="1.5"/></svg>');r();e0();e$();f();l();class k$ extends E${initialize($){t(this,$)}createIcon($){return this._createIcon("icon",$)}createShadow($){return this._createIcon("shadow",$)}_createIcon($,Q){let K=this._getIconUrl($);if(!K){if($==="icon")throw Error("iconUrl not set in Icon options (see the docs).");return null}let W=this._createImg(K,Q&&Q.tagName==="IMG"?Q:null);if(this._setIconStyles(W,$),this.options.crossOrigin||this.options.crossOrigin==="")W.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;return W}_setIconStyles($,Q){let K=this.options,W=K[`${Q}Size`];if(typeof W==="number")W=[W,W];let J=D.validate(W)&&new D(W),U=Q==="shadow"&&K.shadowAnchor||K.iconAnchor||J&&J.divideBy(2)._round(),V=D.validate(U)&&new D(U);if($.className=`tsmap-marker-${Q} ${K.className||""}`,V)$.style.marginLeft=`${-V.x}px`,$.style.marginTop=`${-V.y}px`;if(J)$.style.width=`${J.x}px`,$.style.height=`${J.y}px`}_createImg($,Q){return Q??=document.createElement("img"),Q.src=$,Q}_getIconUrl($){return X0.retina&&this.options[`${$}RetinaUrl`]||this.options[`${$}Url`]}}k$.setDefaultOptions({popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1});function QJ($){return $.startsWith("data:")||$.startsWith("http://")||$.startsWith("https://")||$.startsWith("blob:")||$.startsWith("/")}class K$ extends k${static imagePath;_getIconUrl($){let Q=super._getIconUrl($);if(!Q)return null;if(QJ(Q))return Q;if(!K$.imagePath)K$.imagePath=this._detectIconPath();return(this.options.imagePath||K$.imagePath)+Q}_stripUrl($){let Q=(W,J,U)=>{let V=J.exec(W);return V&&V[U]},K=Q($,/^url\((['"])?(.+)\1\)$/,2);if(!K)return null;if(K.startsWith("data:"))return"";return Q(K,/^(.*)marker-icon\.svg$/,1)}_detectIconPath(){let $=v("div","tsmap-default-icon-path",document.body),Q=this._stripUrl(getComputedStyle($).backgroundImage);if(document.body.removeChild($),Q)return Q;let K=document.querySelector('link[href$="ts-maps.css"]');if(!K)return"";return K.href.substring(0,K.href.length-11-1)}}K$.setDefaultOptions({iconUrl:w7,iconRetinaUrl:w7,shadowUrl:$J,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]});r();W0();l();class kQ extends D0{_marker;initialize($){super.initialize($._map),this._marker=$}addHooks(){let $=this._marker._icon;if(!this._draggable)this._draggable=new S0($,$,!0);this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),$.classList.add("tsmap-marker-draggable")}removeHooks(){this._draggable?.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon?.classList.remove("tsmap-marker-draggable")}moved(){return this._draggable?._moved}_adjustPan($){let Q=this._marker,K=Q._map,W=Q.options.autoPanSpeed,J=Q.options.autoPanPadding,U=J$(Q._icon),V=K.getPixelBounds(),X=K.getPixelOrigin(),Y=new P(V.min._subtract(X).add(J),V.max._subtract(X).subtract(J));if(!Y.contains(U)){let Z=new D((Math.max(Y.max.x,U.x)-Y.max.x)/(V.max.x-Y.max.x)-(Math.min(Y.min.x,U.x)-Y.min.x)/(V.min.x-Y.min.x),(Math.max(Y.max.y,U.y)-Y.max.y)/(V.max.y-Y.max.y)-(Math.min(Y.min.y,U.y)-Y.min.y)/(V.min.y-Y.min.y)).multiplyBy(W);K.panBy(Z,{animate:!1});let H=this._draggable;H._newPos._add(Z),H._startPos._add(Z),K0(Q._icon,H._newPos),this._onDrag($),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,$))}}_onDragStart(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup?.(),this._marker.fire("movestart").fire("dragstart")}_onPreDrag($){if(this._marker.options.autoPan){if(this._panRequest!==void 0)cancelAnimationFrame(this._panRequest);this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,$))}}_onDrag($){let Q=this._marker,K=Q._shadow,W=J$(Q._icon),J=Q._map.layerPointToLatLng(W);if(K)K0(K,W);Q._latlng=J,$.latlng=J,$.oldLatLng=this._oldLatLng,Q.fire("move",$).fire("drag",$)}_onDragEnd($){if(this._panRequest!==void 0)cancelAnimationFrame(this._panRequest);delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",$)}}class w$ extends H0{initialize($,Q){t(this,Q),this._latlng=new O($)}onAdd($){if(this._zoomAnimated=this._zoomAnimated&&$.options.markerZoomAnimation,this._zoomAnimated)$.on("zoomanim",this._animateZoom,this);this._initIcon(),this.update()}onRemove($){if(this.dragging?.enabled())this.options.draggable=!0,this.dragging.removeHooks();if(delete this.dragging,this._zoomAnimated)$.off("zoomanim",this._animateZoom,this);this._removeIcon(),this._removeShadow()}getEvents(){return{zoom:this.update,viewreset:this.update}}getLatLng(){return this._latlng}setLatLng($){let Q=this._latlng;return this._latlng=new O($),this.update(),this.fire("move",{oldLatLng:Q,latlng:this._latlng})}setZIndexOffset($){return this.options.zIndexOffset=$,this.update()}getIcon(){return this.options.icon}setIcon($){if(this.options.icon=$,this._map)this._initIcon(),this.update();if(this._popup)this.bindPopup(this._popup,this._popup.options);return this}getElement(){return this._icon}update(){if(this._icon&&this._map){let $=this._map.latLngToLayerPoint(this._latlng).round();this._setPos($)}return this}_initIcon(){let $=this.options,Q=`tsmap-zoom-${this._zoomAnimated?"animated":"hide"}`,K=$.icon.createIcon(this._icon),W=!1;if(K!==this._icon){if(this._icon)this._removeIcon();if(W=!0,$.title)K.title=$.title;if(K.tagName==="IMG")K.alt=$.alt??""}if(K.classList.add(Q),$.keyboard)K.tabIndex=0,K.setAttribute("role","button");if(this._icon=K,$.riseOnHover)this.on({pointerover:this._bringToFront,pointerout:this._resetZIndex});if($.autoPanOnFocus)B(K,"focus",this._panOnFocus,this);let J=$.icon.createShadow(this._shadow),U=!1;if(J!==this._shadow)this._removeShadow(),U=!0;if(J)J.classList.add(Q),J.alt="";if(this._shadow=J,$.opacity<1)this._updateOpacity();if(W)this.getPane().appendChild(this._icon);if(this._initInteraction(),J&&U)this.getPane($.shadowPane).appendChild(this._shadow)}_removeIcon(){if(this.options.riseOnHover)this.off({pointerover:this._bringToFront,pointerout:this._resetZIndex});if(this.options.autoPanOnFocus)h(this._icon,"focus",this._panOnFocus,this);this._icon?.remove(),this.removeInteractiveTarget(this._icon),this._icon=null}_removeShadow(){this._shadow?.remove(),this._shadow=null}_setPos($){if(this._icon)K0(this._icon,$);if(this._shadow)K0(this._shadow,$);this._zIndex=$.y+this.options.zIndexOffset,this._resetZIndex()}_updateZIndex($){if(this._icon)this._icon.style.zIndex=String(this._zIndex+$)}_animateZoom($){let Q=this._map._latLngToNewLayerPoint(this._latlng,$.zoom,$.center).round();this._setPos(Q)}_initInteraction(){if(!this.options.interactive)return;if(this._icon.classList.add("tsmap-interactive"),this.addInteractiveTarget(this._icon),kQ){let $=this.options.draggable;if(this.dragging)$=this.dragging.enabled(),this.dragging.disable();if(this.dragging=new kQ(this),$)this.dragging.enable()}}setOpacity($){if(this.options.opacity=$,this._map)this._updateOpacity();return this}_updateOpacity(){let $=this.options.opacity;if(this._icon)this._icon.style.opacity=String($);if(this._shadow)this._shadow.style.opacity=String($)}_bringToFront(){this._updateZIndex(this.options.riseOffset)}_resetZIndex(){this._updateZIndex(0)}_panOnFocus(){let $=this._map;if(!$)return;let Q=this.options.icon.options,K=Q.iconSize?new D(Q.iconSize):new D(0,0),W=Q.iconAnchor?new D(Q.iconAnchor):new D(0,0);$.panInside(this._latlng,{paddingTopLeft:W,paddingBottomRight:K.subtract(W)})}_getPopupAnchor(){return this.options.icon.options.popupAnchor}_getTooltipAnchor(){return this.options.icon.options.tooltipAnchor}}w$.setDefaultOptions({icon:new K$,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingPointerEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10});C$();A0();f();Y0();W0();f();O0();class X$ extends H0{beforeAdd($){this._renderer=$.getRenderer(this)}onAdd(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)}onRemove(){this._renderer._removePath(this)}redraw(){if(this._map)this._renderer._updatePath(this);return this}setStyle($){if(t(this,$),this._renderer){if(this._renderer._updateStyle(this),this.options.stroke&&$&&Object.hasOwn($,"weight"))this._updateBounds()}return this}bringToFront(){return this._renderer?._bringToFront(this),this}bringToBack(){return this._renderer?._bringToBack(this),this}getElement(){return this._path}_reset(){this._project(),this._update()}_clickTolerance(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}_project(){}_update(){}_updateBounds(){}}X$.setDefaultOptions({stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:0.2,fillRule:"evenodd",interactive:!0,bubblingPointerEvents:!0});class _$ extends X${initialize($,Q){t(this,Q),this._latlng=new O($),this._radius=this.options.radius}setLatLng($){let Q=this._latlng;return this._latlng=new O($),this.redraw(),this.fire("move",{oldLatLng:Q,latlng:this._latlng})}getLatLng(){return this._latlng}setRadius($){return this.options.radius=this._radius=$,this.redraw()}getRadius(){return this._radius}setStyle($){if(super.setStyle($),$?.radius!==void 0)this.setRadius($.radius);return this}_project(){this._point=this._map.latLngToLayerPoint(this._latlng),this._pxRadius=this._radius,this._updateBounds()}_updateBounds(){let $=this._pxRadius,Q=this._pxRadiusY??$,K=this._clickTolerance(),W=[$+K,Q+K];this._pxBounds=new P(this._point.subtract(W),this._point.add(W))}_update(){if(this._map)this._updatePath()}_updatePath(){this._renderer._updateCircle(this)}_empty(){return!!this._pxRadius&&!this._renderer._bounds.intersects(this._pxBounds)}_containsPoint($){return $.distanceTo(this._point)<=this._pxRadius+this._clickTolerance()}}_$.setDefaultOptions({fill:!0,radius:10});class m8 extends _${initialize($,Q){if(super.initialize($,Q),Number.isNaN(this.options.radius))throw Error("Circle radius cannot be NaN")}getBounds(){let $=[this._pxRadius,this._pxRadiusY??this._pxRadius];return new z(this._map.layerPointToLatLng(this._point.subtract($)),this._map.layerPointToLatLng(this._point.add($)))}_project(){let $=this._latlng.lng,Q=this._latlng.lat,K=this._map,W=K.options.crs;if(W.distance===s0.distance){let J=Math.PI/180,U=this._radius/s0.R/J,V=K.project([Q+U,$]),X=K.project([Q-U,$]),Y=V.add(X).divideBy(2),Z=K.unproject(Y).lat,H=Math.acos((Math.cos(U*J)-Math.sin(Q*J)*Math.sin(Z*J))/(Math.cos(Q*J)*Math.cos(Z*J)))/J;if(Number.isNaN(H)||H===0)H=U/Math.cos(Math.PI/180*Q);this._point=Y.subtract(K.getPixelOrigin()),this._pxRadius=Number.isNaN(H)?0:Y.x-K.project([Z,$-H]).x,this._pxRadiusY=Y.y-V.y}else{let J=W.unproject(W.project(this._latlng).subtract([this._radius,0]));this._point=K.latLngToLayerPoint(this._latlng),this._pxRadius=Math.abs(this._point.x-K.latLngToLayerPoint(J).x)}this._updateBounds()}}Y0();W0();l();f();Y0();A0();W0();l();class H$ extends X${initialize($,Q){t(this,Q),this._setLatLngs($)}getLatLngs(){return this._latlngs}setLatLngs($){return this._setLatLngs($),this.redraw()}isEmpty(){return!this._latlngs.length}closestLayerPoint($){$=new D($);let Q=1/0,K=null,W=Q8;for(let J of this._parts)for(let U=1,V=J.length;U<V;U++){let X=J[U-1],Y=J[U],Z=W($,X,Y,!0);if(Z<Q)Q=Z,K=W($,X,Y)}if(K)K.distance=Math.sqrt(Q);return K}getCenter(){if(!this._map)throw Error("Must add layer to map before using getCenter()");return f9(this._defaultShape(),this._map.options.crs)}getBounds(){return this._bounds}addLatLng($,Q){let K=Q??this._defaultShape(),W=new O($);return K.push(W),this._bounds.extend(W),this.redraw()}_setLatLngs($){this._bounds=new z,this._latlngs=this._convertLatLngs($)}_defaultShape(){return T0(this._latlngs)?this._latlngs:this._latlngs[0]}_convertLatLngs($){let Q=[],K=T0($);for(let W=0,J=$.length;W<J;W++)if(K)Q[W]=new O($[W]),this._bounds.extend(Q[W]);else Q[W]=this._convertLatLngs($[W]);return Q}_project(){let $=new P;if(this._rings=[],this._projectLatlngs(this._latlngs,this._rings,$),this._bounds.isValid()&&$.isValid())this._rawPxBounds=$,this._updateBounds()}_updateBounds(){let $=this._clickTolerance(),Q=new D($,$);if(!this._rawPxBounds)return;this._pxBounds=new P([this._rawPxBounds.min.subtract(Q),this._rawPxBounds.max.add(Q)])}_projectLatlngs($,Q,K){if($[0]instanceof O){let J=$.map((U)=>this._map.latLngToLayerPoint(U));J.forEach((U)=>K.extend(U)),Q.push(J)}else $.forEach((J)=>this._projectLatlngs(J,Q,K))}_clipPoints(){let $=this._renderer._bounds;if(this._parts=[],!this._pxBounds||!this._pxBounds.intersects($))return;if(this.options.noClip){this._parts=this._rings;return}let Q=this._parts;for(let K=0,W=0,J=this._rings.length;K<J;K++){let U=this._rings[K];for(let V=0,X=U.length;V<X-1;V++){let Y=v9(U[V],U[V+1],$,!!V,!0);if(!Y)continue;if(Q[W]??=[],Q[W].push(Y[0]),Y[1]!==U[V+1]||V===X-2)Q[W].push(Y[1]),W++}}}_simplifyPoints(){let $=this._parts,Q=this.options.smoothFactor;for(let K=0,W=$.length;K<W;K++)$[K]=L9($[K],Q)}_update(){if(!this._map)return;this._clipPoints(),this._simplifyPoints(),this._updatePath()}_updatePath(){this._renderer._updatePoly(this)}_containsPoint($,Q){let K=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains($))return!1;for(let W=0,J=this._parts.length;W<J;W++){let U=this._parts[W];for(let V=0,X=U.length,Y=X-1;V<X;Y=V++){if(!Q&&V===0)continue;if(z9($,U[Y],U[V])<=K)return!0}}return!1}}H$.setDefaultOptions({smoothFactor:0.5,noClip:!1});class A$ extends H${isEmpty(){return!this._latlngs.length||!this._latlngs[0].length}getCenter(){if(!this._map)throw Error("Must add layer to map before using getCenter()");return P9(this._defaultShape(),this._map.options.crs)}_convertLatLngs($){let Q=super._convertLatLngs($),K=Q.length;if(K>=2&&Q[0]instanceof O&&Q[0].equals(Q[K-1]))Q.pop();return Q}_setLatLngs($){if(super._setLatLngs($),T0(this._latlngs))this._latlngs=[this._latlngs]}_defaultShape(){return T0(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]}_clipPoints(){let $=this._renderer._bounds,Q=this.options.weight,K=new D(Q,Q);if($=new P($.min.subtract(K),$.max.add(K)),this._parts=[],!this._pxBounds||!this._pxBounds.intersects($))return;if(this.options.noClip){this._parts=this._rings;return}for(let W of this._rings){let J=S9(W,$,!0);if(J.length)this._parts.push(J)}}_updatePath(){this._renderer._updatePoly(this,!0)}_containsPoint($){let Q=!1;if(!this._pxBounds||!this._pxBounds.contains($))return!1;for(let K=0,W=this._parts.length;K<W;K++){let J=this._parts[K];for(let U=0,V=J.length,X=V-1;U<V;X=U++){let Y=J[U],Z=J[X];if(Y.y>$.y!==Z.y>$.y&&$.x<(Z.x-Y.x)*($.y-Y.y)/(Z.y-Y.y)+Y.x)Q=!Q}}return Q||super._containsPoint($,!0)}}A$.setDefaultOptions({fill:!0});class d extends P0{initialize($,Q){if(super.initialize(void 0,Q),$)this.addData($)}addData($){let Q=Array.isArray($)?$:$.features;if(Q){for(let J of Q)if(J.geometries||J.geometry||J.features||J.coordinates)this.addData(J);return this}let K=this.options;if(K.filter&&!K.filter($))return this;let W=d.geometryToLayer($,K);if(!W)return this;if(W.feature=d.asFeature($),W.defaultOptions=W.options,this.resetStyle(W),K.onEachFeature)K.onEachFeature($,W);return this.addLayer(W)}resetStyle($){if($===void 0)return this.eachLayer(this.resetStyle,this);return $.options=Object.create($.defaultOptions),this._setLayerStyle($,this.options.style),this}setStyle($){return this.eachLayer((Q)=>this._setLayerStyle(Q,$))}_setLayerStyle($,Q){if($.setStyle){if(typeof Q==="function")Q=Q($.feature);$.setStyle(Q)}}static geometryToLayer($,Q){let K=$.type==="Feature"?$.geometry:$,W=K?.coordinates,J=[],U=Q?.pointToLayer,V=Q?.coordsToLatLng??d.coordsToLatLng,X,Y;if(!W&&!K)return null;switch(K.type){case"Point":return X=V(W),d._pointToLayer(U,$,X,Q);case"MultiPoint":for(let Z of W)X=V(Z),J.push(d._pointToLayer(U,$,X,Q));return new P0(J);case"LineString":case"MultiLineString":return Y=d.coordsToLatLngs(W,K.type==="LineString"?0:1,V),new H$(Y,Q);case"Polygon":case"MultiPolygon":return Y=d.coordsToLatLngs(W,K.type==="Polygon"?1:2,V),new A$(Y,Q);case"GeometryCollection":for(let Z of K.geometries){let H=d.geometryToLayer({geometry:Z,type:"Feature",properties:$.properties},Q);if(H)J.push(H)}return new P0(J);case"FeatureCollection":for(let Z of K.features){let H=d.geometryToLayer(Z,Q);if(H)J.push(H)}return new P0(J);default:throw Error("Invalid GeoJSON object.")}}static _pointToLayer($,Q,K,W){return $?$(Q,K):new w$(K,W?.markersInheritOptions&&W)}static coordsToLatLng($){return new O($[1],$[0],$[2])}static coordsToLatLngs($,Q,K){return $.map((W)=>Q?d.coordsToLatLngs(W,Q-1,K):(K||d.coordsToLatLng)(W))}static latLngToCoords($,Q){let K=new O($);return K.alt!==void 0?[_0(K.lng,Q),_0(K.lat,Q),_0(K.alt,Q)]:[_0(K.lng,Q),_0(K.lat,Q)]}static latLngsToCoords($,Q,K,W){let J=$.map((U)=>Q?d.latLngsToCoords(U,T0(U)?0:Q-1,K,W):d.latLngToCoords(U,W));if(!Q&&K&&J.length>0)J.push(J[0].slice());return J}static getFeature($,Q){return $.feature?{...$.feature,geometry:Q}:d.asFeature(Q)}static asFeature($){if($.type==="Feature"||$.type==="FeatureCollection")return $;return{type:"Feature",properties:{},geometry:$}}}var F6={toGeoJSON($){return d.getFeature(this,{type:"Point",coordinates:d.latLngToCoords(this.getLatLng(),$)})}};w$.include(F6);m8.include(F6);_$.include(F6);H$.include({toGeoJSON($){let Q=!T0(this._latlngs),K=d.latLngsToCoords(this._latlngs,Q?1:0,!1,$);return d.getFeature(this,{type:`${Q?"Multi":""}LineString`,coordinates:K})}});A$.include({toGeoJSON($){let Q=!T0(this._latlngs),K=Q&&!T0(this._latlngs[0]),W=d.latLngsToCoords(this._latlngs,K?2:Q?1:0,!0,$);if(!Q)W=[W];return d.getFeature(this,{type:`${K?"Multi":""}Polygon`,coordinates:W})}});J8.include({toMultiPoint($){let Q=[];return this.eachLayer((K)=>{Q.push(K.toGeoJSON($).geometry.coordinates)}),d.getFeature(this,{type:"MultiPoint",coordinates:Q})},toGeoJSON($){let Q=this.feature?.geometry?.type;if(Q==="MultiPoint")return this.toMultiPoint($);let K=Q==="GeometryCollection",W=[];if(this.eachLayer((J)=>{if(J.toGeoJSON){let U=J.toGeoJSON($);if(K)W.push(U.geometry);else{let V=d.asFeature(U);if(V.type==="FeatureCollection")W.push(...V.features);else W.push(V)}}}),K)return d.getFeature(this,{geometries:W,type:"GeometryCollection"});return{type:"FeatureCollection",features:W}}});class $K{nodeSize;points;ids;constructor($,Q=64){this.nodeSize=Q,this.points=new Float64Array($*2),this.ids=new Uint32Array($),this._count=0,this._finished=!1}_count;_finished;add($,Q){let K=this._count;return this.ids[K]=K,this.points[K*2]=$,this.points[K*2+1]=Q,this._count++,K}finish(){if(this._finished)return this;return wQ(this.ids,this.points,this.nodeSize,0,this.ids.length-1,0),this._finished=!0,this}range($,Q,K,W){let J=[];if(this.ids.length===0)return J;return _Q(this.ids,this.points,$,Q,K,W,0,this.ids.length-1,0,this.nodeSize,J),J}within($,Q,K){let W=[];if(this.ids.length===0)return W;return SQ(this.ids,this.points,$,Q,K,0,this.ids.length-1,0,this.nodeSize,W),W}}function wQ($,Q,K,W,J,U){if(J-W<=K)return;let V=W+J>>1;QK($,Q,V,W,J,U),wQ($,Q,K,W,V-1,1-U),wQ($,Q,K,V+1,J,1-U)}function QK($,Q,K,W,J,U){while(J>W){if(J-W>600){let Z=J-W+1,H=K-W+1,A=Math.log(Z),G=0.5*Math.exp(2*A/3),F=0.5*Math.sqrt(A*G*(Z-G)/Z)*(H-Z/2<0?-1:1),N=Math.max(W,Math.floor(K-H*G/Z+F)),q=Math.min(J,Math.floor(K+(Z-H)*G/Z+F));QK($,Q,K,N,q,U)}let V=Q[2*K+U],X=W,Y=J;if(x$($,Q,W,K),Q[2*J+U]>V)x$($,Q,W,J);while(X<Y){x$($,Q,X,Y),X++,Y--;while(Q[2*X+U]<V)X++;while(Q[2*Y+U]>V)Y--}if(Q[2*W+U]===V)x$($,Q,W,Y);else Y++,x$($,Q,Y,J);if(Y<=K)W=Y+1;if(K<=Y)J=Y-1}}function x$($,Q,K,W){let J=$[K];$[K]=$[W],$[W]=J;let U=Q[2*K],V=Q[2*K+1];Q[2*K]=Q[2*W],Q[2*K+1]=Q[2*W+1],Q[2*W]=U,Q[2*W+1]=V}function _Q($,Q,K,W,J,U,V,X,Y,Z,H){if(X-V<=Z){for(let N=V;N<=X;N++){let q=Q[2*N],R=Q[2*N+1];if(q>=K&&q<=J&&R>=W&&R<=U)H.push($[N])}return}let A=V+X>>1,G=Q[2*A],F=Q[2*A+1];if(G>=K&&G<=J&&F>=W&&F<=U)H.push($[A]);if(Y===0?K<=G:W<=F)_Q($,Q,K,W,J,U,V,A-1,1-Y,Z,H);if(Y===0?J>=G:U>=F)_Q($,Q,K,W,J,U,A+1,X,1-Y,Z,H)}function SQ($,Q,K,W,J,U,V,X,Y,Z){let H=J*J;if(V-U<=Y){for(let N=U;N<=V;N++)if(_7(Q[2*N],Q[2*N+1],K,W)<=H)Z.push($[N]);return}let A=U+V>>1,G=Q[2*A],F=Q[2*A+1];if(_7(G,F,K,W)<=H)Z.push($[A]);if(X===0?K-J<=G:W-J<=F)SQ($,Q,K,W,J,U,A-1,1-X,Y,Z);if(X===0?K+J>=G:W+J>=F)SQ($,Q,K,W,J,A+1,V,1-X,Y,Z)}function _7($,Q,K,W){let J=$-K,U=Q-W;return J*J+U*U}var B0=2,R$=3,D8=4,m0=5,QQ=6,c=7;class KJ{options;_points=[];_trees=[];_clusterProps=[];_data=[];constructor($={}){this.options={radius:$.radius??40,maxZoom:$.maxZoom??16,minZoom:$.minZoom??0,minPoints:$.minPoints??2,extent:$.extent??512,nodeSize:$.nodeSize??64,reduce:$.reduce,map:$.map,log:$.log??!1}}load($){this._points=$,this._trees=[],this._clusterProps=[],this._data=[];let{maxZoom:Q,minZoom:K}=this.options,W=new ArrayBuffer($.length*c*8),J=new Float64Array(W);for(let V=0;V<$.length;V++){let X=$[V];if(!X.geometry)continue;let[Y,Z]=X.geometry.coordinates;J[V*c+0]=KQ(Y),J[V*c+1]=WQ(Z),J[V*c+B0]=1/0,J[V*c+R$]=V,J[V*c+D8]=-1,J[V*c+m0]=1,J[V*c+QQ]=-1}this._data[Q+1]=J,this._trees[Q+1]=this._buildTree(J);let U=J;for(let V=Q;V>=K;V--)U=this._cluster(U,V),this._data[V]=U,this._trees[V]=this._buildTree(U);return this}getClusters($,Q){let K=this._limitZoom(Q),W=this._trees[K],J=this._data[K];if(!W||!J)return[];let U=(($[0]+180)%360+360)%360-180,V=Math.max(-90,Math.min(90,$[1])),X=$[2]===180?180:(($[2]+180)%360+360)%360-180,Y=Math.max(-90,Math.min(90,$[3]));if($[2]-$[0]>=360)U=-180,X=180;else if(U>X){let A=this.getClusters([U,V,180,Y],Q),G=this.getClusters([-180,V,X,Y],Q);return A.concat(G)}let Z=W.range(KQ(U),WQ(Y),KQ(X),WQ(V)),H=[];for(let A of Z)H.push(this._dataToFeature(J,A));return H}getChildren($){let Q=$>>5,K=$&31,W=this._data[K];if(!W)throw Error("no cluster with the specified id");let J=this.options.radius/(this.options.extent*2**(K-1)),U=this._trees[K];if(!U)return[];let V=W[Q*c],X=W[Q*c+1],Y=U.within(V,X,J),Z=[];for(let H of Y)if(W[H*c+D8]===$)Z.push(this._dataToFeature(W,H));if(Z.length===0)throw Error("no cluster with the specified id");return Z}getLeaves($,Q=10,K=0){let W=[];return this._appendLeaves(W,$,Q,K,0),W}getClusterExpansionZoom($){let Q=($&31)-1;while(Q<=this.options.maxZoom){let K=this.getChildren($);if(Q++,K.length!==1)break;$=K[0].properties.cluster_id}return Q}getTile($,Q,K){let W=this._data[this._limitZoom($)],J=this._trees[this._limitZoom($)];if(!W||!J)return null;let U=2**$,V=this.options.radius/this.options.extent,X=(K-V)/U,Y=(K+1+V)/U,Z={features:[]};if(this._addTileFeatures(J.range((Q-V)/U,X,(Q+1+V)/U,Y),W,Q,K,U,Z),Q===0)this._addTileFeatures(J.range(1-V/U,X,1,Y),W,U,K,U,Z);if(Q===U-1)this._addTileFeatures(J.range(0,X,V/U,Y),W,-1,K,U,Z);return Z.features.length>0?Z:null}_limitZoom($){return Math.max(this.options.minZoom,Math.min(Math.floor($),this.options.maxZoom+1))}_buildTree($){let Q=$.length/c,K=new $K(Q,this.options.nodeSize);for(let W=0;W<Q;W++)K.add($[W*c],$[W*c+1]);return K.finish(),K}_cluster($,Q){let{radius:K,extent:W,reduce:J,minPoints:U}=this.options,V=K/(W*2**Q),X=this._trees[Q+1],Y=[];for(let A=0;A<$.length;A+=c){if($[A+B0]<=Q)continue;$[A+B0]=Q;let G=$[A],F=$[A+1],N=X.within(G,F,V),q=$[A+m0],R=q;for(let I of N){let C=I*c;if($[C+B0]>Q)R+=$[C+m0]}if(R>q&&R>=U){let I=G*q,C=F*q,M,j=-1,E=(A/c<<5)+(Q+1);for(let _ of N){let x=_*c;if($[x+B0]<=Q)continue;$[x+B0]=Q;let n=$[x+m0];if(I+=$[x]*n,C+=$[x+1]*n,$[x+D8]=E,J){if(!M)M=this._mapForCluster(A,$);let p=this._mapForCluster(x,$);J(M,p)}}if($[A+D8]=E,M)j=this._clusterProps.length,this._clusterProps.push(M);Y.push(I/R,C/R,1/0,E,-1,R,j)}else{for(let I=0;I<c;I++)Y.push($[A+I]);if(Y[Y.length-c+B0]=1/0,R>1)for(let I of N){let C=I*c;if($[C+B0]<=Q)continue;$[C+B0]=Q;for(let M=0;M<c;M++)Y.push($[C+M]);Y[Y.length-c+B0]=1/0}}}let Z=new ArrayBuffer(Y.length*8),H=new Float64Array(Z);for(let A=0;A<Y.length;A++)H[A]=Y[A];return H}_mapForCluster($,Q){let K=Q[$+m0],W=Q[$+QQ];if(K>1&&W>=0)return{...this._clusterProps[W]};let J=this._points[Q[$+R$]];if(this.options.map&&J)return this.options.map({...J.properties??{}});return{...J?.properties??{}}}_addTileFeatures($,Q,K,W,J,U){for(let V of $){let X=V*c,Y=Q[X+m0]>1,Z=(Q[X]*J-K)*this.options.extent,H=(Q[X+1]*J-W)*this.options.extent;U.features.push({type:"Feature",geometry:{type:"Point",coordinates:[Z,H]},properties:Y?this._getClusterProperties(Q,X,Q[X+R$]):{...this._points[Q[X+R$]]?.properties??{}}})}}_dataToFeature($,Q){let K=Q*c,W=$[K+m0]>1,J=WJ($[K]),U=JJ($[K+1]);if(W)return{type:"Feature",geometry:{type:"Point",coordinates:[J,U]},properties:this._getClusterProperties($,K,$[K+R$])};let V=this._points[$[K+R$]];return{type:"Feature",geometry:{type:"Point",coordinates:[J,U]},properties:{...V.properties??{}},id:V.id}}_getClusterProperties($,Q,K){let W=$[Q+QQ],J=$[Q+m0],U={cluster:!0,cluster_id:K,point_count:J,point_count_abbreviated:J>=1e4?`${Math.round(J/1000)}k`:J>=1000?`${(J/1000).toFixed(1)}k`:J};if(W>=0){let V=this._clusterProps[W];if(V)Object.assign(U,V)}return U}_appendLeaves($,Q,K,W,J){let U=this.getChildren(Q);for(let V of U){let X=V.properties;if(X&&X.cluster)J=this._appendLeaves($,X.cluster_id,K,W,J);else if(J<W)J++;else if($.length<K)$.push(V);if($.length===K)break}return J}}function KQ($){return $/360+0.5}function WQ($){let Q=Math.sin($*Math.PI/180),K=0.5-0.25*Math.log((1+Q)/(1-Q))/Math.PI;return K<0?0:K>1?1:K}function WJ($){return($-0.5)*360}function JJ($){let Q=(180-$*360)*Math.PI/180;return 360*Math.atan(Math.exp(Q))/Math.PI-90}f();O0();var UJ={0.4:"blue",0.6:"cyan",0.7:"lime",0.8:"yellow",1:"red"};class N6 extends H0{initialize($){t(this,$),this._data=$?.data?[...$.data]:[],this._redrawScheduled=!1}setData($){return this._data=[...$],this.redraw()}addPoint($){return this._data.push($),this.redraw()}clearData(){return this._data=[],this.redraw()}setOptions($){if(t(this,$),$.gradient)this._gradientTexture=void 0;if($.data)this._data=[...$.data];return this.redraw()}redraw(){if(!this._map||this._redrawScheduled)return this;if(this._redrawScheduled=!0,typeof requestAnimationFrame==="function")requestAnimationFrame(()=>this._draw());else this._draw();return this}onAdd($){if(!this._canvas){let Q=this._canvas=document.createElement("canvas");if(Q.className="tsmap-heatmap-canvas tsmap-zoom-animated",Q.style)Q.style.position="absolute",Q.style.left="0",Q.style.top="0",Q.style.pointerEvents="none";this._ctx=Q.getContext("2d")??void 0}this.getPane().appendChild(this._canvas),this._resize(),this._draw()}onRemove($){this._canvas?.remove()}getEvents(){return{viewreset:this._resize,resize:this._resize,moveend:this._draw,zoomend:this._draw}}_resize(){if(!this._canvas||!this._map)return;let $=this._map.getSize();if(this._canvas.width=$.x,this._canvas.height=$.y,this._canvas.style)this._canvas.style.width=`${$.x}px`,this._canvas.style.height=`${$.y}px`;this._draw()}_draw(){if(this._redrawScheduled=!1,!this._map||!this._ctx||!this._canvas)return;let $=this._ctx,Q=this._canvas;if($.clearRect(0,0,Q.width,Q.height),!this._data.length)return;let K=this.options,W=K.radius??25,J=K.blur??15,U=K.minOpacity??0.05,V=K.max??1,X=this._map._getMapPanePos(),Y=document.createElement("canvas");Y.width=Q.width,Y.height=Q.height;let Z=Y.getContext("2d");if(!Z)return;let H=W+J,A=this._intensityBlob(H,W,J);for(let q of this._data){let R=this._map.latLngToContainerPoint([q.lat,q.lng]),I=R.x-X.x,C=R.y-X.y,M=Math.max(0,Math.min((q.weight??1)/V,1));if(M<=0)continue;Z.globalAlpha=Math.max(U,M),Z.drawImage(A,I-H,C-H)}Z.globalAlpha=1;let G=Z.getImageData(0,0,Q.width,Q.height),F=G.data,N=this._colourRamp();for(let q=0;q<F.length;q+=4){let R=F[q+3];if(R===0)continue;let I=R*4;F[q]=N[I],F[q+1]=N[I+1],F[q+2]=N[I+2]}$.putImageData(G,0,0)}_intensityBlob($,Q,K){let W=$*2,J=document.createElement("canvas");J.width=W,J.height=W;let U=J.getContext("2d");if(!U)return J;let V=U.createRadialGradient($,$,0,$,$,$),X=Q/$;return V.addColorStop(0,"rgba(0,0,0,1)"),V.addColorStop(Math.min(1,X),`rgba(0,0,0,${Math.max(0.2,1-K/(Q+K))})`),V.addColorStop(1,"rgba(0,0,0,0)"),U.fillStyle=V,U.fillRect(0,0,W,W),J}_colourRamp(){if(this._gradientTexture)return this._gradientTexture;let $=this.options?.gradient??UJ,Q=document.createElement("canvas");Q.width=1,Q.height=256;let K=Q.getContext("2d");if(!K)return this._gradientTexture=new Uint8ClampedArray(1024),this._gradientTexture;let W=K.createLinearGradient(0,0,0,256);for(let[J,U]of Object.entries($))W.addColorStop(Number(J),U);return K.fillStyle=W,K.fillRect(0,0,1,256),this._gradientTexture=K.getImageData(0,0,1,256).data,this._gradientTexture}}N6.setDefaultOptions({radius:25,blur:15,max:1,minOpacity:0.05,pane:"overlayPane"});f();r();A0();W0();O0();class S$ extends H0{_url;initialize($,Q,K){this._url=$,this._bounds=new z(Q),t(this,K)}onAdd(){if(!this._image){if(this._initImage(),this.options.opacity<1)this._updateOpacity()}if(this.options.interactive)this._image.classList.add("tsmap-interactive"),this.addInteractiveTarget(this._image);this.getPane().appendChild(this._image),this._reset()}onRemove(){if(this._image.remove(),this.options.interactive)this.removeInteractiveTarget(this._image)}setOpacity($){if(this.options.opacity=$,this._image)this._updateOpacity();return this}setStyle($){if($.opacity)this.setOpacity($.opacity);return this}bringToFront(){if(this._map)o$(this._image);return this}bringToBack(){if(this._map)t$(this._image);return this}setUrl($){if(this._url=$,this._image)this._image.src=$;return this}setBounds($){if(this._bounds=new z($),this._map)this._reset();return this}getEvents(){let $={zoom:this._reset,viewreset:this._reset};if(this._zoomAnimated)$.zoomanim=this._animateZoom;return $}setZIndex($){return this.options.zIndex=$,this._updateZIndex(),this}getBounds(){return this._bounds}getElement(){return this._image}_initImage(){let $=this._url.tagName==="IMG",Q=this._image=$?this._url:v("img");if(Q.classList.add("tsmap-image-layer"),this._zoomAnimated)Q.classList.add("tsmap-zoom-animated");if(this.options.className)Q.classList.add(...L0(this.options.className));if(Q.onselectstart=M0,Q.onpointermove=M0,Q.onload=this.fire.bind(this,"load"),Q.onerror=this._overlayOnError.bind(this),this.options.crossOrigin||this.options.crossOrigin==="")Q.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;if(Q.decoding=this.options.decoding,this.options.zIndex)this._updateZIndex();if($){this._url=Q.src;return}Q.src=this._url,Q.alt=this.options.alt}_animateZoom($){let Q=this._map.getZoomScale($.zoom),K=this._map._latLngBoundsToNewLayerBounds(this._bounds,$.zoom,$.center).min;W$(this._image,K,Q)}_reset(){let $=this._image,Q=new P(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),K=Q.getSize();K0($,Q.min),$.style.width=`${K.x}px`,$.style.height=`${K.y}px`}_updateOpacity(){this._image.style.opacity=this.options.opacity}_updateZIndex(){if(this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null)this._image.style.zIndex=this.options.zIndex}_overlayOnError(){this.fire("error");let $=this.options.errorOverlayUrl;if($&&this._url!==$)this._url=$,this._image.src=$}getCenter(){return this._bounds.getCenter()}}S$.setDefaultOptions({opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:"",decoding:"auto"});O0();i();r();l();$0();O0();class P$ extends g8{openOn($){let Q=arguments.length?$:this._source._map;if(!Q.hasLayer(this)&&Q._popup&&Q._popup.options.autoClose)Q.removeLayer(Q._popup);return Q._popup=this,super.openOn(Q)}onAdd($){if(super.onAdd($),$.fire("popupopen",{popup:this}),this._source){if(this._source.fire("popupopen",{popup:this},!0),!(this._source instanceof X$))this._source.on("preclick",i0)}}onRemove($){if(super.onRemove($),$.fire("popupclose",{popup:this}),this._source){if(this._source.fire("popupclose",{popup:this},!0),!(this._source instanceof X$))this._source.off("preclick",i0)}}getEvents(){let $=super.getEvents();if(this.options.closeOnClick??this._map.options.closePopupOnClick)$.preclick=this.close;if(this.options.keepInView)$.moveend=this._adjustPan;return $}_initLayout(){let Q=this._container=v("div",`tsmap-popup ${this.options.className||""} tsmap-zoom-animated`),K=this._wrapper=v("div","tsmap-popup-content-wrapper",Q);if(this._contentNode=v("div","tsmap-popup-content",K),O$(Q),cQ(this._contentNode),B(Q,"contextmenu",i0),this._tipContainer=v("div","tsmap-popup-tip-container",Q),this._tip=v("div","tsmap-popup-tip",this._tipContainer),this.options.closeButton){let W=this._closeButton=v("a","tsmap-popup-close-button",Q);W.setAttribute("role","button"),W.setAttribute("aria-label",this.options.closeButtonLabel),W.href="#close",W.innerHTML='<span aria-hidden="true">×</span>',B(W,"click",(J)=>{J.preventDefault(),this.close()})}if(this.options.trackResize)this._resizeObserver=new ResizeObserver((W)=>{if(!this._map)return;this._containerWidth=W[0]?.contentRect?.width,this._containerHeight=W[0]?.contentRect?.height,this._updateLayout(),this._updatePosition(),this._adjustPan()}),this._resizeObserver.observe(this._contentNode)}_updateLayout(){let $=this._contentNode,Q=$.style;Q.maxWidth=`${this.options.maxWidth}px`,Q.minWidth=`${this.options.minWidth}px`;let K=this._containerHeight??$.offsetHeight,W=this.options.maxHeight,J="tsmap-popup-scrolled";if(W&&K>W)Q.height=`${W}px`,$.classList.add(J);else $.classList.remove(J);this._containerWidth=this._container.offsetWidth,this._containerHeight=this._container.offsetHeight}_animateZoom($){let Q=this._map._latLngToNewLayerPoint(this._latlng,$.zoom,$.center),K=this._getAnchor();K0(this._container,Q.add(K))}_adjustPan(){if(!this.options.autoPan)return;if(this._map._panAnim?.stop(),this._autopanning){this._autopanning=!1;return}let $=this._map,Q=Number.parseInt(getComputedStyle(this._container).marginBottom,10)||0,K=this._containerHeight+Q,W=this._containerWidth,J=new D(this._containerLeft,-K-this._containerBottom);J._add(J$(this._container));let U=$.layerPointToContainerPoint(J),V=new D(this.options.autoPanPadding),X=new D(this.options.autoPanPaddingTopLeft??V),Y=new D(this.options.autoPanPaddingBottomRight??V),Z=$.getSize(),H=0,A=0;if(U.x+W+Y.x>Z.x)H=U.x+W-Z.x+Y.x;if(U.x-H-X.x<0)H=U.x-X.x;if(U.y+K+Y.y>Z.y)A=U.y+K-Z.y+Y.y;if(U.y-A-X.y<0)A=U.y-X.y;if(H||A){if(this.options.keepInView)this._autopanning=!0;$.fire("autopanstart").panBy([H,A])}}_getAnchor(){return new D(this._source?._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}P$.setDefaultOptions({pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,closeButtonLabel:"Close popup",autoClose:!0,closeOnEscapeKey:!0,className:"",trackResize:!0});L.mergeOptions({closePopupOnClick:!0});L.include({openPopup($,Q,K){return this._initOverlay(P$,$,Q,K).openOn(this),this},closePopup($){return(arguments.length?$:this._popup)?.close(),this}});H0.include({bindPopup($,Q){if(this._popup=this._initOverlay(P$,this._popup,$,Q),!this._popupHandlersAdded)this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0;return this},unbindPopup(){if(this._popup)this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null;return this},openPopup($){if(this._popup){if(!(this instanceof P0))this._popup._source=this;if(this._popup._prepareOpen($||this._latlng))this._popup.openOn(this._map)}return this},closePopup(){return this._popup?.close(),this},togglePopup(){return this._popup?.toggle(this),this},isPopupOpen(){return this._popup?.isOpen()??!1},setPopupContent($){return this._popup?.setContent($),this},getPopup(){return this._popup},_openPopup($){if(!this._popup||!this._map)return;o0($);let Q=$.propagatedFrom??$.target;if(this._popup._source===Q&&!(Q instanceof X$)){if(this._map.hasLayer(this._popup))this.closePopup();else this.openPopup($.latlng);return}this._popup._source=Q,this.openPopup($.latlng)},_movePopup($){this._popup.setLatLng($.latlng)},_onKeyPress($){if($.originalEvent.code==="Enter")this._openPopup($)}});f();class q6 extends S${_initImage(){let $=this._image=this._url;if($.classList.add("tsmap-image-layer"),this._zoomAnimated)$.classList.add("tsmap-zoom-animated");if(this.options.className)$.classList.add(...L0(this.options.className));$.onselectstart=M0,$.onpointermove=M0}}f();i();r();l();$0();O0();class L$ extends g8{onAdd($){if(super.onAdd($),this.setOpacity(this.options.opacity),$.fire("tooltipopen",{tooltip:this}),this._source)this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0)}onRemove($){if(super.onRemove($),$.fire("tooltipclose",{tooltip:this}),this._source)this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0)}getEvents(){let $=super.getEvents();if(!this.options.permanent)$.preclick=this.close;return $}_initLayout(){let Q=`tsmap-tooltip ${this.options.className||""} tsmap-zoom-${this._zoomAnimated?"animated":"hide"}`;this._contentNode=this._container=v("div",Q),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id",`tsmap-tooltip-${u(this)}`)}_updateLayout(){}_adjustPan(){}_setPosition($){let Q,K,W=this.options.direction,J=this._map,U=this._container,V=J.latLngToContainerPoint(J.getCenter()),X=J.layerPointToContainerPoint($),Y=U.offsetWidth,Z=U.offsetHeight,H=new D(this.options.offset),A=this._getAnchor();if(W==="top")Q=Y/2,K=Z;else if(W==="bottom")Q=Y/2,K=0;else if(W==="center")Q=Y/2,K=Z/2;else if(W==="right")Q=0,K=Z/2;else if(W==="left")Q=Y,K=Z/2;else if(X.x<V.x)W="right",Q=0,K=Z/2;else W="left",Q=Y+(H.x+A.x)*2,K=Z/2;$=$.subtract(new D(Q,K,!0)).add(H).add(A),U.classList.remove("tsmap-tooltip-right","tsmap-tooltip-left","tsmap-tooltip-top","tsmap-tooltip-bottom"),U.classList.add(`tsmap-tooltip-${W}`),K0(U,$)}_updatePosition(){let $=this._map.latLngToLayerPoint(this._latlng);this._setPosition($)}setOpacity($){if(this.options.opacity=$,this._container)this._container.style.opacity=String($)}_animateZoom($){let Q=this._map._latLngToNewLayerPoint(this._latlng,$.zoom,$.center);this._setPosition(Q)}_getAnchor(){return new D(this._source?._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}L$.setDefaultOptions({pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:0.9});L.include({openTooltip($,Q,K){return this._initOverlay(L$,$,Q,K).openOn(this),this},closeTooltip($){return $.close(),this}});H0.include({bindTooltip($,Q){if(this._tooltip&&this.isTooltipOpen())this.unbindTooltip();if(this._tooltip=this._initOverlay(L$,this._tooltip,$,Q),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this))this.openTooltip();return this},unbindTooltip(){if(this._tooltip)this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null;return this},_initTooltipInteractions($){if(!$&&this._tooltipHandlersAdded)return;let Q=$?"off":"on",K={remove:this.closeTooltip,move:this._moveTooltip};if(!this._tooltip.options.permanent)if(K.pointerover=this._openTooltip,K.pointerout=this.closeTooltip,K.click=this._openTooltip,this._map)this._addFocusListeners($);else K.add=()=>this._addFocusListeners($);else K.add=this._openTooltip;if(this._tooltip.options.sticky)K.pointermove=this._moveTooltip;this[Q](K),this._tooltipHandlersAdded=!$},openTooltip($){if(this._tooltip){if(!(this instanceof P0))this._tooltip._source=this;if(this._tooltip._prepareOpen($)){if(this._tooltip.openOn(this._map),this.getElement)this._setAriaDescribedByOnLayer(this);else if(this.eachLayer)this.eachLayer(this._setAriaDescribedByOnLayer,this)}}return this},closeTooltip(){if(this._tooltip)return this._tooltip.close()},toggleTooltip(){return this._tooltip?.toggle(this),this},isTooltipOpen(){return this._tooltip.isOpen()},setTooltipContent($){return this._tooltip?.setContent($),this},getTooltip(){return this._tooltip},_addFocusListeners($){if(this.getElement)this._addFocusListenersOnLayer(this,$);else if(this.eachLayer)this.eachLayer((Q)=>this._addFocusListenersOnLayer(Q,$),this)},_addFocusListenersOnLayer($,Q){let K=typeof $.getElement==="function"&&$.getElement();if(K){let W=Q?"off":"on";if(!Q){if(K._tsmap_focus_handler)h(K,"focus",K._tsmap_focus_handler,this);K._tsmap_focus_handler=()=>{if(this._tooltip)this._tooltip._source=$,this.openTooltip()}}if(K._tsmap_focus_handler)ZQ[W](K,"focus",K._tsmap_focus_handler,this);if(ZQ[W](K,"blur",this.closeTooltip,this),Q)delete K._tsmap_focus_handler}},_setAriaDescribedByOnLayer($){(typeof $.getElement==="function"&&$.getElement())?.setAttribute?.("aria-describedby",this._tooltip._container.id)},_openTooltip($){if(!this._tooltip||!this._map)return;if(this._map.dragging?.moving()){if($.type==="add"&&!this._moveEndOpensTooltip)this._moveEndOpensTooltip=!0,this._map.once("moveend",()=>{this._moveEndOpensTooltip=!1,this._openTooltip($)});return}this._tooltip._source=$.propagatedFrom??$.target,this.openTooltip(this._tooltip.options.sticky?$.latlng:void 0)},_moveTooltip($){let Q=$.latlng;if(this._tooltip.options.sticky&&$.originalEvent){let K=this._map.pointerEventToContainerPoint($.originalEvent),W=this._map.containerPointToLayerPoint(K);Q=this._map.layerPointToLatLng(W)}this._tooltip.setLatLng(Q)}});f();i();r();class d8 extends S${_initImage(){let $=this._url.tagName==="VIDEO",Q=this._image=$?this._url:v("video");if(Q.classList.add("tsmap-image-layer"),this._zoomAnimated)Q.classList.add("tsmap-zoom-animated");if(this.options.className)Q.classList.add(...L0(this.options.className));if(B(Q,"pointerdown",(K)=>{if(Q.controls)i0(K)}),Q.onloadeddata=this.fire.bind(this,"load"),$){let K=Array.from(Q.getElementsByTagName("source")),W=K.map((J)=>J.src);this._url=K.length>0?W:[Q.src];return}if(!Array.isArray(this._url))this._url=[this._url];if(!this.options.keepAspectRatio&&Object.hasOwn(Q.style,"objectFit"))Q.style.objectFit="fill";Q.autoplay=!!this.options.autoplay,Q.controls=!!this.options.controls,Q.loop=!!this.options.loop,Q.muted=!!this.options.muted,Q.playsInline=!!this.options.playsInline;for(let K of this._url){let W=v("source");W.src=K,Q.appendChild(W)}}}d8.setDefaultOptions({autoplay:!0,controls:!1,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0});l();class c8 extends k${createIcon($){let Q=$&&$.tagName==="DIV"?$:document.createElement("div"),K=this.options;if(K.html instanceof Element)Q.replaceChildren(),Q.appendChild(K.html);else Q.innerHTML=K.html!==!1?K.html:"";if(K.bgPos){let W=new D(K.bgPos);Q.style.backgroundPosition=`${-W.x}px ${-W.y}px`}return this._setIconStyles(Q,"icon"),Q}createShadow(){return null}}c8.setDefaultOptions({iconSize:[12,12],html:!1,bgPos:null,className:"tsmap-div-icon"});oQ();i();i$();function S7($){if($.startsWith("#")){let Q=$.slice(1);if(Q.length===3)return[Number.parseInt(Q[0]+Q[0],16),Number.parseInt(Q[1]+Q[1],16),Number.parseInt(Q[2]+Q[2],16)];return[Number.parseInt(Q.slice(0,2),16),Number.parseInt(Q.slice(2,4),16),Number.parseInt(Q.slice(4,6),16)]}if($==="white"||$==="#fff")return[255,255,255];if($==="black"||$==="#000")return[0,0,0];return[255,255,255]}class R6 extends V${initialize($,Q){super.initialize($,{tileSize:512,...Q}),this._encoding=Q?.encoding??"mapbox"}createTile($,Q){let K=document.createElement("canvas"),W=this.options.tileSize;if(K.width=W,K.height=W,K.style)K.style.width=`${W}px`,K.style.height=`${W}px`;let J=new Image;if(this.options.crossOrigin||this.options.crossOrigin==="")J.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;return B(J,"load",()=>{try{this._shadeInto(J,K),Q(null,K)}catch(U){Q(U,K)}}),B(J,"error",(U)=>Q(U,K)),J.src=this.getTileUrl($),K}_shadeInto($,Q){let K=Q.width,W=Q.getContext("2d");if(!W)return;let J=document.createElement("canvas");J.width=K,J.height=K;let U=J.getContext("2d");if(!U)return;U.drawImage($,0,0,K,K);let V=U.getImageData(0,0,K,K),X=new Float32Array(K*K),Y=V.data,Z=this._encoding==="terrarium"?h7:f7;for(let a=0,y=0;a<X.length;a++,y+=4)X[a]=Z(Y[y],Y[y+1],Y[y+2]);let H=this.options.azimuth??335,A=this.options.altitude??45,G=this.options.exaggeration??0.5,F=H*Math.PI/180,N=A*Math.PI/180,q=Math.sin(F)*Math.cos(N),R=-Math.cos(F)*Math.cos(N),I=Math.sin(N),[C,M,j]=S7(this.options.accentColor??"#ffffff"),[E,_,x]=S7(this.options.shadowColor??"#000000"),n=this.options.opacity??1,p=W.createImageData(K,K),J0=p.data;for(let a=0;a<K;a++){let y=Math.max(0,a-1),o=Math.min(K-1,a+1);for(let U0=0;U0<K;U0++){let b=Math.max(0,U0-1),G0=Math.min(K-1,U0+1),F0=(X[a*K+G0]-X[a*K+b])*0.5*G,e=(X[o*K+U0]-X[y*K+U0])*0.5*G,V0=Math.hypot(F0,e,1),Z0=-F0/V0,f0=-e/V0,G$=1/V0,F$=Math.max(0,Z0*q+f0*R+G$*I),GK=F$*C+(1-F$)*E,FK=F$*M+(1-F$)*_,NK=F$*j+(1-F$)*x,V8=(a*K+U0)*4;J0[V8]=GK,J0[V8+1]=FK,J0[V8+2]=NK,J0[V8+3]=Math.round(255*n)}}W.putImageData(p,0,0)}}var LJ=R6;i$();B9();e0();W0();i$();class U8 extends V${defaultWmsParams={service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"};initialize($,Q){super.initialize($,Q);let K={...this.defaultWmsParams};for(let[U,V]of Object.entries(Q??{}))if(!(U in U8.prototype.options))K[U]=V;let W=this.options.detectRetina&&X0.retina?2:1,J=this.getTileSize();K.width=J.x*W,K.height=J.y*W,this.wmsParams=K}onAdd($){this._crs=this.options.crs??$.options.crs,this._wmsVersion=Number.parseFloat(this.wmsParams.version);let Q=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[Q]=this._crs.code,super.onAdd()}getTileUrl($){let Q=this._tileCoordsToNwSe($),K=this._crs,W=new P(K.project(Q[0]),K.project(Q[1])),J=W.min,U=W.max,V=(this._wmsVersion>=1.3&&this._crs===$6?[J.y,J.x,U.y,U.x]:[J.x,J.y,U.x,U.y]).join(","),X=new URL(super.getTileUrl($));for(let[Y,Z]of Object.entries({...this.wmsParams,bbox:V}))X.searchParams.append(this.options.uppercase?Y.toUpperCase():Y,String(Z));return X.toString()}setParams($,Q){if(Object.assign(this.wmsParams,$),!Q)this.redraw();return this}}U8.setDefaultOptions({crs:null,uppercase:!1});f();i();W0();f();class M6 extends G6{initialize($){super.initialize({...$,continuous:!1}),u(this),this._layers??={}}onAdd($){super.onAdd($),this.on("update",this._updatePaths,this)}onRemove($){super.onRemove($),this.off("update",this._updatePaths,this)}_onZoomEnd(){for(let $ of Object.values(this._layers))$._project()}_updatePaths(){for(let $ of Object.values(this._layers))$._update()}_onViewReset(){for(let $ of Object.values(this._layers))$._reset()}_onSettled($){this._update()}_update(){}}class D6 extends M6{getEvents(){let $=super.getEvents();return $.viewprereset=this._onViewPreReset,$}_onViewPreReset(){this._postponeUpdatePaths=!0}onAdd($){super.onAdd($),this._draw()}onRemove(){super.onRemove(),clearTimeout(this._pointerHoverThrottleTimeout)}_initContainer(){let $=this._container=document.createElement("canvas");B($,"pointermove",this._onPointerMove,this),B($,"click dblclick pointerdown pointerup contextmenu",this._onClick,this),B($,"pointerout",this._handlePointerOut,this),$._tsmap_disable_events=!0,this._ctx=$.getContext("2d")}_destroyContainer(){if(this._redrawRequest!==void 0&&this._redrawRequest!==null)cancelAnimationFrame(this._redrawRequest);this._redrawRequest=null,delete this._ctx,super._destroyContainer()}_resizeContainer(){let $=this.options.padding,Q=this._map.getSize().multiplyBy(1+$*2).round();this._container.style.width=`${Q.x}px`,this._container.style.height=`${Q.y}px`;let K=this._ctxScale=window.devicePixelRatio;return this._container.width=K*Q.x,this._container.height=K*Q.y,Q}_updatePaths(){if(this._postponeUpdatePaths)return;this._redrawBounds=null;for(let $ of Object.values(this._layers))$._update();this._redraw()}_update(){if(this._map._animatingZoom&&this._bounds)return;let $=this._bounds,Q=this._ctxScale;this._ctx.setTransform(Q,0,0,Q,-$.min.x*Q,-$.min.y*Q),this.fire("update")}_reset(){this._onSettled.bind(this)();let Q=this;if(Q._updateTransform(Q._center,Q._zoom),this._onViewReset(),this._postponeUpdatePaths)this._postponeUpdatePaths=!1,this._updatePaths()}_initPath($){this._updateDashArray($),this._layers[u($)]=$;let Q={layer:$,prev:this._drawLast??null,next:null};if(this._drawLast)this._drawLast.next=Q;this._drawLast=Q,this._drawFirst??=this._drawLast,$._order=Q}_addPath($){this._requestRedraw($)}_removePath($){let Q=$._order,K=Q.next,W=Q.prev;if(K)K.prev=W;else this._drawLast=W;if(W)W.next=K;else this._drawFirst=K;delete $._order,delete this._layers[u($)],this._requestRedraw($)}_updatePath($){this._extendRedrawBounds($),$._project(),$._update(),this._requestRedraw($)}_updateStyle($){this._updateDashArray($),this._requestRedraw($)}_updateDashArray($){if(typeof $.options.dashArray==="string"){let Q=$.options.dashArray.split(/[, ]+/);$.options._dashArray=Q.map((K)=>Number(K)).filter((K)=>!Number.isNaN(K))}else $.options._dashArray=$.options.dashArray}_requestRedraw($){if(!this._map)return;this._extendRedrawBounds($),this._redrawRequest??=requestAnimationFrame(this._redraw.bind(this))}_extendRedrawBounds($){if($._pxBounds){let Q=($.options.weight??0)+1;this._redrawBounds??=new P,this._redrawBounds.extend($._pxBounds.min.subtract([Q,Q])),this._redrawBounds.extend($._pxBounds.max.add([Q,Q]))}}_redraw(){if(this._redrawRequest=null,this._redrawBounds)this._redrawBounds.min._floor(),this._redrawBounds.max._ceil();this._clear(),this._draw(),this._redrawBounds=null}_clear(){let $=this._redrawBounds;if($){let Q=$.getSize();this._ctx.clearRect($.min.x,$.min.y,Q.x,Q.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()}_draw(){let $=this._redrawBounds;if(this._ctx.save(),$){let Q=$.getSize();this._ctx.beginPath(),this._ctx.rect($.min.x,$.min.y,Q.x,Q.y),this._ctx.clip()}this._drawing=!0;for(let Q=this._drawFirst;Q;Q=Q.next){let K=Q.layer;if(!$||K._pxBounds&&K._pxBounds.intersects($))K._updatePath()}this._drawing=!1,this._ctx.restore()}_updatePoly($,Q){if(!this._drawing)return;let K=$._parts,W=this._ctx;if(!K.length)return;W.beginPath(),K.forEach((J)=>{if(J.forEach((U,V)=>{W[V?"lineTo":"moveTo"](U.x,U.y)}),Q)W.closePath()}),this._fillStroke(W,$)}_updateCircle($){if(!this._drawing||$._empty())return;let Q=$._point,K=this._ctx,W=Math.max(Math.round($._pxRadius),1),J=(Math.max(Math.round($._pxRadiusY),1)||W)/W;if(J!==1)K.save(),K.scale(1,J);if(K.beginPath(),K.arc(Q.x,Q.y/J,W,0,Math.PI*2,!1),J!==1)K.restore();this._fillStroke(K,$)}_fillStroke($,Q){let K=Q.options;if(K.fill)$.globalAlpha=K.fillOpacity,$.fillStyle=K.fillColor??K.color,$.fill(K.fillRule||"evenodd");if(K.stroke&&K.weight!==0){if($.setLineDash)$.lineDashOffset=Number(K.dashOffset??0),$.setLineDash(K._dashArray??[]);$.globalAlpha=K.opacity,$.lineWidth=K.weight,$.strokeStyle=K.color,$.lineCap=K.lineCap,$.lineJoin=K.lineJoin,$.stroke()}}_onClick($){let Q=this._map.pointerEventToLayerPoint($),K;for(let W=this._drawFirst;W;W=W.next){let J=W.layer;if(J.options.interactive&&J._containsPoint(Q)){if(!($.type==="click"||$.type==="preclick")||!this._map._draggableMoved(J))K=J}}this._fireEvent(K?[K]:!1,$)}_onPointerMove($){if(!this._map||this._map.dragging.moving()||this._map._animatingZoom)return;let Q=this._map.pointerEventToLayerPoint($);this._handlePointerHover($,Q)}_handlePointerOut($){let Q=this._hoveredLayer;if(Q)this._container.classList.remove("tsmap-interactive"),this._fireEvent([Q],$,"pointerout"),this._hoveredLayer=null,this._pointerHoverThrottled=!1}_handlePointerHover($,Q){if(this._pointerHoverThrottled)return;let K;for(let W=this._drawFirst;W;W=W.next){let J=W.layer;if(J.options.interactive&&J._containsPoint(Q))K=J}if(K!==this._hoveredLayer){if(this._handlePointerOut($),K)this._container.classList.add("tsmap-interactive"),this._fireEvent([K],$,"pointerover"),this._hoveredLayer=K}this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,$),this._pointerHoverThrottled=!0,this._pointerHoverThrottleTimeout=setTimeout(()=>{this._pointerHoverThrottled=!1},32)}_fireEvent($,Q,K){this._map._fireDOMEvent(Q,K||Q.type,$||void 0)}_bringToFront($){let Q=$._order;if(!Q)return;let{next:K,prev:W}=Q;if(K)K.prev=W;else return;if(W)W.next=K;else if(K)this._drawFirst=K;Q.prev=this._drawLast,this._drawLast.next=Q,Q.next=null,this._drawLast=Q,this._requestRedraw($)}_bringToBack($){let Q=$._order;if(!Q)return;let{next:K,prev:W}=Q;if(W)W.next=K;else return;if(K)K.prev=W;else if(W)this._drawLast=W;Q.prev=null,Q.next=this._drawFirst,this._drawFirst.prev=Q,this._drawFirst=Q,this._requestRedraw($)}}D6.setDefaultOptions({tolerance:0});A0();class I6 extends A${initialize($,Q){super.initialize(this._boundsToLatLngs($),Q)}setBounds($){return this.setLatLngs(this._boundsToLatLngs($))}_boundsToLatLngs($){let Q=new z($);return[Q.getSouthWest(),Q.getNorthWest(),Q.getNorthEast(),Q.getSouthEast()]}}$0();r();f();class D$ extends M6{_initContainer(){this._container=D$.create("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=D$.create("g"),this._container.appendChild(this._rootGroup)}_destroyContainer(){super._destroyContainer(),delete this._rootGroup,delete this._svgSize}_resizeContainer(){let $=this.options.padding,Q=this._map.getSize().multiplyBy(1+$*2).round();if(this._container.style.width=`${Q.x}px`,this._container.style.height=`${Q.y}px`,!this._svgSize||!this._svgSize.equals(Q))this._svgSize=Q,this._container.setAttribute("width",Q.x),this._container.setAttribute("height",Q.y);let K=this._bounds;if(K)this._container.setAttribute("viewBox",[K.min.x,K.min.y,Q.x,Q.y].join(" "));return Q}_update(){if(this._map._animatingZoom&&this._bounds)return;let $=this._bounds,Q=$.getSize();this._container.setAttribute("viewBox",[$.min.x,$.min.y,Q.x,Q.y].join(" ")),this.fire("update")}_initPath($){let Q=$._path=D$.create("path");if($.options.className)Q.classList.add(...L0($.options.className));if($.options.interactive)Q.classList.add("tsmap-interactive");this._updateStyle($),this._layers[u($)]=$}_addPath($){if(!this._rootGroup)this._initContainer();this._rootGroup.appendChild($._path),$.addInteractiveTarget($._path)}_removePath($){$._path.remove(),$.removeInteractiveTarget($._path),delete this._layers[u($)]}_updatePath($){$._project(),$._update()}_updateStyle($){let{_path:Q,options:K}=$;if(!Q)return;if(K.stroke){if(Q.setAttribute("stroke",K.color),Q.setAttribute("stroke-opacity",K.opacity),Q.setAttribute("stroke-width",K.weight),Q.setAttribute("stroke-linecap",K.lineCap),Q.setAttribute("stroke-linejoin",K.lineJoin),K.dashArray)Q.setAttribute("stroke-dasharray",K.dashArray);else Q.removeAttribute("stroke-dasharray");if(K.dashOffset)Q.setAttribute("stroke-dashoffset",K.dashOffset);else Q.removeAttribute("stroke-dashoffset")}else Q.setAttribute("stroke","none");if(K.fill)Q.setAttribute("fill",K.fillColor||K.color),Q.setAttribute("fill-opacity",K.fillOpacity),Q.setAttribute("fill-rule",K.fillRule||"evenodd");else Q.setAttribute("fill","none")}_updatePoly($,Q){this._setPath($,D$.pointsToPath($._parts,Q))}_updateCircle($){let Q=$._point,K=Math.max(Math.round($._pxRadius),1),W=Math.max(Math.round($._pxRadiusY),1)||K,J=`a${K},${W} 0 1,0 `,U=$._empty()?"M0 0":`M${Q.x-K},${Q.y}${J}${K*2},0 ${J}${-K*2},0 `;this._setPath($,U)}_setPath($,Q){$._path.setAttribute("d",Q)}_bringToFront($){o$($._path)}_bringToBack($){t$($._path)}static create($){return document.createElementNS("http://www.w3.org/2000/svg",$)}static pointsToPath($,Q){return $.flatMap((W)=>[...W.map((J,U)=>`${(U?"L":"M")+J.x} ${J.y}`),Q?"z":""]).join("")||"M0 0"}}L.include({getRenderer($){let Q=$.options.renderer??this._getPaneRenderer($.options.pane)??this.options.renderer??this._renderer;if(!Q)Q=this._renderer=this._createRenderer();if(!this.hasLayer(Q))this.addLayer(Q);return Q},_getPaneRenderer($){if($==="overlayPane"||$===void 0)return;let Q=this._paneRenderers[$];if(Q===void 0)Q=this._createRenderer({pane:$}),this._paneRenderers[$]=Q;return Q},_createRenderer($){return this.options.preferCanvas&&new D6($)||new D$($)}});$0();i();r();A0();W0();$0();L.mergeOptions({boxZoom:!0});class KK extends D0{_resetStateTimeout=0;_moved=!1;initialize($){super.initialize($),this._container=$._container,this._pane=$._panes.overlayPane,this._resetStateTimeout=0,$.on("unload",this._destroy,this)}addHooks(){B(this._container,"pointerdown",this._onPointerDown,this)}removeHooks(){h(this._container,"pointerdown",this._onPointerDown,this)}moved(){return this._moved}_destroy(){this._pane?.remove(),this._pane=void 0}_resetState(){this._resetStateTimeout=0,this._moved=!1}_clearDeferredResetState(){if(this._resetStateTimeout!==0)clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0}_onPointerDown($){if(!$.shiftKey||$.button!==0)return!1;this._clearDeferredResetState(),this._resetState(),bQ(),yQ(),this._startPoint=this._map.pointerEventToContainerPoint($),B(this._container,{contextmenu:o0,pointermove:this._onPointerMove,pointerup:this._onPointerUp,keydown:this._onKeyDown},this),B(document,"keydown",this._onKeyDown,this)}_onPointerMove($){if(!this._moved)this._moved=!0,this._box=v("div","tsmap-zoom-box",this._container),this._container.classList.add("tsmap-crosshair"),this._map.fire("boxzoomstart");this._point=this._map.pointerEventToContainerPoint($);let Q=new P(this._point,this._startPoint),K=Q.getSize();K0(this._box,Q.min),this._box.style.width=`${K.x}px`,this._box.style.height=`${K.y}px`}_finish(){if(this._moved)this._box?.remove(),this._container.classList.remove("tsmap-crosshair");xQ(),uQ(),h(this._container,{contextmenu:o0,pointermove:this._onPointerMove,pointerup:this._onPointerUp},this),h(document,"keydown",this._onKeyDown,this)}_onPointerUp($){if($.button!==0)return;if(this._finish(),!this._moved)return;this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(this._resetState.bind(this),0);let Q=new z(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(Q).fire("boxzoomend",{boxZoomBounds:Q})}_onKeyDown($){if($.code==="Escape")this._finish(),this._clearDeferredResetState(),this._resetState()}}L.addInitHook("addHandler","boxZoom",KK);$0();L.mergeOptions({doubleClickZoom:!0});class WK extends D0{addHooks(){this._map.on("dblclick",this._onDoubleClick,this)}removeHooks(){this._map.off("dblclick",this._onDoubleClick,this)}_onDoubleClick($){let Q=this._map,K=Q.getZoom(),W=Q.options.zoomDelta,J=$.originalEvent.shiftKey?K-W:K+W;if(Q.options.doubleClickZoom==="center")Q.setZoom(J);else Q.setZoomAround($.containerPoint,J)}}L.addInitHook("addHandler","doubleClickZoom",WK);A0();W0();$0();L.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:0.2,worldCopyJump:!1,maxBoundsViscosity:0});class JK extends D0{_positions=[];_times=[];_offsetLimit=null;_viscosity=0;_initialWorldOffset=0;_worldWidth=0;addHooks(){if(!this._draggable){let $=this._map;if(this._draggable=new S0($._mapPane,$._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),$.options.worldCopyJump)this._draggable.on("predrag",this._onPreDragWrap,this),$.on("zoomend",this._onZoomEnd,this),$.whenReady(this._onZoomEnd,this)}this._map._container.classList.add("tsmap-grab","tsmap-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]}removeHooks(){this._map._container.classList.remove("tsmap-grab","tsmap-touch-drag"),this._draggable.disable()}moved(){return this._draggable?._moved}moving(){return this._draggable?._moving}_onDragStart(){let $=this._map;if($._stop(),$.options.maxBounds&&$.options.maxBoundsViscosity){let Q=new z($.options.maxBounds);this._offsetLimit=new P($.latLngToContainerPoint(Q.getNorthWest()).multiplyBy(-1),$.latLngToContainerPoint(Q.getSouthEast()).multiplyBy(-1).add($.getSize())),this._viscosity=Math.min(1,Math.max(0,$.options.maxBoundsViscosity))}else this._offsetLimit=null;if($.fire("movestart").fire("dragstart"),$.options.inertia)this._positions=[],this._times=[]}_onDrag($){if(this._map.options.inertia){let Q=this._lastTime=Date.now(),K=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(K),this._times.push(Q),this._prunePositions(Q)}this._map.fire("move",$).fire("drag",$)}_prunePositions($){while(this._positions.length>1&&$-this._times[0]>50)this._positions.shift(),this._times.shift()}_onZoomEnd(){let $=this._map.getSize().divideBy(2),Q=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=Q.subtract($).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x}_viscousLimit($,Q){return $-($-Q)*this._viscosity}_onPreDragLimit(){if(!this._viscosity||!this._offsetLimit)return;let $=this._draggable,Q=$._newPos.subtract($._startPos),K=this._offsetLimit;if(Q.x<K.min.x)Q.x=this._viscousLimit(Q.x,K.min.x);if(Q.y<K.min.y)Q.y=this._viscousLimit(Q.y,K.min.y);if(Q.x>K.max.x)Q.x=this._viscousLimit(Q.x,K.max.x);if(Q.y>K.max.y)Q.y=this._viscousLimit(Q.y,K.max.y);$._newPos=$._startPos.add(Q)}_onPreDragWrap(){let $=this._draggable,Q=this._worldWidth,K=Math.round(Q/2),W=this._initialWorldOffset,J=$._newPos.x,U=(J-K+W)%Q+K-W,V=(J+K+W)%Q-K-W,X=Math.abs(U+W)<Math.abs(V+W)?U:V;$._absPos=$._newPos.clone(),$._newPos.x=X}_onDragEnd($){let Q=this._map,K=Q.options,W=!K.inertia||$.noInertia||this._times.length<2;if(Q.fire("dragend",$),W)Q.fire("moveend");else{this._prunePositions(Date.now());let J=this._lastPos.subtract(this._positions[0]),U=(this._lastTime-this._times[0])/1000,V=K.easeLinearity,X=J.multiplyBy(V/U),Y=X.distanceTo([0,0]),Z=Math.min(K.inertiaMaxSpeed,Y),H=X.multiplyBy(Z/Y),A=Z/(K.inertiaDeceleration*V),G=H.multiplyBy(-A/2).round();if(!G.x&&!G.y)Q.fire("moveend");else G=Q._limitOffset(G,Q.options.maxBounds),requestAnimationFrame(()=>{Q.panBy(G,{duration:A,easeLinearity:V,noMoveStart:!0,animate:!0})})}}}L.addInitHook("addHandler","dragging",JK);i();l();$0();L.mergeOptions({keyboard:!0,keyboardPanDelta:80});class g$ extends D0{static keyCodes={left:["ArrowLeft"],right:["ArrowRight"],down:["ArrowDown"],up:["ArrowUp"],zoomIn:["Equal","NumpadAdd","BracketRight"],zoomOut:["Minus","NumpadSubtract","Digit6","Slash"]};_panKeys={};_zoomKeys={};_focused=!1;initialize($){super.initialize($),this._setPanDelta($.options.keyboardPanDelta),this._setZoomDelta($.options.zoomDelta)}addHooks(){let $=this._map._container;if($.tabIndex<=0)$.tabIndex=0;$.ariaKeyShortcuts=Object.values(g$.keyCodes).flat().join(" "),B($,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)}removeHooks(){this._removeHooks(),h(this._map._container,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)}_onPointerDown(){if(this._focused)return;let{body:$,documentElement:Q}=document,K=$.scrollTop||Q.scrollTop,W=$.scrollLeft||Q.scrollLeft;this._map._container.focus(),window.scrollTo(W,K)}_onFocus(){this._focused=!0,this._map.fire("focus")}_onBlur(){this._focused=!1,this._map.fire("blur")}_setPanDelta($){let Q=this._panKeys={},K=g$.keyCodes;for(let W of K.left)Q[W]=[-1*$,0];for(let W of K.right)Q[W]=[$,0];for(let W of K.down)Q[W]=[0,$];for(let W of K.up)Q[W]=[0,-1*$]}_setZoomDelta($){let Q=this._zoomKeys={},K=g$.keyCodes;for(let W of K.zoomIn)Q[W]=$;for(let W of K.zoomOut)Q[W]=-$}_addHooks(){B(document,"keydown",this._onKeyDown,this)}_removeHooks(){h(document,"keydown",this._onKeyDown,this)}_onKeyDown($){if($.altKey||$.ctrlKey||$.metaKey)return;let Q=$.code,K=this._map,W;if(Q in this._panKeys){if(!K._panAnim||!K._panAnim._inProgress){if(W=this._panKeys[Q],$.shiftKey)W=new D(W).multiplyBy(3);if(K.options.maxBounds)W=K._limitOffset(new D(W),K.options.maxBounds);if(K.options.worldCopyJump){let J=K.wrapLatLng(K.unproject(K.project(K.getCenter()).add(W)));K.panTo(J)}else K.panBy(W)}}else if(Q in this._zoomKeys)K.setZoom(K.getZoom()+($.shiftKey?3:1)*this._zoomKeys[Q]);else if(Q==="Escape"&&K._popup&&K._popup.options.closeOnEscapeKey)K.closePopup?.();else return;o0($)}}L.addInitHook("addHandler","keyboard",g$);i();Z$();$0();L.mergeOptions({pinchZoom:!0,bounceAtZoomLimits:!0});class UK extends D0{_zooming=!1;_moved=!1;addHooks(){this._map._container.classList.add("tsmap-touch-zoom"),B(this._map._container,"pointerdown",this._onPointerStart,this)}removeHooks(){this._map._container.classList.remove("tsmap-touch-zoom"),h(this._map._container,"pointerdown",this._onPointerStart,this)}_onPointerStart($){let Q=this._map,K=z0();if(K.length!==2||Q._animatingZoom||this._zooming)return;let W=Q.pointerEventToContainerPoint(K[0]),J=Q.pointerEventToContainerPoint(K[1]);if(this._centerPoint=Q.getSize()._divideBy(2),this._startLatLng=Q.containerPointToLatLng(this._centerPoint),Q.options.pinchZoom!=="center")this._pinchStartLatLng=Q.containerPointToLatLng(W.add(J)._divideBy(2));this._startDist=W.distanceTo(J),this._startZoom=Q.getZoom(),this._moved=!1,this._zooming=!0,Q._stop(),B(this._map._container,"pointermove",this._onPointerMove,this),B(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),$.preventDefault()}_onPointerMove($){let Q=z0();if(Q.length!==2||!this._zooming)return;let K=this._map,W=K.pointerEventToContainerPoint(Q[0]),J=K.pointerEventToContainerPoint(Q[1]),U=W.distanceTo(J)/this._startDist;this._zoom=K.getScaleZoom(U,this._startZoom);let V=this._zoom;if(!K.options.bounceAtZoomLimits&&(V<K.getMinZoom()&&U<1||V>K.getMaxZoom()&&U>1))this._zoom=K._limitZoom(this._zoom);if(K.options.pinchZoom==="center"){if(this._center=this._startLatLng,U===1)return}else{let Y=W._add(J)._divideBy(2)._subtract(this._centerPoint);if(U===1&&Y.x===0&&Y.y===0)return;this._center=K.unproject(K.project(this._pinchStartLatLng,this._zoom).subtract(Y),this._zoom)}if(!this._moved)K._moveStart(!0,!1),this._moved=!0;if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);let X=K._move.bind(K,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(X.bind(this)),$.preventDefault()}_onPointerEnd(){if(!this._moved||!this._zooming){this._zooming=!1;return}if(this._zooming=!1,this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);if(h(this._map._container,"pointermove",this._onPointerMove,this),h(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),this._map.options.zoomAnimation)this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap);else this._map._resetView(this._center,this._map._limitZoom(this._zoom))}}L.addInitHook("addHandler","pinchZoom",UK);L.addInitHook(function(){if(this.touchZoom=this.pinchZoom,this.options.touchZoom!==void 0)console.warn("Map: touchZoom option is deprecated and will be removed in future versions. Use pinchZoom instead."),this.options.pinchZoom=this.options.touchZoom,delete this.options.touchZoom;if(this.options.pinchZoom)this.pinchZoom.enable();else this.pinchZoom.disable()});i();$0();L.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60});class VK extends D0{_delta=0;_startTime=null;addHooks(){B(this._map._container,"wheel",this._onWheelScroll,this),this._delta=0}removeHooks(){h(this._map._container,"wheel",this._onWheelScroll,this),clearTimeout(this._timer)}_onWheelScroll($){let Q=o7($),K=this._map.options.wheelDebounceTime;if(this._delta+=Q,this._lastMousePos=this._map.pointerEventToContainerPoint($),!this._startTime)this._startTime=Date.now();let W=Math.max(K-(Date.now()-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(this._performZoom.bind(this),W),o0($)}_performZoom(){let $=this._map,Q=$.getZoom(),K=$.options.zoomSnap??0;$._stop();let W=this._delta/($.options.wheelPxPerZoomLevel*4),J=4*Math.log(2/(1+Math.exp(-Math.abs(W))))/Math.LN2,U=K?Math.ceil(J/K)*K:J,V=$._limitZoom(Q+(this._delta>0?U:-U))-Q;if(this._delta=0,this._startTime=null,!V)return;if($.options.scrollWheelZoom==="center")$.setZoom(Q+V);else $.setZoomAround(this._lastMousePos,Q+V)}}L.addInitHook("addHandler","scrollWheelZoom",VK);e0();i();Z$();l();$0();var VJ=600;L.mergeOptions({tapHold:X0.safari&&X0.mobile,tapTolerance:15});class XK extends D0{addHooks(){B(this._map._container,"pointerdown",this._onDown,this)}removeHooks(){h(this._map._container,"pointerdown",this._onDown,this),clearTimeout(this._holdTimeout)}_onDown($){if(clearTimeout(this._holdTimeout),z0().length!==1||$.pointerType==="mouse")return;let Q=this._map._container;this._startPos=this._newPos=new D($.clientX,$.clientY),this._holdTimeout=setTimeout(()=>{if(this._cancel(),!this._isTapValid())return;B(Q,"pointerup",a0),B(Q,"pointerup pointercancel",this._cancelClickPrevent,this),this._simulateEvent("contextmenu",$)},VJ),B(Q,"pointerup pointercancel contextmenu",this._cancel,this),B(Q,"pointermove",this._onMove,this)}_cancelClickPrevent(){let $=this._map._container;h($,"pointerup",a0),h($,"pointerup pointercancel",this._cancelClickPrevent,this)}_cancel(){clearTimeout(this._holdTimeout);let $=this._map._container;h($,"pointerup pointercancel contextmenu",this._cancel,this),h($,"pointermove",this._onMove,this)}_onMove($){this._newPos=new D($.clientX,$.clientY)}_isTapValid(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance}_simulateEvent($,Q){let K=new MouseEvent($,{bubbles:!0,cancelable:!0,view:window,screenX:Q.screenX,screenY:Q.screenY,clientX:Q.clientX,clientY:Q.clientY});K._simulated=!0,Q.target.dispatchEvent(K)}}L.addInitHook("addHandler","tapHold",XK);i();Z$();$0();L.mergeOptions({touchPitch:!0});class YK extends D0{_pitching=!1;_moved=!1;addHooks(){B(this._map._container,"pointerdown",this._onPointerStart,this)}removeHooks(){h(this._map._container,"pointerdown",this._onPointerStart,this)}_onPointerStart($){let Q=z0();if(Q.length!==2||this._pitching)return;let K=this._map,W=K.pointerEventToContainerPoint(Q[0]),J=K.pointerEventToContainerPoint(Q[1]);this._startX1=W.x,this._startY1=W.y,this._startX2=J.x,this._startY2=J.y,this._startPitch=K.getPitch(),this._startDist=W.distanceTo(J),this._pitching=!0,this._moved=!1,B(this._map._container,"pointermove",this._onPointerMove,this),B(this._map._container,"pointerup pointercancel",this._onPointerEnd,this)}_onPointerMove($){let Q=z0();if(Q.length!==2||!this._pitching)return;let K=this._map,W=K.pointerEventToContainerPoint(Q[0]),J=K.pointerEventToContainerPoint(Q[1]),U=W.y-this._startY1,V=J.y-this._startY2,X=W.x-this._startX1,Y=J.x-this._startX2;if(Math.sign(U)!==Math.sign(V)&&Math.abs(U)>5&&Math.abs(V)>5)return;let Z=(U+V)/2,H=(X+Y)/2;if(Math.abs(H)>Math.abs(Z)*1.5)return;let G=W.distanceTo(J)/this._startDist;if(Math.abs(G-1)>0.1)return;if(!this._moved&&Math.abs(Z)<5)return;if(!this._moved)this._moved=!0,K.fire("pitchstart");let F=this._startPitch-Z*0.3;if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);this._animRequest=requestAnimationFrame(()=>{K.setPitch(F)}),$.preventDefault()}_onPointerEnd(){if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);if(h(this._map._container,"pointermove",this._onPointerMove,this),h(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),this._moved)this._map.fire("pitchend");this._pitching=!1,this._moved=!1}}L.addInitHook("addHandler","touchPitch",YK);i();Z$();$0();L.mergeOptions({touchRotate:!0});class ZK extends D0{_rotating=!1;_moved=!1;addHooks(){B(this._map._container,"pointerdown",this._onPointerStart,this)}removeHooks(){h(this._map._container,"pointerdown",this._onPointerStart,this)}_onPointerStart($){let Q=z0();if(Q.length!==2||this._rotating)return;let K=this._map,W=K.pointerEventToContainerPoint(Q[0]),J=K.pointerEventToContainerPoint(Q[1]);if(this._startAngle=Math.atan2(J.y-W.y,J.x-W.x),this._startBearing=K.getBearing(),K.options.touchRotate==="center"){let U=K.getSize();this._pivot={x:U.x/2,y:U.y/2}}else this._pivot={x:(W.x+J.x)/2,y:(W.y+J.y)/2};this._rotating=!0,this._moved=!1,B(this._map._container,"pointermove",this._onPointerMove,this),B(this._map._container,"pointerup pointercancel",this._onPointerEnd,this)}_onPointerMove($){let Q=z0();if(Q.length!==2||!this._rotating)return;let K=this._map,W=K.pointerEventToContainerPoint(Q[0]),J=K.pointerEventToContainerPoint(Q[1]),V=(Math.atan2(J.y-W.y,J.x-W.x)-this._startAngle)*180/Math.PI,X=this._startBearing+V;if(!this._moved)this._moved=!0,K.fire("rotatestart");if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);this._animRequest=requestAnimationFrame(()=>{K.setBearing(X)}),$.preventDefault()}_onPointerEnd(){if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);if(h(this._map._container,"pointermove",this._onPointerMove,this),h(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),this._moved)this._map.fire("rotateend");this._rotating=!1,this._moved=!1}}L.addInitHook("addHandler","touchRotate",ZK);P8();sQ();aQ();var XJ="0.3.1";function g($){return(...Q)=>new $(...Q)}var zJ=k9,YJ=g(w$),ZJ=g(k$),HJ=g(c8),AJ=g(J8),GJ=g(P0),HK=g(d),FJ=HK,NJ=g(T$),qJ=Object.assign(g(V$),{wms:g(U8)}),RJ=g(s$),vJ=g(N6),fJ=g(R6),MJ=g(S$),DJ=g(d8),IJ=g(q6),jJ=g(P$),TJ=g(L$),CJ=g(H$),OJ=g(A$),EJ=g(I6),BJ=g(m8),kJ=g(_$),wJ=Object.assign(g(y0),{zoom:g(W8),layers:g(y8),attribution:g(K8),scale:g(u8),locate:g(A6)}),AK={version:XJ,Class:E$,Evented:R0,Handler:D0,Util:L7,Browser:X0,Bounds:P,Point:D,Transformation:Y$,LineUtil:w9,PolyUtil:_9,toBounds:_K,toPoint:UQ,toTransformation:vK,CRS:L8,EPSG3395:b9,EPSG3857:O8,EPSG4326:$6,SimpleCRS:x9,LatLng:O,LatLngBounds:z,Projection:h9,toLatLng:hK,toLatLngBounds:fK,Animation:pQ,Draggable:S0,PosAnimation:iQ,Map:L,TsMap:L,Layer:H0,LayerGroup:J8,FeatureGroup:P0,GeoJSON:d,ImageOverlay:S$,VideoOverlay:d8,SVGOverlay:q6,Popup:P$,Tooltip:L$,Icon:k$,DefaultIcon:K$,DivIcon:c8,Marker:w$,GridLayer:T$,TileLayer:V$,VectorTileMapLayer:s$,WMSTileLayer:U8,Polyline:H$,Polygon:A$,Rectangle:I6,Circle:m8,CircleMarker:_$,Control:y0,ZoomControl:W8,AttributionControl:K8,ScaleControl:u8,LayersControl:y8,map:k9,marker:YJ,icon:ZJ,divIcon:HJ,layerGroup:AJ,featureGroup:GJ,geoJSON:HK,geoJson:FJ,gridLayer:NJ,tileLayer:qJ,vectorTileLayer:RJ,imageOverlay:MJ,videoOverlay:DJ,svgOverlay:IJ,popup:jJ,tooltip:TJ,polyline:CJ,polygon:OJ,rectangle:EJ,circle:BJ,circleMarker:kJ,control:wJ,services:y9};if(typeof window<"u")window.tsMap??=AK;var hJ=AK;export{DJ as videoOverlay,XJ as version,RJ as vectorTileLayer,TJ as tooltip,vK as toTransformation,UQ as toPoint,fK as toLatLngBounds,hK as toLatLng,_K as toBounds,qJ as tileLayer,IJ as svgOverlay,y9 as services,EK as saveOfflineRegion,b7 as sampleElevationBilinear,_J as resetDefaultCache,EJ as rectangle,fJ as rasterDEMLayer,jJ as popup,CJ as polyline,OJ as polygon,YJ as marker,zJ as map,AJ as layerGroup,MJ as imageOverlay,ZJ as icon,vJ as heatmapLayer,NJ as gridLayer,bK as getElevationDecoder,j$ as getDefaultCache,FJ as geoJson,HK as geoJSON,Z9 as flatten,GJ as featureGroup,tK as easing,Y9 as earcut,HJ as divIcon,SJ as deviation,hJ as default,h7 as decodeTerrariumRGB,f7 as decodeMapboxRGB,xK as decodeElevationGrid,k9 as createMap,wJ as control,CK as computeTileCoords,kJ as circleMarker,BJ as circle,PQ as cachedFetch,yK as buildTerrainMesh,W8 as ZoomControl,nQ as WebGLUnsupportedError,rQ as WebGLTileRenderer,U8 as WMSTileLayer,d8 as VideoOverlay,s$ as VectorTileMapLayer,L7 as Util,ZK as TwoFingerRotateHandler,YK as TwoFingerPitchHandler,L as TsMap,Y$ as Transformation,L$ as Tooltip,V$ as TileLayer,S8 as TileCache,y7 as TerrainSource,XK as TapHoldHandler,x9 as SimpleCRS,VK as ScrollWheelZoomHandler,u8 as ScaleControl,q6 as SVGOverlay,D$ as SVG,M6 as Renderer,I6 as Rectangle,R6 as RasterDEMLayer,v7 as RTree,h9 as Projection,iQ as PosAnimation,P$ as Popup,H$ as Polyline,A$ as Polygon,_9 as PolyUtil,D as Point,UK as PinchZoomHandler,X$ as Path,kQ as MarkerDrag,w$ as Marker,R4 as Map,A6 as LocateControl,w9 as LineUtil,y8 as LayersControl,J8 as LayerGroup,H0 as Layer,z as LatLngBounds,O as LatLng,g$ as KeyboardHandler,$K as KDBush,S$ as ImageOverlay,k$ as Icon,LJ as HillshadeLayer,N6 as HeatmapLayer,D0 as Handler,T$ as GridLayer,KJ as GeoJSONClusterSource,d as GeoJSON,P0 as FeatureGroup,R0 as Evented,s0 as EarthCRS,lK as EPSG900913,$6 as EPSG4326,O8 as EPSG3857,b9 as EPSG3395,S0 as Draggable,JK as DragHandler,WK as DoubleClickZoomHandler,oK as DomUtil,ZQ as DomEvent,g8 as DivOverlay,c8 as DivIcon,K$ as DefaultIcon,y0 as Control,E$ as Class,_$ as CircleMarker,m8 as Circle,D6 as Canvas,L8 as CRS,X0 as Browser,KK as BoxZoomHandler,P as Bounds,G6 as BlanketOverlay,K8 as AttributionControl,pQ as Animation}; |
| 121 | +${e}`)}return i}createBuffer(t,e){let n=this.gl,i=n.createBuffer();if(!i)throw Error("Failed to allocate WebGL buffer.");return n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferData(n.ARRAY_BUFFER,t,e??n.STATIC_DRAW),i}resize(t,e){let n=this.canvas;if(n.width!==t)n.width=t;if(n.height!==e)n.height=e;this.gl.viewport(0,0,t,e)}clear(t,e,n,i){let s=this.gl;s.clearColor(t,e,n,i),s.clear(s.COLOR_BUFFER_BIT)}}var Eo,zo=P(()=>{Eo=class extends Error{constructor(e){super(e??"WebGL2 is not supported in this environment.");this.name="WebGLUnsupportedError"}}});class Co{ctx;_projection;_fill;_line;_circle;_fillExtrusion;_sky;_buffers;constructor(t){this.ctx=new Nl(t),this._projection=new Float32Array(16),this._buffers=[],this._projection[0]=1,this._projection[5]=1,this._projection[10]=1,this._projection[15]=1,this._fill=this._buildFillProgram(),this._line=this._buildLineProgram(),this._circle=this._buildCircleProgram(),this._fillExtrusion=null,this._sky=null}setProjectionMatrix(t){this._projection.set(t)}clear(){this.ctx.clear(0,0,0,0)}destroy(){let t=this.ctx.gl;for(let e of this._buffers)t.deleteBuffer(e);if(this._buffers.length=0,t.deleteProgram(this._fill.program),t.deleteProgram(this._line.program),t.deleteProgram(this._circle.program),this._fillExtrusion)t.deleteProgram(this._fillExtrusion.program),this._fillExtrusion=null;if(this._sky)t.deleteProgram(this._sky.program),this._sky=null}drawFill(t,e){if(t.length<6)return;let n=this.ctx.gl,i=this._fill;if(n.useProgram(i.program),i.u_matrix)n.uniformMatrix4fv(i.u_matrix,!1,this._projection);if(i.u_color)n.uniform4f(i.u_color,e[0],e[1],e[2],e[3]);let s=this.ctx.createBuffer(t);this._buffers.push(s),n.bindBuffer(n.ARRAY_BUFFER,s),n.enableVertexAttribArray(i.a_position),n.vertexAttribPointer(i.a_position,2,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,t.length/2),this._disposeBuffer(s)}drawLine(t,e){if(t.length<4)return;let n=id(t);if(n.length===0)return;let i=this.ctx.gl,s=this._line;if(i.useProgram(s.program),s.u_matrix)i.uniformMatrix4fv(s.u_matrix,!1,this._projection);if(s.u_color)i.uniform4f(s.u_color,e.color[0],e.color[1],e.color[2],e.color[3]);if(s.u_width)i.uniform1f(s.u_width,e.width);let o=this.ctx.createBuffer(n);this._buffers.push(o),i.bindBuffer(i.ARRAY_BUFFER,o);let r=20;i.enableVertexAttribArray(s.a_position),i.vertexAttribPointer(s.a_position,2,i.FLOAT,!1,r,0),i.enableVertexAttribArray(s.a_normal),i.vertexAttribPointer(s.a_normal,2,i.FLOAT,!1,r,8),i.enableVertexAttribArray(s.a_progress),i.vertexAttribPointer(s.a_progress,1,i.FLOAT,!1,r,16),i.drawArrays(i.TRIANGLE_STRIP,0,n.length/5),this._disposeBuffer(o)}drawCircles(t,e){if(t.length<2)return;let n=this.ctx.gl,i=this._circle;if(n.useProgram(i.program),i.u_matrix)n.uniformMatrix4fv(i.u_matrix,!1,this._projection);if(i.u_color)n.uniform4f(i.u_color,e.color[0],e.color[1],e.color[2],e.color[3]);let s=e.strokeColor??[0,0,0,0];if(i.u_stroke_color)n.uniform4f(i.u_stroke_color,s[0],s[1],s[2],s[3]);if(i.u_stroke_width)n.uniform1f(i.u_stroke_width,e.strokeWidth??0);if(i.u_radius)n.uniform1f(i.u_radius,e.radius);if(typeof n.drawArraysInstanced==="function")this._drawCirclesInstanced(i,t);else this._drawCirclesBatched(i,t)}drawFillExtrusion(t,e,n,i,s,o){if(t.length===0)return 0;let r=this._fillExtrusion??(this._fillExtrusion=this._buildFillExtrusionProgram()),a=this.ctx.gl;a.useProgram(r.program);let l=o??this._projection;if(r.u_matrix)a.uniformMatrix4fv(r.u_matrix,!1,l);if(r.u_color)a.uniform4f(r.u_color,i[0],i[1],i[2],i[3]);if(r.u_opacity)a.uniform1f(r.u_opacity,s);let c=[];for(let p=0;p<t.length;p++){let m=t[p].rings;if(!m||m.length===0)continue;let _=e[p]??0,g=typeof n==="number"?n:n[p]??0;if(_<=g)continue;let b=Cl(m),y=zl(b.vertices,b.holes,2);for(let w=0;w<y.length;w++){let T=y[w],L=b.vertices[T*2],C=b.vertices[T*2+1];c.push(L,C,_,0,0,1)}for(let w of m){if(w.length<2)continue;for(let T=0;T<w.length;T++){let L=w[T],C=w[(T+1)%w.length],D=C.y-L.y,W=-(C.x-L.x),J=Math.hypot(D,W)||1;D/=J,W/=J,c.push(L.x,L.y,g,D,W,0),c.push(C.x,C.y,g,D,W,0),c.push(C.x,C.y,_,D,W,0),c.push(L.x,L.y,g,D,W,0),c.push(C.x,C.y,_,D,W,0),c.push(L.x,L.y,_,D,W,0)}}}if(c.length===0)return 0;let h=new Float32Array(c),u=this.ctx.createBuffer(h);this._buffers.push(u),a.bindBuffer(a.ARRAY_BUFFER,u);let f=24;a.enableVertexAttribArray(r.a_position),a.vertexAttribPointer(r.a_position,3,a.FLOAT,!1,f,0),a.enableVertexAttribArray(r.a_normal),a.vertexAttribPointer(r.a_normal,3,a.FLOAT,!1,f,12);let d=c.length/6;return a.drawArrays(a.TRIANGLES,0,d),this._disposeBuffer(u),d}drawSky(t,e,n,i){if(n<=0)return;let s=this._sky??(this._sky=this._buildSkyProgram()),o=this.ctx.gl;if(o.useProgram(s.program),s.u_sky_color)o.uniform4f(s.u_sky_color,t[0],t[1],t[2],t[3]);if(s.u_horizon_color)o.uniform4f(s.u_horizon_color,e[0],e[1],e[2],e[3]);if(s.u_pitch_t)o.uniform1f(s.u_pitch_t,n);if(s.u_horizon_blend)o.uniform1f(s.u_horizon_blend,i);let r=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),a=this.ctx.createBuffer(r);this._buffers.push(a),o.bindBuffer(o.ARRAY_BUFFER,a),o.enableVertexAttribArray(s.a_position),o.vertexAttribPointer(s.a_position,2,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,6),this._disposeBuffer(a)}drawTerrain(t,e,n,i,s){if(t.length===0||e.length===0)return 0;let o=this._fillExtrusion??(this._fillExtrusion=this._buildFillExtrusionProgram()),r=this.ctx.gl;r.useProgram(o.program);let a=s??this._projection;if(o.u_matrix)r.uniformMatrix4fv(o.u_matrix,!1,a);if(o.u_color)r.uniform4f(o.u_color,n[0],n[1],n[2],n[3]);if(o.u_opacity)r.uniform1f(o.u_opacity,i);let l=this.ctx.createBuffer(t);this._buffers.push(l),r.bindBuffer(r.ARRAY_BUFFER,l);let c=24;r.enableVertexAttribArray(o.a_position),r.vertexAttribPointer(o.a_position,3,r.FLOAT,!1,c,0),r.enableVertexAttribArray(o.a_normal),r.vertexAttribPointer(o.a_normal,3,r.FLOAT,!1,c,12);let h=r.createBuffer();return r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,h),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e,r.STATIC_DRAW),r.drawElements(r.TRIANGLES,e.length,r.UNSIGNED_INT,0),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null),r.deleteBuffer(h),this._disposeBuffer(l),e.length}_drawCirclesInstanced(t,e){let n=this.ctx.gl,i=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),s=this.ctx.createBuffer(i);this._buffers.push(s),n.bindBuffer(n.ARRAY_BUFFER,s),n.enableVertexAttribArray(t.a_offset),n.vertexAttribPointer(t.a_offset,2,n.FLOAT,!1,0,0),n.vertexAttribDivisor(t.a_offset,0);let o=this.ctx.createBuffer(e);this._buffers.push(o),n.bindBuffer(n.ARRAY_BUFFER,o),n.enableVertexAttribArray(t.a_center),n.vertexAttribPointer(t.a_center,2,n.FLOAT,!1,0,0),n.vertexAttribDivisor(t.a_center,1),n.drawArraysInstanced(n.TRIANGLES,0,6,e.length/2),n.vertexAttribDivisor(t.a_center,0),this._disposeBuffer(s),this._disposeBuffer(o)}_drawCirclesBatched(t,e){let n=this.ctx.gl,i=e.length/2,s=new Float32Array(i*6*4),o=[-1,-1,1,-1,-1,1,-1,1,1,-1,1,1];for(let l=0;l<i;l++){let c=e[l*2],h=e[l*2+1];for(let u=0;u<6;u++){let f=(l*6+u)*4;s[f]=c,s[f+1]=h,s[f+2]=o[u*2],s[f+3]=o[u*2+1]}}let r=this.ctx.createBuffer(s);this._buffers.push(r),n.bindBuffer(n.ARRAY_BUFFER,r);let a=16;n.enableVertexAttribArray(t.a_center),n.vertexAttribPointer(t.a_center,2,n.FLOAT,!1,a,0),n.enableVertexAttribArray(t.a_offset),n.vertexAttribPointer(t.a_offset,2,n.FLOAT,!1,a,8),n.drawArrays(n.TRIANGLES,0,i*6),this._disposeBuffer(r)}_buildFillProgram(){let t=this.ctx.compileProgram(Cf,If),e=this.ctx.gl;return{program:t,u_matrix:e.getUniformLocation(t,"u_matrix"),u_color:e.getUniformLocation(t,"u_color"),a_position:e.getAttribLocation(t,"a_position")}}_buildLineProgram(){let t=this.ctx.compileProgram(Ff,Rf),e=this.ctx.gl;return{program:t,u_matrix:e.getUniformLocation(t,"u_matrix"),u_color:e.getUniformLocation(t,"u_color"),u_width:e.getUniformLocation(t,"u_width"),a_position:e.getAttribLocation(t,"a_position"),a_normal:e.getAttribLocation(t,"a_normal"),a_progress:e.getAttribLocation(t,"a_progress")}}_buildCircleProgram(){let t=this.ctx.compileProgram(Nf,$f),e=this.ctx.gl;return{program:t,u_matrix:e.getUniformLocation(t,"u_matrix"),u_color:e.getUniformLocation(t,"u_color"),u_stroke_color:e.getUniformLocation(t,"u_stroke_color"),u_stroke_width:e.getUniformLocation(t,"u_stroke_width"),u_radius:e.getUniformLocation(t,"u_radius"),a_center:e.getAttribLocation(t,"a_center"),a_offset:e.getAttribLocation(t,"a_offset")}}_buildFillExtrusionProgram(){let t=this.ctx.compileProgram(Zf,Bf),e=this.ctx.gl;return{program:t,u_matrix:e.getUniformLocation(t,"u_matrix"),u_color:e.getUniformLocation(t,"u_color"),u_opacity:e.getUniformLocation(t,"u_opacity"),a_position:e.getAttribLocation(t,"a_position"),a_normal:e.getAttribLocation(t,"a_normal")}}_buildSkyProgram(){let t=this.ctx.compileProgram(Df,jf),e=this.ctx.gl;return{program:t,u_sky_color:e.getUniformLocation(t,"u_sky_color"),u_horizon_color:e.getUniformLocation(t,"u_horizon_color"),u_pitch_t:e.getUniformLocation(t,"u_pitch_t"),u_horizon_blend:e.getUniformLocation(t,"u_horizon_blend"),a_position:e.getAttribLocation(t,"a_position")}}_disposeBuffer(t){let e=this.ctx.gl,n=this._buffers.indexOf(t);if(n>=0)this._buffers.splice(n,1);e.deleteBuffer(t)}}function id(t){let e=t.length/2;if(e<2)return new Float32Array(0);let n=[];for(let i=0;i<e;i++){let s=t[i*2],o=t[i*2+1],r=0,a=0;if(i>0){let u=t[(i-1)*2],f=t[(i-1)*2+1],d=s-u,p=o-f,m=Math.hypot(d,p)||1;r+=d/m,a+=p/m}if(i<e-1){let u=t[(i+1)*2],f=t[(i+1)*2+1],d=u-s,p=f-o,m=Math.hypot(d,p)||1;r+=d/m,a+=p/m}let l=Math.hypot(r,a)||1;r/=l,a/=l;let c=-a,h=r;n.push(s,o,c,h,1),n.push(s,o,-c,-h,-1)}return new Float32Array(n)}var Io=P(()=>{zo()});class Fo{buf;pos;type;length;_view;constructor(t){if(t instanceof Uint8Array)this.buf=t;else if(t instanceof ArrayBuffer)this.buf=new Uint8Array(t);else this.buf=new Uint8Array(0);this.pos=0,this.type=0,this.length=this.buf.length,this._view=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}readFields(t,e,n){let i=n===void 0?this.length:n;while(this.pos<i){let s=this.readVarint(),o=s>>3,r=this.pos;if(this.type=s&7,t(o,e,this),this.pos===r)this.skip(s)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){let t=this._view.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this._view.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this._view.getUint32(this.pos,!0),e=this._view.getUint32(this.pos+4,!0);return this.pos+=8,e*Se+t}readSFixed64(){let t=this._view.getUint32(this.pos,!0),e=this._view.getInt32(this.pos+4,!0);return this.pos+=8,e*Se+t}readFloat(){let t=this._view.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this._view.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let e=this.buf,n,i;if(i=e[this.pos++],n=i&127,i<128)return n;if(i=e[this.pos++],n|=(i&127)<<7,i<128)return n;if(i=e[this.pos++],n|=(i&127)<<14,i<128)return n;if(i=e[this.pos++],n|=(i&127)<<21,i<128)return n>>>0;return i=e[this.pos],sd(n>>>0,t===!0,this)}readVarint64(){return this.readVarint(!0)}readSVarint(){let t=this.readVarint();return t%2===1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){let t=this.readVarint()+this.pos,e=this.pos;if(this.pos=t,Gs!==null)return Gs.decode(this.buf.subarray(e,t));return bd(this.buf,e,t)}readBytes(){let t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,new Uint8Array(e)}readPackedVarint(t,e){return ee(this,t,(n)=>n.readVarint(e))}readPackedSVarint(t){return ee(this,t,(e)=>e.readSVarint())}readPackedBoolean(t){return ee(this,t,(e)=>e.readBoolean())}readPackedFloat(t){return ee(this,t,(e)=>e.readFloat())}readPackedDouble(t){return ee(this,t,(e)=>e.readDouble())}readPackedFixed32(t){return ee(this,t,(e)=>e.readFixed32())}readPackedSFixed32(t){return ee(this,t,(e)=>e.readSFixed32())}readPackedFixed64(t){return ee(this,t,(e)=>e.readFixed64())}readPackedSFixed64(t){return ee(this,t,(e)=>e.readSFixed64())}skip(t){let e=t&7;if(e===ds)while(this.buf[this.pos++]>=128);else if(e===Pn)this.pos=this.readVarint()+this.pos;else if(e===fi)this.pos+=4;else if(e===ui)this.pos+=8;else throw Error(`Unimplemented wire type: ${e}`)}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=Math.max(this.length,16);while(e<this.pos+t)e*=2;if(e!==this.buf.length){let n=new Uint8Array(e);n.set(this.buf),this.buf=n,this._view=new DataView(n.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}destroy(){this.buf=new Uint8Array(0),this._view=new DataView(this.buf.buffer),this.pos=0,this.length=0,this.type=0}writeVarint(t){if(t>268435455||t<0){ad(t,this);return}this.realloc(4);let e=t|0;if(this.buf[this.pos++]=e&127|(e>127?128:0),e<=127)return;if(this.buf[this.pos++]=e>>>7&127|(e>16383?128:0),e<=16383)return;if(this.buf[this.pos++]=e>>>14&127|(e>2097151?128:0),e<=2097151)return;if(this.buf[this.pos++]=e>>>21&127|(e>268435455?128:0),e<=268435455)return}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(t?1:0)}writeString(t){let e=Ys!==null?Ys.encode(t):wd(t);this.writeVarint(e.length),this.realloc(e.length),this.buf.set(e,this.pos),this.pos+=e.length}writeFloat(t){this.realloc(4),this._view.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this._view.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){this.writeVarint(t.length),this.realloc(t.length),this.buf.set(t,this.pos),this.pos+=t.length}writeRawFixed32(t){this.realloc(4),this._view.setUint32(this.pos,t>>>0,!0),this.pos+=4}writeRawSFixed32(t){this.realloc(4),this._view.setInt32(this.pos,t|0,!0),this.pos+=4}writeRawFixed64(t){this.realloc(8);let e=t>>>0,n=Math.floor(t*Vs)>>>0;this._view.setUint32(this.pos,e,!0),this._view.setUint32(this.pos+4,n,!0),this.pos+=8}writeRawSFixed64(t){this.realloc(8);let e=t>>>0,n=Math.floor(t*Vs)|0;this._view.setUint32(this.pos,e,!0),this._view.setInt32(this.pos+4,n,!0),this.pos+=8}writeMessage(t,e,n){this.writeTag(t,Pn);let i=this.pos;this.pos++;let s=this.pos;e(n,this);let o=this.pos-s;if(o>=128){let r=rd(o);this.realloc(r-1),this.buf.copyWithin(s+r-1,s,s+o),this.pos=i,this.writeVarint(o),this.pos=s+r-1+o}else this.buf[i]=o}writePackedVarint(t,e){if(e.length>0)this.writeMessage(t,hd,e)}writePackedSVarint(t,e){if(e.length>0)this.writeMessage(t,ud,e)}writePackedBoolean(t,e){if(e.length>0)this.writeMessage(t,fd,e)}writePackedFloat(t,e){if(e.length>0)this.writeMessage(t,dd,e)}writePackedDouble(t,e){if(e.length>0)this.writeMessage(t,pd,e)}writePackedFixed32(t,e){if(e.length>0)this.writeMessage(t,md,e)}writePackedSFixed32(t,e){if(e.length>0)this.writeMessage(t,_d,e)}writePackedFixed64(t,e){if(e.length>0)this.writeMessage(t,gd,e)}writePackedSFixed64(t,e){if(e.length>0)this.writeMessage(t,yd,e)}writeBytesField(t,e){this.writeTag(t,Pn),this.writeBytes(e)}writeFixed32(t,e){this.writeTag(t,fi),this.writeRawFixed32(e)}writeSFixed32(t,e){this.writeTag(t,fi),this.writeRawSFixed32(e)}writeFixed64(t,e){this.writeTag(t,ui),this.writeRawFixed64(e)}writeSFixed64(t,e){this.writeTag(t,ui),this.writeRawSFixed64(e)}writeVarintField(t,e){this.writeTag(t,ds),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,ds),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,Pn),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,fi),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,ui),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,e?1:0)}}function sd(t,e,n){let i=n.buf,s,o=0;if(s=i[n.pos++],t|=(s&15)<<28,o=(s&112)>>4,s<128)return Ge(t,o,e);if(s=i[n.pos++],o|=(s&127)<<3,s<128)return Ge(t,o,e);if(s=i[n.pos++],o|=(s&127)<<10,s<128)return Ge(t,o,e);if(s=i[n.pos++],o|=(s&127)<<17,s<128)return Ge(t,o,e);if(s=i[n.pos++],o|=(s&127)<<24,s<128)return Ge(t,o,e);if(s=i[n.pos++],o|=(s&1)<<31,s<128)return Ge(t,o,e);throw Error("Expected varint not more than 10 bytes")}function Ge(t,e,n){if(n&&(e&2147483648)!==0){let s=~t+1>>>0,o=~e>>>0;if(s===0)o=o+1>>>0;let r=o*Se+s;if(r>qs)throw Error("Varint exceeds safe integer range");return-r}let i=(e>>>0)*Se+(t>>>0);if(i>qs)throw Error("Varint exceeds safe integer range");return i}function od(t){return t.readVarint()+t.pos}function ee(t,e,n){if(t.type!==Pn){if(e===void 0)return[n(t)];return e.push(n(t)),e}let i=e===void 0?[]:e,s=od(t);while(t.pos<s)i.push(n(t));return i}function rd(t){let e=1;while(t>=128)t=Math.floor(t/128),e++;return e}function ad(t,e){let n,i;if(t<0){let s=-t;if(n=~(s>>>0)+1>>>0,i=~Math.floor(s/Se)>>>0,n===0)i=i+1>>>0}else n=t>>>0,i=Math.floor(t/Se)>>>0;e.realloc(10);for(let s=0;s<10;s++){let o=s*7,r=ld(n,i,o),a=o+7<64?cd(n,i,o+7):!1;if(e.buf[e.pos++]=a?r|128:r,!a)break}}function ld(t,e,n){if(n>=32)return e>>>n-32&127;if(n+7<=32)return t>>>n&127;return(t>>>n|e<<32-n)&127}function cd(t,e,n){if(n>=64)return!1;if(n>=32)return e>>>n-32!==0;return t>>>n!==0||e!==0}function hd(t,e){for(let n=0;n<t.length;n++)e.writeVarint(t[n])}function ud(t,e){for(let n=0;n<t.length;n++)e.writeSVarint(t[n])}function fd(t,e){for(let n=0;n<t.length;n++)e.writeBoolean(t[n])}function dd(t,e){for(let n=0;n<t.length;n++)e.writeFloat(t[n])}function pd(t,e){for(let n=0;n<t.length;n++)e.writeDouble(t[n])}function md(t,e){for(let n=0;n<t.length;n++)e.writeRawFixed32(t[n])}function _d(t,e){for(let n=0;n<t.length;n++)e.writeRawSFixed32(t[n])}function gd(t,e){for(let n=0;n<t.length;n++)e.writeRawFixed64(t[n])}function yd(t,e){for(let n=0;n<t.length;n++)e.writeRawSFixed64(t[n])}function bd(t,e,n){let i="",s=e;while(s<n){let o=t[s++];if(o<128)i+=String.fromCharCode(o);else if(o<224){let r=t[s++]&63;i+=String.fromCharCode((o&31)<<6|r)}else if(o<240){let r=t[s++]&63,a=t[s++]&63;i+=String.fromCharCode((o&15)<<12|r<<6|a)}else{let r=t[s++]&63,a=t[s++]&63,l=t[s++]&63,c=(o&7)<<18|r<<12|a<<6|l;c-=65536,i+=String.fromCharCode(55296|c>>10),i+=String.fromCharCode(56320|c&1023)}}return i}function wd(t){let e=[];for(let n=0;n<t.length;n++){let i=t.charCodeAt(n);if(i>=55296&&i<=56319&&n+1<t.length){let s=t.charCodeAt(n+1);if(s>=56320&&s<=57343)i=65536+((i&1023)<<10|s&1023),n++}if(i<128)e.push(i);else if(i<2048)e.push(192|i>>6,128|i&63);else if(i<65536)e.push(224|i>>12,128|i>>6&63,128|i&63);else e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63)}return new Uint8Array(e)}var ds=0,ui=1,Pn=2,fi=5,Se,Vs,qs,Gs,Ys,$l=P(()=>{Se=4294967296,Vs=1/Se,qs=Number.MAX_SAFE_INTEGER,Gs=typeof TextDecoder<"u"?new TextDecoder("utf-8"):null,Ys=typeof TextEncoder<"u"?new TextEncoder:null}),Zl={};tt(Zl,{GLYPH_BORDER:()=>Ee,GlyphSource:()=>jl,decodeGlyphPbf:()=>Dl,glyphUrl:()=>Bl,rangeStartFor:()=>Qe});function Bl(t,e,n){let i=`${n}-${n+255}`;return t.replace("{fontstack}",encodeURIComponent(e)).replace("{range}",i)}function Qe(t){return Math.floor(t/256)*256}function Dl(t){let e=new Map,n=new Fo(t);while(n.pos<n.length){let i=n.readVarint()>>3;if(i!==1){n.skip(i<<3);continue}let s=n.readVarint()+n.pos;while(n.pos<s){let o=n.readVarint(),r=o>>3;if(n.type=o&7,r!==3){n.skip(o);continue}let a=n.readVarint()+n.pos,l={id:0,width:0,height:0,left:0,top:0,advance:0};while(n.pos<a){let c=n.readVarint(),h=c>>3;switch(n.type=c&7,h){case 1:l.id=n.readVarint();break;case 2:l.bitmap=n.readBytes();break;case 3:l.width=n.readVarint();break;case 4:l.height=n.readVarint();break;case 5:l.left=n.readSVarint();break;case 6:l.top=n.readSVarint();break;case 7:l.advance=n.readVarint();break;default:n.skip(c)}}n.pos=a,e.set(l.id,l)}n.pos=s}return e}class jl{_template;_fetch;_ranges;_pending;constructor(t,e={}){this._template=t,this._fetch=e.fetch??globalThis.fetch,this._ranges=new Map,this._pending=new Map}get(t,e){let n=`${t}/${Qe(e)}`;return this._ranges.get(n)?.get(e)}has(t,e){return this._ranges.has(`${t}/${Qe(e)}`)}async load(t,e,n){let i=Qe(e),s=`${t}/${i}`,o=this._ranges.get(s);if(o)return o;let r=this._pending.get(s);if(r)return r;let a=(async()=>{let l=Bl(this._template,t,i),c=await this._fetch(l,{signal:n});if(!c.ok)throw Error(`HTTP ${c.status} fetching glyphs ${l}`);let h=Dl(new Uint8Array(await c.arrayBuffer()));return this._ranges.set(s,h),this._pending.delete(s),h})();return this._pending.set(s,a),a.catch(()=>this._pending.delete(s)),a}async loadForText(t,e,n){let i=new Set;for(let s of e)i.add(Qe(s.codePointAt(0)??0));await Promise.all([...i].map((s)=>this.load(t,s,n)))}get size(){return this._ranges.size}}var Ee=3,Ro=P(()=>{$l()}),Ul={};tt(Ul,{GlyphAtlas:()=>No});function ga(t,e){if(!e)return!0;if(!("letterSpacing"in t))return!1;let n=t;return n.letterSpacing=`${e}px`,!0}function ya(t,e){if(!e)return 0;let n=0;for(let i of t)n++;return n*e}function vd(t){if(!t)return"r";return`${t.italic?"i":"r"}${t.bold?"b":""}`}function ps(t){return`${t.codePoint}:${vd(t)}`}class No{canvas;_ctx;_fontFamily;_fontSize;_padding;_glyphs;_shelfY;_shelfX;_shelfH;constructor(t){this._fontFamily=t?.fontFamily??"system-ui, -apple-system, Segoe UI, Roboto",this._fontSize=t?.fontSize??24,this._padding=t?.padding??8;let e=t?.bucketSize??512;this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=e,this._ctx=this.canvas.getContext("2d"),this._glyphs=new Map,this._shelfX=0,this._shelfY=0,this._shelfH=0}getOrAddGlyph(t,e){let n={codePoint:t,italic:!!e?.italic,bold:!!e?.bold},i=this._glyphs.get(ps(n));if(i)return i;return this._rasterize(n)}measure(t,e){let n=0,i=0;for(let s of t){let o=s.codePointAt(0)??0,r=this.getOrAddGlyph(o,e);if(n+=r.advance,r.height>i)i=r.height}return{width:n,height:i}}advances(t,e,n){let i=this._ctx,s=[];if(i){i.save(),i.font=this.fontString(e,n);let r=n?.letterSpacing??0;for(let a of t)s.push({char:a,advance:i.measureText(a).width+r});return i.restore(),s}let o=e/this._fontSize;for(let r of t){let a=r.codePointAt(0)??0,l=this.getOrAddGlyph(a,n);s.push({char:r,advance:l.advance*o})}return s}measureText(t,e,n){let i=this._ctx;if(!i){let c=this.measure(t,n),h=e/this._fontSize,u=c.height*h,f=ya(t,n?.letterSpacing);return{width:c.width*h+f,height:u,ascent:u*0.8,descent:u*0.2}}i.save(),i.font=this.fontString(e,n);let s=ga(i,n?.letterSpacing),o=i.measureText(t),r=s?o.width:o.width+ya(t,n?.letterSpacing);i.restore();let a=o.fontBoundingBoxAscent||o.actualBoundingBoxAscent||e*0.8,l=o.fontBoundingBoxDescent||o.actualBoundingBoxDescent||e*0.2;return{width:r,height:a+l,ascent:a,descent:l}}fontString(t,e){let n=[];if(e?.italic)n.push("italic");if(e?.bold)n.push("700");return n.push(`${t}px`,e?.family||this._fontFamily),n.join(" ")}resolveFont(t){let e=Array.isArray(t)?t:t?[t]:[];if(!e.length)return{family:this._fontFamily,bold:!1,italic:!1};let n=!1,i=!1,s=[];for(let o of e){if(typeof o!=="string"||!o)continue;let r=o;for(let[l,c]of[["Semibold",()=>{n=!0}],["Bold",()=>{n=!0}],["Italic",()=>{i=!0}],["Oblique",()=>{i=!0}],["Regular",()=>{}],["Medium",()=>{}],["Light",()=>{}]])if(r.includes(l))c(),r=r.replace(l,"");let a=r.replace(/\s+/g," ").trim();if(a)s.push(a.includes(" ")?`"${a}"`:a)}return s.push(this._fontFamily),{family:s.join(", "),bold:n,italic:i}}drawText(t,e,n,i,s){let o={italic:!!s.italic,bold:!!s.bold,family:s.family};if(t.save(),t.font=this.fontString(s.size,o),ga(t,s.letterSpacing),t.textAlign="left",t.textBaseline="alphabetic",s.haloColor&&s.haloWidth&&s.haloWidth>0)t.strokeStyle=s.haloColor,t.lineWidth=s.haloWidth*2,t.lineJoin="round",t.miterLimit=2,t.strokeText(e,n,i);t.fillStyle=s.color,t.fillText(e,n,i),t.restore()}_buildSDF(t){let{width:e,height:n}=t,i=this._padding,s=1048576,o=new Int32Array(e*n),r=new Int32Array(e*n);for(let l=0;l<e*n;l++)if(t.data[l*4+3]>=128)o[l]=1048576,r[l]=0;else o[l]=0,r[l]=1048576;ba(o,e,n),ba(r,e,n);let a=xd(e,n);for(let l=0;l<e*n;l++){let h=128-(r[l]-o[l])/3/i*128;if(h<0)h=0;else if(h>255)h=255;a.data[l*4+0]=255,a.data[l*4+1]=255,a.data[l*4+2]=255,a.data[l*4+3]=h|0}return a}_rasterize(t){let e=this._ctx;if(!e){let _={codePoint:t.codePoint,x:0,y:0,width:0,height:0,advance:this._fontSize*0.6,bearingX:0,bearingY:0};return this._glyphs.set(ps(t),_),_}let n=this._buildFontSpec(t);e.font=n;let i=String.fromCodePoint(t.codePoint),s=e.measureText(i),o=s.width&&s.width>0?s.width:this._fontSize*0.6,r=s.actualBoundingBoxAscent&&s.actualBoundingBoxAscent>0?s.actualBoundingBoxAscent:this._fontSize*0.8,a=s.actualBoundingBoxDescent&&s.actualBoundingBoxDescent>0?s.actualBoundingBoxDescent:this._fontSize*0.2,l=this._padding,c=Math.max(1,Math.ceil(o))+l*2,h=Math.max(1,Math.ceil(r+a))+l*2,u=document.createElement("canvas");u.width=c,u.height=h;let f=u.getContext("2d");if(f){f.font=n,f.fillStyle="#000",f.textBaseline="alphabetic",f.fillText(i,l,l+r);try{let _=f.getImageData(0,0,c,h),g=this._buildSDF(_);f.putImageData(g,0,0)}catch{}}if(this._shelfX+c>this.canvas.width)this._shelfY+=this._shelfH,this._shelfX=0,this._shelfH=0;if(this._shelfY+h>this.canvas.height)this._growAtlas(Math.max(this.canvas.width*2,this._shelfY+h));if(this._shelfX+c>this.canvas.width)this._growAtlas(Math.max(this.canvas.width*2,this._shelfX+c));let d=this._shelfX,p=this._shelfY;if(e.drawImage(u,d,p),this._shelfX+=c,h>this._shelfH)this._shelfH=h;let m={codePoint:t.codePoint,x:d,y:p,width:c,height:h,advance:o,bearingX:-l,bearingY:r+l};return this._glyphs.set(ps(t),m),m}_buildFontSpec(t){let e=[];if(t.italic)e.push("italic");if(t.bold)e.push("bold");return e.push(`${this._fontSize}px`),e.push(this._fontFamily),e.join(" ")}_growAtlas(t){let e=this.canvas,n=document.createElement("canvas");n.width=Math.max(t,e.width),n.height=Math.max(t,e.height);let i=n.getContext("2d");if(i)i.drawImage(e,0,0);this.canvas=n,this._ctx=i}}function xd(t,e){let n=new Uint8ClampedArray(t*e*4),i=globalThis.ImageData;if(typeof i==="function")try{return new i(n,t,e)}catch{}return{data:n,width:t,height:e,colorSpace:"srgb"}}function ba(t,e,n){for(let i=0;i<n;i++)for(let s=0;s<e;s++){let o=i*e+s,r=t[o];if(i>0){if(s>0){let l=t[o-e-1]+4;if(l<r)r=l}let a=t[o-e]+3;if(a<r)r=a;if(s<e-1){let l=t[o-e+1]+4;if(l<r)r=l}}if(s>0){let a=t[o-1]+3;if(a<r)r=a}t[o]=r}for(let i=n-1;i>=0;i--)for(let s=e-1;s>=0;s--){let o=i*e+s,r=t[o];if(i<n-1){if(s<e-1){let l=t[o+e+1]+4;if(l<r)r=l}let a=t[o+e]+3;if(a<r)r=a;if(s>0){let l=t[o+e-1]+4;if(l<r)r=l}}if(s<e-1){let a=t[o+1]+3;if(a<r)r=a}t[o]=r}}var Hl={};tt(Hl,{addSpriteToAtlas:()=>Pd,loadSprite:()=>Td,spriteUrl:()=>Ks});function Ks(t,e,n){let i=n>1?"@2x":"",s=t.indexOf("?");if(s===-1)return`${t}${i}.${e}`;return`${t.slice(0,s)}${i}.${e}${t.slice(s)}`}function Sd(t){return new Promise((e,n)=>{let i=new Image;i.crossOrigin="anonymous",i.onload=()=>e(i),i.onerror=()=>n(Error(`failed to load sprite image ${t}`)),i.src=t})}async function Td(t,e={}){let n=e.fetch??globalThis.fetch,i=e.loadImage??Sd,s=(e.pixelRatio??1)>1?2:1,o=async(r)=>{let a=await n(Ks(t,"json",r),{signal:e.signal});if(!a.ok)throw Error(`HTTP ${a.status} fetching sprite index for ${t}`);let l=await a.json(),c=await i(Ks(t,"png",r));return{index:l,image:c,pixelRatio:r}};if(s===2)try{return await o(2)}catch{}return o(1)}function Pd(t,e,n){let i=0;for(let[s,o]of Object.entries(e.index)){let r=n?`${n}:${s}`:s;if(!o||typeof o.width!=="number"||typeof o.height!=="number")continue;if(o.width<=0||o.height<=0)continue;let a={id:r,x:o.x,y:o.y,width:o.width,height:o.height,pixelRatio:o.pixelRatio??e.pixelRatio,sdf:o.sdf===!0};t.addSprite(a,e.image),i+=1}return i}var mt,Mt=P(()=>{N(),Pe(),st(),mt=class extends wt{getEvents(){return{}}onAdd(e){}onRemove(e){}beforeAdd(e){}addTo(e){return e.addLayer(this),this}remove(){return this.removeFrom(this._map||this._mapToAdd)}removeFrom(e){return e?.removeLayer(this),this}getPane(e){return this._map.getPane(e?this.options?.[e]||e:this.options.pane)}addInteractiveTarget(e){return this._map._targets[j(e)]=this,this}removeInteractiveTarget(e){return delete this._map._targets[j(e)],this}getAttribution(){return this.options?.attribution}_layerAdd(e){let n=e.target;if(!n.hasLayer(this))return;this._map=n,this._zoomAnimated=n._zoomAnimated;let i=this.getEvents();if(i&&Object.keys(i).length)n.on(i,this),this.once("remove",()=>n.off(i,this));this.onAdd(n),this.fire("add"),n.fire("layeradd",{layer:this})}},mt.setDefaultOptions({pane:"overlayPane",attribution:null,bubblingPointerEvents:!0}),F.include({addLayer(t){if(!t._layerAdd)throw Error("The provided object is not a Layer.");let e=j(t);if(this._layers[e])return this;return this._layers[e]=t,t._mapToAdd=this,t.beforeAdd(this),this.whenReady(t._layerAdd,t),this},removeLayer(t){let e=j(t);if(!this._layers[e])return this;if(this._loaded)t.onRemove(this);if(delete this._layers[e],this._loaded)this.fire("layerremove",{layer:t}),t.fire("remove");return t._map=t._mapToAdd=null,this},hasLayer(t){return j(t)in this._layers},eachLayer(t,e){for(let n of Object.values(this._layers))t.call(e,n);return this},_addLayers(t){let e=t?Array.isArray(t)?t:[t]:[];for(let n of e)this.addLayer(n)},_addZoomLimit(t){let e=t.options;if(!Number.isNaN(e?.maxZoom)||!Number.isNaN(e?.minZoom))this._zoomBoundLayers[j(t)]=t,this._updateZoomLevels()},_removeZoomLimit(t){let e=j(t);if(this._zoomBoundLayers[e])delete this._zoomBoundLayers[e],this._updateZoomLevels()},_updateZoomLevels(){let t=1/0,e=-1/0,n=this._getZoomSpan();for(let i of Object.values(this._zoomBoundLayers)){let s=i.options;t=Math.min(t,s.minZoom??1/0),e=Math.max(e,s.maxZoom??-1/0)}if(this._layersMaxZoom=e===-1/0?void 0:e,this._layersMinZoom=t===1/0?void 0:t,n!==this._getZoomSpan())this.fire("zoomlevelschange");if(this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom)this.setZoom(this._layersMaxZoom);if(this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom)this.setZoom(this._layersMinZoom)}})}),sn,$o=P(()=>{Te(),N(),Y(),vt(),ct(),G(),Mt(),sn=class extends mt{_onMove;initialize(e){et(this,e)}onAdd(e){this._initContainer(),this._levels={},this._tiles={},this._resetView()}beforeAdd(e){e._addZoomLimit(this)}onRemove(e){this._removeAllTiles(),this._container?.remove(),e._removeZoomLimit(this),this._container=void 0,this._tileZoom=void 0,clearTimeout(this._pruneTimeout)}bringToFront(){if(this._map)Wn(this._container),this._setAutoZIndex(Math.max);return this}bringToBack(){if(this._map)Vn(this._container),this._setAutoZIndex(Math.min);return this}getContainer(){return this._container}setOpacity(e){return this.options.opacity=e,this._updateOpacity(),this}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}isLoading(){return this._loading}redraw(){if(this._map){this._removeAllTiles();let e=this._clampZoom(this._map.getZoom());if(e!==this._tileZoom)this._tileZoom=e,this._updateLevels();this._update()}return this}getEvents(){let e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd};if(!this.options.updateWhenIdle){if(!this._onMove)this._onMove=co(this._onMoveEnd,this.options.updateInterval,this);e.move=this._onMove}if(this._zoomAnimated)e.zoomanim=this._animateZoom;return e}createTile(e,n){return document.createElement("div")}getTileSize(){let e=this.options.tileSize;return e instanceof v?e:new v(e,e)}_updateZIndex(){if(this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null)this._container.style.zIndex=this.options.zIndex}_setAutoZIndex(e){let n=this.getPane().children,i=-e(-1/0,1/0);for(let s of Array.from(n)){let o=s.style.zIndex;if(s!==this._container&&o)i=e(i,+o)}if(Number.isFinite(i))this.options.zIndex=i+e(-1,1),this._updateZIndex()}_updateOpacity(){if(!this._map)return;this._container.style.opacity=String(this.options.opacity);let e=Date.now(),n=!1,i=!1;for(let s of Object.values(this._tiles??{})){if(!s.current||!s.loaded)continue;let o=Math.min(1,(e-s.loaded)/200);if(s.el.style.opacity=String(o),o<1)n=!0;else{if(s.active)i=!0;else this._onOpaqueTile(s);s.active=!0}}if(i&&!this._noPrune)this._pruneTiles();if(n){if(this._fadeFrame!==void 0)cancelAnimationFrame(this._fadeFrame);this._fadeFrame=requestAnimationFrame(this._updateOpacity.bind(this))}}_onOpaqueTile(e){}_initContainer(){if(this._container)return;if(this._container=A("div",`tsmap-layer ${this.options.className??""}`),this._updateZIndex(),this.options.opacity<1)this._updateOpacity();this.getPane().appendChild(this._container)}_updateLevels(){let e=this._tileZoom,n=this.options.maxZoom;if(e===void 0)return;for(let o of Object.keys(this._levels)){let r=Number(o);if(o=r,this._levels[r].el.children.length||r===e)this._levels[r].el.style.zIndex=String(n-Math.abs(e-r)),this._onUpdateLevel(r);else this._levels[r].el.remove(),this._removeTilesAtZoom(r),this._onRemoveLevel(r),delete this._levels[r]}let i=this._levels[e],s=this._map;if(!i)i=this._levels[e]={},i.el=A("div","tsmap-tile-container tsmap-zoom-animated",this._container),i.el.style.zIndex=String(n),i.origin=s.project(s.unproject(s.getPixelOrigin()),e).round(),i.zoom=e,this._setZoomTransform(i,s.getCenter(),s.getZoom()),Et(i.el.offsetWidth),this._onCreateLevel(i);return this._level=i,i}_onUpdateLevel(e){}_onRemoveLevel(e){}_onCreateLevel(e){}_pruneTiles(){if(!this._map)return;let e=this._map.getZoom();if(e>this.options.maxZoom||e<this.options.minZoom){this._removeAllTiles();return}for(let n of Object.values(this._tiles))n.retain=n.current;for(let n of Object.values(this._tiles))if(n.current&&!n.active){let i=n.coords;if(!this._retainParent(i.x,i.y,i.z,i.z-5))this._retainChildren(i.x,i.y,i.z,i.z+2)}for(let[n,i]of Object.entries(this._tiles))if(!i.retain)this._removeTile(n)}_removeTilesAtZoom(e){for(let[n,i]of Object.entries(this._tiles))if(i.coords.z===e)this._removeTile(n)}_removeAllTiles(){for(let e of Object.keys(this._tiles))this._removeTile(e)}_invalidateAll(){for(let e of Object.keys(this._levels))this._levels[e].el.remove(),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0}_retainParent(e,n,i,s){let o=Math.floor(e/2),r=Math.floor(n/2),a=i-1,l=new v(o,r);l.z=a;let c=this._tileCoordsToKey(l),h=this._tiles[c];if(h?.active)return h.retain=!0,!0;else if(h?.loaded)h.retain=!0;if(a>s)return this._retainParent(o,r,a,s);return!1}_retainChildren(e,n,i,s){for(let o=2*e;o<2*e+2;o++)for(let r=2*n;r<2*n+2;r++){let a=new v(o,r);a.z=i+1;let l=this._tileCoordsToKey(a),c=this._tiles[l];if(c?.active){c.retain=!0;continue}else if(c?.loaded)c.retain=!0;if(i+1<s)this._retainChildren(o,r,i+1,s)}}_resetView(e){let n=e&&(e.pinch||e.flyTo);this._setView(this._map.getCenter(),this._map.getZoom(),n,n)}_animateZoom(e){this._setView(e.center,e.zoom,!0,e.noUpdate)}_clampZoom(e){let n=this.options;if(n.minNativeZoom!==void 0&&e<n.minNativeZoom)return n.minNativeZoom;if(n.maxNativeZoom!==void 0&&n.maxNativeZoom<e)return n.maxNativeZoom;return e}_setView(e,n,i,s){let o=Math.round(n);if(this.options.maxZoom!==void 0&&o>this.options.maxZoom||this.options.minZoom!==void 0&&o<this.options.minZoom)o=void 0;else o=this._clampZoom(o);let r=this.options.updateWhenZooming&&o!==this._tileZoom;if(!s||r){if(this._tileZoom=o,this._abortLoading)this._abortLoading();if(this._updateLevels(),this._resetGrid(),o!==void 0)this._update(e);if(!i)this._pruneTiles();this._noPrune=!!i}this._setZoomTransforms(e,n)}_setZoomTransforms(e,n){for(let i of Object.values(this._levels))this._setZoomTransform(i,e,n)}_setZoomTransform(e,n,i){let s=this._map.getZoomScale(i,e.zoom),o=e.origin.multiplyBy(s).subtract(this._map._getNewPixelOrigin(n,i)).round();Fe(e.el,o,s)}_resetGrid(){let e=this._map,n=e.options.crs,i=this._tileSize=this.getTileSize(),s=this._tileZoom,o=this._map.getPixelWorldBounds(this._tileZoom);if(o)this._globalTileRange=this._pxBoundsToTileRange(o);this._wrapX=n.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,n.wrapLng[0]],s).x/i.x),Math.ceil(e.project([0,n.wrapLng[1]],s).x/i.y)],this._wrapY=n.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([n.wrapLat[0],0],s).y/i.x),Math.ceil(e.project([n.wrapLat[1],0],s).y/i.y)]}_onMoveEnd(){if(!this._map||this._map._animatingZoom)return;this._update()}_getTiledPixelBounds(e){let n=this._map,i=n._animatingZoom?Math.max(n._animateToZoom,n.getZoom()):n.getZoom(),s=n.getZoomScale(i,this._tileZoom),o=n.project(e,this._tileZoom).floor(),r=n.getSize().divideBy(s*2);return new I(o.subtract(r),o.add(r))}_update(e){let n=this._map;if(!n)return;let i=this._clampZoom(n.getZoom());if(e===void 0)e=n.getCenter();if(this._tileZoom===void 0)return;let s=this._getTiledPixelBounds(e),o=this._pxBoundsToTileRange(s),r=o.getCenter(),a=[],l=this.options.keepBuffer,c=new I(o.getBottomLeft().subtract([l,-l]),o.getTopRight().add([l,-l]));if(!(Number.isFinite(o.min.x)&&Number.isFinite(o.min.y)&&Number.isFinite(o.max.x)&&Number.isFinite(o.max.y)))throw Error("Attempted to load an infinite number of tiles");for(let h of Object.values(this._tiles)){let u=h.coords;if(u.z!==this._tileZoom||!c.contains(new v(u.x,u.y)))h.current=!1}if(Math.abs(i-this._tileZoom)>1){this._setView(e,i);return}for(let h=o.min.y;h<=o.max.y;h++)for(let u=o.min.x;u<=o.max.x;u++){let f=new v(u,h);if(f.z=this._tileZoom,!this._isValidTile(f))continue;let d=this._tiles[this._tileCoordsToKey(f)];if(d)d.current=!0;else a.push(f)}if(a.sort((h,u)=>h.distanceTo(r)-u.distanceTo(r)),a.length!==0){if(!this._loading)this._loading=!0,this.fire("loading");let h=document.createDocumentFragment();for(let u of a)this._addTile(u,h);this._level.el.appendChild(h)}}_isValidTile(e){let n=this._map.options.crs;if(!n.infinite){let s=this._globalTileRange;if(!n.wrapLng&&(e.x<s.min.x||e.x>s.max.x)||!n.wrapLat&&(e.y<s.min.y||e.y>s.max.y))return!1}if(!this.options.bounds)return!0;let i=this._tileCoordsToBounds(e);return new R(this.options.bounds).overlaps(i)}_keyToBounds(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))}_tileCoordsToNwSe(e){let n=this._map,i=this.getTileSize(),s=e.scaleBy(i),o=s.add(i),r=n.unproject(s,e.z),a=n.unproject(o,e.z);return[r,a]}_tileCoordsToBounds(e){let n=this._tileCoordsToNwSe(e),i=new R(n[0],n[1]);if(!this.options.noWrap)i=this._map.wrapLatLngBounds(i);return i}_tileCoordsToKey(e){return`${e.x}:${e.y}:${e.z}`}_keyToTileCoords(e){let n=e.split(":"),i=new v(+n[0],+n[1]);return i.z=+n[2],i}_removeTile(e){let n=this._tiles[e];if(!n)return;n.el.remove(),delete this._tiles[e],this.fire("tileunload",{tile:n.el,coords:this._keyToTileCoords(e)})}_initTile(e){e.classList.add("tsmap-tile");let n=this.getTileSize();e.style.width=`${n.x}px`,e.style.height=`${n.y}px`,e.onselectstart=Et,e.onpointermove=Et}_addTile(e,n){let i=this._getTilePos(e),s=this._tileCoordsToKey(e),o=this.createTile(this._wrapCoords(e),this._tileReady.bind(this,e));if(this._initTile(o),this.createTile.length<2)requestAnimationFrame(this._tileReady.bind(this,e,null,o));lt(o,i),this._tiles[s]={el:o,coords:e,current:!0},n.appendChild(o),this.fire("tileloadstart",{tile:o,coords:e})}_tileReady(e,n,i){if(n)this.fire("tileerror",{error:n,tile:i,coords:e});let s=this._tileCoordsToKey(e),o=this._tiles[s];if(!o)return;if(o.loaded=Date.now(),this._map._fadeAnimated){if(o.el.style.opacity="0",this._fadeFrame!==void 0)cancelAnimationFrame(this._fadeFrame);this._fadeFrame=requestAnimationFrame(this._updateOpacity.bind(this))}else o.active=!0,this._pruneTiles();if(!n)o.el.classList.add("tsmap-tile-loaded"),this.fire("tileload",{tile:o.el,coords:e});if(this._noTilesToLoad())if(this._loading=!1,this.fire("load"),!this._map._fadeAnimated)requestAnimationFrame(this._pruneTiles.bind(this));else this._pruneTimeout=setTimeout(this._pruneTiles.bind(this),250)}_getTilePos(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)}_wrapCoords(e){let n=new v(this._wrapX?En(e.x,this._wrapX):e.x,this._wrapY?En(e.y,this._wrapY):e.y);return n.z=e.z,n}_pxBoundsToTileRange(e){let n=this.getTileSize();return new I(e.min.unscaleBy(n).floor(),e.max.unscaleBy(n).ceil().subtract([1,1]))}_noTilesToLoad(){return Object.values(this._tiles).every((e)=>!!e.loaded)}},sn.setDefaultOptions({tileSize:256,opacity:1,updateWhenIdle:pt.mobile,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:"tilePane",className:"",keepBuffer:2})}),Wl={};tt(Wl,{TileLayer:()=>$e});var $e,qi=P(()=>{Te(),N(),H(),$i(),$o(),$e=class extends sn{initialize(e,n){if(super.initialize(n),this._url=e,this.options.attribution===null){let s=new URL(e,location.href).hostname;if(["tile.openstreetmap.org","tile.osm.org"].some((r)=>s.endsWith(r)))this.options.attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}if(this.options.detectRetina&&pt.retina&&this.options.maxZoom>0){if(this.options.tileSize=Math.floor(this.options.tileSize/2),!this.options.zoomReverse)this.options.zoomOffset++,this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom-1);else this.options.zoomOffset--,this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom+1);this.options.minZoom=Math.max(0,this.options.minZoom)}else if(!this.options.zoomReverse)this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom);else this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom);if(typeof this.options.subdomains==="string")this.options.subdomains=this.options.subdomains.split("");let i=this.options.offlineCache;if(i instanceof Ni)this._offlineCache=i;else if(i===!0)this._offlineCache=nn();this._activeBlobUrls=new Set,this.on("tileunload",this._onTileRemove)}setUrl(e,n){if(this._url===e&&n===void 0)n=!0;if(this._url=e,!n)this.redraw();return this}createTile(e,n){let i=document.createElement("img");if(k(i,"load",this._tileOnLoad.bind(this,n,i)),k(i,"error",this._tileOnError.bind(this,n,i)),this.options.crossOrigin||this.options.crossOrigin==="")i.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;if(typeof this.options.referrerPolicy==="string")i.referrerPolicy=this.options.referrerPolicy;i.alt="";let s=this.getTileUrl(e);if(this._offlineCache)this._resolveThroughCache(i,s);else i.src=s;return i}_resolveThroughCache(e,n){let i=this._offlineCache??nn();lo(n,{cache:i}).then((s)=>{let o=globalThis.URL;if(o&&typeof o.createObjectURL==="function"&&typeof globalThis.Blob==="function"){let r=new globalThis.Blob([s.data],{type:s.mime}),a=o.createObjectURL(r);this._activeBlobUrls.add(a),e.src=a}else e.src=n}).catch(()=>{e.src=n})}getTileUrl(e){let n=Object.create(this.options);if(Object.assign(n,{r:pt.retina?"@2x":"",s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()}),this._map&&!this._map.options.crs.infinite){let i=this._globalTileRange.max.y-e.y;if(this.options.tms)n.y=i;n["-y"]=i}return ho(this._url,n)}_tileOnLoad(e,n){e(null,n)}_tileOnError(e,n,i){let s=this.options.errorTileUrl;if(s&&n.getAttribute("src")!==s)n.src=s;e(i,n)}_onTileRemove(e){e.tile.onload=null}_getZoomForUrl(){let e=this._tileZoom,n=this.options.maxZoom,i=this.options.zoomReverse,s=this.options.zoomOffset;if(i)e=n-e;return e+s}_getSubdomain(e){let n=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[n]}_abortLoading(){for(let e of Object.keys(this._tiles))if(this._tiles[e].coords.z!==this._tileZoom){let n=this._tiles[e].el;if(n.onload=Et,n.onerror=Et,!n.complete){n.setAttribute("src","");let i=this._tiles[e].coords;n.remove(),delete this._tiles[e],this.fire("tileabort",{tile:n,coords:i})}}}_removeTile(e){let n=this._tiles[e];if(!n)return;let i=n.el,s=i.getAttribute("src")??"";if(s.startsWith("blob:")&&this._activeBlobUrls.has(s)){let o=globalThis.URL;if(o&&typeof o.revokeObjectURL==="function")o.revokeObjectURL(s);this._activeBlobUrls.delete(s)}i.setAttribute("src",""),super._removeTile(e)}_tileReady(e,n,i){if(!this._map||i&&i.getAttribute("src")==="")return;super._tileReady(e,n,i)}_clampZoom(e){return Math.round(super._clampZoom(e))}},$e.setDefaultOptions({minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1})});class Vl{id;type;extent;properties;_pbf;_geometry;_geometryEnd;_keys;_values;constructor(t,e,n,i,s){this.id=void 0,this.type=Md,this.extent=n,this.properties={},this._pbf=t,this._geometry=-1,this._geometryEnd=-1,this._keys=i,this._values=s;let o=[];while(t.pos<e){let r=t.readVarint(),a=r>>3;if(t.type=r&7,a===1)this.id=t.readVarint();else if(a===2)o=t.readPackedVarint(o);else if(a===3)this.type=t.readVarint();else if(a===4){this._geometry=t.pos;let l=t.readVarint()+t.pos;this._geometryEnd=l,t.pos=l}else t.skip(r)}for(let r=0;r<o.length;r+=2){let a=i[o[r]],l=s[o[r+1]];if(a!==void 0)this.properties[a]=l??null}}loadGeometry(){if(this._geometry<0)return[];let t=this._pbf,e=t.pos;t.pos=this._geometry;let n=t.readVarint()+t.pos,i=1,s=0,o=0,r=0,a=[],l=null;while(t.pos<n){if(s<=0){let c=t.readVarint();i=c&7,s=c>>3}if(s--,i===ms||i===wa){let c=t.readVarint(),h=t.readVarint();if(o+=c>>1^-(c&1),r+=h>>1^-(h&1),i===ms){if(l!==null)a.push(l);l=[]}if(l===null)l=[];l.push(new v(o,r))}else if(i===va){if(l!==null&&l.length>0)l.push(l[0].clone())}else throw t.pos=e,Error(`Unknown geometry command id: ${i}`)}if(l!==null)a.push(l);if(s>0)throw t.pos=e,Error(`Truncated geometry: ${s} coordinate pair(s) missing`);return t.pos=e,a}bbox(){if(this._geometry<0)return[0,0,0,0];let t=this._pbf,e=t.pos;t.pos=this._geometry;let n=t.readVarint()+t.pos,i=1,s=0,o=0,r=0,a=1/0,l=-1/0,c=1/0,h=-1/0;while(t.pos<n){if(s<=0){let u=t.readVarint();i=u&7,s=u>>3}if(s--,i===ms||i===wa){let u=t.readVarint(),f=t.readVarint();if(o+=u>>1^-(u&1),r+=f>>1^-(f&1),o<a)a=o;if(o>l)l=o;if(r<c)c=r;if(r>h)h=r}else if(i!==va)throw t.pos=e,Error(`Unknown geometry command id: ${i}`)}if(s>0)throw t.pos=e,Error(`Truncated geometry: ${s} coordinate pair(s) missing`);return t.pos=e,[a,c,l,h]}toGeoJSON(t,e,n){return ql(this.type,this.loadGeometry(),this.extent,t,e,n,this.properties,this.id)}}function ql(t,e,n,i,s,o,r,a){let l=n*Math.pow(2,o),c=n*i,h=n*s,u=(p)=>{let m=[];for(let _=0;_<p.length;_++){let g=p[_],b=g.x+c,y=g.y+h,w=b*360/l-180,T=180-y*360/l,L=360/Math.PI*Math.atan(Math.exp(T*Math.PI/180))-90;m.push([w,L])}return m},f;if(t===Ld){let p=[];for(let m=0;m<e.length;m++){let _=e[m];for(let g=0;g<_.length;g++){let b=u([_[g]]);p.push(b[0])}}if(p.length===1)f={type:"Point",coordinates:p[0]};else f={type:"MultiPoint",coordinates:p}}else if(t===Ad){let p=[];for(let m=0;m<e.length;m++)p.push(u(e[m]));if(p.length===1)f={type:"LineString",coordinates:p[0]};else f={type:"MultiLineString",coordinates:p}}else if(t===Od){let p=[],m=null;for(let _=0;_<e.length;_++){let g=kd(e[_]);if(g===0)continue;let b=u(e[_]);if(g>0)m=[b],p.push(m);else if(m!==null)m.push(b)}if(p.length===1)f={type:"Polygon",coordinates:p[0]};else f={type:"MultiPolygon",coordinates:p}}else f={type:"Point",coordinates:[0,0]};let d={type:"Feature",geometry:f,properties:r};if(a!==void 0)d.id=a;return d}function kd(t){let e=0;for(let n=0,i=t.length,s=i-1;n<i;s=n++){let o=t[n],r=t[s];e+=(r.x-o.x)*(o.y+r.y)}return e}var Md=0,Ld=1,Ad=2,Od=3,ms=1,wa=2,va=7,Gl=P(()=>{G()});class Yl{id;type;extent;_layer;_index;_properties;constructor(t,e){this._layer=t,this._index=e,this.extent=t.extent,this.type=t.types[e];let n=t.ids[e];this.id=Number.isNaN(n)?void 0:n}get properties(){if(this._properties)return this._properties;let t=this._layer,e={},n=t.tagStart[this._index],i=t.tagStart[this._index+1];for(let s=n;s+1<i;s+=2){let o=t.keys[t.tags[s]];if(o!==void 0)e[o]=t.values[t.tags[s+1]]}return this._properties=e,e}loadGeometry(){let t=this._layer,e=t.ringStart[this._index],n=t.ringStart[this._index+1],i=[];for(let s=e;s<n;s++){let o=t.ringOffset[s],r=t.ringOffset[s+1],a=[];for(let l=o;l<r;l++)a.push(new v(t.coords[l*2],t.coords[l*2+1]));i.push(a)}return i}bbox(){let t=this._layer,e=t.ringOffset[t.ringStart[this._index]],n=t.ringOffset[t.ringStart[this._index+1]];if(e===void 0||n===void 0||n<=e)return[0,0,0,0];let i=1/0,s=1/0,o=-1/0,r=-1/0;for(let a=e;a<n;a++){let l=t.coords[a*2],c=t.coords[a*2+1];if(l<i)i=l;if(l>o)o=l;if(c<s)s=c;if(c>r)r=c}return[i,s,o,r]}toGeoJSON(t,e,n){return ql(this.type,this.loadGeometry(),this.extent,t,e,n,this.properties,this.id)}}class Kl{name;version;extent;length;_data;constructor(t){this._data=t,this.name=t.name,this.version=t.version,this.extent=t.extent,this.length=t.types.length}feature(t){if(t<0||t>=this.length)throw Error(`feature index out of bounds: ${t}`);return new Yl(this._data,t)}}class Xl{layers;constructor(t){this.layers={};for(let e of t.layers)this.layers[e.name]=new Kl(e)}}var Ed=P(()=>{G(),Gl()});class Jl{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[];let n=e===void 0?t.length:e;while(t.pos<n){let i=t.readVarint(),s=i>>3;if(t.type=i&7,s===15)this.version=t.readVarint();else if(s===1)this.name=t.readString();else if(s===5)this.extent=t.readVarint();else if(s===2){this._features.push(t.pos);let o=t.readVarint()+t.pos;t.pos=o}else if(s===3)this._keys.push(t.readString());else if(s===4)this._values.push(zd(t));else t.skip(i)}this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw Error(`feature index out of bounds: ${t}`);let e=this._pbf;e.pos=this._features[t];let n=e.readVarint()+e.pos;return new Vl(e,n,this.extent,this._keys,this._values)}}function zd(t){let e=t.readVarint()+t.pos,n=null;while(t.pos<e){let i=t.readVarint(),s=i>>3;if(t.type=i&7,s===1)n=t.readString();else if(s===2)n=t.readFloat();else if(s===3)n=t.readDouble();else if(s===4)n=t.readVarint(!0);else if(s===5)n=t.readVarint();else if(s===6)n=t.readSVarint();else if(s===7)n=t.readBoolean();else t.skip(i)}return n}var Cd=P(()=>{Gl()});class Ql{layers;constructor(t,e){this.layers={};let n=e===void 0?t.length:e;while(t.pos<n){let i=t.readVarint(),s=i>>3;if(t.type=i&7,s===3){let o=t.readVarint()+t.pos,r=new Jl(t,o);if(t.pos=o,r.name.length>0)this.layers[r.name]=r}else t.skip(i)}}}var Id=P(()=>{Cd()});function Fd(t){let e=[];for(let n of t.layers)e.push(n.ids.buffer,n.types.buffer,n.tagStart.buffer,n.tags.buffer,n.ringStart.buffer,n.ringOffset.buffer,n.coords.buffer);return e}function xa(t){let e=t,n=e.length,i=0,s=typeof TextDecoder<"u"?new TextDecoder("utf-8"):null;function o(p){let m=e[i++],_=m&127;if(m<128)return _;if(m=e[i++],_|=(m&127)<<7,m<128)return _;if(m=e[i++],_|=(m&127)<<14,m<128)return _;if(m=e[i++],_|=(m&127)<<21,m<128)return _;let g=0;if(m=e[i++],_|=(m&15)<<28,g=(m&112)>>4,m<128)return r(_,g,p===!0);let b=[3,10,17,24];for(let y of b)if(m=e[i++],g|=(m&127)<<y,m<128)return r(_,g,p===!0);if(m=e[i++],g|=(m&1)<<31,m<128)return r(_,g,p===!0);throw Error("Expected varint not more than 10 bytes")}function r(p,m,_){if(_&&(m&2147483648)!==0){let y=~p+1>>>0,w=~m>>>0;if(y===0)w=w+1>>>0;let T=w*4294967296+y;if(T>Number.MAX_SAFE_INTEGER)throw Error("Varint exceeds safe integer range");return-T}let b=(m>>>0)*4294967296+(p>>>0);if(b>Number.MAX_SAFE_INTEGER)throw Error("Varint exceeds safe integer range");return b}function a(){let p=o();return p%2===1?(p+1)/-2:p/2}function l(p){let m=e.subarray(i,p);if(i=p,s)return s.decode(m);let _="";for(let g=0;g<m.length;g++)_+=String.fromCharCode(m[g]);return _}function c(){let p=new DataView(e.buffer,e.byteOffset+i,8);return i+=8,p.getFloat64(0,!0)}function h(){let p=new DataView(e.buffer,e.byteOffset+i,4);return i+=4,p.getFloat32(0,!0)}function u(p){if(p===0)while(e[i++]>=128);else if(p===2)i=o()+i;else if(p===5)i+=4;else if(p===1)i+=8;else throw Error(`Unimplemented wire type: ${p}`)}function f(){let p=o()+i,m=null;while(i<p){let _=o(),g=_>>3,b=_&7;if(g===1)m=l(o()+i);else if(g===2)m=h();else if(g===3)m=c();else if(g===4)m=o(!0);else if(g===5)m=o();else if(g===6)m=a();else if(g===7)m=o()!==0;else u(b)}return i=p,m}let d=[];while(i<n){let p=o(),m=p>>3,_=p&7;if(m!==3){u(_);continue}let g=o()+i,b="",y=1,w=4096,T=[],L=[],C=[];while(i<g){let nt=o(),ot=nt>>3,xt=nt&7;if(ot===15)y=o();else if(ot===1)b=l(o()+i);else if(ot===5)w=o();else if(ot===3)T.push(l(o()+i));else if(ot===4)L.push(f());else if(ot===2){let yt=o()+i;C.push(i,yt),i=yt}else u(xt)}let D=C.length/2,W=new Float64Array(D),J=new Uint8Array(D),gt=new Uint32Array(D+1),E=new Uint32Array(D+1),V=[],Lt=[0],O=[];for(let nt=0;nt<D;nt++){let ot=C[nt*2],xt=C[nt*2+1];i=ot,W[nt]=Number.NaN,gt[nt]=V.length,E[nt]=Lt.length-1;let yt=-1,bt=-1;while(i<xt){let ht=o(),Ft=ht>>3,He=ht&7;if(Ft===1)W[nt]=o();else if(Ft===2){let Ae=o()+i;while(i<Ae)V.push(o())}else if(Ft===3)J[nt]=o();else if(Ft===4)bt=o()+i,yt=i,i=bt;else u(He)}if(yt<0)continue;i=yt;let rt=1,oe=0,Le=0,St=0,Jt=0,Qt=0,Bt=0,Tt=!1;while(i<bt){if(oe<=0){let ht=o();rt=ht&7,oe=ht>>3}if(oe--,rt===1||rt===2){let ht=o(),Ft=o();if(Le+=ht>>1^-(ht&1),St+=Ft>>1^-(Ft&1),rt===1){if(Tt)Lt.push(O.length/2);Tt=!0,Jt=0}if(!Tt)Tt=!0,Jt=0;if(Jt===0)Qt=Le,Bt=St;O.push(Le,St),Jt++}else if(rt===7){if(Tt&&Jt>0)O.push(Qt,Bt),Jt++}else throw Error(`Unknown geometry command id: ${rt}`)}if(Tt)Lt.push(O.length/2);if(oe>0)throw Error(`Truncated geometry: ${oe} coordinate pair(s) missing`)}if(gt[D]=V.length,E[D]=Lt.length-1,i=g,b.length===0)continue;d.push({name:b,version:y,extent:w,keys:T,values:L,ids:W,types:J,tagStart:gt,tags:new Uint32Array(V),ringStart:E,ringOffset:new Uint32Array(Lt),coords:new Int32Array(O)})}return{layers:d}}function Rd(t,e,n={}){Gi.set(t,{fn:e,deps:n.deps??[],transfer:n.transfer})}function Nd(){let t=[],e=[],n=new Set;for(let[i,s]of Gi){for(let o of s.deps){if(!o.name||n.has(o.name))continue;n.add(o.name),e.push(`const ${o.name} = ${o.toString()};`)}t.push(`[${JSON.stringify(i)}, (${s.fn.toString()})]`)}return[...e,"function collectTransferables(value) {"," const out = []; const seen = new Set();"," const walk = (v) => {",' if (!v || typeof v !== "object" || seen.has(v)) return;'," seen.add(v);"," if (ArrayBuffer.isView(v)) { out.push(v.buffer); return; }"," if (v instanceof ArrayBuffer) { out.push(v); return; }"," if (Array.isArray(v)) { for (const item of v) walk(item); return; }"," for (const key of Object.keys(v)) walk(v[key]);"," };"," walk(value);"," return out;","}",`const registry = new Map([${t.join(",")}]);`,"self.onmessage = async (e) => {"," const data = e.data || {};"," const id = data.id; const type = data.type; const payload = data.payload;"," if (data.__register && type && data.source) {"," try {"," registry.set(type, new Function(`return (${data.source})`)());"," }"," catch (err) {"," self.postMessage({ id: id, ok: false, error: String(err) });"," }"," return;"," }"," const handler = registry.get(type);"," if (!handler) {"," self.postMessage({ id: id, ok: false, error: `unknown task type: ${type}` });"," return;"," }"," try {"," const result = await handler({ type: type, payload: payload });"," const transfer = collectTransferables(result);"," self.postMessage({ id: id, ok: true, result: result }, transfer);"," }"," catch (err) {"," self.postMessage({ id: id, ok: false, error: err && err.message ? err.message : String(err) });"," }","};"].join(` |
| 122 | +`)}class tc{constructor(t){if(this._size=Math.max(1,t?.size??2),this._scriptUrl=t?.scriptUrl,this._workers=[],this._nextId=1,this._pending=new Map,this._rr=0,this._usable=this._canUseWorkers(),this._usable)this._spawn()}size(){return this._usable?this._workers.length:0}_canUseWorkers(){if(typeof globalThis>"u")return!1;let t=globalThis;if(typeof t.Worker!=="function")return!1;if(!this._scriptUrl){if(typeof t.Blob!=="function")return!1;if(typeof t.URL>"u"||typeof t.URL.createObjectURL!=="function")return!1}return!0}_spawn(){let t=globalThis,e=this._scriptUrl;if(!e){let n=new t.Blob([Nd()],{type:"application/javascript"});e=t.URL.createObjectURL(n),this._blobUrl=e}for(let n=0;n<this._size;n++)try{let i=new t.Worker(e);i.onmessage=(s)=>this._onMessage(s),i.onerror=()=>{},this._workers.push(i)}catch{this._usable=!1;for(let i of this._workers)i.terminate();if(this._workers=[],this._blobUrl&&typeof t.URL?.revokeObjectURL==="function")t.URL.revokeObjectURL(this._blobUrl),this._blobUrl=void 0;return}}_onMessage(t){let{id:e,ok:n,result:i,error:s}=t.data||{},o=this._pending.get(e);if(!o)return;if(this._pending.delete(e),n)o.resolve(i);else o.reject(Error(s??"worker task failed"))}async run(t){if(!this._usable||this._workers.length===0){let i=Gi.get(t.type);if(!i)throw Error(`unknown task type: ${t.type}`);return await i.fn(t)}let e=this._nextId++,n=this._workers[this._rr%this._workers.length];return this._rr++,await new Promise((i,s)=>{this._pending.set(e,{resolve:i,reject:s});try{n.postMessage({id:e,type:t.type,payload:t.payload})}catch(o){this._pending.delete(e),s(o)}})}async shutdown(){for(let e of this._workers)e.terminate();this._workers=[];let t=globalThis;if(this._blobUrl&&typeof t.URL?.revokeObjectURL==="function")t.URL.revokeObjectURL(this._blobUrl),this._blobUrl=void 0;for(let[,e]of this._pending)e.reject(Error("pool shut down"));this._pending.clear()}}var Gi,$d=P(()=>{Gi=new Map,Rd("mvt-decode",({payload:t})=>xa(t),{deps:[xa],transfer:(t)=>Fd(t)})});class ec{_cellSize;_cells;_ownerCells;constructor(t){this._cellSize=t?.cellSize??64,this._cells=new Map,this._ownerCells=new Map}hits(t){let e=this._cellRange(t);for(let n=e.y0;n<=e.y1;n++)for(let i=e.x0;i<=e.x1;i++){let s=this._cells.get(_s(i,n));if(!s)continue;for(let o of s){if(!Sa(t,o))continue;if(o.priority===void 0||t.priority===void 0)return!0;if(o.priority>=t.priority)return!0}}return!1}tryInsert(t){let e=this._cellRange(t);for(let n=e.y0;n<=e.y1;n++)for(let i=e.x0;i<=e.x1;i++){let s=this._cells.get(_s(i,n));if(!s)continue;for(let o of s){if(!Sa(t,o))continue;if(o.priority===void 0||t.priority===void 0)return!1;if(o.priority>=t.priority)return!1}}return this._insertBucketed(t,e),!0}insert(t){this._insertBucketed(t,this._cellRange(t))}removeOwner(t){let e=this._ownerCells.get(t);if(!e)return;for(let n of e){let i=this._cells.get(n);if(!i)continue;let s=i.filter((o)=>o.owner!==t);if(s.length)this._cells.set(n,s);else this._cells.delete(n)}this._ownerCells.delete(t)}clear(){this._cells.clear(),this._ownerCells.clear()}get size(){let t=new Set;for(let e of this._cells.values())for(let n of e)t.add(n);return t.size}_cellRange(t){let e=this._cellSize;return{x0:Math.floor(t.minX/e),y0:Math.floor(t.minY/e),x1:Math.floor(t.maxX/e),y1:Math.floor(t.maxY/e)}}_insertBucketed(t,e){let n;if(t.owner!==void 0){if(n=this._ownerCells.get(t.owner),!n)n=new Set,this._ownerCells.set(t.owner,n)}for(let i=e.y0;i<=e.y1;i++)for(let s=e.x0;s<=e.x1;s++){let o=_s(s,i),r=this._cells.get(o);if(r)r.push(t);else this._cells.set(o,[t]);n?.add(o)}}}function _s(t,e){return`${t}:${e}`}function Sa(t,e){if(t.maxX<e.minX)return!1;if(t.minX>e.maxX)return!1;if(t.maxY<e.minY)return!1;if(t.minY>e.maxY)return!1;return!0}function nc(t,e,n){let i=n.size*(e.scale??1);if(!e.fontStack)return{size:i,color:e.color??n.color,italic:!!n.italic,bold:!!n.bold,family:n.family};let s=t.resolveFont(e.fontStack);return{size:i,color:e.color??n.color,italic:s.italic,bold:s.bold,family:s.family}}function Zd(t,e,n){let i=0,s=0,o=0;for(let r of e){if(!r.text)continue;let a=nc(t,r,n),l=t.measureText(r.text,a.size,a);i+=l.width,s=Math.max(s,l.ascent),o=Math.max(o,l.descent)}return{width:i,height:s+o,ascent:s,descent:o}}function Bd(t,e,n,i,s,o){let r=i;for(let a of n){if(!a.text)continue;let l=nc(e,a,o);e.drawText(t,a.text,r,s,{color:l.color,haloColor:o.haloColor,haloWidth:o.haloWidth,size:l.size,italic:l.italic,bold:l.bold,family:l.family}),r+=e.measureText(a.text,l.size,l).width}}function ic(t,e,n,i){let s=new Uint8ClampedArray(e*n*4),o=Pa(i.color),r=i.haloWidth??0,a=i.haloColor&&r>0?Pa(i.haloColor):null,l=a?Math.max(0.02,0.5-r/16):0,c=0.06;for(let h=0;h<e*n;h++){let u=t[h*4+3]/255,f=Ta(0.44,0.56,u),d=a?Ta(l-0.06,l+0.06,u):0,p=f+d*(1-f);if(p<=0)continue;let m=d*(1-f);s[h*4]=a?(o[0]*f+a[0]*m)/p:o[0],s[h*4+1]=a?(o[1]*f+a[1]*m)/p:o[1],s[h*4+2]=a?(o[2]*f+a[2]*m)/p:o[2],s[h*4+3]=Math.round(p*255)}return s}function Ta(t,e,n){if(e<=t)return n<t?0:1;let i=Math.min(1,Math.max(0,(n-t)/(e-t)));return i*i*(3-2*i)}function Pa(t){let e=t.trim(),n=/^#([0-9a-f]{3,8})$/i.exec(e);if(n){let s=n[1];if(s.length===3||s.length===4)s=s.slice(0,3).split("").map((r)=>r+r).join("");if(s.length<6)return[0,0,0];let o=Number.parseInt(s.slice(0,6),16);return[o>>16&255,o>>8&255,o&255]}let i=/^rgba?\(([^)]+)\)$/i.exec(e);if(i){let s=i[1].split(/[,/\s]+/).filter(Boolean);if(s.length>=3){let o=(r)=>{let a=Number.parseFloat(r);if(Number.isNaN(a))return 0;return Math.max(0,Math.min(255,Math.round(r.includes("%")?a/100*255:a)))};return[o(s[0]),o(s[1]),o(s[2])]}}return Dd(e)}function Dd(t){if(typeof document>"u")return[0,0,0];let e=document.createElement("canvas");e.width=1,e.height=1;let n=e.getContext("2d");if(!n)return[0,0,0];n.fillStyle=t,n.fillRect(0,0,1,1);try{let i=n.getImageData(0,0,1,1).data;return[i[0],i[1],i[2]]}catch{return[0,0,0]}}function jd(t,e){let n=[];for(let i of e){let s=i.codePointAt(0);if(s===void 0)continue;let o=t(s);if(!o)return null;n.push(o)}return n}function Ud(t,e){let n=e/rc,i=0,s=0,o=0;for(let l of t)i+=l.advance*n,s=Math.max(s,l.top*n),o=Math.max(o,(l.height-l.top)*n);let r=s||e*0.8,a=o||e*0.2;return{width:i,height:r+a,ascent:r,descent:a}}function Hd(t,e,n,i,s,o){let r=s.size/rc,a=n;for(let l of e){if(l.bitmap&&l.width>0&&l.height>0){let c=o?o.get(l,s):sc(l,s);if(c){let h=(l.width+Ee*2)*r,u=(l.height+Ee*2)*r,f=a+(l.left-Ee)*r,d=i-(l.top+Ee)*r;t.drawImage(c,f,d,h,u)}}a+=l.advance*r}}function sc(t,e){if(!t.bitmap)return null;let n=t.width+Ee*2,i=t.height+Ee*2;if(t.bitmap.length<n*i)return null;let s=document.createElement("canvas");s.width=n,s.height=i;let o=s.getContext("2d");if(!o)return null;let r=new Uint8ClampedArray(n*i*4);for(let l=0;l<n*i;l++)r[l*4+3]=t.bitmap[l];let a=o.createImageData(n,i);return a.data.set(ic(r,n,i,{color:e.color,haloColor:e.haloColor,haloWidth:e.haloWidth})),o.putImageData(a,0,0),s}class oc{_entries;_limit;constructor(t=2048){this._entries=new Map,this._limit=t}get(t,e){let n=`${t.id}|${e.color}|${e.haloColor??""}|${e.haloWidth??0}`;if(this._entries.has(n))return this._entries.get(n)??null;let i=sc(t,e);if(this._entries.size>=this._limit)this._entries.clear();return this._entries.set(n,i),i}clear(){this._entries.clear()}get size(){return this._entries.size}}var rc=24,ac=P(()=>{Ro()});class lc{constructor(t,e){this._map=t,this._host=e,this.canvas=null,this._ratio=1,this._frame=null,this._attach()}_attach(){let t=this._map?.getPane?.("symbolPane")??this._map?.getContainer?.();if(!t||typeof t.appendChild!=="function")return;let e=t,i=(e.ownerDocument??document).createElement("canvas");if(i.className="tsmap-symbol-overlay",i.style)i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.pointerEvents="none";e.appendChild(i),this.canvas=i,this._resize()}_pixelRatio(){let t=typeof window<"u"?window.devicePixelRatio:1;return Math.min(2,Math.max(1,t||1))}_resize(){let t=this.canvas,e=this._map;if(!t||!e?.getSize)return;let n=e.getSize(),i=this._pixelRatio();if(this._ratio=i,t.width=Math.max(1,Math.round(n.x*i)),t.height=Math.max(1,Math.round(n.y*i)),t.style)t.style.width=`${n.x}px`,t.style.height=`${n.y}px`}_position(){let t=this.canvas,e=this._map?._getMapPanePos?.();if(!t?.style||!e)return;t.style.transform=`translate3d(${-e.x}px, ${-e.y}px, 0)`}schedule(){if(this._frame!==null||typeof requestAnimationFrame!=="function"){if(typeof requestAnimationFrame!=="function")this.redraw();return}this._frame=requestAnimationFrame(()=>{this._frame=null,this.redraw()})}redraw(){let t=this.canvas,e=this._map;if(!t||!e)return;let n=e.getSize?.();if(n&&(t.width!==Math.round(n.x*this._ratio)||t.height!==Math.round(n.y*this._ratio)))this._resize();let i=t.getContext("2d");if(!i)return;this._position(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,t.width,t.height),i.setTransform(this._ratio,0,0,this._ratio,0,0),this._host.drawSymbols(i,this._host.createCollisionIndex())}remove(){if(this._frame!==null&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(this._frame);this._frame=null,this.canvas?.remove?.(),this.canvas=null}}class cc{canvas;_ctx;_sprites;_cursorX;_cursorY;_rowH;_sdfCache;constructor(){this.canvas=document.createElement("canvas"),this.canvas.width=512,this.canvas.height=512,this._ctx=this.canvas.getContext("2d"),this._sprites=new Map,this._cursorX=0,this._cursorY=0,this._rowH=0,this._sdfCache=new Map}addSprite(t,e){let{width:n,height:i}=t;if(this._cursorX+n>this.canvas.width)this._cursorY+=this._rowH,this._cursorX=0,this._rowH=0;if(this._cursorY+i>this.canvas.height)this._grow(Math.max(this.canvas.width*2,this._cursorY+i));let s=this._cursorX,o=this._cursorY,r=this._ctx;if(r)if(Wd(e)){let l=document.createElement("canvas");l.width=e.width,l.height=e.height;let c=l.getContext("2d");if(c)c.putImageData(e,0,0),r.drawImage(l,t.x,t.y,n,i,s,o,n,i)}else r.drawImage(e,t.x,t.y,n,i,s,o,n,i);let a={id:t.id,x:s,y:o,width:n,height:i,pixelRatio:t.pixelRatio??1,sdf:t.sdf};if(this._sprites.set(t.id,a),this._cursorX+=n,i>this._rowH)this._rowH=i}get(t){return this._sprites.get(t)}drawIcon(t,e,n,i,s){let o=this._sprites.get(e);if(!o)return;let a=(s?.size??o.width)/o.width,l=o.width*a,c=o.height*a,h=o.sdf?this._renderSdf(o,s):this.canvas,u=h===this.canvas?o.x:0,f=h===this.canvas?o.y:0,d=t.globalAlpha,p=s?.opacity;if(p!==void 0&&p<1)t.globalAlpha=d*Math.max(0,p);if(s?.rotation)t.save(),t.translate(n,i),t.rotate(s.rotation),t.drawImage(h,u,f,o.width,o.height,-l/2,-c/2,l,c),t.restore();else t.drawImage(h,u,f,o.width,o.height,n-l/2,i-c/2,l,c);t.globalAlpha=d}_renderSdf(t,e){let n=e?.color??"#000000",i=e?.haloColor,s=e?.haloWidth??0,o=`${t.id}|${n}|${i??""}|${s}`,r=this._sdfCache.get(o);if(r)return r;let{width:a,height:l}=t,c=document.createElement("canvas");c.width=a,c.height=l;let h=c.getContext("2d"),u=this._ctx;if(!h||!u)return c;let f;try{f=u.getImageData(t.x,t.y,a,l)}catch{return c}let d=h.createImageData(a,l);if(d.data.set(ic(f.data,a,l,{color:n,haloColor:i,haloWidth:s})),h.putImageData(d,0,0),this._sdfCache.size>128)this._sdfCache.clear();return this._sdfCache.set(o,c),c}_grow(t){let e=this.canvas,n=document.createElement("canvas");n.width=Math.max(t,e.width),n.height=Math.max(t,e.height);let i=n.getContext("2d");if(i)i.drawImage(e,0,0);this.canvas=n,this._ctx=i}}function Wd(t){if(!t||typeof t!=="object")return!1;let e=t;return typeof e.width==="number"&&typeof e.height==="number"&&(e.data instanceof Uint8ClampedArray||e.data instanceof Uint8Array)}var Vd=()=>{};function qd(t,e,n){let i,s;switch(t){case"left":case"top-left":case"bottom-left":i=0;break;case"right":case"top-right":case"bottom-right":i=-e;break;default:i=-e/2}switch(t){case"top":case"top-left":case"top-right":s=0;break;case"bottom":case"bottom-left":case"bottom-right":s=-n;break;default:s=-n/2}return{x:i,y:s}}function Gd(t,e){if(!Array.isArray(t)||t.length<2)return{x:0,y:0};let n=Number(t[0]),i=Number(t[1]);return{x:Number.isFinite(n)?n*e:0,y:Number.isFinite(i)?i*e:0}}function hc(t,e,n,i,s,o=t,r=e){let a=Math.cos(s),l=Math.sin(s),c=[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}],h=1/0,u=1/0,f=-1/0,d=-1/0;for(let p of c){let m=p.x-o,_=p.y-r,g=o+m*a-_*l,b=r+m*l+_*a;if(g<h)h=g;if(b<u)u=b;if(g>f)f=g;if(b>d)d=b}return{minX:h,minY:u,maxX:f,maxY:d}}function uc(t){let e=0;for(let n=1;n<t.length;n++){let i=t[n].x-t[n-1].x,s=t[n].y-t[n-1].y;e+=Math.hypot(i,s)}return e}function gs(t,e){if(t.length<2||e<0)return null;let n=0;for(let i=1;i<t.length;i++){let s=t[i-1],o=t[i],r=o.x-s.x,a=o.y-s.y,l=Math.hypot(r,a);if(l===0)continue;if(n+l>=e){let c=(e-n)/l;return{x:s.x+r*c,y:s.y+a*c,angle:Math.atan2(a,r)}}n+=l}return null}function Yd(t,e){let{advances:n,start:i}=e;if(!n.length||t.length<2)return null;let s=(e.maxAngle??45)*Math.PI/180,o=n.reduce((h,u)=>h+u,0);if(i+o>uc(t))return null;let r=!1;if(e.keepUpright!==!1){let h=gs(t,i),u=gs(t,i+o);if(h&&u&&u.x<h.x)r=!0}let a=[],l=i,c=null;for(let h=0;h<n.length;h++){let u=r?n.length-1-h:h,f=n[u],d=gs(t,l+f/2);if(!d)return null;let p=r?d.angle+Math.PI:d.angle;if(c===null)c=p;else if(Math.abs((p-c+Math.PI*3)%(Math.PI*2)-Math.PI)>s)return null;let m=Math.cos(p),_=Math.sin(p);a.push({x:d.x-m*(f/2),y:d.y-_*(f/2),angle:p,index:u}),l+=f}return r?a.reverse():a}function Kd(t,e,n){let i=t-e;if(i<0)return[];if(n<=0||i<n)return[i/2];let s=[];for(let o=n/2;o<=i;o+=n)s.push(o);return s.length?s:[i/2]}function ka(t,e,n,i,s,o,r){let a=r??new Float32Array(16),l=1/(t-e),c=1/(n-i),h=1/(s-o);return a[0]=-2*l,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*c,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*h,a[11]=0,a[12]=(t+e)*l,a[13]=(i+n)*c,a[14]=(o+s)*h,a[15]=1,a}function Xd(t,e){let n=typeof e==="string"?e.split(""):e;if(!n||n.length===0)return"";let i=Math.abs(t.x+t.y)%n.length;return n[i]}function Jd(t,e){return ho(t,e)}var Qd=P(()=>{N()}),fc={};tt(fc,{GlyphProvider:()=>dc,stackKey:()=>Xs});class dc{cache;_source;_available;_onLoad;_requested;_availability;constructor(t){this._source=t.source,this._available=t.isFontAvailable,this._onLoad=t.onLoad,this._requested=new Set,this._availability=new Map,this.cache=new oc}needsServer(t){let e=Xs(t),n=this._availability.get(e);if(n!==void 0)return!n;let i=this._available(t);return this._availability.set(e,i),!i}glyphs(t,e){let n=Xs(t),i=jd((s)=>this._source.get(n,s),e);if(i)return i;return this._request(n,e),null}invalidate(){this._availability.clear(),this.cache.clear()}_request(t,e){for(let n of e){let i=n.codePointAt(0);if(i===void 0)continue;let s=Qe(i),o=`${t}/${s}`;if(this._requested.has(o))continue;this._requested.add(o),this._source.load(t,i).then(()=>this._onLoad()).catch(()=>{})}}}function Xs(t){if(Array.isArray(t))return t.join(",");return t??""}var tp=P(()=>{ac(),Ro()}),Js={};tt(Js,{VectorTileMapLayer:()=>jn,shutdownDecodePool:()=>np});function ep(t){if(!Ln){let e=typeof navigator<"u"?navigator.hardwareConcurrency??4:4;Ln=new tc({size:t??Math.max(1,Math.min(4,e-1))})}return Ln}async function np(){let t=Ln;Ln=null,await t?.shutdown()}function U(t,e,n,i,s){if(!Yn(t))return t;try{let o=ke(t,"value"),r={zoom:e,feature:n?{type:n.type,id:n.id,properties:n.properties,geometry:s?pc(n,s):void 0}:void 0,featureState:i};return o.evaluate(r)}catch{return}}function pc(t,e){let n,i=!1;return()=>{if(!i){i=!0;try{n=t.toGeoJSON(e.x,e.y,e.z)}catch{n=void 0}}return n}}function Ma(t,e,n,i,s,o,r){if(e.length===0)return;let a=U(i?.["fill-color"],s,o,r)??"#000",l=U(i?.["fill-opacity"],s,o,r),c=U(i?.["fill-outline-color"],s,o,r);t.beginPath();for(let h of e){if(h.length===0)continue;t.moveTo(h[0].x*n,h[0].y*n);for(let u=1;u<h.length;u++)t.lineTo(h[u].x*n,h[u].y*n)}if(t.save(),l!==void 0)t.globalAlpha=l;if(t.fillStyle=a,t.fill("evenodd"),t.restore(),c)t.save(),t.strokeStyle=c,t.lineWidth=1,t.stroke(),t.restore()}function ip(t,e,n,i,s,o,r){if(e.length<2)return null;let a=e[0],l=e[e.length-1],c=t.createLinearGradient(a.x*n,a.y*n,l.x*n,l.y*n),h={zoom:s,feature:{type:o.type,id:o.id,properties:o.properties},featureState:r,lineProgress:0};for(let u of _c){h.lineProgress=u;try{let f=i.evaluate(h);if(typeof f==="string")c.addColorStop(u,f)}catch{}}return c}function sp(t,e,n,i,s,o,r,a,l){if(e.length===0)return;let c=U(i?.["line-color"],s,o,r)??"#000",h=U(i?.["line-width"],s,o,r)??1,u=U(i?.["line-opacity"],s,o,r),f=i?.["line-cap"],d=i?.["line-join"];if(t.save(),l){let p=ip(t,e[0],n,l,s,o,r);t.strokeStyle=p??c}else t.strokeStyle=c;if(t.lineWidth=h,u!==void 0)t.globalAlpha=u;if(a&&Array.isArray(a))t.setLineDash(a);if(f)t.lineCap=f;if(d)t.lineJoin=d;t.beginPath();for(let p of e){if(p.length===0)continue;t.moveTo(p[0].x*n,p[0].y*n);for(let m=1;m<p.length;m++)t.lineTo(p[m].x*n,p[m].y*n)}t.stroke(),t.restore()}function op(t,e,n,i,s,o,r){if(e.length===0)return;let a=U(i?.["circle-color"],s,o,r)??"#000",l=U(i?.["circle-radius"],s,o,r)??4,c=U(i?.["circle-opacity"],s,o,r),h=U(i?.["circle-stroke-color"],s,o,r),u=U(i?.["circle-stroke-width"],s,o,r);if(t.save(),c!==void 0)t.globalAlpha=c;for(let f of e)for(let d of f)if(t.beginPath(),t.arc(d.x*n,d.y*n,l,0,Math.PI*2),t.fillStyle=a,t.fill(),h&&u)t.strokeStyle=h,t.lineWidth=u,t.stroke();t.restore()}function K(t,e,n,i){return U(t,e,n,i)}function La(t){if(t===void 0||t===null)return"";if(typeof t==="string")return t;if(typeof t==="number")return String(t);if(typeof t==="boolean")return t?"true":"false";return""}function rp(t,e,n,i,s,o,r,a,l,c,h){if(e.length===0||e[0].length===0)return;let{layout:u,paint:f}=n,d=K(u?.["text-field"],s,i,o),p=Wr(d)&&!Sl(d.sections)?d:null,m=p?p.toString():La(Wr(d)?d.toString():d),_=K(u?.["text-size"],s,i,o)??16,g=r.resolveFont(u?.["text-font"]),b=g.italic||!!K(u?.["text-italic"],s,i,o),y=g.bold||!!K(u?.["text-bold"],s,i,o),w=K(f?.["text-color"],s,i,o)??"#000",T=K(f?.["text-halo-color"],s,i,o),L=K(f?.["text-halo-width"],s,i,o),C=La(K(u?.["icon-image"],s,i,o)),D=K(u?.["icon-size"],s,i,o),W=K(u?.["icon-rotate"],s,i,o),J=C&&a?a.get(C):void 0,gt=K(f?.["icon-opacity"],s,i,o),E=J?.sdf?K(f?.["icon-color"],s,i,o)??"#000000":void 0,V=J?.sdf?K(f?.["icon-halo-color"],s,i,o):void 0,Lt=J?.sdf?K(f?.["icon-halo-width"],s,i,o):void 0,O=K(u?.["symbol-sort-key"],s,i,o)??u?.["symbol-priority"],nt=!!(K(u?.["text-allow-overlap"],s,i,o)??K(u?.["icon-allow-overlap"],s,i,o)),ot=!!(K(u?.["text-ignore-placement"],s,i,o)??K(u?.["icon-ignore-placement"],s,i,o)),xt=(Ae)=>{if(nt){if(!ot)l.insert({...Ae,priority:O});return!0}if(ot)return!l.hits({...Ae,priority:O});return l.tryInsert({...Ae,priority:O})},yt=(K(u?.["text-letter-spacing"],s,i,o)??0)*_,bt={italic:b,bold:y,family:g.family,letterSpacing:yt},rt={color:w,haloColor:T,haloWidth:L,size:_,italic:b,bold:y,family:g.family,letterSpacing:yt};if((u?.["symbol-placement"]==="line"||u?.["symbol-placement"]==="line-center")&&m&&i.type!==1){ap(t,e,c,{text:m,textSize:_,textStyle:bt,drawOptions:rt,maxAngle:K(u?.["text-max-angle"],s,i,o)??45,spacing:K(u?.["symbol-spacing"],s,i,o)??250,centreOnly:u?.["symbol-placement"]==="line-center",place:xt},r);return}if(i.type!==1)return;let Le=K(u?.["text-anchor"],s,i,o)??"center",St=Gd(K(u?.["text-offset"],s,i,o),_),Qt=(K(u?.["text-rotate"],s,i,o)??0)*Math.PI/180,Bt=m&&!p&&h?.needsServer(u?.["text-font"])?h.glyphs(u?.["text-font"],m):null,Tt=m&&!p&&!!h?.needsServer(u?.["text-font"])&&Bt===null,ht=m&&!Tt?Bt?Ud(Bt,_):p?Zd(r,p.sections,{...rt,color:w}):r.measureText(m,_,bt):null,Ft=ht?ht.width:0,He=ht?ht.height:0;for(let Ae of e)for(let cr of Ae){if(!m&&!J)continue;let os=c(cr.x,cr.y);if(!os)continue;let{x:re,y:ae}=os,dn=re,pn=ae,mn=re,_n=ae,gn=0,yn=0;if(ht){let Rt=qd(Le,Ft,He);gn=re+Rt.x+St.x,yn=ae+Rt.y+St.y;let le=Qt===0?{minX:gn,minY:yn,maxX:gn+Ft,maxY:yn+He}:hc(gn,yn,Ft,He,Qt,re,ae);dn=Math.min(dn,le.minX),pn=Math.min(pn,le.minY),mn=Math.max(mn,le.maxX),_n=Math.max(_n,le.maxY)}if(J){let Rt=D??J.width,le=re-Rt/2,We=ae-Rt/2;dn=Math.min(dn,le),pn=Math.min(pn,We),mn=Math.max(mn,le+Rt),_n=Math.max(_n,We+Rt)}if(!xt({minX:dn,minY:pn,maxX:mn,maxY:_n}))continue;if(J&&a)a.drawIcon(t,C,re,ae,{size:D??J.width,rotation:W,color:E,opacity:gt,haloColor:V,haloWidth:Lt});if(m&&ht){let Rt=gn,We=yn+(ht?.ascent??He),hr=()=>{if(Bt)Hd(t,Bt,Rt,We,rt,h?.cache);else if(p)Bd(t,r,p.sections,Rt,We,rt);else r.drawText(t,m,Rt,We,rt)};if(Qt===0)hr();else t.save(),t.translate(re,ae),t.rotate(Qt),t.translate(-re,-ae),hr(),t.restore()}}}function ap(t,e,n,i,s){let o=s.advances(i.text,i.textSize,i.textStyle);if(!o.length)return;let r=o.map((c)=>c.advance),a=r.reduce((c,h)=>c+h,0);if(a<=0)return;let l=s.measureText(i.text,i.textSize,i.textStyle).height;for(let c of e){if(c.length<2)continue;let h=[];for(let d of c){let p=n(d.x,d.y);if(p)h.push(p)}if(h.length<2)continue;let u=uc(h),f=i.centreOnly?u>=a?[(u-a)/2]:[]:Kd(u,a,i.spacing);for(let d of f){let p=Yd(h,{advances:r,start:d,maxAngle:i.maxAngle});if(!p)continue;let m=1/0,_=1/0,g=-1/0,b=-1/0;for(let y of p){let w=hc(y.x,y.y-l/2,r[y.index],l,y.angle,y.x,y.y);if(w.minX<m)m=w.minX;if(w.minY<_)_=w.minY;if(w.maxX>g)g=w.maxX;if(w.maxY>b)b=w.maxY}if(!i.place({minX:m,minY:_,maxX:g,maxY:b}))continue;for(let y of p)t.save(),t.translate(y.x,y.y),t.rotate(y.angle),s.drawText(t,o[y.index].char,0,l*0.35,i.drawOptions),t.restore()}}}function xn(t,e,n,i){let s=t.filter;if(!s)return!0;if(!Array.isArray(s))return!0;let o=s[0];if(typeof o==="string"&&gc.has(o)&&mc(s))return xi(s,e);if(t._compiledFilter===void 0)try{t._compiledFilter=ke(s,"boolean")}catch{t._compiledFilter=!1}let r=t._compiledFilter;if(!r)return!0;try{let a=r.evaluate({zoom:n,feature:{type:e.type,id:e.id,properties:e.properties,geometry:i?pc(e,i):void 0}});return Boolean(a)}catch{return!0}}function mc(t){let e=t[0];if(e==="all"||e==="any"||e==="none")return t.slice(1).every((n)=>Array.isArray(n)&&mc(n));for(let n=1;n<t.length;n++){let i=t[n];if(Array.isArray(i)){let s=i[0];if(s!=="get"&&s!=="geometry-type"&&s!=="$type")return!1}}return!0}function xi(t,e){let[n,...i]=t;if(n==="all")return i.every((o)=>xi(o,e));if(n==="any")return i.some((o)=>xi(o,e));if(n==="none")return i.every((o)=>!xi(o,e));if(n==="has"){let o=i[0];return typeof o==="string"&&o in e.properties}if(n==="!has"){let o=i[0];return typeof o==="string"&&!(o in e.properties)}let s=lp(i[0],e);if(n==="=="||n==="!="){let o=kn(i[1],e);return n==="=="?s===o:s!==o}if(n==="<"||n==="<="||n===">"||n===">="){let o=kn(i[1],e);if(typeof s!=="number"||typeof o!=="number")return!1;return n==="<"?s<o:n==="<="?s<=o:n===">"?s>o:s>=o}if(n==="in")return i.slice(1).map((r)=>kn(r,e)).includes(s);if(n==="!in")return!i.slice(1).map((r)=>kn(r,e)).includes(s);return!0}function lp(t,e){if(Array.isArray(t))return kn(t,e);if(t==="$type"){let n=e.type;return n===1?"Point":n===2?"LineString":n===3?"Polygon":"Unknown"}if(t==="$id")return e.id??null;if(typeof t==="string")return e.properties[t]??null;return t}function kn(t,e){if(Array.isArray(t)){if(t[0]==="get"&&typeof t[1]==="string")return e.properties[t[1]]??null;if(t[0]==="geometry-type"){let n=e.type;return n===1?"Point":n===2?"LineString":n===3?"Polygon":"Unknown"}}return t}function Aa(t){let e=[];for(let i of Object.keys(t.layers)){let s=t.layers[i];for(let o=0;o<s.length;o++){let a=s.feature(o).bbox(),l=[a[0],a[1],a[2],a[3]];e.push({bbox:l,data:{featureIndex:o,sourceLayerName:i,bbox:l}})}}let n=new Ga;return n.load(e),n}function cp(t,e,n,i,s,o={f:1,sx:0,sy:0}){if(!i)return null;if(e){let[[r,a],[l,c]]=e,h=i.containerPointToLayerPoint?.({x:r,y:a})??{x:r,y:a},u=i.containerPointToLayerPoint?.({x:l,y:c})??{x:l,y:c},f=Math.min(h.x,u.x)-n.x*s,d=Math.min(h.y,u.y)-n.y*s,p=Math.max(h.x,u.x)-n.x*s,m=Math.max(h.y,u.y)-n.y*s;if(p<0||m<0||f>s||d>s)return null;let _=4096,g=_/(s*o.f),b=o.sx*_/o.f,y=o.sy*_/o.f;return{kind:"bbox",px:(f+p)*0.5*g+b,py:(d+m)*0.5*g+y,bbox:[f*g+b,d*g+y,p*g+b,m*g+y],scale:g}}if(t){let r=i.containerPointToLayerPoint?.(t)??t,a=r.x-n.x*s,l=r.y-n.y*s;if(a<0||l<0||a>s||l>s)return null;let c=4096,h=c/(s*o.f),u=a*h+o.sx*c/o.f,f=l*h+o.sy*c/o.f,d=8*h;return{kind:"point",px:u,py:f,bbox:[u-d,f-d,u+d,f+d],scale:h}}return null}function hp(t,e){if(t.index)return(e.kind==="point"?t.index.search(e.bbox):t.index.search(e.bbox)).map((s)=>s.data);if(!t.tile)return[];let n=[];for(let i of Object.keys(t.tile.layers)){let s=t.tile.layers[i];for(let o=0;o<s.length;o++){let a=s.feature(o).bbox();n.push({featureIndex:o,sourceLayerName:i,bbox:[a[0],a[1],a[2],a[3]]})}}return n}function up(t,e,n,i){let s=t.extent/i,o=e.px*(s/e.scale),r=e.py*(s/e.scale),a=[e.bbox[0]*(s/e.scale),e.bbox[1]*(s/e.scale),e.bbox[2]*(s/e.scale),e.bbox[3]*(s/e.scale)],l=t.loadGeometry();if(e.kind==="bbox"){if(t.type===3){if(Oa({x:o,y:r},l))return!0}for(let c of l)for(let h of c)if(h.x>=a[0]&&h.x<=a[2]&&h.y>=a[1]&&h.y<=a[3])return!0;return!1}if(t.type===3)return Oa({x:o,y:r},l);if(t.type===2){let h=((n.paint?.["line-width"]??1)/2+4)*s,u=h*h;for(let f of l)for(let d=1;d<f.length;d++)if(_p({x:o,y:r},f[d-1],f[d])<=u)return!0;return!1}if(t.type===1){let h=((n.paint?.["circle-radius"]??4)+2)*s,u=h*h;for(let f of l)for(let d of f){let p=d.x-o,m=d.y-r;if(p*p+m*m<=u)return!0}return!1}return!1}function Oa(t,e){let n=!1;for(let i of e)for(let s=0,o=i.length-1;s<i.length;o=s++){let r=i[s].x,a=i[s].y,l=i[o].x,c=i[o].y;if(a>t.y!==c>t.y&&t.x<(l-r)*(t.y-a)/(c-a||1)+r)n=!n}return n}function fp(t,e,n,i,s,o,r){if(e.length===0)return;let a=U(i?.["fill-color"],s,o,r)??"#000",l=U(i?.["fill-opacity"],s,o,r)??1,c=Dn(a,l),h=e.map((m)=>m.map((_)=>({x:_.x*n,y:_.y*n}))),{vertices:u,holes:f}=Cl(h),d=zl(u,f,2);if(d.length===0)return;let p=new Float32Array(d.length*2);for(let m=0;m<d.length;m++)p[m*2]=u[d[m]*2],p[m*2+1]=u[d[m]*2+1];t.drawFill(p,c)}function dp(t,e,n,i,s,o,r){if(e.length===0)return;let a=U(i?.["fill-extrusion-color"],s,o,r)??"#000",l=U(i?.["fill-extrusion-opacity"],s,o,r)??1,c=U(i?.["fill-extrusion-height"],s,o,r)??0,h=U(i?.["fill-extrusion-base"],s,o,r)??0;if(c<=h)return;let u=Dn(a,1),f=e.map((d)=>d.map((p)=>({x:p.x*n,y:p.y*n})));t.drawFillExtrusion([{rings:f}],[c*n],[h*n],u,l)}function pp(t,e,n,i,s,o,r){if(e.length===0)return;let a=U(i?.["line-color"],s,o,r)??"#000",l=U(i?.["line-width"],s,o,r)??1,c=U(i?.["line-opacity"],s,o,r)??1,h=Dn(a,c);for(let u of e){if(u.length<2)continue;let f=new Float32Array(u.length*2);for(let d=0;d<u.length;d++)f[d*2]=u[d].x*n,f[d*2+1]=u[d].y*n;t.drawLine(f,{width:l,color:h,cap:i?.["line-cap"],join:i?.["line-join"]})}}function mp(t,e,n,i,s,o,r){if(e.length===0)return;let a=U(i?.["circle-color"],s,o,r)??"#000",l=U(i?.["circle-radius"],s,o,r)??4,c=U(i?.["circle-opacity"],s,o,r)??1,h=U(i?.["circle-stroke-color"],s,o,r),u=U(i?.["circle-stroke-width"],s,o,r)??0,f=Dn(a,c),d=h?Dn(h,c):void 0,p=0;for(let g of e)p+=g.length;if(p===0)return;let m=new Float32Array(p*2),_=0;for(let g of e)for(let b of g)m[_++]=b.x*n,m[_++]=b.y*n;t.drawCircles(m,{radius:l,color:f,strokeColor:d,strokeWidth:u})}function Dn(t,e){let n=t.trim();if(n.charAt(0)==="#"){let s=n.slice(1);if(s.length===3){let o=Number.parseInt(s[0]+s[0],16)/255,r=Number.parseInt(s[1]+s[1],16)/255,a=Number.parseInt(s[2]+s[2],16)/255;return[o,r,a,e]}if(s.length===4){let o=Number.parseInt(s[0]+s[0],16)/255,r=Number.parseInt(s[1]+s[1],16)/255,a=Number.parseInt(s[2]+s[2],16)/255,l=Number.parseInt(s[3]+s[3],16)/255;return[o,r,a,l*e]}if(s.length===6){let o=Number.parseInt(s.slice(0,2),16)/255,r=Number.parseInt(s.slice(2,4),16)/255,a=Number.parseInt(s.slice(4,6),16)/255;return[o,r,a,e]}if(s.length===8){let o=Number.parseInt(s.slice(0,2),16)/255,r=Number.parseInt(s.slice(2,4),16)/255,a=Number.parseInt(s.slice(4,6),16)/255,l=Number.parseInt(s.slice(6,8),16)/255;return[o,r,a,l*e]}}let i=/^rgba?\(([^)]+)\)/i.exec(n);if(i){let s=i[1].split(",").map((c)=>c.trim()),o=Number.parseFloat(s[0]??"0")/255,r=Number.parseFloat(s[1]??"0")/255,a=Number.parseFloat(s[2]??"0")/255,l=s.length>3?Number.parseFloat(s[3]??"1"):1;return[o,r,a,l*e]}return[0,0,0,e]}function _p(t,e,n){let i=n.x-e.x,s=n.y-e.y,o=0;if(i!==0||s!==0){if(o=((t.x-e.x)*i+(t.y-e.y)*s)/(i*i+s*s),o>1)o=1;else if(o<0)o=0}let r=e.x+o*i-t.x,a=e.y+o*s-t.y;return r*r+a*a}var Ln=null,jn,_c,gc,Qs=P(()=>{Wi(),$l(),Ed(),Id(),$d(),ac(),Vd(),$i(),zo(),Io(),$o(),Qd(),jn=class extends sn{initialize(e){super.initialize(e),this._styleLayers=this.options.layers??[],this._decodedTiles=new Map,this._sourceCache=new Map,this._sourcePending=new Map,this._glyphAtlas=this.options.glyphAtlas,this._iconAtlas=this.options.iconAtlas;let n=this.options.offlineCache;if(n instanceof Ni)this._offlineCache=n;else if(n===!0)this._offlineCache=nn();if(typeof this.options.subdomains==="string")this.options.subdomains=this.options.subdomains.split("")}getGlyphAtlas(){if(!this._glyphAtlas)this._glyphAtlas=new No;return this._glyphAtlas}getIconAtlas(){if(!this._iconAtlas)this._iconAtlas=new cc;return this._iconAtlas}setFeatureStateLookup(e){return this._featureStateLookup=e,this}setSourceId(e){return this._sourceId=e,this}_repaintDecodedTiles(){for(let e of this._decodedTiles.values()){if(!e.tile)continue;if(e.gl)e.gl.clear();else{let n=e.canvas.getContext("2d");if(!n)continue;n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,e.canvas.width,e.canvas.height)}try{this._drawTile(e.canvas,e.tile,{x:e.coords.x,y:e.coords.y,z:e.coords.z})}catch{}}}setStyleLayers(e){return this._styleLayers=e,this.redraw(),this._refreshSymbols(),this}updateStyleLayers(e){return this._styleLayers=e,this._repaintDecodedTiles(),this._refreshSymbols(),this}getStyleLayer(e){for(let n of this._styleLayers)if(n.id===e)return n;return}queryRenderedFeatures(e,n){let i,s,o;if(e&&typeof e.x==="number"&&typeof e.y==="number")i=e,o=n;else if(o=e,o?.bbox)s=o.bbox;else if(o?.point){let h=o.point;i=Array.isArray(h)?{x:h[0],y:h[1]}:h}let r=o?.layers,a=[],l=this.getTileSize().x,c=this._map?.getZoom?.()??0;for(let h of this._decodedTiles.values()){if(!h.tile)continue;if(i===void 0&&s===void 0){for(let d of this._styleLayers){if(r&&!r.includes(d.id))continue;if(d.layout?.visibility==="none")continue;let p=h.tile.layers[d.sourceLayer];if(!p)continue;for(let m=0;m<p.length;m++){let _=p.feature(m);if(!xn(d,_,c,h.coords))continue;a.push({feature:_,layer:d,tile:h.coords})}}continue}let u=cp(i,s,h.coords,this._map,l,this._subTile(h.coords));if(!u)continue;let f=hp(h,u);if(f.length===0)continue;for(let d of this._styleLayers){if(r&&!r.includes(d.id))continue;if(d.layout?.visibility==="none")continue;let p=h.tile.layers[d.sourceLayer];if(!p)continue;let m=new Set;for(let _ of f){if(_.sourceLayerName!==d.sourceLayer)continue;if(m.has(_.featureIndex))continue;m.add(_.featureIndex);let g=p.feature(_.featureIndex);if(!xn(d,g,c,h.coords))continue;if(up(g,u,d,l))a.push({feature:g,layer:d,tile:h.coords})}}}return a}querySourceFeatures(e={}){let n=[],i=e.sourceLayer,s=this._map?.getZoom?.()??0,o=e.filter===void 0?null:{id:"_query",type:"fill",sourceLayer:"",filter:e.filter},r=new Set;for(let a of this._decodedTiles.values()){if(!a.tile)continue;for(let[l,c]of Object.entries(a.tile.layers)){if(i&&l!==i)continue;for(let h=0;h<c.length;h++){let u=c.feature(h);if(o&&!xn(o,u,s))continue;let f=u.id;if(f!==void 0){let d=`${l}|${typeof f}|${f}`;if(r.has(d))continue;r.add(d)}n.push({feature:u,sourceLayer:l,tile:a.coords})}}}return n}_pixelRatio(){let e=typeof window<"u"?window.devicePixelRatio:1;return Math.min(2,Math.max(1,e||1))}createTile(e,n){let i=this.getTileSize(),s=this._pixelRatio(),o=document.createElement("canvas");if(o.width=Math.round(i.x*s),o.height=Math.round(i.y*s),o.style)o.style.width=`${i.x}px`,o.style.height=`${i.y}px`;o.setAttribute("role","presentation");let r=new AbortController,a={canvas:o,tile:null,coords:{x:e.x,y:e.y,z:e.z},abort:r,index:null,gl:null};this._decodedTiles.set(o,a);let l=this.options.localSource;if(l)return this._drawLocalTile(l,o,a,e,n),o;let c=this.getTileUrl(e);return this._fetchAndDraw(c,o,a,e,n).catch((h)=>{n(h,o)}),o}onAdd(e){super.onAdd(e),this._initSymbolOverlay()}onRemove(e){this._destroySymbolOverlay();for(let n of this._decodedTiles.values())n.abort.abort(),this._releaseSource(n),n.gl?.destroy();this._decodedTiles.clear();for(let n of this._sourcePending.values())n.abort.abort();this._sourcePending.clear(),this._sourceCache.clear(),super.onRemove(e)}_removeTile(e){let n=this._tiles?.[e];if(n){let i=this._decodedTiles.get(n.el);if(i)i.abort.abort(),this._releaseSource(i),i.gl?.destroy(),this._decodedTiles.delete(n.el)}super._removeTile(e),this._refreshSymbols()}getTileUrl(e){let n=this._subTile(e),i=Object.create(this.options);return i.s=Xd(n,this.options.subdomains??"abc"),i.x=n.x,i.y=n.y,i.z=this._getZoomForUrl(n.z),i.r="",Jd(this.options.url??"",i)}_subTile(e){let n=this.options.sourceMaxZoom;if(n===void 0||e.z<=n)return{x:e.x,y:e.y,z:e.z,f:1,sx:0,sy:0};let i=2**(e.z-n),s=Math.floor(e.x/i),o=Math.floor(e.y/i);return{x:s,y:o,z:n,f:i,sx:e.x-s*i,sy:e.y-o*i}}_getZoomForUrl(e){let n=this.getTileSize().x,i=256,s=n>0?Math.round(Math.log2(256/n)):0;return e+s+(this.options.zoomOffset??0)}_initSymbolOverlay(){if(this._symbolOverlay||!this._map)return;this._symbolOverlay=new lc(this._map,{drawSymbols:(n,i)=>this._drawSymbols(n,i),createCollisionIndex:()=>new ec});let e=()=>this._symbolOverlay?.schedule();this._symbolHandlers={moveend:e,zoomend:e,rotate:e,rotateend:e,pitchend:e,resize:e,load:e,viewreset:e};for(let[n,i]of Object.entries(this._symbolHandlers))this._map.on(n,i)}_destroySymbolOverlay(){if(this._symbolHandlers&&this._map)for(let[e,n]of Object.entries(this._symbolHandlers))this._map.off(e,n);this._symbolHandlers=void 0,this._symbolOverlay?.remove(),this._symbolOverlay=void 0}_refreshSymbols(){this._symbolOverlay?.schedule()}_projectTilePoint(e,n,i){let s=this._map;if(!s)return null;let o=this.getTileSize().x,r=s.unproject([e.x*o+n,e.y*o+i],e.z),a=s.latLngToContainerPoint(r);return{x:a.x,y:a.y}}_drawSymbols(e,n){let i=this._map;if(!i)return;let s=i.getZoom?.()??0,o=this._sourceId??"",r=this._featureStateLookup,a=this.getTileSize().x;for(let l of this._styleLayers){if(l.type!=="symbol")continue;if(l.layout?.visibility==="none")continue;if(l.minzoom!==void 0&&s<l.minzoom)continue;if(l.maxzoom!==void 0&&s>l.maxzoom)continue;for(let c of this._decodedTiles.values()){let h=c.tile;if(!h)continue;let u=h.layers[l.sourceLayer];if(!u)continue;let f=c.coords,d=this._subTile(f),p=a*d.f/(u.extent||4096),m=-d.sx*a,_=-d.sy*a,g=(b,y)=>this._projectTilePoint(f,b*p+m,y*p+_);for(let b=0;b<u.length;b++){let y=u.feature(b);if(!xn(l,y,s,f))continue;let w;if(r&&y.id!==void 0)w=r(o,l.sourceLayer,y.id);rp(e,y.loadGeometry(),l,y,s,w,this.getGlyphAtlas(),this._iconAtlas,n,g,this._glyphProvider())}}}}_drawLocalTile(e,n,i,s,o){let r;try{r=e.getTile(s.z,s.x,s.y)}catch(a){o(a,n);return}if(!r){o(null,n);return}i.tile=r,i.index=Aa(r);try{this._drawTile(n,r,s)}catch(a){o(a,n);return}o(null,n)}_glyphProvider(){let e=this._map,n=e?.getGlyphSource?.();if(!n)return;let i=this._glyphs;if(i!==void 0&&i.source===n)return i.provider;let{GlyphProvider:s}=(tp(),ut(fc)),o=new s({source:n,isFontAvailable:(r)=>e.isFontAvailable?.(r)??!0,onLoad:()=>this._refreshSymbols()});return this._glyphs={source:n,provider:o},o}_abortLoading(){let e=new Set;for(let n of Object.keys(this._tiles??{})){let i=this._tiles[n];if(i?.current&&i.coords)e.add(this._sourceKey(i.coords))}for(let[n,i]of[...this._sourcePending.entries()]){if(e.has(n))continue;i.abort.abort(),this._sourcePending.delete(n)}}_sourceKey(e){let n=this._subTile(e);return`${n.z}/${n.x}/${n.y}`}async _acquireSource(e,n,i){let s=this._sourceCache.get(e);if(s)return s.refs+=1,i.sourceKey=e,{tile:s.tile,index:s.index};let o=this._sourcePending.get(e);if(o)return o.refs+=1,i.sourceKey=e,i.sourcePending=!0,o.promise;let r=new AbortController,a={refs:1,abort:r,promise:(async()=>{let l=await this._fetchTileBytes(n,{abort:r}),c=await this._decode(l),h={tile:c,index:Aa(c)},u=this._sourcePending.get(e)?.refs??1;return this._sourcePending.delete(e),this._sourceCache.set(e,{...h,refs:u}),h})()};return this._sourcePending.set(e,a),i.sourceKey=e,i.sourcePending=!0,a.promise.catch(()=>this._sourcePending.delete(e)),a.promise}async _decode(e){let n=this._workerPool();if(n)try{return new Xl(await n.run({type:"mvt-decode",payload:e}))}catch(i){this._workersUsable=!1,console.warn("[ts-maps] worker decode failed; falling back to the main thread.",i)}return new Ql(new Fo(e))}_workerPool(){if(this._workersUsable===!1)return null;let e=this.options?.workers;if(e===!1)return null;let n=ep(typeof e==="number"?e:void 0);return n.size()>0?n:null}_releaseSource(e){let n=e.sourceKey;if(!n)return;e.sourceKey=void 0;let i=this._sourceCache.get(n);if(i){if(i.refs-=1,i.refs<=0)this._sourceCache.delete(n);return}let s=this._sourcePending.get(n);if(s){if(s.refs-=1,s.refs<=0)s.abort.abort(),this._sourcePending.delete(n)}}async _fetchAndDraw(e,n,i,s,o){let r;try{r=await this._acquireSource(this._sourceKey(s),e,i)}catch(a){o(a,n);return}if(i.abort.signal.aborted){this._releaseSource(i),o(new DOMException("aborted","AbortError"),n);return}i.tile=r.tile,i.index=r.index;try{this._drawTile(n,r.tile,s)}catch(a){o(a,n);return}this._refreshSymbols(),o(null,n)}async _fetchTileBytes(e,n){if(this._offlineCache)return(await lo(e,{cache:this._offlineCache,signal:n.abort.signal})).data;let i={signal:n.abort.signal};if(this.options.crossOrigin===!0)i.credentials="same-origin";else if(typeof this.options.crossOrigin==="string")i.credentials="include";let s=await fetch(e,i);if(!s.ok)throw Error(`HTTP ${s.status} fetching ${e}`);return new Uint8Array(await s.arrayBuffer())}_drawTile(e,n,i){let s=this.getTileSize().x,o=this._subTile(i),r=this._map?.getZoom?.()??i.z,a=this._sourceId??"",l=this._featureStateLookup,c=this.options.renderer==="webgl",h=this._decodedTiles.get(e),u=h?.gl??null;if(c&&h&&!u)try{u=new Co(e),h.gl=u;let d=ka(o.sx*s,(o.sx+1)*s,(o.sy+1)*s,o.sy*s,-1,1);u.setProjectionMatrix(d)}catch(d){if(u=null,d instanceof Eo){if(!this._webglFallbackWarned)this._webglFallbackWarned=!0,console.warn("[ts-maps] WebGL2 unavailable; VectorTileMapLayer falling back to Canvas2D.")}else if(!this._webglFallbackWarned)this._webglFallbackWarned=!0,console.warn("[ts-maps] WebGL initialization failed; falling back to Canvas2D.",d)}let f=u?null:e.getContext("2d");if(!u&&!f)return;if(u)u.clear();else if(f){let d=this._pixelRatio();f.setTransform(d,0,0,d,-o.sx*s*d,-o.sy*s*d)}for(let d of this._styleLayers){if(d.layout?.visibility==="none")continue;if(d.minzoom!==void 0&&r<d.minzoom)continue;if(d.maxzoom!==void 0&&r>d.maxzoom)continue;let p=n.layers[d.sourceLayer];if(!p)continue;let m=d.paint,_=m&&m["line-dasharray"]?U(m["line-dasharray"],r,void 0,void 0):void 0,g=null;if(d.type==="line"&&m&&m["line-gradient"]!==void 0)try{g=ke(m["line-gradient"],"color")}catch{g=null}for(let b=0;b<p.length;b++){let y=p.feature(b);if(!xn(d,y,r,i))continue;let w=y.loadGeometry(),T=s*o.f/y.extent,L;if(l&&y.id!==void 0)L=l(a,d.sourceLayer,y.id);if(d.type==="fill"){if(u)fp(u,w,T,m,r,y,L);else if(f)Ma(f,w,T,m,r,y,L)}else if(d.type==="fill-extrusion"){if(u)dp(u,w,T,m,r,y,L);else if(f)Ma(f,w,T,m,r,y,L)}else if(d.type==="line"){if(u)pp(u,w,T,m,r,y,L);else if(f)sp(f,w,T,m,r,y,L,_,g)}else if(d.type==="circle"){if(u)mp(u,w,T,m,r,y,L);else if(f)op(f,w,T,m,r,y,L)}}}if(u&&this._map){let d=ka(0,s,s,0,-1,1),p=this._map;if(typeof p._drawTerrainForTile==="function")p._drawTerrainForTile(u,i,s,d);if(typeof p._invokeCustomLayerRender==="function")p._invokeCustomLayerRender(u.ctx.gl,d)}}},jn.setDefaultOptions({url:"",tileSize:512,subdomains:"abc",minZoom:0,maxZoom:22,crossOrigin:!1,layers:[],sources:void 0,localSource:void 0,zoomOffset:0,workers:!0}),_c=[0,0.25,0.5,0.75,1],gc=new Set(["all","any","none","has","!has","in","!in","==","!=","<","<=",">",">="])}),yc={};tt(yc,{HillshadeLayer:()=>bc,RasterDEMLayer:()=>Ci,decodeMapboxRGB:()=>po,decodeTerrariumRGB:()=>mo});function Ea(t){if(t.startsWith("#")){let e=t.slice(1);if(e.length===3)return[Number.parseInt(e[0]+e[0],16),Number.parseInt(e[1]+e[1],16),Number.parseInt(e[2]+e[2],16)];return[Number.parseInt(e.slice(0,2),16),Number.parseInt(e.slice(2,4),16),Number.parseInt(e.slice(4,6),16)]}if(t==="white"||t==="#fff")return[255,255,255];if(t==="black"||t==="#000")return[0,0,0];return[255,255,255]}var Ci,bc,wc=P(()=>{H(),qi(),Ci=class extends $e{initialize(e,n){super.initialize(e,{tileSize:512,crossOrigin:!0,...n}),this._encoding=n?.encoding??"mapbox"}createTile(e,n){let i=document.createElement("canvas"),s=this.options.tileSize;if(i.width=s,i.height=s,i.style)i.style.width=`${s}px`,i.style.height=`${s}px`;let o=new Image;if(this.options.crossOrigin||this.options.crossOrigin==="")o.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;return k(o,"load",()=>{try{this._shadeInto(o,i),n(null,i)}catch(r){n(r,i)}}),k(o,"error",(r)=>n(r,i)),o.src=this.getTileUrl(e),i}_shadeInto(e,n){let i=n.width,s=n.getContext("2d");if(!s)return;let o=document.createElement("canvas");o.width=i,o.height=i;let r=o.getContext("2d");if(!r)return;r.drawImage(e,0,0,i,i);let a=r.getImageData(0,0,i,i),l=new Float32Array(i*i),c=a.data,h=this._encoding==="terrarium"?mo:po;for(let E=0,V=0;E<l.length;E++,V+=4)l[E]=h(c[V],c[V+1],c[V+2]);let u=this.options.azimuth??335,f=this.options.altitude??45,d=this.options.exaggeration??0.5,p=u*Math.PI/180,m=f*Math.PI/180,_=Math.sin(p)*Math.cos(m),g=-Math.cos(p)*Math.cos(m),b=Math.sin(m),[y,w,T]=Ea(this.options.accentColor??"#ffffff"),[L,C,D]=Ea(this.options.shadowColor??"#000000"),W=this.options.opacity??1,J=s.createImageData(i,i),gt=J.data;for(let E=0;E<i;E++){let V=Math.max(0,E-1),Lt=Math.min(i-1,E+1);for(let O=0;O<i;O++){let nt=Math.max(0,O-1),ot=Math.min(i-1,O+1),xt=(l[E*i+ot]-l[E*i+nt])*0.5*d,yt=(l[Lt*i+O]-l[V*i+O])*0.5*d,bt=Math.hypot(xt,yt,1),rt=-xt/bt,oe=-yt/bt,Le=1/bt,St=Math.max(0,rt*_+oe*g+Le*b),Jt=St*y+(1-St)*L,Qt=St*w+(1-St)*C,Bt=St*T+(1-St)*D,Tt=(E*i+O)*4;gt[Tt]=Jt,gt[Tt+1]=Qt,gt[Tt+2]=Bt,gt[Tt+3]=Math.round(255*W)}}s.putImageData(J,0,0)}},bc=Ci}),vc={};tt(vc,{GeoJSONTileSource:()=>xc,clusterTileSource:()=>wp});class Zo{constructor(t,e){this.type=t.type,this.id=t.id,this.properties=t.properties,this.extent=ze,this._rings=e}loadGeometry(){return this._rings}bbox(){let t=1/0,e=1/0,n=-1/0,i=-1/0;for(let s of this._rings)for(let o of s){if(o.x<t)t=o.x;if(o.y<e)e=o.y;if(o.x>n)n=o.x;if(o.y>i)i=o.y}if(t===1/0)return[0,0,0,0];return[t,e,n,i]}}class Bo{constructor(t,e){this.name=t,this.extent=ze,this.length=e.length,this._features=e}feature(t){return this._features[t]}}function Xe(t,e){let n=t/360+0.5,i=Math.sin(e*Math.PI/180),s=0.5-0.25*Math.log((1+i)/(1-i))/Math.PI;return{x:n,y:s<0?0:s>1?1:s}}function gp(t){let e=t?.type,n=t?.coordinates;if(!e||!n)return[];switch(e){case"Point":return[[Xe(n[0],n[1])]];case"MultiPoint":return n.map((i)=>[Xe(i[0],i[1])]);case"LineString":return[n.map((i)=>Xe(i[0],i[1]))];case"MultiLineString":case"Polygon":return n.map((i)=>i.map((s)=>Xe(s[0],s[1])));case"MultiPolygon":return n.flatMap((i)=>i.map((s)=>s.map((o)=>Xe(o[0],o[1]))));default:return[]}}function di(t,e,n){let i=[];for(let s=0;s<t.length;s++){let o=t[s],r=t[(s+t.length-1)%t.length],a=e(o),l=e(r);if(a){if(!l)i.push(n(r,o));i.push(o)}else if(l)i.push(n(r,o))}return i}function yp(t,e,n,i,s){let o=t,r=(a,l,c)=>({x:a.x+(l.x-a.x)*c,y:a.y+(l.y-a.y)*c});if(o=di(o,(a)=>a.x>=e,(a,l)=>r(a,l,(e-a.x)/(l.x-a.x))),!o.length)return o;if(o=di(o,(a)=>a.x<=i,(a,l)=>r(a,l,(i-a.x)/(l.x-a.x))),!o.length)return o;if(o=di(o,(a)=>a.y>=n,(a,l)=>r(a,l,(n-a.y)/(l.y-a.y))),!o.length)return o;return o=di(o,(a)=>a.y<=s,(a,l)=>r(a,l,(s-a.y)/(l.y-a.y))),o}function bp(t,e,n,i,s){let o=[],r=[];for(let a=0;a<t.length-1;a++){let l=t[a],c=t[a+1],h=c.x-l.x,u=c.y-l.y,f=0,d=1,p=!0;for(let[g,b]of[[-h,l.x-e],[h,i-l.x],[-u,l.y-n],[u,s-l.y]]){if(g===0){if(b<0){p=!1;break}continue}let y=b/g;if(g<0){if(y>d){p=!1;break}if(y>f)f=y}else{if(y<f){p=!1;break}if(y<d)d=y}}if(!p){if(r.length>1)o.push(r);r=[];continue}let m={x:l.x+h*f,y:l.y+u*f},_={x:l.x+h*d,y:l.y+u*d};if(!r.length)r.push(m);else if(f>0){if(r.length>1)o.push(r);r=[m]}if(r.push(_),d<1){if(r.length>1)o.push(r);r=[]}}if(r.length>1)o.push(r);return o}class xc{constructor(t,e={}){if(this._layerName=e.layerName??"geojson",this._buffer=e.buffer??64,this._features=[],t)this.setData(t)}setData(t){this._features=[];let e=t,n=e?.type==="FeatureCollection"?e.features??[]:e?.type==="Feature"?[e]:Array.isArray(e)?e:[];for(let i of n){let s=i?.geometry??i,o=Sc[s?.type];if(!o)continue;let r=gp(s);if(!r.length)continue;let a=1/0,l=1/0,c=-1/0,h=-1/0;for(let u of r)for(let f of u){if(f.x<a)a=f.x;if(f.y<l)l=f.y;if(f.x>c)c=f.x;if(f.y>h)h=f.y}this._features.push({type:o,id:i?.id,properties:i?.properties??{},rings:r,bbox:[a,l,c,h]})}return this}get length(){return this._features.length}getTile(t,e,n){let i=2**t,s=this._buffer/ze,o=(e-s)/i,r=(e+1+s)/i,a=(n-s)/i,l=(n+1+s)/i,c=(u)=>({x:Math.round((u.x*i-e)*ze),y:Math.round((u.y*i-n)*ze)}),h=[];for(let u of this._features){let[f,d,p,m]=u.bbox;if(p<o||f>r||m<a||d>l)continue;let _;if(u.type===1)_=u.rings.map((g)=>g.filter((b)=>b.x>=o&&b.x<=r&&b.y>=a&&b.y<=l)).filter((g)=>g.length>0);else if(u.type===2)_=u.rings.flatMap((g)=>bp(g,o,a,r,l));else _=u.rings.map((g)=>yp(g,o,a,r,l)).filter((g)=>g.length>=3);if(!_.length)continue;h.push(new Zo(u,_.map((g)=>g.map(c))))}if(!h.length)return null;return{layers:{[this._layerName]:new Bo(this._layerName,h)}}}}function wp(t,e="geojson"){return{getTile(n,i,s){let o=t.getTile(n,i,s);if(!o?.features?.length)return null;let r=2**n,a=o.features.map((l)=>{let[c,h]=l.geometry.coordinates,u=Xe(c,h),f={x:Math.round((u.x*r-i)*ze),y:Math.round((u.y*r-s)*ze)};return new Zo({type:1,id:l.id,properties:l.properties,rings:[],bbox:[0,0,0,0]},[[f]])});return{layers:{[e]:new Bo(e,a)}}}}}var ze=4096,Sc,Tc=P(()=>{Sc={Point:1,MultiPoint:1,LineString:2,MultiLineString:2,Polygon:3,MultiPolygon:3}}),Pc={};tt(Pc,{GeoJSONClusterSource:()=>Mc,KDBush:()=>Do});class Do{nodeSize;points;ids;constructor(t,e=64){this.nodeSize=e,this.points=new Float64Array(t*2),this.ids=new Uint32Array(t),this._count=0,this._finished=!1}_count;_finished;add(t,e){let n=this._count;return this.ids[n]=n,this.points[n*2]=t,this.points[n*2+1]=e,this._count++,n}finish(){if(this._finished)return this;return to(this.ids,this.points,this.nodeSize,0,this.ids.length-1,0),this._finished=!0,this}range(t,e,n,i){let s=[];if(this.ids.length===0)return s;return eo(this.ids,this.points,t,e,n,i,0,this.ids.length-1,0,this.nodeSize,s),s}within(t,e,n){let i=[];if(this.ids.length===0)return i;return no(this.ids,this.points,t,e,n,0,this.ids.length-1,0,this.nodeSize,i),i}}function to(t,e,n,i,s,o){if(s-i<=n)return;let r=i+s>>1;kc(t,e,r,i,s,o),to(t,e,n,i,r-1,1-o),to(t,e,n,r+1,s,1-o)}function kc(t,e,n,i,s,o){while(s>i){if(s-i>600){let c=s-i+1,h=n-i+1,u=Math.log(c),f=0.5*Math.exp(2*u/3),d=0.5*Math.sqrt(u*f*(c-f)/c)*(h-c/2<0?-1:1),p=Math.max(i,Math.floor(n-h*f/c+d)),m=Math.min(s,Math.floor(n+(c-h)*f/c+d));kc(t,e,n,p,m,o)}let r=e[2*n+o],a=i,l=s;if(Sn(t,e,i,n),e[2*s+o]>r)Sn(t,e,i,s);while(a<l){Sn(t,e,a,l),a++,l--;while(e[2*a+o]<r)a++;while(e[2*l+o]>r)l--}if(e[2*i+o]===r)Sn(t,e,i,l);else l++,Sn(t,e,l,s);if(l<=n)i=l+1;if(n<=l)s=l-1}}function Sn(t,e,n,i){let s=t[n];t[n]=t[i],t[i]=s;let o=e[2*n],r=e[2*n+1];e[2*n]=e[2*i],e[2*n+1]=e[2*i+1],e[2*i]=o,e[2*i+1]=r}function eo(t,e,n,i,s,o,r,a,l,c,h){if(a-r<=c){for(let p=r;p<=a;p++){let m=e[2*p],_=e[2*p+1];if(m>=n&&m<=s&&_>=i&&_<=o)h.push(t[p])}return}let u=r+a>>1,f=e[2*u],d=e[2*u+1];if(f>=n&&f<=s&&d>=i&&d<=o)h.push(t[u]);if(l===0?n<=f:i<=d)eo(t,e,n,i,s,o,r,u-1,1-l,c,h);if(l===0?s>=f:o>=d)eo(t,e,n,i,s,o,u+1,a,1-l,c,h)}function no(t,e,n,i,s,o,r,a,l,c){let h=s*s;if(r-o<=l){for(let p=o;p<=r;p++)if(za(e[2*p],e[2*p+1],n,i)<=h)c.push(t[p]);return}let u=o+r>>1,f=e[2*u],d=e[2*u+1];if(za(f,d,n,i)<=h)c.push(t[u]);if(a===0?n-s<=f:i-s<=d)no(t,e,n,i,s,o,u-1,1-a,l,c);if(a===0?n+s>=f:i+s>=d)no(t,e,n,i,s,u+1,r,1-a,l,c)}function za(t,e,n,i){let s=t-n,o=e-i;return s*s+o*o}class Mc{options;_points=[];_trees=[];_clusterProps=[];_data=[];constructor(t={}){this.options={radius:t.radius??40,maxZoom:t.maxZoom??16,minZoom:t.minZoom??0,minPoints:t.minPoints??2,extent:t.extent??512,nodeSize:t.nodeSize??64,reduce:t.reduce,map:t.map,log:t.log??!1}}load(t){this._points=t,this._trees=[],this._clusterProps=[],this._data=[];let{maxZoom:e,minZoom:n}=this.options,i=new ArrayBuffer(t.length*X*8),s=new Float64Array(i);for(let r=0;r<t.length;r++){let a=t[r];if(!a.geometry)continue;let[l,c]=a.geometry.coordinates;s[r*X+0]=ys(l),s[r*X+1]=bs(c),s[r*X+jt]=1/0,s[r*X+Ye]=r,s[r*X+pi]=-1,s[r*X+de]=1,s[r*X+ws]=-1}this._data[e+1]=s,this._trees[e+1]=this._buildTree(s);let o=s;for(let r=e;r>=n;r--)o=this._cluster(o,r),this._data[r]=o,this._trees[r]=this._buildTree(o);return this}getClusters(t,e){let n=this._limitZoom(e),i=this._trees[n],s=this._data[n];if(!i||!s)return[];let o=((t[0]+180)%360+360)%360-180,r=Math.max(-90,Math.min(90,t[1])),a=t[2]===180?180:((t[2]+180)%360+360)%360-180,l=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)o=-180,a=180;else if(o>a){let u=this.getClusters([o,r,180,l],e),f=this.getClusters([-180,r,a,l],e);return u.concat(f)}let c=i.range(ys(o),bs(l),ys(a),bs(r)),h=[];for(let u of c)h.push(this._dataToFeature(s,u));return h}getChildren(t){let e=t>>5,n=t&31,i=this._data[n];if(!i)throw Error("no cluster with the specified id");let s=this.options.radius/(this.options.extent*2**(n-1)),o=this._trees[n];if(!o)return[];let r=i[e*X],a=i[e*X+1],l=o.within(r,a,s),c=[];for(let h of l)if(i[h*X+pi]===t)c.push(this._dataToFeature(i,h));if(c.length===0)throw Error("no cluster with the specified id");return c}getLeaves(t,e=10,n=0){let i=[];return this._appendLeaves(i,t,e,n,0),i}getClusterExpansionZoom(t){let e=(t&31)-1;while(e<=this.options.maxZoom){let n=this.getChildren(t);if(e++,n.length!==1)break;t=n[0].properties.cluster_id}return e}getTile(t,e,n){let i=this._data[this._limitZoom(t)],s=this._trees[this._limitZoom(t)];if(!i||!s)return null;let o=2**t,r=this.options.radius/this.options.extent,a=(n-r)/o,l=(n+1+r)/o,c={features:[]};if(this._addTileFeatures(s.range((e-r)/o,a,(e+1+r)/o,l),i,e,n,o,c),e===0)this._addTileFeatures(s.range(1-r/o,a,1,l),i,o,n,o,c);if(e===o-1)this._addTileFeatures(s.range(0,a,r/o,l),i,-1,n,o,c);return c.features.length>0?c:null}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(t),this.options.maxZoom+1))}_buildTree(t){let e=t.length/X,n=new Do(e,this.options.nodeSize);for(let i=0;i<e;i++)n.add(t[i*X],t[i*X+1]);return n.finish(),n}_cluster(t,e){let{radius:n,extent:i,reduce:s,minPoints:o}=this.options,r=n/(i*2**e),a=this._trees[e+1],l=[];for(let u=0;u<t.length;u+=X){if(t[u+jt]<=e)continue;t[u+jt]=e;let f=t[u],d=t[u+1],p=a.within(f,d,r),m=t[u+de],_=m;for(let g of p){let b=g*X;if(t[b+jt]>e)_+=t[b+de]}if(_>m&&_>=o){let g=f*m,b=d*m,y,w=-1,T=(u/X<<5)+(e+1);for(let L of p){let C=L*X;if(t[C+jt]<=e)continue;t[C+jt]=e;let D=t[C+de];if(g+=t[C]*D,b+=t[C+1]*D,t[C+pi]=T,s){if(!y)y=this._mapForCluster(u,t);let W=this._mapForCluster(C,t);s(y,W)}}if(t[u+pi]=T,y)w=this._clusterProps.length,this._clusterProps.push(y);l.push(g/_,b/_,1/0,T,-1,_,w)}else{for(let g=0;g<X;g++)l.push(t[u+g]);if(l[l.length-X+jt]=1/0,_>1)for(let g of p){let b=g*X;if(t[b+jt]<=e)continue;t[b+jt]=e;for(let y=0;y<X;y++)l.push(t[b+y]);l[l.length-X+jt]=1/0}}}let c=new ArrayBuffer(l.length*8),h=new Float64Array(c);for(let u=0;u<l.length;u++)h[u]=l[u];return h}_mapForCluster(t,e){let n=e[t+de],i=e[t+ws];if(n>1&&i>=0)return{...this._clusterProps[i]};let s=this._points[e[t+Ye]];if(this.options.map&&s)return this.options.map({...s.properties??{}});return{...s?.properties??{}}}_addTileFeatures(t,e,n,i,s,o){for(let r of t){let a=r*X,l=e[a+de]>1,c=(e[a]*s-n)*this.options.extent,h=(e[a+1]*s-i)*this.options.extent;o.features.push({type:"Feature",geometry:{type:"Point",coordinates:[c,h]},properties:l?this._getClusterProperties(e,a,e[a+Ye]):{...this._points[e[a+Ye]]?.properties??{}}})}}_dataToFeature(t,e){let n=e*X,i=t[n+de]>1,s=vp(t[n]),o=xp(t[n+1]);if(i)return{type:"Feature",geometry:{type:"Point",coordinates:[s,o]},properties:this._getClusterProperties(t,n,t[n+Ye])};let r=this._points[t[n+Ye]];return{type:"Feature",geometry:{type:"Point",coordinates:[s,o]},properties:{...r.properties??{}},id:r.id}}_getClusterProperties(t,e,n){let i=t[e+ws],s=t[e+de],o={cluster:!0,cluster_id:n,point_count:s,point_count_abbreviated:s>=1e4?`${Math.round(s/1000)}k`:s>=1000?`${(s/1000).toFixed(1)}k`:s};if(i>=0){let r=this._clusterProps[i];if(r)Object.assign(o,r)}return o}_appendLeaves(t,e,n,i,s){let o=this.getChildren(e);for(let r of o){let a=r.properties;if(a&&a.cluster)s=this._appendLeaves(t,a.cluster_id,n,i,s);else if(s<i)s++;else if(t.length<n)t.push(r);if(t.length===n)break}return s}}function ys(t){return t/360+0.5}function bs(t){let e=Math.sin(t*Math.PI/180),n=0.5-0.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function vp(t){return(t-0.5)*360}function xp(t){let e=(180-t*360)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}var jt=2,Ye=3,pi=4,de=5,ws=6,X=7,Lc={};tt(Lc,{HeatmapLayer:()=>Ii});var Ca,Ii,Ac=P(()=>{N(),Mt(),Ca={0.4:"blue",0.6:"cyan",0.7:"lime",0.8:"yellow",1:"red"},Ii=class extends mt{initialize(e){et(this,e),this._data=e?.data?[...e.data]:[],this._redrawScheduled=!1}setData(e){return this._data=[...e],this.redraw()}addPoint(e){return this._data.push(e),this.redraw()}clearData(){return this._data=[],this.redraw()}setOptions(e){if(et(this,e),e.gradient)this._gradientTexture=void 0;if(e.data)this._data=[...e.data];return this.redraw()}redraw(){if(!this._map||this._redrawScheduled)return this;if(this._redrawScheduled=!0,typeof requestAnimationFrame==="function")requestAnimationFrame(()=>this._draw());else this._draw();return this}onAdd(e){if(!this._canvas){let n=this._canvas=document.createElement("canvas");if(n.className="tsmap-heatmap-canvas tsmap-zoom-animated",n.style)n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.pointerEvents="none";this._ctx=n.getContext("2d")??void 0}this.getPane().appendChild(this._canvas),this._resize(),this._draw()}onRemove(e){this._canvas?.remove()}getEvents(){return{viewreset:this._resize,resize:this._resize,moveend:this._draw,zoomend:this._draw}}_resize(){if(!this._canvas||!this._map)return;let e=this._map.getSize();if(this._canvas.width=e.x,this._canvas.height=e.y,this._canvas.style)this._canvas.style.width=`${e.x}px`,this._canvas.style.height=`${e.y}px`;this._draw()}_draw(){if(this._redrawScheduled=!1,!this._map||!this._ctx||!this._canvas)return;let e=this._ctx,n=this._canvas;if(e.clearRect(0,0,n.width,n.height),!this._data.length)return;let i=this.options,s=i.radius??25,o=i.blur??15,r=i.minOpacity??0.05,a=i.max??1,l=this._map._getMapPanePos(),c=document.createElement("canvas");c.width=n.width,c.height=n.height;let h=c.getContext("2d");if(!h)return;let u=s+o,f=this._intensityBlob(u,s,o);for(let _ of this._data){let g=this._map.latLngToContainerPoint([_.lat,_.lng]),b=g.x-l.x,y=g.y-l.y,w=Math.max(0,Math.min((_.weight??1)/a,1));if(w<=0)continue;h.globalAlpha=Math.max(r,w),h.drawImage(f,b-u,y-u)}h.globalAlpha=1;let d=h.getImageData(0,0,n.width,n.height),p=d.data,m=this._colourRamp();for(let _=0;_<p.length;_+=4){let g=p[_+3];if(g===0)continue;let b=g*4;p[_]=m[b],p[_+1]=m[b+1],p[_+2]=m[b+2]}e.putImageData(d,0,0)}_intensityBlob(e,n,i){let s=e*2,o=document.createElement("canvas");o.width=s,o.height=s;let r=o.getContext("2d");if(!r)return o;let a=r.createRadialGradient(e,e,0,e,e,e),l=n/e;return a.addColorStop(0,"rgba(0,0,0,1)"),a.addColorStop(Math.min(1,l),`rgba(0,0,0,${Math.max(0.2,1-i/(n+i))})`),a.addColorStop(1,"rgba(0,0,0,0)"),r.fillStyle=a,r.fillRect(0,0,s,s),o}_colourRamp(){if(this._gradientTexture)return this._gradientTexture;let e=this.options?.gradient??Ca,n=document.createElement("canvas");n.width=1,n.height=256;let i=n.getContext("2d");if(!i)return this._gradientTexture=new Uint8ClampedArray(1024),this._gradientTexture;let s=i.createLinearGradient(0,0,0,256);for(let[o,r]of Object.entries(e))s.addColorStop(Number(o),r);return i.fillStyle=s,i.fillRect(0,0,1,256),this._gradientTexture=i.getImageData(0,0,1,256).data,this._gradientTexture}},Ii.setDefaultOptions({radius:25,blur:15,max:1,minOpacity:0.05,pane:"overlayPane"})}),Si={};tt(Si,{heatmapGradient:()=>Sp,heatmapPoints:()=>Tp,heatmapWeightKey:()=>Pp});function Sp(t,e=8){if(t===void 0||t===null)return;if(typeof t==="string")return{0:t,1:t};if(!Yn(t))return;let n;try{n=ke(t,"value",[])}catch{return}let i={};for(let s=0;s<=e;s++){let o=s/e;try{let r=n.evaluate({zoom:0,heatmapDensity:o});if(typeof r==="string")i[o]=r}catch{}}return Object.keys(i).length>1?i:void 0}function Tp(t,e){let n=t?.type==="FeatureCollection"?t.features??[]:Array.isArray(t)?t:t?[t]:[],i=[];for(let s of n){let o=s?.geometry??s;if(!o)continue;let r=e?Number(s?.properties?.[e]):void 0;if(o.type==="Point"&&Array.isArray(o.coordinates))i.push({lng:o.coordinates[0],lat:o.coordinates[1],weight:Number.isFinite(r)?r:void 0});else if(o.type==="MultiPoint"&&Array.isArray(o.coordinates))for(let a of o.coordinates)i.push({lng:a[0],lat:a[1],weight:Number.isFinite(r)?r:void 0})}return i}function Pp(t){if(Array.isArray(t)&&t[0]==="get"&&typeof t[1]==="string")return t[1];return}var vs=P(()=>{Wi()});function Oc(t,e){return new F(t,e)}async function kp(t,e){if(typeof fetch!=="function"||typeof Image!=="function"||typeof document?.createElement!=="function")return null;try{let n=await fetch(t);if(!n.ok)return null;let i=await n.blob(),s=await new Promise((l,c)=>{let h=new Image;h.crossOrigin="anonymous",h.onload=()=>l(h),h.onerror=c,h.src=URL.createObjectURL(i)}),o=document.createElement("canvas");o.width=e,o.height=e;let r=o.getContext("2d");if(!r)return null;r.drawImage(s,0,0,e,e);let a=r.getImageData(0,0,e,e).data;return new Uint8Array(a.buffer,a.byteOffset,a.byteLength)}catch{return null}}var mi=24,F,Mp,st=P(()=>{Te(),N(),H(),De(),Y(),Pe(),wl(),vl(),Qa(),_t(),vt(),ct(),G(),Af(),$i(),Ka(),Ja(),Io(),F=class t extends wt{static _pointerEvents=["click","dblclick","pointerover","pointerout","contextmenu"];_sizeChanged=!0;_initControlPos;_clearControlPos;_addLayers;initialize(e,n){if(n=et(this,n),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._bearing=typeof n.bearing==="number"?(n.bearing%360+360)%360:0,this._pitch=typeof n.pitch==="number"?this._clampPitch(n.pitch):0,this._initContainer(e),this._initLayout(),this._initEvents(),this._wireTerrainCameraHooks(),n.maxBounds)this.setMaxBounds(n.maxBounds);if(n.zoom!==void 0)this._zoom=this._limitZoom(n.zoom);if(n.center&&n.zoom!==void 0)this.setView(new S(n.center),n.zoom,{reset:!0});if(this._bearing||this._pitch)this._applyCameraTransform();if(this.callInitHooks(),this._zoomAnimated=this.options.zoomAnimation,this._zoomAnimated)this._createAnimProxy();if(this._addLayers?.(this.options.layers),n.style!==void 0)this.setStyle(n.style)}setView(e,n,i){if(n=n===void 0?this._zoom:this._limitZoom(n),e=this._limitCenter(new S(e),n,this.options.maxBounds),i??={},this._stop(),this._loaded&&!i.reset&&i!==!0){if(i.animate!==void 0)i.zoom={animate:i.animate,...i.zoom},i.pan={animate:i.animate,duration:i.duration,...i.pan};if(this._zoom!==n?this._tryAnimatedZoom&&this._tryAnimatedZoom(e,n,i.zoom):this._tryAnimatedPan(e,i.pan))return clearTimeout(this._sizeTimer),this}return this._resetView(e,n,i.pan?.noMoveStart),this}setZoom(e,n){if(!this._loaded)return this._zoom=e,this;return this.setView(this.getCenter(),e,{zoom:n})}zoomIn(e,n){return e??=this.options.zoomDelta,this.setZoom(this._zoom+e,n)}zoomOut(e,n){return e??=this.options.zoomDelta,this.setZoom(this._zoom-e,n)}setZoomAround(e,n,i){let s=this.getZoomScale(n),o=this.getSize().divideBy(2),a=(e instanceof v?e:this.latLngToContainerPoint(e)).subtract(o).multiplyBy(1-1/s),l=this.containerPointToLatLng(o.add(a));return this.setView(l,n,{zoom:i})}_getBoundsCenterZoom(e,n){n??={},e=e.getBounds?e.getBounds():new R(e);let i=new v(n.paddingTopLeft||n.padding||[0,0]),s=new v(n.paddingBottomRight||n.padding||[0,0]),o=this.getBoundsZoom(e,!1,i.add(s));if(o=typeof n.maxZoom==="number"?Math.min(n.maxZoom,o):o,o===1/0)return{center:e.getCenter(),zoom:o};let r=s.subtract(i).divideBy(2),a=this.project(e.getSouthWest(),o),l=this.project(e.getNorthEast(),o);return{center:this.unproject(a.add(l).divideBy(2).add(r),o),zoom:o}}fitBounds(e,n){let i=new R(e);if(!i.isValid())throw Error("Bounds are not valid.");let s=this._getBoundsCenterZoom(i,n);return this.setView(s.center,s.zoom,n)}fitWorld(e){return this.fitBounds([[-90,-180],[90,180]],e)}panTo(e,n){return this.setView(e,this._zoom,{pan:n})}panBy(e,n){if(e=new v(e).round(),n??={},!e.x&&!e.y)return this.fire("moveend");if(n.animate!==!0&&!this.getSize().contains(e))return this._resetView(this.unproject(this.project(this.getCenter()).add(e)),this.getZoom()),this;if(!this._panAnim)this._panAnim=new ko,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this);if(!n.noMoveStart)this.fire("movestart");if(n.animate!==!1){this._mapPane.classList.add("tsmap-pan-anim");let i=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,i,n.duration||0.25,n.easeLinearity)}else this._rawPanBy(e),this.fire("move").fire("moveend");return this}flyTo(e,n,i){if(i??={},i.animate===!1)return this.setView(e,n,i);this._stop();let s=this.project(this.getCenter()),o=this.project(e),r=this.getSize(),a=this._zoom,l=this._bearing,c=this._pitch;e=new S(e);let h=n===void 0?a:this._limitZoom(n),u=typeof i.bearing==="number"?(i.bearing%360+360)%360:l,f=typeof i.pitch==="number"?this._clampPitch(i.pitch):c,d=Math.max(r.x,r.y),p=d*this.getZoomScale(a,h),m=o.distanceTo(s)||1,_=1.42,g=_*_;function b(O){let nt=O?-1:1,ot=O?p:d,xt=p*p-d*d+nt*g*g*m*m,yt=2*ot*g*m,bt=xt/yt,rt=Math.sqrt(bt*bt+1)-bt;return rt<0.000000015?-18:Math.log(rt)}function y(O){return(Math.exp(O)-Math.exp(-O))/2}function w(O){return(Math.exp(O)+Math.exp(-O))/2}function T(O){return y(O)/w(O)}let L=b(0);function C(O){return d*(w(L)/w(L+_*O))}function D(O){return d*(w(L)*T(L+_*O)-y(L))/g}let W=(b(1)-L)/_,J=i.duration?i.duration:1000*W*0.8,gt=this._getCamAnim(),E=Math.abs((u-l+540)%360-180)>0.000001,V=Math.abs(f-c)>0.000001,Lt=Math.abs(h-a)>0.000001;if(this._moveStart(!0,i.noMoveStart),E)this.fire("rotatestart",{bearing:l});if(V)this.fire("pitchstart",{pitch:c});return gt.run({duration:J,easing:(O)=>1-(1-O)**1.5,onFrame:({t:O})=>{let nt=O*W,ot=this.unproject(s.add(o.subtract(s).multiplyBy(D(nt)/m)),a),xt=this.getScaleZoom(d/C(nt),a);if(E)this._bearing=t._lerpBearing(l,u,O);if(V)this._pitch=c+(f-c)*O;if(this._move(ot,xt,{flyTo:!0}),E||V)this._applyCameraTransform();if(E)this.fire("rotate",{bearing:this._bearing});if(V)this.fire("pitch",{pitch:this._pitch})},onEnd:(O)=>{if(O){if(E)this._bearing=u;if(V)this._pitch=f;if(this._move(e,h),E||V)this._applyCameraTransform();if(this._moveEnd(Lt),E)this.fire("rotateend",{bearing:u});if(V)this.fire("pitchend",{pitch:f})}else{if(this._moveEnd(Lt),E)this.fire("rotateend",{bearing:this._bearing});if(V)this.fire("pitchend",{pitch:this._pitch})}}}),this}flyToBounds(e,n){let i=this._getBoundsCenterZoom(e,n);return this.flyTo(i.center,i.zoom,n)}setMaxBounds(e){let n=new R(e);if(this.listens("moveend",this._panInsideMaxBounds))this.off("moveend",this._panInsideMaxBounds);if(!n.isValid())return this.options.maxBounds=null,this;if(this.options.maxBounds=n,this._loaded)this._panInsideMaxBounds();return this.on("moveend",this._panInsideMaxBounds,this)}setMinZoom(e){let n=this.options.minZoom;if(this.options.minZoom=e,this._loaded&&n!==e){if(this.fire("zoomlevelschange"),this.getZoom()<this.options.minZoom)return this.setZoom(e)}return this}setMaxZoom(e){let n=this.options.maxZoom;if(this.options.maxZoom=e,this._loaded&&n!==e){if(this.fire("zoomlevelschange"),this.getZoom()>this.options.maxZoom)return this.setZoom(e)}return this}panInsideBounds(e,n){this._enforcingBounds=!0;let i=this.getCenter(),s=this._limitCenter(i,this._zoom,new R(e));if(!i.equals(s))this.panTo(s,n);return this._enforcingBounds=!1,this}panInside(e,n){n??={};let i=new v(n.paddingTopLeft||n.padding||[0,0]),s=new v(n.paddingBottomRight||n.padding||[0,0]),o=this.project(this.getCenter()),r=this.project(e),a=this.getPixelBounds(),l=new I([a.min.add(i),a.max.subtract(s)]),c=l.getSize();if(!l.contains(r)){this._enforcingBounds=!0;let h=r.subtract(l.getCenter()),u=l.extend(r).getSize().subtract(c);o.x+=h.x<0?-u.x:u.x,o.y+=h.y<0?-u.y:u.y,this.panTo(this.unproject(o),n),this._enforcingBounds=!1}return this}invalidateSize(e){if(!this._loaded)return this;e={animate:!1,pan:!0,...e===!0?{animate:!0}:e};let n=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let i=this.getSize(),s=n.divideBy(2).round(),o=i.divideBy(2).round(),r=s.subtract(o);if(!r.x&&!r.y)return this;if(e.animate&&e.pan)this.panBy(r);else{if(e.pan)this._rawPanBy(r);if(this.fire("move"),e.debounceMoveend)clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,"moveend"),200);else this.fire("moveend")}if(this._bearing||this._pitch)this._applyCameraTransform();return this.fire("resize",{oldSize:n,newSize:i})}stop(){if(this.setZoom(this._limitZoom(this._zoom)),!this.options.zoomSnap)this.fire("viewreset");return this._stop()}locate(e){let n=this._locateOptions={timeout:1e4,watch:!1,...e};if(!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;let i=this._handleGeolocationResponse.bind(this),s=this._handleGeolocationError.bind(this);if(n.watch){if(this._locationWatchId!==void 0)navigator.geolocation.clearWatch(this._locationWatchId);this._locationWatchId=navigator.geolocation.watchPosition(i,s,n)}else navigator.geolocation.getCurrentPosition(i,s,n);return this}stopLocate(){if(navigator.geolocation?.clearWatch?.(this._locationWatchId),this._locateOptions)this._locateOptions.setView=!1;return this}_handleGeolocationError(e){if(!this._container._tsmap_id)return;let n=e.code,i=e.message||(n===1?"permission denied":n===2?"position unavailable":"timeout");if(this._locateOptions.setView&&!this._loaded)this.fitWorld();this.fire("locationerror",{code:n,message:`Geolocation error: ${i}.`})}_handleGeolocationResponse(e){if(!this._container._tsmap_id)return;let n=e.coords.latitude,i=e.coords.longitude,s=new S(n,i),o=s.toBounds(e.coords.accuracy*2),r=this._locateOptions;if(r.setView){let l=this.getBoundsZoom(o);this.setView(s,r.maxZoom?Math.min(l,r.maxZoom):l)}let a={latlng:s,bounds:o,timestamp:e.timestamp};for(let l in e.coords)if(typeof e.coords[l]==="number")a[l]=e.coords[l];this.fire("locationfound",a)}addHandler(e,n){if(!n)return this;let i=this[e]=new n(this);if(this._handlers.push(i),this.options[e])i.enable();return this}remove(){if(this._initEvents(!0),this.options.maxBounds)this.off("moveend",this._panInsideMaxBounds);if(this._containerId!==this._container._tsmap_id)throw Error("Map container is being reused by another instance");if(delete this._container._tsmap_id,delete this._containerId,this._locationWatchId!==void 0)this.stopLocate();if(this._detachThemeQuery(),this._container.classList.remove("tsmap-dark"),this._stop(),ul(this._container),this._mapPane.remove(),this._clearControlPos)this._clearControlPos();if(this._resizeRequest)cancelAnimationFrame(this._resizeRequest),this._resizeRequest=null;if(this._clearHandlers(),clearTimeout(this._transitionEndTimer),clearTimeout(this._sizeTimer),this._loaded)this.fire("unload");this._destroyAnimProxy();for(let e of Object.values(this._layers))e.remove();for(let e of Object.values(this._panes))e.remove();if(this._layers={},this._panes={},delete this._mapPane,delete this._renderer,this._destroyTerrainOverlay(),this._atmosphereOverlay&&this._atmosphereOverlay.parentNode)this._atmosphereOverlay.parentNode.removeChild(this._atmosphereOverlay);if(this._atmosphereOverlay=void 0,this._terrainSource?.clear(),this._terrainFetchInFlight?.clear(),this._offlineApi)delete this._offlineApi;return this}createPane(e,n){let i=`tsmap-pane${e?` tsmap-${e.replace("Pane","")}-pane`:""}`,s=A("div",i,n||this._mapPane);if(e)this._panes[e]=s;return s}getCenter(){if(this._checkIfLoaded(),this._lastCenter&&!this._moved())return this._lastCenter.clone();return this.layerPointToLatLng(this._getCenterLayerPoint())}getZoom(){return this._zoom}getBearing(){return this._bearing}setBearing(e){let n=(e%360+360)%360;if(n===this._bearing)return this;return this.fire("rotatestart",{bearing:this._bearing}),this._bearing=n,this._applyCameraTransform(),this.fire("rotate",{bearing:n}),this.fire("rotateend",{bearing:n}),this}rotateTo(e,n){if(!n?.animate)return this.setBearing(e);return this.easeTo({bearing:e,duration:n.duration??300,easing:n.easing})}getPitch(){return this._pitch}setPitch(e){let n=this._clampPitch(e);if(n===this._pitch)return this;if(this.fire("pitchstart",{pitch:this._pitch}),this._pitch=n,this._applyCameraTransform(),this._atmosphereOverlay)this._updateAtmosphereOverlay();return this.fire("pitch",{pitch:n}),this.fire("pitchend",{pitch:n}),this}pitchTo(e,n){if(!n?.animate)return this.setPitch(e);return this.easeTo({pitch:e,duration:n.duration??300,easing:n.easing})}_clampPitch(e){let n=this.options.minPitch??0,i=this.options.maxPitch??60;return Math.max(n,Math.min(i,e))}easeTo(e={}){this._stop();let n=this.getCenter(),i=this._zoom,s=this._bearing,o=this._pitch,r=e.center!==void 0?new S(e.center):n,a=e.zoom!==void 0?this._limitZoom(e.zoom):i,l=typeof e.bearing==="number"?(e.bearing%360+360)%360:s,c=typeof e.pitch==="number"?this._clampPitch(e.pitch):o,h=e.duration??300,u=!n.equals(r),f=Math.abs(a-i)>0.000000001,d=(l-s+540)%360-180,p=Math.abs(d)>0.000000001,m=Math.abs(c-o)>0.000000001;if(!u&&!f&&!p&&!m){if(!e.noMoveStart)this.fire("movestart");return this.fire("moveend"),this}let _=this.project(n,i),g=this.project(r,i);if(h<=0){if(!e.noMoveStart)this._moveStart(f,!1);if(p)this.fire("rotatestart",{bearing:s});if(m)this.fire("pitchstart",{pitch:o});if(this._bearing=l,this._pitch=c,this._move(r,a),p||m)this._applyCameraTransform();if(this._moveEnd(f),p)this.fire("rotate",{bearing:l}),this.fire("rotateend",{bearing:l});if(m)this.fire("pitch",{pitch:c}),this.fire("pitchend",{pitch:c});return this}let b=this._getCamAnim();if(!e.noMoveStart)this._moveStart(f,!1);if(p)this.fire("rotatestart",{bearing:s});if(m)this.fire("pitchstart",{pitch:o});return b.run({duration:h,easing:e.easing,onFrame:({t:y})=>{let w=i+(a-i)*y,T=_.add(g.subtract(_).multiplyBy(y)),L=this.unproject(T,i);if(p)this._bearing=t._lerpBearing(s,l,y);if(m)this._pitch=o+(c-o)*y;if(this._move(L,w,{easeTo:!0}),p||m)this._applyCameraTransform();if(p)this.fire("rotate",{bearing:this._bearing});if(m)this.fire("pitch",{pitch:this._pitch})},onEnd:(y)=>{if(y){if(p)this._bearing=l;if(m)this._pitch=c;if(this._move(r,a),p||m)this._applyCameraTransform();if(this._moveEnd(f),p)this.fire("rotateend",{bearing:l});if(m)this.fire("pitchend",{pitch:c})}else{if(this._moveEnd(f),p)this.fire("rotateend",{bearing:this._bearing});if(m)this.fire("pitchend",{pitch:this._pitch})}}}),this}isEasing(){return!!this._camAnim?.isRunning()}getCamera(){return{center:this.getCenter(),zoom:this.getZoom(),bearing:this.getBearing(),pitch:this.getPitch()}}jumpTo(e={}){this._stop();let n=this.getCenter(),i=this._zoom,s=this._bearing,o=this._pitch;if(e.bearing!==void 0){let r=(e.bearing%360+360)%360;if(r!==s)this._bearing=r,this.fire("rotate")}if(e.pitch!==void 0){let r=this._clampPitch(e.pitch);if(r!==o)this._pitch=r,this.fire("pitch")}if(e.center!==void 0||e.zoom!==void 0){let r=e.center!==void 0?new S(e.center):n,a=e.zoom!==void 0?this._limitZoom(e.zoom):i;if(!r.equals(n)||a!==i)this._move(r,a)}return this._applyCameraTransform(),this}_getCamAnim(){if(!this._camAnim)this._camAnim=new Po;return this._camAnim}static _lerpBearing(e,n,i){let s=(n-e+540)%360-180;return((e+s*i)%360+360)%360}getBounds(){let e=this.getPixelBounds(),n=this.unproject(e.getBottomLeft()),i=this.unproject(e.getTopRight());return new R(n,i)}getMinZoom(){return this.options.minZoom??this._layersMinZoom??0}getMaxZoom(){return this.options.maxZoom??this._layersMaxZoom??1/0}getBoundsZoom(e,n,i){let s=new R(e),o=new v(i??[0,0]),r=this.getZoom()??0,a=this.getMinZoom(),l=this.getMaxZoom(),c=s.getNorthWest(),h=s.getSouthEast(),u=this.getSize().subtract(o),f=new I(this.project(h,r),this.project(c,r)).getSize(),d=this.options.zoomSnap,p=u.x/f.x,m=u.y/f.y,_=n?Math.max(p,m):Math.min(p,m);if(r=this.getScaleZoom(_,r),d)r=Math.round(r/(d/100))*(d/100),r=n?Math.ceil(r/d)*d:Math.floor(r/d)*d;return Math.max(a,Math.min(l,r))}getSize(){if(!this._size||this._sizeChanged)this._size=new v(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1;return this._size.clone()}getPixelBounds(e,n){let i=this._getTopLeftPoint(e,n);return new I(i,i.add(this.getSize()))}getPixelOrigin(){return this._checkIfLoaded(),this._pixelOrigin}getPixelWorldBounds(e){return this.options.crs.getProjectedBounds(e??this.getZoom())}getPane(e){return typeof e==="string"?this._panes[e]:e}getPanes(){return this._panes}getContainer(){return this._container}getZoomScale(e,n){let i=this.options.crs;return n??=this._zoom,i.scale(e)/i.scale(n)}getScaleZoom(e,n){let i=this.options.crs;n??=this._zoom;let s=i.zoom(e*i.scale(n));return Number.isNaN(s)?1/0:s}project(e,n){return n??=this._zoom,this.options.crs.latLngToPoint(new S(e),n)}unproject(e,n){return n??=this._zoom,this.options.crs.pointToLatLng(new v(e),n)}layerPointToLatLng(e){let n=new v(e).add(this.getPixelOrigin());return this.unproject(n)}latLngToLayerPoint(e){return this.project(new S(e))._round()._subtract(this.getPixelOrigin())}wrapLatLng(e){return this.options.crs.wrapLatLng(new S(e))}wrapLatLngBounds(e){return this.options.crs.wrapLatLngBounds(new R(e))}distance(e,n){return this.options.crs.distance(new S(e),new S(n))}containerPointToLayerPoint(e){let n=new v(e);if(!this._bearing&&!this._pitch)return n.subtract(this._getMapPanePos());let i=this.getSize()._divideBy(2),s=n.subtract(this._getMapPanePos())._subtract(i);if(this._pitch)s=this._unpitchPoint(s);if(this._bearing)s=this._rotatePoint(s,-this._bearing,new v(0,0));return s._add(i)}layerPointToContainerPoint(e){let n=new v(e);if(!this._bearing&&!this._pitch)return n.add(this._getMapPanePos());let i=this.getSize()._divideBy(2),s=n.subtract(i);if(this._bearing)s=this._rotatePoint(s,this._bearing,new v(0,0));if(this._pitch)s=this._pitchPoint(s);return s._add(i)._add(this._getMapPanePos())}containerPointToLatLng(e){let n=this.containerPointToLayerPoint(new v(e));return this.layerPointToLatLng(n)}latLngToContainerPoint(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(new S(e)))}pointerEventToContainerPoint(e){return gl(e,this._container)}pointerEventToLayerPoint(e){return this.containerPointToLayerPoint(this.pointerEventToContainerPoint(e))}pointerEventToLatLng(e){return this.layerPointToLatLng(this.pointerEventToLayerPoint(e))}_initContainer(e){let n=this._container=pl(e);if(!n)throw Error("Map container not found.");else if(n._tsmap_id)throw Error("Map container is already initialized.");hl(n),k(n,"scroll",this._onScroll,this),this._containerId=j(n)}_initLayout(){let e=this._container;this._fadeAnimated=this.options.fadeAnimation;let n=["tsmap-container","tsmap-touch"];if(pt.retina)n.push("tsmap-retina");if(pt.safari)n.push("tsmap-safari");if(this._fadeAnimated)n.push("tsmap-fade-anim");e.classList.add(...n),this.setTheme(this.options.theme??"light"),this.on("zoomend",this._syncStyleBackground,this);let{position:i}=getComputedStyle(e);if(i!=="absolute"&&i!=="relative"&&i!=="fixed"&&i!=="sticky")e.style.position="relative";if(this._initPanes(),this._initControlPos)this._initControlPos()}_initPanes(){let e=this._panes={};if(this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),lt(this._mapPane,new v(0,0)),this.createPane("tilePane"),this.createPane("symbolPane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),!this.options.markerZoomAnimation)e.markerPane.classList.add("tsmap-zoom-hide"),e.shadowPane.classList.add("tsmap-zoom-hide")}_resetView(e,n,i){lt(this._mapPane,new v(0,0));let s=!this._loaded;this._loaded=!0,n=this._limitZoom(n),this.fire("viewprereset");let o=this._zoom!==n;if(this._moveStart(o,i)._move(e,n)._moveEnd(o),this.fire("viewreset"),s)this.fire("load")}_moveStart(e,n){if(e)this.fire("zoomstart");if(!n)this.fire("movestart");return this}_move(e,n,i,s){if(n===void 0)n=this._zoom;let o=this._zoom!==n;if(this._zoom=n,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),!s){if(o||i?.pinch)this.fire("zoom",i);this.fire("move",i)}else if(i?.pinch)this.fire("zoom",i);return this}_moveEnd(e){if(e)this.fire("zoomend");return this.fire("moveend")}_stop(){if(this._flyToFrame!==void 0)cancelAnimationFrame(this._flyToFrame);return this._panAnim?.stop(),this._camAnim?.stop(),this}_rawPanBy(e){lt(this._mapPane,this._getMapPanePos().subtract(e))}_getZoomSpan(){return this.getMaxZoom()-this.getMinZoom()}_panInsideMaxBounds(){if(!this._enforcingBounds)this.panInsideBounds(this.options.maxBounds)}_checkIfLoaded(){if(!this._loaded)throw Error("Set map center and zoom first.")}_initEvents(e){if(this._targets={},this._targets[j(this._container)]=this,(e?Z:k)(this._container,"click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize)if(!e){if(!this._resizeObserver)this._resizeObserver=new ResizeObserver(this._onResize.bind(this));this._resizeObserver.observe(this._container)}else this._resizeObserver?.disconnect();if(this.options.transform3DLimit)(e?this.off:this.on).call(this,"moveend",this._onMoveEnd)}_onResize(){if(this._resizeRequest!==void 0&&this._resizeRequest!==null)cancelAnimationFrame(this._resizeRequest);this._resizeRequest=requestAnimationFrame(()=>{this.invalidateSize({debounceMoveend:!0})})}_onScroll(){this._container.scrollTop=0,this._container.scrollLeft=0}_onMoveEnd(){let e=this._getMapPanePos();if(Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit)this._resetView(this.getCenter(),this.getZoom())}_findEventTargets(e,n){let i=[],s,o=e.target||e.srcElement,r=!1,a=n==="pointerout"||n==="pointerover";while(o){if(s=this._targets[j(o)],s&&(n==="click"||n==="preclick")&&this._draggableMoved(s)){r=!0;break}if(s&&s.listens(n,!0)){if(a&&!To(o,e))break;if(i.push(s),a)break}if(o===this._container)break;o=o.parentNode}if(!i.length&&!r&&!a&&this.listens(n,!0))i=[this];return i}_isClickDisabled(e){while(e&&e!==this._container){if(e._tsmap_disable_click||!e.parentNode)return!0;e=e.parentNode}}_handleDOMEvent(e){let n=e.target??e.srcElement;if(!this._loaded||n._tsmap_disable_events||e.type==="click"&&this._isClickDisabled(n))return;let i=e.type;if(i==="pointerdown")vo(n);this._fireDOMEvent(e,i)}_fireDOMEvent(e,n,i){if(n==="click")this._fireDOMEvent(e,"preclick",i);let s=this._findEventTargets(e,n);if(i)s=i.filter((l)=>l.listens(n,!0)).concat(s);if(!s.length)return;if(n==="contextmenu")e.preventDefault();let o=s[0],r={originalEvent:e};if(e.type!=="keypress"&&e.type!=="keydown"&&e.type!=="keyup"){let a=o.getLatLng&&(!o._pxRadius||o._pxRadius<=10);r.containerPoint=a?this.latLngToContainerPoint(o.getLatLng()):this.pointerEventToContainerPoint(e),r.layerPoint=this.containerPointToLayerPoint(r.containerPoint),r.latlng=a?o.getLatLng():this.layerPointToLatLng(r.layerPoint)}for(let a of s)if(a.fire(n,r,!0),r.originalEvent._stopped||a.options?.bubblingPointerEvents===!1&&t._pointerEvents.includes(n))return}_draggableMoved(e){return e=e.dragging?.enabled()?e:this,e.dragging?.moved()||this.boxZoom?.moved()}_clearHandlers(){for(let e of this._handlers)e.disable()}whenReady(e,n){if(this._loaded)e.call(n||this,{target:this});else this.on("load",e,n);return this}_getMapPanePos(){return Re(this._mapPane)}_rotatePoint(e,n,i){if(!n)return e.clone();let s=n*Math.PI/180,o=Math.cos(s),r=Math.sin(s),a=e.x-i.x,l=e.y-i.y;return new v(i.x+a*o-l*r,i.y+a*r+l*o)}_applyCameraTransform(){if(!this._mapPane)return;let e=this.getSize()._divideBy(2),n=`${e.x}px ${e.y}px`;this._mapPane.style.transformOrigin=n;let i=this._getMapPanePos();lt(this._mapPane,i,this._bearing,this._pitch);let s=["symbolPane","markerPane","popupPane","tooltipPane"],o=!!this._bearing||!!this._pitch;for(let r of s){let a=this._panes?.[r];if(!a)continue;if(o)a.classList.add("tsmap-upright"),a.style.transformOrigin=n,a.style.transform=`rotateX(${-this._pitch}deg) rotate(${-this._bearing}deg) translateZ(0)`;else a.classList.remove("tsmap-upright"),a.style.transform="",a.style.transformOrigin=""}}_pitchPoint(e){let n=this._pitch*Math.PI/180;if(!n)return e.clone();let s=this.getSize().y/2/Math.tan(36.87*Math.PI/180/2),o=Math.sin(n),r=Math.cos(n),a=s-e.y*o;if(Math.abs(a)<0.000001)return e.clone();let l=s*e.x/a,c=s*e.y*r/a;return new v(l,c)}_unpitchPoint(e){let n=this._pitch*Math.PI/180;if(!n)return e.clone();let s=this.getSize().y/2/Math.tan(36.87*Math.PI/180/2),o=Math.sin(n),r=Math.cos(n),a=s*r+e.y*o;if(Math.abs(a)<0.000001)return e.clone();let l=e.y*s/a,c=e.x*s*r/a;return new v(c,l)}_moved(){let e=this._getMapPanePos();return!!e&&!e.equals([0,0])}_getTopLeftPoint(e,n){return(e&&n!==void 0?this._getNewPixelOrigin(e,n):this.getPixelOrigin()).subtract(this._getMapPanePos())}_getNewPixelOrigin(e,n){let i=this.getSize()._divideBy(2);return this.project(e,n)._subtract(i)._add(this._getMapPanePos())._round()}_latLngToNewLayerPoint(e,n,i){let s=this._getNewPixelOrigin(i,n);return this.project(e,n)._subtract(s)}_latLngBoundsToNewLayerBounds(e,n,i){let s=this._getNewPixelOrigin(i,n);return new I([this.project(e.getSouthWest(),n)._subtract(s),this.project(e.getNorthWest(),n)._subtract(s),this.project(e.getSouthEast(),n)._subtract(s),this.project(e.getNorthEast(),n)._subtract(s)])}_getCenterLayerPoint(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))}_getCenterOffset(e){return this.latLngToLayerPoint(e).subtract(this._getCenterLayerPoint())}_limitCenter(e,n,i){if(!i)return e;let s=this.project(e,n),o=this.getSize().divideBy(2),r=new I(s.subtract(o),s.add(o)),a=this._getBoundsOffset(r,i,n);if(Math.abs(a.x)<=1&&Math.abs(a.y)<=1)return e;return this.unproject(s.add(a),n)}_limitOffset(e,n){if(!n)return e;let i=this.getPixelBounds(),s=new I(i.min.add(e),i.max.add(e));return e.add(this._getBoundsOffset(s,n))}_getBoundsOffset(e,n,i){let s=new I(this.project(n.getNorthEast(),i),this.project(n.getSouthWest(),i)),o=s.min.subtract(e.min),r=s.max.subtract(e.max),a=this._rebound(o.x,-r.x),l=this._rebound(o.y,-r.y);return new v(a,l)}_rebound(e,n){return e+n>0?Math.round(e-n)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(n))}_limitZoom(e){let n=this.getMinZoom(),i=this.getMaxZoom(),s=this.options.zoomSnap;if(s)e=Math.round(e/s)*s;return Math.max(n,Math.min(i,e))}_onPanTransitionStep(){this.fire("move")}_onPanTransitionEnd(){this._mapPane.classList.remove("tsmap-pan-anim"),this.fire("moveend")}_tryAnimatedPan(e,n){let i=this._getCenterOffset(e)._trunc();if(n?.animate!==!0&&!this.getSize().contains(i))return!1;return this.panBy(i,n),!0}_createAnimProxy(){this._proxy=A("div","tsmap-proxy tsmap-zoom-animated"),this._panes.mapPane?.appendChild(this._proxy),this.on("zoomanim",this._animateProxyZoom,this),this.on("load moveend",this._animMoveEnd,this),k(this._proxy,"transitionend",this._catchTransitionEnd,this)}_animateProxyZoom(e){let n=this._proxy.style.transform;if(Fe(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===this._proxy.style.transform&&this._animatingZoom)this._onZoomTransitionEnd()}_animMoveEnd(){let e=this.getCenter(),n=this.getZoom();Fe(this._proxy,this.project(e,n),this.getZoomScale(n,1))}_destroyAnimProxy(){if(this._proxy)Z(this._proxy,"transitionend",this._catchTransitionEnd,this),this._proxy.remove(),this.off("zoomanim",this._animateProxyZoom,this),this.off("load moveend",this._animMoveEnd,this),delete this._proxy}_catchTransitionEnd(e){if(this._animatingZoom&&e.propertyName.includes("transform"))this._onZoomTransitionEnd()}_nothingToAnimate(){return!this._container.getElementsByClassName("tsmap-zoom-animated").length}_tryAnimatedZoom(e,n,i){if(this._animatingZoom)return!0;if(i??={},!this._zoomAnimated||i.animate===!1||this._nothingToAnimate()||Math.abs(n-this._zoom)>this.options.zoomAnimationThreshold)return!1;let s=this.getZoomScale(n),o=this._getCenterOffset(e)._divideBy(1-1/s);if(i.animate!==!0&&!this.getSize().contains(o))return!1;return requestAnimationFrame(()=>{this._moveStart(!0,i.noMoveStart??!1)._animateZoom(e,n,!0)}),!0}_animateZoom(e,n,i,s){if(!this._mapPane)return;if(i)this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=n,this._mapPane.classList.add("tsmap-zoom-anim");if(this.fire("zoomanim",{center:e,zoom:n,noUpdate:s}),!this._tempFireZoomEvent)this._tempFireZoomEvent=this._zoom!==this._animateToZoom;this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._transitionEndTimer=setTimeout(this._onZoomTransitionEnd.bind(this),250)}_onZoomTransitionEnd(){if(!this._animatingZoom)return;if(this._mapPane?.classList.remove("tsmap-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent)this.fire("zoom");delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0)}setStyle(e,n){if(typeof e==="string"){let o=this._styleLoadToken=(this._styleLoadToken??0)+1;return fetch(e).then((r)=>{if(!r.ok)throw Error(`HTTP ${r.status} fetching style ${e}`);return r.json()}).then((r)=>{if(o!==this._styleLoadToken)return;this.setStyle(r,n)}).catch((r)=>this.fire("error",{error:r,style:e})),this}this._styleLoadToken=(this._styleLoadToken??0)+1;let i=n?.diff!==!1,s=n?.validate!==!1;if(i&&this._style){let o=zf(this._style.spec,e);if(!o.commands.find((a)=>a.command==="setStyle")){let a=new Set;for(let l of o.commands){this._applyStyleCommand(l);let c=l.args?.[0];if(typeof c==="string")a.add(c)}for(let l of a)this._syncStyleLayer(l);return this._style.spec.name=e.name,this._style.spec.metadata=e.metadata,this._syncStyleBackground(),this.fire("styledata"),this}}if(this._style)for(let o of this._style.sourceLayers.values())this.removeLayer(o);this._style=new vi(e,{validate:s});for(let[o,r]of Object.entries(this._style.spec.sources)){let a=this._makeSourceLayer(o,r);if(!a)continue;this._installFeatureStateLookup(o,a),this.addLayer(a)}return this._loadSprite(),this._initGlyphSource(),this._syncStyleBackground(),this.fire("styledata"),this}_syncStyleBackground(){let e=this._container;if(!e)return;let n=this._styleBackgroundColor();if(n)e.style.backgroundColor=n;else e.style.removeProperty("background-color")}_styleBackgroundColor(){let e=this._style?.spec.layers;if(!e)return;let n;for(let s of e)if(s.type==="background")n=s;if(!n||n.layout?.visibility==="none")return;let i=n.paint?.["background-color"];if(i===void 0)return;if(typeof i==="string")return i;try{let{evaluate:s}=(Wi(),ut(Ml)),o=s(i,{zoom:this.getZoom()},"color");return typeof o==="string"?o:void 0}catch{return}}_initGlyphSource(){let e=this._style?.spec.glyphs;if(typeof e!=="string"||!e){this._glyphSource=void 0;return}let{GlyphSource:n}=(Ro(),ut(Zl));this._glyphSource=new n(e)}getGlyphSource(){return this._glyphSource}isFontAvailable(e){let n=globalThis.document?.fonts;if(!n||typeof n.check!=="function")return!0;let i=Array.isArray(e)?e:e?[e]:[];if(!i.length)return!0;try{let{GlyphAtlas:s}=ut(Ul),o=new s,{family:r}=o.resolveFont(i);return n.check(`16px ${r}`)}catch{return!0}}_loadSprite(){let e=this._style?.spec.sprite;if(!e)return;let n=typeof e==="string"?[{url:e}]:Array.isArray(e)?e.filter((r)=>r&&typeof r.url==="string"):[];if(n.length===0)return;let i=this._spriteToken=(this._spriteToken??0)+1,{loadSprite:s,addSpriteToAtlas:o}=ut(Hl);for(let r of n)s(r.url,{pixelRatio:typeof window<"u"?window.devicePixelRatio:1}).then((a)=>{if(i!==this._spriteToken||!this._style)return;let l=0;for(let c of this._style.sourceLayers.values()){let h=c;if(typeof h.getIconAtlas!=="function")continue;l+=o(h.getIconAtlas(),a,r.id),h._repaintDecodedTiles?.()}this.fire("spriteload",{sprite:r.url,id:r.id,icons:Object.keys(a.index).length,added:l})}).catch((a)=>{this.fire("error",{error:a,sprite:r.url,id:r.id})})}getStyle(){return this._style?.serialize()}isStyleLoaded(){return!!this._style}addSource(e,n){if(!this._style)this._style=new vi({version:8,sources:{[e]:n},layers:[]});else this._style.spec.sources[e]=n;let i=this._makeSourceLayer(e,n);if(i)this._installFeatureStateLookup(e,i),this.addLayer(i);return this.fire("styledata"),this}getSource(e){return this._style?.spec.sources[e]}removeSource(e){if(!this._style)return this;let n=this._style.sourceLayers.get(e);if(n)this.removeLayer(n),this._style.sourceLayers.delete(e);if(this._geoJSONSources)delete this._geoJSONSources[e];return delete this._style.spec.sources[e],this.fire("styledata"),this}_makeSourceLayer(e,n){if(n.type==="raster"){let{TileLayer:i}=(qi(),ut(Wl)),o=(n.tiles??[])[0];if(!o)throw Error(`source "${e}" has no tiles URL`);let r=new i(o,{tileSize:n.tileSize??256,minNativeZoom:n.minzoom,maxNativeZoom:n.maxzoom,maxZoom:mi,attribution:n.attribution,offlineCache:n.offlineCache});return this._style.sourceLayers.set(e,r),r}if(n.type==="vector"){let{VectorTileMapLayer:i}=(Qs(),ut(Js)),o=(n.tiles??[])[0];if(!o)throw Error(`source "${e}" has no tiles URL`);let r=this._style.spec.layers.filter((h)=>h.type!=="background"&&h.type!=="raster"&&h.source===e).map((h)=>this._style.toVectorStyleLayer(h)),a=n.tileSize??512,l=Math.round(Math.log2(a/256)),c=new i({url:o,tileSize:a,minNativeZoom:n.minzoom!==void 0?n.minzoom+l:void 0,sourceMaxZoom:n.maxzoom!==void 0?n.maxzoom+l:void 0,maxZoom:mi,attribution:n.attribution,offlineCache:n.offlineCache,layers:r});return this._style.sourceLayers.set(e,c),c}if(n.type==="raster-dem"){let s=(n.tiles??[])[0];if(!s)throw Error(`source "${e}" (raster-dem) has no tiles URL`);let o=this._style.spec.layers.find((c)=>c.type==="hillshade"&&c.source===e&&c.layout?.visibility!=="none");if(!o)return;let{RasterDEMLayer:r}=(wc(),ut(yc)),a=o.paint??{},l=new r(s,{encoding:n.encoding==="terrarium"?"terrarium":"mapbox",tileSize:n.tileSize??512,minNativeZoom:n.minzoom,maxNativeZoom:n.maxzoom,maxZoom:mi,exaggeration:a["hillshade-exaggeration"],azimuth:a["hillshade-illumination-direction"],accentColor:a["hillshade-highlight-color"]??a["hillshade-accent-color"],shadowColor:a["hillshade-shadow-color"],attribution:n.attribution});return this._style.sourceLayers.set(e,l),l}if(n.type==="geojson"){let{VectorTileMapLayer:i}=(Qs(),ut(Js)),{GeoJSONTileSource:s,clusterTileSource:o}=(Tc(),ut(vc)),{GeoJSONClusterSource:r}=ut(Pc),a=this._style.spec.layers.find((m)=>m.type==="heatmap"&&m.source===e&&m.layout?.visibility!=="none"),l=this._style.spec.layers.filter((m)=>m.type!=="background"&&m.type!=="raster"&&m.type!=="heatmap"&&m.source===e).map((m)=>this._style.toVectorStyleLayer(m)),c=e,h=n,u,f;if(h.cluster)f=new r({radius:h.clusterRadius??50,maxZoom:h.clusterMaxZoom??16,minPoints:h.clusterMinPoints??2}),u=o(f,c);else f=new s(void 0,{layerName:c,buffer:h.buffer}),u=f;let d=new i({localSource:u,tileSize:512,sourceMaxZoom:n.maxzoom!==void 0?n.maxzoom+1:void 0,maxZoom:mi,attribution:n.attribution,layers:l}),p;if(a){let{HeatmapLayer:m}=(Ac(),ut(Lc)),{heatmapGradient:_}=(vs(),ut(Si)),g=a.paint??{},b=typeof g["heatmap-radius"]==="number"?g["heatmap-radius"]:void 0,y=typeof g["heatmap-intensity"]==="number"?g["heatmap-intensity"]:void 0;p=new m({radius:b,gradient:_(g["heatmap-color"]),max:y!==void 0&&y>0?1/y:void 0,minOpacity:g["heatmap-opacity"],attribution:n.attribution}),this.addLayer(p)}if(this._geoJSONSources??={},this._geoJSONSources[e]={index:f,layer:d,clustered:!!h.cluster,heatmap:p,heatmapWeightKey:a?(vs(),ut(Si)).heatmapWeightKey(a.paint?.["heatmap-weight"]):void 0},h.data!==void 0)this.setSourceData(e,h.data);return this._style.sourceLayers.set(e,d),d}throw Error(`source type "${n.type}" is not supported in setStyle yet`)}setSourceData(e,n){let i=this._geoJSONSources?.[e];if(!i)throw Error(`source "${e}" is not a geojson source on this map`);let s=(o)=>{let r=o?.type==="FeatureCollection"?o.features??[]:Array.isArray(o)?o:o?[o]:[];if(i.clustered)i.index.load(r);else i.index.setData(o);if(i.heatmap){let{heatmapPoints:a}=(vs(),ut(Si));i.heatmap.setData(a(o,i.heatmapWeightKey))}i.layer.redraw?.(),this.fire("sourcedata",{sourceId:e,isSourceLoaded:!0})};if(typeof n==="string")return fetch(n).then((o)=>o.json()).then(s).catch((o)=>this.fire("error",{error:o,sourceId:e})),this;return s(n),this}addStyleLayer(e,n){if(!this._style)throw Error("addStyleLayer requires a loaded style");let i=this._style.spec.layers;if(n){let s=i.findIndex((o)=>o.id===n);if(s>=0)i.splice(s,0,e);else i.push(e)}else i.push(e);if(this._style.layerSpecs.set(e.id,e),e.source){let s=this._style.sourceLayers.get(e.source);if(typeof s?.setStyleLayers==="function"){let o=i.filter((a)=>a.type!=="background"&&a.type!=="raster"&&a.source===e.source).map((a)=>this._style.toVectorStyleLayer(a)),r=s;r.setStyleLayers(o),r.redraw?.()}}return this.fire("styledata"),this}removeStyleLayer(e){if(!this._style)return this;let n=this._style.spec.layers.findIndex((s)=>s.id===e);if(n<0)return this;let i=this._style.spec.layers.splice(n,1)[0];if(this._style.layerSpecs.delete(e),i.source){let s=this._style.sourceLayers.get(i.source);if(typeof s?.setStyleLayers==="function"){let o=this._style.spec.layers.filter((a)=>a.type!=="background"&&a.type!=="raster"&&a.source===i.source).map((a)=>this._style.toVectorStyleLayer(a)),r=s;r.setStyleLayers(o),r.redraw?.()}}return this.fire("styledata"),this}getStyleLayer(e){return this._style?.layerSpecs.get(e)}setPaintProperty(e,n,i){return this._style?.setPaintProperty(e,n,i),this._syncStyleLayer(e),this.fire("styledata"),this}setLayoutProperty(e,n,i){return this._style?.setLayoutProperty(e,n,i),this._syncStyleLayer(e),this.fire("styledata"),this}setFilter(e,n){return this._style?.setFilter(e,n),this._syncStyleLayer(e),this.fire("styledata"),this}_syncStyleLayer(e){let n=this._style,i=n?.layerSpecs.get(e);if(!n||!i)return;if(i.type==="background"){this._syncStyleBackground();return}let s=i.source,o=s?n.sourceLayers.get(s):void 0;if(!o||typeof o.updateStyleLayers!=="function")return;let r=n.spec.layers.filter((a)=>a.type!=="background"&&a.type!=="raster"&&a.source===s).map((a)=>n.toVectorStyleLayer(a));o.updateStyleLayers(r)}on(e,n,i,s){if(typeof n==="string"&&typeof e==="string"&&typeof i==="function"){let o=n,r=i,a=s,l=(h)=>{if(!h||!h.containerPoint)return;let u=this.queryRenderedFeatures(h.containerPoint,{layers:[o]});if(!u.length)return;r.call(a??this,Object.assign({},h,{features:u}))};if(!this._layerHandlers)this._layerHandlers=new globalThis.Map;let c=this._layerHandlers.get(e)??[];return c.push({layerId:o,listener:r,wrapped:l,context:a}),this._layerHandlers.set(e,c),wt.prototype.on.call(this,e,l,this)}return wt.prototype.on.call(this,e,n,i)}off(e,n,i,s){if(typeof n==="string"&&typeof e==="string"&&typeof i==="function"){let o=n,r=i,a=this._layerHandlers?.get(e);if(a){let l=a.findIndex((c)=>c.layerId===o&&c.listener===r);if(l>=0){let[c]=a.splice(l,1);if(wt.prototype.off.call(this,e,c.wrapped,this),a.length===0)this._layerHandlers.delete(e);return this}}return this}return wt.prototype.off.call(this,e,n,i,s)}once(e,n,i,s){if(typeof n==="string"&&typeof e==="string"&&typeof i==="function"){let o=n,r=i,a=s,l=this,c=function(u){l.off(e,o,c),r.call(a??l,u)};return l.on(e,o,c),this}return wt.prototype.once.call(this,e,n,i)}queryRenderedFeatures(e,n){if(!this._style)return[];let i=[];for(let s of this._style.sourceLayers.values()){let o=s;if(typeof o.queryRenderedFeatures==="function"){let r=e===void 0?o.queryRenderedFeatures():o.queryRenderedFeatures(e,n);for(let a of r)i.push(a)}}return i}querySourceFeatures(e,n){if(!this._style)return[];let i=this._style.sourceLayers.get(e);if(!i)return[];if(typeof i.querySourceFeatures!=="function")return[];return i.querySourceFeatures(n??{})}_featureStateKey(e){let n=typeof e.id==="number"?`n:${e.id}`:`s:${e.id}`;return`${e.source}|${e.sourceLayer??""}|${n}`}_ensureFeatureStateMap(){if(!this._featureState)this._featureState=new globalThis.Map;return this._featureState}_repaintSource(e){let n=this._style?.sourceLayers.get(e);if(!n)return;if(typeof n._repaintDecodedTiles==="function")n._repaintDecodedTiles()}setFeatureState(e,n){let i=this._ensureFeatureStateMap(),s=this._featureStateKey(e),o=i.get(s);if(o)Object.assign(o,n);else i.set(s,{...n});return this._repaintSource(e.source),this}getFeatureState(e){let n=this._featureState;if(!n)return{};let i=this._featureStateKey(e);return n.get(i)??{}}removeFeatureState(e,n){let i=this._featureState;if(!i)return this;let s=this._featureStateKey(e);if(n===void 0)i.delete(s);else{let o=i.get(s);if(o){if(delete o[n],Object.keys(o).length===0)i.delete(s)}}return this._repaintSource(e.source),this}_installFeatureStateLookup(e,n){if(typeof n?.setFeatureStateLookup!=="function")return;if(n.setFeatureStateLookup((i,s,o)=>{let r=this._featureState;if(!r)return{};let a=typeof o==="number"?`n:${o}`:`s:${o}`;return r.get(`${i}|${s}|${a}`)??{}}),typeof n.setSourceId==="function")n.setSourceId(e)}_applyStyleCommand(e){switch(e.command){case"addSource":{let[n,i]=e.args;if(!this._style)this._style=new vi({version:8,sources:{},layers:[]},{validate:!1});this._style.spec.sources[n]=i;let s=this._makeSourceLayer(n,i);if(s)this._installFeatureStateLookup(n,s),this.addLayer(s);break}case"removeSource":{let[n]=e.args;this.removeSource(n);break}case"addLayer":{let[n,i]=e.args;this.addStyleLayer(n,i);break}case"removeLayer":{let[n]=e.args;this.removeStyleLayer(n);break}case"setPaintProperty":{let[n,i,s]=e.args;this._style?.setPaintProperty(n,i,s);break}case"setLayoutProperty":{let[n,i,s]=e.args;this._style?.setLayoutProperty(n,i,s);break}case"setFilter":{let[n,i]=e.args;this._style?.setFilter(n,i);break}case"setLayerZoomRange":{let[n,i,s]=e.args;this._style?.setLayerZoomRange(n,i,s);break}}}setFog(e){if(e!==null){if(e.range!==void 0){let[n,i]=e.range;if(!(n<i))throw RangeError(`setFog: range[0] (${n}) must be < range[1] (${i}).`)}if(e["star-intensity"]!==void 0&&e["star-intensity"]<0)throw RangeError(`setFog: star-intensity must be >= 0 (got ${e["star-intensity"]}).`)}return this._fog=e===null?null:{...e},this._updateAtmosphereOverlay(),this.fire("fogchange",{fog:this._fog}),this}getFog(){return this._fog??null}setSky(e){if(e!==null){let n=["fog-ground-blend","sun-intensity"];for(let s of n){let o=e[s];if(o!==void 0&&Number.isNaN(o))throw RangeError(`setSky: ${s} is NaN.`)}if(e["sun-position"]!==void 0){let[s,o]=e["sun-position"];if(Number.isNaN(s)||Number.isNaN(o))throw RangeError("setSky: sun-position contains NaN.")}let i={...e};if(i["fog-ground-blend"]!==void 0)i["fog-ground-blend"]=Math.max(0,Math.min(1,i["fog-ground-blend"]));if(i["sun-intensity"]!==void 0)i["sun-intensity"]=Math.max(0,Math.min(1,i["sun-intensity"]));this._sky=i}else this._sky=null;return this._updateAtmosphereOverlay(),this.fire("skychange",{sky:this._sky}),this}getSky(){return this._sky??null}setTerrain(e){if(e!==null){if(typeof e.source!=="string"||e.source.length===0)throw TypeError("setTerrain: `source` must be a non-empty string.");if(e.exaggeration!==void 0&&!Number.isFinite(e.exaggeration))throw RangeError(`setTerrain: exaggeration must be a finite number (got ${e.exaggeration}).`);if(e.exaggeration!==void 0&&e.exaggeration<0)throw RangeError(`setTerrain: exaggeration must be >= 0 (got ${e.exaggeration}).`);this._terrain={source:e.source,exaggeration:e.exaggeration??1};let n=this._style?.spec.sources?.[e.source],i=n?.encoding==="terrarium"?"terrarium":"mapbox",s=n?.tileSize??256;if(!this._terrainSource)this._terrainSource=new Xa({demSize:s,encoding:i,exaggeration:this._terrain.exaggeration});else this._terrainSource.setExaggeration(this._terrain.exaggeration??1)}else this._terrain=null,this._terrainSource?.clear();if(this._terrain)this._ensureTerrainOverlay();else this._destroyTerrainOverlay();return this.fire("terrainchange",{terrain:this._terrain}),this._renderTerrainOverlay(),this}_ensureTerrainOverlay(){if(this._terrainOverlayCanvas)return;let e=this._container;if(!e||typeof e.appendChild!=="function")return;let i=(e.ownerDocument??document).createElement("canvas");i.className="ts-maps-terrain-overlay";let s=this.getSize?.()??new v(e.clientWidth||300,e.clientHeight||150);if(i.width=Math.max(1,s.x),i.height=Math.max(1,s.y),i.style)i.style.position="absolute",i.style.inset="0",i.style.pointerEvents="none",i.style.zIndex="390";e.appendChild(i),this._terrainOverlayCanvas=i}_destroyTerrainOverlay(){if(this._terrainOverlayRenderer){try{this._terrainOverlayRenderer.destroy()}catch{}this._terrainOverlayRenderer=void 0}if(this._terrainOverlayCanvas&&this._terrainOverlayCanvas.parentNode)this._terrainOverlayCanvas.parentNode.removeChild(this._terrainOverlayCanvas);this._terrainOverlayCanvas=void 0}_renderTerrainOverlay(){if(!this._terrain||!this._terrainSource)return;let e=this._terrainOverlayCanvas;if(!e)return;let n=this.getSize?.();if(n){if(e.width!==n.x)e.width=Math.max(1,n.x);if(e.height!==n.y)e.height=Math.max(1,n.y)}if(!this._terrainOverlayRenderer)try{this._terrainOverlayRenderer=new Co(e)}catch{return}let i=this._terrainOverlayRenderer;i.clear();let s=Math.max(0,Math.floor(this.getZoom?.()??0)),o=this.getBounds?.();if(!o||!o.isValid||!o.isValid())return;let r=o.getSouthWest(),a=o.getNorthEast(),l=256,c=2**s,h=(b)=>Math.floor((b+180)/360*c),u=(b)=>{let y=Math.max(-85.05112878,Math.min(85.05112878,b))*Math.PI/180;return Math.floor((1-Math.log(Math.tan(y)+1/Math.cos(y))/Math.PI)/2*c)},f=Math.max(0,h(r.lng)),d=Math.min(c-1,h(a.lng)),p=Math.max(0,u(a.lat)),m=Math.min(c-1,u(r.lat)),{width:_,height:g}=e;for(let b=f;b<=d;b++)for(let y=p;y<=m;y++){let w={z:s,x:b,y};if(!this._terrainSource.hasTile(w)){this._maybeFetchTerrainTile(w);continue}let T=180/Math.PI*Math.atan(Math.sinh(Math.PI*(1-2*y/c))),L=b/c*360-180,C=this.latLngToContainerPoint?.({lat:T,lng:L});if(!C)continue;let D=C.x/_*2-1,W=1-C.y/g*2,J=l/_*2,gt=-(l/g)*2,E=new Float32Array(16);E[0]=J,E[5]=gt,E[10]=1,E[15]=1,E[12]=D,E[13]=W,this._drawTerrainForTile(i,w,l,E)}}getTerrain(){return this._terrain??null}getTerrainSource(){return this._terrainSource}setRenderer(e){let n=this.options;if(n.preferredRenderer=e,this._style)for(let i of this._style.sourceLayers.values()){let s=i;if(typeof s.setRenderer==="function")try{s.setRenderer(e)}catch{}if(typeof s.redraw==="function")try{s.redraw()}catch{}}return this.fire("rendererchange",{renderer:e}),this}setTheme(e){if(this._detachThemeQuery(),this._theme=e,this.options.theme=e,e==="auto"&&typeof matchMedia==="function"){let n=matchMedia("(prefers-color-scheme: dark)"),i=(s)=>this._applyTheme(s.matches);if(typeof n.addEventListener==="function")n.addEventListener("change",i);else n.addListener?.(i);return this._themeQuery=n,this._themeQueryListener=i,this._applyTheme(n.matches),this}return this._applyTheme(e==="dark"),this}getTheme(){return this._theme??"light"}_applyTheme(e){if(e)this._container?.classList.add("tsmap-dark");else this._container?.classList.remove("tsmap-dark");this.fire("themechange",{theme:this.getTheme(),dark:e})}_detachThemeQuery(){let e=this._themeQuery,n=this._themeQueryListener;if(e&&n)if(typeof e.removeEventListener==="function")e.removeEventListener("change",n);else e.removeListener?.(n);this._themeQuery=void 0,this._themeQueryListener=void 0}setProjection(e){if(this.getProjection()===e)return this;let n=this.options;return n.projection=e,this._updateAtmosphereOverlay(),this._resetView(this.getCenter(),this.getZoom(),!0),this.fire("projectionchange",{projection:e}),this}getProjection(){return this._isGlobeProjection()?"globe":"mercator"}getPreferredRenderer(){return this.options.preferredRenderer??"canvas2d"}queryTerrainElevation(e){if(!this._terrain||!this._terrainSource)return null;let n=Math.max(0,Math.floor(this.getZoom?.()??0));return this._terrainSource.queryElevation(e.lng,e.lat,n)}toCanvas(){let e=this._container,n=e.ownerDocument??document,i=this.getSize(),s=globalThis.devicePixelRatio??1,o=n.createElement("canvas"),r=Math.max(1,Math.round(i.x)),a=Math.max(1,Math.round(i.y));if(o.width=Math.round(r*s),o.height=Math.round(a*s),o.style)o.style.width=`${r}px`,o.style.height=`${a}px`;let l=o.getContext("2d");if(!l)return o;l.scale(s,s);let c=e.getBoundingClientRect(),h=n.createTreeWalker(e,1),u=h.nextNode();while(u){if(u.tagName==="CANVAS"||u.tagName==="IMG"){let f=u.getBoundingClientRect?.();if(f&&f.width>0&&f.height>0)try{l.drawImage(u,f.left-c.left,f.top-c.top,f.width,f.height)}catch{}}u=h.nextNode()}return o}toDataURL(e="image/png",n){return this._requestExportFrame(),this.toCanvas().toDataURL(e,n)}toBlob(e="image/png",n){return this._requestExportFrame(),new Promise((i)=>{let s=this.toCanvas();if(typeof s.toBlob==="function")s.toBlob((o)=>i(o),e,n);else try{let o=s.toDataURL(e,n),r=o.indexOf(","),a=o.slice(r+1),l=atob(a),c=new Uint8Array(l.length);for(let h=0;h<l.length;h++)c[h]=l.charCodeAt(h);i(new Blob([c],{type:e}))}catch{i(null)}})}_requestExportFrame(){if(!this._style)return;for(let e of this._style.sourceLayers.values()){let n=e.redraw;if(typeof n==="function")try{n.call(e)}catch{}}}_isGlobeProjection(){let e=this.options??{};if(e.projection==="globe")return!0;return typeof e.crs?.projection?.globeToMercatorMix==="function"}_globeAtmosphereMix(){let n=(this.options??{}).crs?.projection,i=this.getZoom?.()??0;if(typeof n?.globeToMercatorMix==="function")return n.globeToMercatorMix(i);let s=5.5,o=6;if(i<=s)return 1;if(i>=o)return 0;let r=(i-s)/(o-s);return 1-r*r*(3-2*r)}_updateAtmosphereOverlay(){let e=this._container;if(!e||typeof e.appendChild!=="function")return;let n=this._sky!==null&&this._sky!==void 0,i=this._fog!==null&&this._fog!==void 0,s=this._isGlobeProjection()?this._globeAtmosphereMix():0,o=s>0;if(!n&&!i&&!o){if(this._atmosphereOverlay&&this._atmosphereOverlay.parentNode)this._atmosphereOverlay.parentNode.removeChild(this._atmosphereOverlay);this._atmosphereOverlay=void 0;return}if(!this._atmosphereOverlay){let _=(e.ownerDocument??document).createElement("div");if(_.className="ts-maps-atmosphere",_.style)_.style.position="absolute",_.style.inset="0",_.style.pointerEvents="none",_.style.zIndex="400";e.appendChild(_),this._atmosphereOverlay=_}let r=this.getPitch?.()??0,a=Math.max(0,Math.min(1,(r-5)/55)),l=this._sky?.["sky-color"]??"#87ceeb",c=this._sky?.["horizon-color"]??"#ffffff",h=this._fog?.color??"rgb(245, 247, 250)",u=this._fog?.["horizon-blend"]??0.1,f=[];if(o){let _=this._sky?.["sky-color"]??h;f.push(`radial-gradient(circle at 50% 50%, transparent 36%, ${_} 46%, transparent 62%)`)}if(n)f.push(`linear-gradient(to bottom, ${l} 0%, ${c} 40%, transparent 60%)`);if(i){let _=Math.max(0.05,Math.min(0.4,u*2)),g=0.45,b=Math.max(0,0.45-_/2),y=Math.min(1,0.45+_/2);f.push(`linear-gradient(to bottom, transparent ${(b*100).toFixed(1)}%, ${h} ${45 .toFixed(1)}%, transparent ${(y*100).toFixed(1)}%)`)}let d=this._atmosphereOverlay.style;if(!d)return;d.background=f.join(", ");let m=Math.max(n||i?a:0,o?s*0.9:0);d.opacity=String(m.toFixed(3)),d.display=m<=0?"none":"block"}_getCustomLayerGL(){let e=this._container;if(!e||typeof e.querySelector!=="function")return null;let n=e.querySelector("canvas");if(!n||typeof n.getContext!=="function")return null;try{return n.getContext("webgl2")??null}catch{return null}}addCustomLayer(e){if(!this._customLayers)this._customLayers=new globalThis.Map;if(this._customLayers.has(e.id))throw Error(`addCustomLayer: a custom layer with id "${e.id}" is already registered.`);this._customLayers.set(e.id,e);let n=this._getCustomLayerGL();if(n&&typeof e.onAdd==="function")e.onAdd(this,n);return this.fire("customlayer:add",{id:e.id,layer:e}),this}addTerrainTile(e,n){if(!this._terrain||!this._terrainSource)return;this._terrainSource.addTilePixels(e,n)}_drawTerrainForTile(e,n,i,s){if(!this._terrain||!this._terrainSource)return;let o=this._terrainSource;if(!o.hasTile(n)){this._maybeFetchTerrainTile(n);return}let r=o.getTile(n);if(!r)return;let a=Gh({elevation:r,demSize:o.demSize,tileSize:i,resolution:o.meshResolution,exaggeration:o.exaggeration,unitsPerMeter:0.001});e.drawTerrain(a.positions,a.indices,[0.78,0.8,0.75,1],1,s)}_maybeFetchTerrainTile(e){if(!this._terrain||!this._terrainSource||!this._style)return;let n=this._style.spec.sources?.[this._terrain.source];if(!n||n.type!=="raster-dem")return;let i=Array.isArray(n.tiles)?n.tiles[0]:void 0;if(!i||typeof i!=="string")return;let s=i.replace(/\{z\}/g,String(e.z)).replace(/\{x\}/g,String(e.x)).replace(/\{y\}/g,String(e.y));if(!this._terrainFetchInFlight)this._terrainFetchInFlight=new globalThis.Map;if(this._terrainFetchInFlight.has(s))return;let o=kp(s,this._terrainSource.demSize).then((r)=>{if(r&&this._terrainSource&&this._terrain)this._terrainSource.addTilePixels(e,r);this.fire("terrainload",{coord:e})}).catch(()=>{}).finally(()=>{this._terrainFetchInFlight?.delete(s)});this._terrainFetchInFlight.set(s,o)}_wireTerrainCameraHooks(){let e=()=>this._renderTerrainOverlay();this.on("moveend",e),this.on("zoomend",e),this.on("rotate",e),this.on("pitch",e),this.on("resize",e),this.on("terrainload",e)}_invokeCustomLayerRender(e,n){if(!this._customLayers||this._customLayers.size===0)return;for(let i of this._customLayers.values())try{i.render(e,n)}catch(s){console.warn(`[ts-maps] custom layer "${i.id}" threw during render:`,s)}}removeCustomLayer(e){let n=this._customLayers?.get(e);if(!n)return this;let i=this._getCustomLayerGL();if(i&&typeof n.onRemove==="function")n.onRemove(this,i);return this._customLayers.delete(e),this.fire("customlayer:remove",{id:e,layer:n}),this}getCustomLayer(e){return this._customLayers?.get(e)}getCustomLayers(){return this._customLayers?Array.from(this._customLayers.values()):[]}get offline(){if(!this._offlineApi){let e=this;this._offlineApi={save(n){return Ih(n,e)},async size(){return nn().size()},async clear(){await nn().clear()}}}return this._offlineApi}},F.setDefaultOptions({crs:Pi,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,fadeAnimation:!0,markerZoomAnimation:!0,transform3DLimit:8388608,zoomSnap:0,zoomDelta:1,trackResize:!0,bearing:0,pitch:0,maxPitch:60,minPitch:0}),Mp=F});var Ec={};tt(Ec,{TerritoryStore:()=>zc});var zc,Cc=P(()=>{Pe(),Bi(),ll(),zc=class extends wt{initialize(e={}){this._byOwner=new Map,this._options={steal:e.steal??!0,minFragmentArea:e.minFragmentArea??25}}capture(e,n){let i=Mr(n),s=he(i),o=this._byOwner.get(e)??[],r=ls(i,o),a=he(r),l=[];if(this._options.steal){for(let[u,f]of this._byOwner){if(u===e||f.length===0)continue;let d=Os(f,i);if(d.length===0)continue;let p=he(d);if(p<=0)continue;let m=this._prune(ls(f,i));this._byOwner.set(u,m),l.push({owner:u,area:p})}l.sort((u,f)=>f.area-u.area)}let c=this._prune(As(o,i));this._byOwner.set(e,c);let h={owner:e,ring:n,areaClaimed:s,areaGained:a,stolen:l,territory:c,totalArea:he(c)};return this.fire("capture",h),this.fire("change",{owner:e}),h}get(e){return this._byOwner.get(e)??[]}set(e,n){return this._byOwner.set(e,this._prune(n)),this.fire("change",{owner:e}),this}areaOf(e){return he(this.get(e))}owners(){return[...this._byOwner.keys()].filter((e)=>(this._byOwner.get(e)??[]).length>0)}leaderboard(){return this.owners().map((e)=>({owner:e,area:this.areaOf(e),pieces:this.get(e).length})).sort((e,n)=>n.area-e.area)}ownerAt(e){for(let[n,i]of this._byOwner)if(il(i,e))return n;return null}preview(e,n){let i=Mr(n),s=this._byOwner.get(e)??[],o=he(ls(i,s)),r=[];if(this._options.steal){for(let[a,l]of this._byOwner){if(a===e||l.length===0)continue;let c=he(Os(l,i));if(c>0)r.push({owner:a,area:c})}r.sort((a,l)=>l.area-a.area)}return{areaGained:o,stolen:r}}toGeoJSON(){return{type:"FeatureCollection",features:this.owners().map((e)=>({type:"Feature",properties:{owner:e,area:this.areaOf(e)},geometry:{type:"MultiPolygon",coordinates:this.get(e)}}))}}loadGeoJSON(e){this._byOwner.clear();for(let n of e.features??[]){let i=n?.properties?.owner,s=n?.geometry;if(typeof i!=="string"||!s)continue;let o=s.type==="Polygon"?[s.coordinates]:s.type==="MultiPolygon"?s.coordinates:[];if(o.length===0)continue;let r=this._byOwner.get(i);this._byOwner.set(i,r?As(r,o):o)}return this.fire("change",{}),this}clear(){return this._byOwner.clear(),this.fire("change",{}),this}_prune(e){let n=this._options.minFragmentArea;if(n<=0)return e;return e.filter((i)=>he([i])>=n)}}}),Ic={};tt(Ic,{GoogleDirections:()=>Zc,GoogleGeocoder:()=>$c,MapboxDirections:()=>jc,MapboxGeocoder:()=>Dc,MapboxIsochrone:()=>Uc,MapboxMatrix:()=>Hc,MaptilerGeocoder:()=>Wc,NominatimGeocoder:()=>jo,OSRMDirections:()=>Uo,OSRMMatrix:()=>Ho,PhotonGeocoder:()=>Yc,ValhallaDirections:()=>Yo,ValhallaIsochrone:()=>Ko,ValhallaMatrix:()=>Xo,defaultDirections:()=>Gp,defaultGeocoder:()=>Kc,defaultIsochrone:()=>Yp,defaultMatrix:()=>Kp,valhallaDirections:()=>Jp,valhallaMatrix:()=>Xp});var Fc="https://maps.googleapis.com/maps/api";function Rc(t){if(!t)throw Error("Google provider requires an apiKey");return t}var Lp={driving:"driving",walking:"walking",cycling:"bicycling"};function Nc(t,e=5){let n=10**e,i=t.length,s=0,o=0,r=0,a=[];while(s<i){let l=0,c=0,h;do h=t.charCodeAt(s++)-63,c|=(h&31)<<l,l+=5;while(h>=32);let u=c&1?~(c>>1):c>>1;o+=u,l=0,c=0;do h=t.charCodeAt(s++)-63,c|=(h&31)<<l,l+=5;while(h>=32);let f=c&1?~(c>>1):c>>1;r+=f,a.push({lat:o/n,lng:r/n})}return a}async function io(t,e){let n=await fetch(t,{signal:e});if(!n.ok)throw Error(`Google request failed: ${n.status} ${n.statusText}`);return n.json()}function Ap(t){if(!t)return;if(t.includes("country"))return"country";if(t.includes("administrative_area_level_1"))return"region";if(t.includes("administrative_area_level_2"))return"district";if(t.includes("postal_code"))return"postcode";if(t.includes("locality")||t.includes("sublocality"))return"place";if(t.includes("street_address")||t.includes("route")||t.includes("premise"))return"address";if(t.includes("point_of_interest")||t.includes("establishment"))return"poi";return}function Ia(t){let e={text:t.formatted_address,center:{lat:t.geometry.location.lat,lng:t.geometry.location.lng},properties:{place_id:t.place_id,types:t.types,address_components:t.address_components}},n=t.geometry.bounds??t.geometry.viewport;if(n)e.bbox=[n.southwest.lng,n.southwest.lat,n.northeast.lng,n.northeast.lat];let i=Ap(t.types);if(i)e.placeType=i;return e}class $c{name="google";apiKey;baseUrl;constructor(t){this.apiKey=Rc(t.apiKey),this.baseUrl=(t.baseUrl??Fc).replace(/\/$/,"")}async search(t,e){let n=new URLSearchParams;if(n.set("address",t),n.set("key",this.apiKey),e?.language)n.set("language",e.language);if(e?.bbox){let[r,a,l,c]=e.bbox;n.set("bounds",`${a},${r}|${c},${l}`)}if(e?.countries&&e.countries.length>0)n.set("components",e.countries.map((r)=>`country:${r}`).join("|"));let i=`${this.baseUrl}/geocode/json?${n.toString()}`,s=await io(i,e?.signal);if(s.status!=="OK"&&s.status!=="ZERO_RESULTS")throw Error(`Google geocoding error: ${s.status}${s.error_message?` — ${s.error_message}`:""}`);let o=(s.results??[]).map(Ia);return typeof e?.limit==="number"?o.slice(0,e.limit):o}async reverse(t,e){let n=new URLSearchParams;if(n.set("latlng",`${t.lat},${t.lng}`),n.set("key",this.apiKey),e?.language)n.set("language",e.language);let i=`${this.baseUrl}/geocode/json?${n.toString()}`,s=await io(i,e?.signal);if(s.status!=="OK"&&s.status!=="ZERO_RESULTS")throw Error(`Google reverse-geocoding error: ${s.status}${s.error_message?` — ${s.error_message}`:""}`);let o=(s.results??[]).map(Ia);return typeof e?.limit==="number"?o.slice(0,e.limit):o}}function Op(t){return t?t.replace(/<[^>]+>/g,""):""}function Ep(t){let e={distance:t.distance?.value??0,duration:t.duration?.value??0,instruction:Op(t.html_instructions),geometry:t.polyline?Nc(t.polyline.points):[]};if(t.maneuver)e.maneuver=t.maneuver;return e}function zp(t){let e=t.legs??[],n=e.flatMap((r)=>(r.steps??[]).map(Ep)),i=e.reduce((r,a)=>r+(a.distance?.value??0),0),s=e.reduce((r,a)=>r+(a.duration?.value??0),0),o=t.overview_polyline?Nc(t.overview_polyline.points):n.flatMap((r)=>r.geometry);return{distance:i,duration:s,geometry:o,steps:n}}class Zc{name="google";apiKey;baseUrl;constructor(t){this.apiKey=Rc(t.apiKey),this.baseUrl=(t.baseUrl??Fc).replace(/\/$/,"")}async getDirections(t,e){if(t.length<2)throw Error("Google directions requires at least two waypoints");let n=new URLSearchParams;n.set("key",this.apiKey),n.set("mode",Lp[e?.profile??"driving"]);let i=t[0],s=t[t.length-1];if(n.set("origin",`${i.lat},${i.lng}`),n.set("destination",`${s.lat},${s.lng}`),t.length>2){let a=t.slice(1,-1).map((l)=>`${l.lat},${l.lng}`).join("|");n.set("waypoints",a)}if(e?.alternatives)n.set("alternatives","true");if(e?.language)n.set("language",e.language);let o=`${this.baseUrl}/directions/json?${n.toString()}`,r=await io(o,e?.signal);if(r.status!=="OK"&&r.status!=="ZERO_RESULTS")throw Error(`Google directions error: ${r.status}${r.error_message?` — ${r.error_message}`:""}`);return(r.routes??[]).map(zp)}}var Yi="https://api.mapbox.com";function Ki(t){if(!t)throw Error("Mapbox provider requires an accessToken");return t}var Bc={driving:"mapbox/driving",walking:"mapbox/walking",cycling:"mapbox/cycling"},Cp={driving:"mapbox/driving",walking:"mapbox/walking",cycling:"mapbox/cycling"};async function Un(t,e){let n=await fetch(t,{signal:e});if(!n.ok)throw Error(`Mapbox request failed: ${n.status} ${n.statusText}`);return n.json()}function Ip(t){switch(t){case"country":case"region":case"district":case"postcode":case"place":case"address":case"poi":return t;default:return}}function Fa(t){let e=t.geometry?.coordinates??[0,0],n={text:t.properties?.full_address??t.properties?.name??"",center:{lat:e[1],lng:e[0]},properties:t.properties};if(t.properties?.bbox)n.bbox=t.properties.bbox;let i=Ip(t.properties?.feature_type);if(i)n.placeType=i;if(typeof t.relevance==="number")n.relevance=t.relevance;return n}class Dc{name="mapbox";accessToken;baseUrl;constructor(t){this.accessToken=Ki(t.accessToken),this.baseUrl=(t.baseUrl??Yi).replace(/\/$/,"")}async search(t,e){let n=new URLSearchParams;if(n.set("q",t),n.set("access_token",this.accessToken),n.set("limit",String(e?.limit??5)),e?.language)n.set("language",e.language);if(e?.proximity)n.set("proximity",`${e.proximity.lng},${e.proximity.lat}`);if(e?.bbox)n.set("bbox",e.bbox.join(","));if(e?.countries&&e.countries.length>0)n.set("country",e.countries.join(","));let i=`${this.baseUrl}/search/geocode/v6/forward?${n.toString()}`;return((await Un(i,e?.signal)).features??[]).map(Fa)}async reverse(t,e){let n=new URLSearchParams;if(n.set("longitude",String(t.lng)),n.set("latitude",String(t.lat)),n.set("access_token",this.accessToken),n.set("limit",String(e?.limit??1)),e?.language)n.set("language",e.language);let i=`${this.baseUrl}/search/geocode/v6/reverse?${n.toString()}`;return((await Un(i,e?.signal)).features??[]).map(Fa)}}function An(t){return t.map(([e,n])=>({lat:n,lng:e}))}function Fp(t){let e={distance:t.distance,duration:t.duration,instruction:t.maneuver?.instruction??t.name??"",geometry:An(t.geometry?.coordinates??[])};if(t.maneuver?.type)e.maneuver=t.maneuver.modifier?`${t.maneuver.type}-${t.maneuver.modifier}`.replace(/\s+/g,"-"):t.maneuver.type;return e}function Rp(t){let e=(t.legs??[]).flatMap((n)=>(n.steps??[]).map(Fp));return{distance:t.distance,duration:t.duration,geometry:An(t.geometry?.coordinates??[]),steps:e}}class jc{name="mapbox";accessToken;baseUrl;constructor(t){this.accessToken=Ki(t.accessToken),this.baseUrl=(t.baseUrl??Yi).replace(/\/$/,"")}async getDirections(t,e){if(t.length<2)throw Error("Mapbox directions requires at least two waypoints");let n=Bc[e?.profile??"driving"],i=t.map((a)=>`${a.lng},${a.lat}`).join(";"),s=new URLSearchParams;if(s.set("access_token",this.accessToken),s.set("geometries","geojson"),s.set("overview","full"),s.set("steps","true"),s.set("alternatives",e?.alternatives?"true":"false"),e?.language)s.set("language",e.language);let o=`${this.baseUrl}/directions/v5/${n}/${i}?${s.toString()}`,r=await Un(o,e?.signal);if(r.code!=="Ok")throw Error(`Mapbox directions error: ${r.code}${r.message?` — ${r.message}`:""}`);return(r.routes??[]).map(Rp)}}class Uc{name="mapbox";accessToken;baseUrl;constructor(t){this.accessToken=Ki(t.accessToken),this.baseUrl=(t.baseUrl??Yi).replace(/\/$/,"")}async getIsochrones(t,e){let n=Cp[e.profile??"driving"],i=e.contourMetric??"time",s=new URLSearchParams;if(s.set("access_token",this.accessToken),i==="distance")s.set("contours_meters",e.contours.join(","));else s.set("contours_minutes",e.contours.join(","));if(s.set("polygons","true"),typeof e.denoise==="number")s.set("denoise",String(e.denoise));if(typeof e.generalize==="number")s.set("generalize",String(e.generalize));let o=`${this.baseUrl}/isochrone/v1/${n}/${t.lng},${t.lat}?${s.toString()}`,r=await Un(o,e.signal),a=[];for(let l of r.features??[]){let c=l.properties?.contour??0;if(l.geometry.type==="Polygon"){let h=l.geometry.coordinates;if(h.length===0)continue;let u={geometry:An(h[0]),contour:c};if(h.length>1)u.holes=h.slice(1).map((f)=>An(f));a.push(u)}else if(l.geometry.type==="LineString")a.push({geometry:An(l.geometry.coordinates),contour:c})}return a}}class Hc{name="mapbox";accessToken;baseUrl;constructor(t){this.accessToken=Ki(t.accessToken),this.baseUrl=(t.baseUrl??Yi).replace(/\/$/,"")}async getMatrix(t,e,n){let i=Bc[n?.profile??"driving"],o=[...t,...e].map((p)=>`${p.lng},${p.lat}`).join(";"),r=t.map((p,m)=>m).join(";"),a=e.map((p,m)=>m+t.length).join(";"),l=new URLSearchParams;l.set("access_token",this.accessToken),l.set("sources",r),l.set("destinations",a);let c=[],h=n?.metric??"time";if(h==="distance"||h==="time")c.push("duration","distance");l.set("annotations",c.join(","));let u=`${this.baseUrl}/directions-matrix/v1/${i}/${o}?${l.toString()}`,f=await Un(u,n?.signal);if(f.code!=="Ok")throw Error(`Mapbox matrix error: ${f.code}${f.message?` — ${f.message}`:""}`);let d={};if(f.durations)d.durations=f.durations;if(f.distances)d.distances=f.distances;return d}}var Np="https://api.maptiler.com";function $p(t){if(!t||t.length===0)return;let e=t[0];switch(e){case"country":case"region":case"district":case"postcode":case"place":case"address":case"poi":return e;default:return}}function Ra(t){let e=t.center??[0,0],n={text:t.place_name??t.text??"",center:{lat:e[1],lng:e[0]},properties:t.properties};if(t.bbox)n.bbox=t.bbox;let i=$p(t.place_type);if(i)n.placeType=i;if(typeof t.relevance==="number")n.relevance=t.relevance;return n}class Wc{name="maptiler";apiKey;baseUrl;constructor(t){if(!t.apiKey)throw Error("Maptiler provider requires an apiKey");this.apiKey=t.apiKey,this.baseUrl=(t.baseUrl??Np).replace(/\/$/,"")}buildParams(t){let e=new URLSearchParams;if(e.set("key",this.apiKey),t?.limit)e.set("limit",String(t.limit));if(t?.language)e.set("language",t.language);if(t?.proximity)e.set("proximity",`${t.proximity.lng},${t.proximity.lat}`);if(t?.bbox)e.set("bbox",t.bbox.join(","));if(t?.countries&&t.countries.length>0)e.set("country",t.countries.join(","));return e}async fetch(t,e){let n=await fetch(t,{signal:e});if(!n.ok)throw Error(`Maptiler request failed: ${n.status} ${n.statusText}`);return await n.json()}async search(t,e){let n=this.buildParams(e),i=`${this.baseUrl}/geocoding/${encodeURIComponent(t)}.json?${n.toString()}`;return((await this.fetch(i,e?.signal)).features??[]).map(Ra)}async reverse(t,e){let n=this.buildParams(e),i=`${this.baseUrl}/geocoding/${t.lng},${t.lat}.json?${n.toString()}`;return((await this.fetch(i,e?.signal)).features??[]).map(Ra)}}N();function Zp(t,e){if(t==="boundary"&&e==="administrative")return"region";if(e==="country")return"country";if(e==="state"||e==="province")return"region";if(e==="city"||e==="town"||e==="village")return"place";if(e==="postcode")return"postcode";if(e==="administrative")return"district";if(t==="highway"||t==="place"&&e==="house")return"address";if(t==="amenity"||t==="shop"||t==="tourism")return"poi";return}function Na(t){let e=Number.parseFloat(t.lat),n=Number.parseFloat(t.lon),i={text:t.display_name,center:{lat:e,lng:n},properties:{...t.address,osm_id:t.osm_id,osm_type:t.osm_type,class:t.class,type:t.type}};if(t.boundingbox){let[o,r,a,l]=t.boundingbox.map(Number.parseFloat);i.bbox=[a,o,l,r]}let s=Zp(t.class,t.type);if(s)i.placeType=s;if(typeof t.importance==="number")i.relevance=Math.max(0,Math.min(1,t.importance));return i}class jo{name="nominatim";baseUrl;userAgent;scheduleRequest;constructor(t={}){this.baseUrl=(t.baseUrl??"https://nominatim.openstreetmap.org").replace(/\/$/,""),this.userAgent=t.userAgent??"ts-maps",this.scheduleRequest=co((e)=>e(),250)}gate(t){return new Promise((e,n)=>{this.scheduleRequest(()=>{t().then(e,n)})})}buildSearchUrl(t,e){let n=new URLSearchParams;if(n.set("q",t),n.set("format","json"),n.set("addressdetails","1"),n.set("limit",String(e?.limit??5)),e?.language)n.set("accept-language",e.language);if(e?.countries&&e.countries.length>0)n.set("countrycodes",e.countries.join(","));if(e?.bbox){let[i,s,o,r]=e.bbox;n.set("viewbox",`${i},${r},${o},${s}`),n.set("bounded","1")}return`${this.baseUrl}/search?${n.toString()}`}buildReverseUrl(t,e){let n=new URLSearchParams;if(n.set("lat",String(t.lat)),n.set("lon",String(t.lng)),n.set("format","json"),n.set("addressdetails","1"),e?.language)n.set("accept-language",e.language);return`${this.baseUrl}/reverse?${n.toString()}`}async fetch(t,e){let n=await fetch(t,{headers:{"User-Agent":this.userAgent,Accept:"application/json"},signal:e});if(!n.ok)throw Error(`Nominatim request failed: ${n.status} ${n.statusText}`);return n.json()}async search(t,e){if(!t)return[];let n=this.buildSearchUrl(t,e);return this.gate(async()=>{let i=await this.fetch(n,e?.signal);return Array.isArray(i)?i.map(Na):[]})}async reverse(t,e){let n=this.buildReverseUrl(t,e);return this.gate(async()=>{let i=await this.fetch(n,e?.signal);if(!i||i.error)return[];return[Na(i)]})}}var Vc={driving:"driving",walking:"foot",cycling:"bike"};function qc(t){return t.map(([e,n])=>({lat:n,lng:e}))}function Bp(t){if(t.maneuver?.instruction)return t.maneuver.instruction;let e=[];if(t.maneuver?.type)e.push(t.maneuver.type);if(t.maneuver?.modifier)e.push(t.maneuver.modifier);if(t.name)e.push(`onto ${t.name}`);return e.join(" ").trim()||"continue"}function Dp(t){if(!t.maneuver?.type)return;if(t.maneuver.modifier)return`${t.maneuver.type}-${t.maneuver.modifier}`.replace(/\s+/g,"-");return t.maneuver.type}function Gc(t){let e={distance:t.distance,duration:t.duration,instruction:Bp(t),geometry:qc(t.geometry?.coordinates??[])},n=Dp(t);if(n)e.maneuver=n;return e}function jp(t){let e=(t.steps??[]).map(Gc),n=e.flatMap((i)=>i.geometry);return{distance:t.distance,duration:t.duration,geometry:n,steps:e}}function Up(t){let e=(t.legs??[]).flatMap((n)=>(n.steps??[]).map(Gc));return{distance:t.distance,duration:t.duration,geometry:qc(t.geometry?.coordinates??[]),steps:e,legs:(t.legs??[]).map(jp)}}class Uo{name="osrm";baseUrl;constructor(t={}){this.baseUrl=(t.baseUrl??"https://router.project-osrm.org").replace(/\/$/,"")}async getDirections(t,e){if(t.length<2)throw Error("OSRM requires at least two waypoints");let n=Vc[e?.profile??"driving"]??"driving",i=t.map((l)=>`${l.lng},${l.lat}`).join(";"),s=new URLSearchParams;s.set("overview","full"),s.set("geometries","geojson"),s.set("steps","true"),s.set("alternatives",e?.alternatives?"true":"false");let o=`${this.baseUrl}/route/v1/${n}/${i}?${s.toString()}`,r=await fetch(o,{signal:e?.signal});if(!r.ok)throw Error(`OSRM request failed: ${r.status} ${r.statusText}`);let a=await r.json();if(a.code!=="Ok")throw Error(`OSRM error: ${a.code}${a.message?` — ${a.message}`:""}`);return(a.routes??[]).map(Up)}}class Ho{name="osrm";baseUrl;constructor(t={}){this.baseUrl=(t.baseUrl??"https://router.project-osrm.org").replace(/\/$/,"")}async getMatrix(t,e,n){if(t.length===0||e.length===0)throw Error("OSRM matrix requires at least one origin and one destination");let i=Vc[n?.profile??"driving"]??"driving",o=[...t,...e].map((p)=>`${p.lng},${p.lat}`).join(";"),r=t.map((p,m)=>m).join(";"),a=e.map((p,m)=>t.length+m).join(";"),l=n?.metric==="distance"?"distance":"duration",c=new URLSearchParams;c.set("sources",r),c.set("destinations",a),c.set("annotations",l);let h=`${this.baseUrl}/table/v1/${i}/${o}?${c.toString()}`,u=await fetch(h,{signal:n?.signal});if(!u.ok)throw Error(`OSRM matrix request failed: ${u.status} ${u.statusText}`);let f=await u.json();if(f.code!=="Ok")throw Error(`OSRM matrix error: ${f.code}${f.message?` — ${f.message}`:""}`);let d={};if(f.durations)d.durations=f.durations.map((p)=>p.map((m)=>m??Number.POSITIVE_INFINITY));if(f.distances)d.distances=f.distances.map((p)=>p.map((m)=>m??Number.POSITIVE_INFINITY));return d}}function Hp(t){if(!t)return;if(t.osm_value==="country"||t.type==="country")return"country";if(t.osm_value==="state"||t.type==="state")return"region";if(t.type==="county")return"district";if(t.osm_key==="place"&&(t.osm_value==="city"||t.osm_value==="town"||t.osm_value==="village"))return"place";if(t.osm_key==="highway"||t.housenumber)return"address";if(t.postcode&&t.type==="postcode")return"postcode";if(t.osm_key==="amenity"||t.osm_key==="shop"||t.osm_key==="tourism")return"poi";return}function Wp(t){if(!t)return"";let e=[];if(t.name)e.push(t.name);if(t.street){let n=t.housenumber?`${t.street} ${t.housenumber}`:t.street;if(!e.length||e[0]!==n)e.push(n)}if(t.postcode||t.city)e.push([t.postcode,t.city].filter(Boolean).join(" "));if(t.country)e.push(t.country);return e.filter(Boolean).join(", ")}function $a(t){let e=t.geometry?.coordinates??[0,0],n={text:Wp(t.properties),center:{lat:e[1],lng:e[0]},properties:t.properties};if(t.properties?.extent){let[s,o,r,a]=t.properties.extent;n.bbox=[s,a,r,o]}let i=Hp(t.properties);if(i)n.placeType=i;return n}class Yc{name="photon";baseUrl;constructor(t={}){this.baseUrl=(t.baseUrl??"https://photon.komoot.io").replace(/\/$/,"")}async search(t,e){if(!t)return[];let n=new URLSearchParams;if(n.set("q",t),n.set("limit",String(e?.limit??5)),e?.language)n.set("lang",e.language);if(e?.proximity)n.set("lat",String(e.proximity.lat)),n.set("lon",String(e.proximity.lng));if(e?.bbox)n.set("bbox",e.bbox.join(","));let i=`${this.baseUrl}/api?${n.toString()}`,s=await fetch(i,{signal:e?.signal});if(!s.ok)throw Error(`Photon request failed: ${s.status} ${s.statusText}`);return((await s.json()).features??[]).map($a)}async reverse(t,e){let n=new URLSearchParams;if(n.set("lat",String(t.lat)),n.set("lon",String(t.lng)),e?.limit)n.set("limit",String(e.limit));if(e?.language)n.set("lang",e.language);let i=`${this.baseUrl}/reverse?${n.toString()}`,s=await fetch(i,{signal:e?.signal});if(!s.ok)throw Error(`Photon reverse request failed: ${s.status} ${s.statusText}`);return((await s.json()).features??[]).map($a)}}var Wo="https://valhalla1.openstreetmap.de",Vo={driving:"auto",walking:"pedestrian",cycling:"bicycle"};function Vp(t,e=6){let n=10**e,i=t.length,s=0,o=0,r=0,a=[];while(s<i){let l=0,c=0,h;do h=t.charCodeAt(s++)-63,c|=(h&31)<<l,l+=5;while(h>=32);let u=c&1?~(c>>1):c>>1;o+=u,l=0,c=0;do h=t.charCodeAt(s++)-63,c|=(h&31)<<l,l+=5;while(h>=32);let f=c&1?~(c>>1):c>>1;r+=f,a.push({lat:o/n,lng:r/n})}return a}function qp(t){let e=t.shape?Vp(t.shape):[],n=(t.maneuvers??[]).map((i)=>{let s=i.begin_shape_index??0,o=i.end_shape_index??s;return{distance:(i.length??0)*1000,duration:i.time??0,instruction:i.instruction??"",geometry:e.slice(s,o+1)}});return{distance:(t.summary?.length??0)*1000,duration:t.summary?.time??0,geometry:e,steps:n}}function Za(t){let e=(t.legs??[]).map(qp),n=e.flatMap((s)=>s.geometry),i=e.flatMap((s)=>s.steps);return{distance:(t.summary?.length??0)*1000,duration:t.summary?.time??0,geometry:n,steps:i,legs:e}}async function qo(t,e,n){let i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e),signal:n});if(!i.ok)throw Error(`Valhalla request failed: ${i.status} ${i.statusText}`);return i.json()}function Go(t,e,n){let i=t.replace(/\/$/,""),s=n?`?api_key=${encodeURIComponent(n)}`:"";return`${i}${e}${s}`}class Yo{name="valhalla";baseUrl;apiKey;constructor(t={}){this.baseUrl=t.baseUrl??Wo,this.apiKey=t.apiKey}async getDirections(t,e){if(t.length<2)throw Error("Valhalla requires at least two waypoints");let n={locations:t.map((r)=>({lat:r.lat,lon:r.lng})),costing:Vo[e?.profile??"driving"]??"auto",directions_options:{language:e?.language??"en-US"}};if(e?.alternatives)n.alternates=1;let i=Go(this.baseUrl,"/route",this.apiKey),s=await qo(i,n,e?.signal),o=[];if(s.trip)o.push(Za(s.trip));if(s.alternates){for(let r of s.alternates)if(r.trip)o.push(Za(r.trip))}return o}}function Tn(t){return t.map(([e,n])=>({lat:n,lng:e}))}class Ko{name="valhalla";baseUrl;apiKey;constructor(t={}){this.baseUrl=t.baseUrl??Wo,this.apiKey=t.apiKey}async getIsochrones(t,e){let n=e.contourMetric??"time",i={locations:[{lat:t.lat,lon:t.lng}],costing:Vo[e.profile??"driving"]??"auto",contours:e.contours.map((a)=>n==="distance"?{distance:a}:{time:a}),polygons:!0};if(typeof e.denoise==="number")i.denoise=e.denoise;if(typeof e.generalize==="number")i.generalize=e.generalize;let s=Go(this.baseUrl,"/isochrone",this.apiKey),o=await qo(s,i,e.signal),r=[];for(let a of o.features??[]){let l=a.properties?.contour??0,{geometry:c}=a;if(c.type==="Polygon"){let h=c.coordinates;if(h.length===0)continue;let u={geometry:Tn(h[0]),contour:l};if(h.length>1)u.holes=h.slice(1).map(Tn);r.push(u)}else if(c.type==="MultiPolygon"){let h=c.coordinates;for(let u of h){if(u.length===0)continue;let f={geometry:Tn(u[0]),contour:l};if(u.length>1)f.holes=u.slice(1).map(Tn);r.push(f)}}else if(c.type==="LineString")r.push({geometry:Tn(c.coordinates),contour:l})}return r}}class Xo{name="valhalla";baseUrl;apiKey;constructor(t={}){this.baseUrl=t.baseUrl??Wo,this.apiKey=t.apiKey}async getMatrix(t,e,n){let i={sources:t.map((h)=>({lat:h.lat,lon:h.lng})),targets:e.map((h)=>({lat:h.lat,lon:h.lng})),costing:Vo[n?.profile??"driving"]??"auto"},s=Go(this.baseUrl,"/sources_to_targets",this.apiKey),o=await qo(s,i,n?.signal),r=[],a=[];for(let h of o.sources_to_targets??[]){let u=[],f=[];for(let d of h)u.push(d.time??0),f.push((d.distance??0)*1000);r.push(u),a.push(f)}let l=n?.metric??"time",c={};if(l==="time"||l==="distance")c.durations=r,c.distances=a;return c}}var Kc=()=>new jo,Gp=()=>new Uo,Yp=()=>new Ko,Kp=()=>new Ho,Xp=()=>new Xo,Jp=()=>new Yo;ct();G();Hn();_t();vt();G();var Xc={};tt(Xc,{_getBitCode:()=>Ce,_getEdgeIntersection:()=>Fi,_sqClosestPointOnSegment:()=>Kn,clipSegment:()=>ih,closestPointOnSegment:()=>Qp,isFlat:()=>Zt,pointToSegmentDistance:()=>nh,polylineCenter:()=>sh,simplify:()=>eh});var Jc={};tt(Jc,{centroid:()=>Jo,clipPolygon:()=>Qc,polygonCenter:()=>th});_t();vt();G();function Qc(t,e,n){let i,s=[1,4,2,8];for(let o=0,r=t.length;o<r;o++)t[o]._code=Ce(t[o],e);for(let o=0;o<4;o++){let r=s[o];i=[];for(let a=0,l=t.length,c=l-1;a<l;c=a++){let h=t[a],u=t[c];if(!(h._code&r)){if(u._code&r){let f=Fi(u,h,r,e,n);f._code=Ce(f,e),i.push(f)}i.push(h)}else if(!(u._code&r)){let f=Fi(u,h,r,e,n);f._code=Ce(f,e),i.push(f)}}t=i}return t}function th(t,e){if(!t||t.length===0)throw Error("latlngs not passed");if(!Zt(t))console.warn("latlngs are not flat! Only the first ring will be used"),t=t[0];let n=new S(0,0),i=new R(t);if(i.getNorthWest().distanceTo(i.getSouthWest())*i.getNorthEast().distanceTo(i.getNorthWest())<1700)n=Jo(t);let o=t.length,r=[];for(let f=0;f<o;f++){let d=new S(t[f]);r.push(e.project(new S(d.lat-n.lat,d.lng-n.lng)))}let a=0,l=0,c=0,h;for(let f=0,d=o-1;f<o;d=f++){let p=r[f],m=r[d],_=p.y*m.x-m.y*p.x;l+=(p.x+m.x)*_,c+=(p.y+m.y)*_,a+=_*3}if(a===0)h=r[0];else h=[l/a,c/a];let u=e.unproject(new v(h));return new S(u.lat+n.lat,u.lng+n.lng)}function Jo(t){let e=0,n=0,i=0;for(let s of t){let o=new S(s);e+=o.lat,n+=o.lng,i++}return new S(e/i,n/i)}function eh(t,e){if(!e||!t.length)return t.slice();let n=e*e;return t=em(t,n),t=tm(t,n),t}function nh(t,e,n){return Math.sqrt(Kn(t,e,n,!0))}function Qp(t,e,n){return Kn(t,e,n)}function tm(t,e){let n=t.length,i=new Uint8Array(n);i[0]=i[n-1]=1,so(t,i,e,0,n-1);let s=[];for(let o=0;o<n;o++)if(i[o])s.push(t[o]);return s}function so(t,e,n,i,s){let o=0,r=0;for(let a=i+1;a<=s-1;a++){let l=Kn(t[a],t[i],t[s],!0);if(l>o)r=a,o=l}if(o>n)e[r]=1,so(t,e,n,i,r),so(t,e,n,r,s)}function em(t,e){let n=[t[0]],i=0;for(let s=1;s<t.length;s++)if(nm(t[s],t[i])>e)n.push(t[s]),i=s;if(i<t.length-1)n.push(t[t.length-1]);return n}var Ba;function ih(t,e,n,i,s){let o=i?Ba:Ce(t,n),r=Ce(e,n);Ba=r;while(!0){if(!(o|r))return[t,e];if(o&r)return!1;let a=o||r,l=Fi(t,e,a,n,s),c=Ce(l,n);if(a===o)t=l,o=c;else e=l,r=c}}function Fi(t,e,n,i,s){let o=e.x-t.x,r=e.y-t.y,{min:a,max:l}=i,c=0,h=0;if(n&8)c=t.x+o*(l.y-t.y)/r,h=l.y;else if(n&4)c=t.x+o*(a.y-t.y)/r,h=a.y;else if(n&2)c=l.x,h=t.y+r*(l.x-t.x)/o;else if(n&1)c=a.x,h=t.y+r*(a.x-t.x)/o;return new v(c,h,s)}function Ce(t,e){let n=0;if(t.x<e.min.x)n|=1;else if(t.x>e.max.x)n|=2;if(t.y<e.min.y)n|=4;else if(t.y>e.max.y)n|=8;return n}function nm(t,e){let n=e.x-t.x,i=e.y-t.y;return n*n+i*i}function Kn(t,e,n,i){let{x:s,y:o}=e,r=n.x-s,a=n.y-o,l=r*r+a*a,c;if(l>0){if(c=((t.x-s)*r+(t.y-o)*a)/l,c>1)s=n.x,o=n.y;else if(c>0)s+=r*c,o+=a*c}return r=t.x-s,a=t.y-o,i?r*r+a*a:new v(s,o)}function Zt(t){return!Array.isArray(t[0])||typeof t[0][0]!=="object"&&typeof t[0][0]<"u"}function sh(t,e){if(!t||t.length===0)throw Error("latlngs not passed");if(!Zt(t))console.warn("latlngs are not flat! Only the first ring will be used"),t=t[0];let n=new S(0,0),i=new R(t);if(i.getNorthWest().distanceTo(i.getSouthWest())*i.getNorthEast().distanceTo(i.getNorthWest())<1700)n=Jo(t);let o=t.length,r=[];for(let h=0;h<o;h++){let u=new S(t[h]);r.push(e.project(new S(u.lat-n.lat,u.lng-n.lng)))}let a=0;for(let h=0;h<o-1;h++)a+=r[h].distanceTo(r[h+1])/2;let l;if(a===0)l=r[0];else{let h=0;l=r[0];for(let u=0;u<o-1;u++){let f=r[u],d=r[u+1],p=f.distanceTo(d);if(h+=p,h>a){let m=(h-a)/p;l=[d.x-m*(d.x-f.x),d.y-m*(d.y-f.y)];break}}}let c=e.unproject(new v(l));return new S(c.lat+n.lat,c.lng+n.lng)}_t();vt();Ka();Ja();var oh={};tt(oh,{Globe:()=>am,LonLat:()=>Qo,Mercator:()=>oo,SphericalMercator:()=>ye});_t();_o();var im=ye.R;function sm(t){let e=new S(t),n=e.lat*Math.PI/180,i=e.lng*Math.PI/180,s=Math.cos(n);return{x:s*Math.sin(i),y:Math.sin(n),z:s*Math.cos(i)}}function om(t){let e=Math.hypot(t.x,t.y,t.z)||1,n=Math.asin(Math.max(-1,Math.min(1,t.y/e))),i=Math.atan2(t.x,t.z);return new S(n*180/Math.PI,i*180/Math.PI)}function rm(t,e,n){if(t<=e)return 1;if(t>=n)return 0;let i=(t-e)/(n-e);return 1-i*i*(3-2*i)}var am={R:im,GLOBE_START_ZOOM:5.5,GLOBE_END_ZOOM:6,project(t){return ye.project(t)},unproject(t){return ye.unproject(t)},bounds:ye.bounds,toSphere:sm,fromSphere:om,globeToMercatorMix(t){return rm(t,this.GLOBE_START_ZOOM,this.GLOBE_END_ZOOM)}};ct();G();_t();var Qo={project(t){let e=new S(t);return new v(e.lng,e.lat)},unproject(t){let e=new v(t);return new S(e.y,e.x)},bounds:new I([-180,-90],[180,90])};ct();G();_t();var lm=6378137,oo={R:lm,R_MINOR:6356752.314245179,bounds:new I([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project(t){let e=new S(t),n=Math.PI/180,i=this.R,s=this.R_MINOR/i,o=Math.sqrt(1-s*s),r=e.lat*n,a=o*Math.sin(r),l=Math.tan(Math.PI/4-r/2)/((1-a)/(1+a))**(o/2);return r=-i*Math.log(Math.max(l,0.0000000001)),new v(e.lng*n*i,r)},unproject(t){let e=new v(t),n=180/Math.PI,i=this.R,s=this.R_MINOR/i,o=Math.sqrt(1-s*s),r=Math.exp(-e.y/i),a=Math.PI/2-2*Math.atan(r),l=0.1;for(let c=0;c<15&&Math.abs(l)>0.0000001;c++){let h=o*Math.sin(a);h=((1-h)/(1+h))**(o/2),l=Math.PI/2-2*Math.atan(r*h)-a,a+=l}return new S(a*n,e.x*n/i)}};_o();fo();on();Hn();on();class rh extends we{static code="EPSG:3395";static projection=oo;static transformation=(()=>{let t=0.5/(Math.PI*oo.R);return new Be(t,0.5,-t,0.5)})()}Qa();Hn();on();class tr extends we{static code="EPSG:4326";static projection=Qo;static transformation=new Be(0.005555555555555556,1,-0.005555555555555556,0.5)}Hn();fo();class ah extends Zi{static projection=Qo;static transformation=new Be(1,0,-1,0);static infinite=!0;static scale(t){return 2**t}static zoom(t){return Math.log(t)/Math.LN2}static distance(t,e){let n=e.lng-t.lng,i=e.lat-t.lat;return Math.sqrt(n*n+i*i)}}Bi();ll();H();Y();st();N();Y();qn();st();class Ct extends rn{_map;onAdd(t){return document.createElement("div")}onRemove(t){}initialize(...t){et(this,t[0])}getPosition(){return this.options.position}setPosition(t){let e=this._map;return e?.removeControl(this),this.options.position=t,e?.addControl(this),this}getContainer(){return this._container}addTo(t){this.remove(),this._map=t;let e=this._container=this.onAdd(t),n=this.getPosition(),i=t._controlCorners[n];if(e.classList.add("tsmap-control"),n.includes("bottom"))i.insertBefore(e,i.firstChild);else i.appendChild(e);return this._map.on("unload",this.remove,this),this}remove(){if(!this._map)return this;return this._container?.remove(),this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this}_refocusOnMap(t){if(this._map&&t&&!(t.screenX===0&&t.screenY===0))this._map.getContainer().focus()}}Ct.setDefaultOptions({position:"topright"});F.include({addControl(t){return t.addTo(this),this},removeControl(t){return t.remove(),this},_initControlPos(){let t=this._controlCorners={},e="tsmap-",n=this._controlContainer=A("div","tsmap-control-container",this._container);function i(s,o){let r=`${"tsmap-"+s} tsmap-${o}`;t[s+o]=A("div",r,n)}i("top","left"),i("top","right"),i("bottom","left"),i("bottom","right")},_clearControlPos(){for(let t of Object.values(this._controlCorners))t.remove();this._controlContainer?.remove(),delete this._controlCorners,delete this._controlContainer}});var cm='<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" class="tsmap-attribution-flag"><path fill="#4C7BE1" d="M0 0h12v4H0z"/><path fill="#FFD500" d="M0 4h12v3H0z"/><path fill="#E0BC00" d="M0 7h12v1H0z"/></svg>';class Xn extends Ct{initialize(t){super.initialize(t),this._attributions={}}onAdd(t){t.attributionControl=this,this._container=A("div","tsmap-control-attribution"),se(this._container);for(let e of Object.values(t._layers))if(e.getAttribution)this.addAttribution(e.getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container}onRemove(t){t.off("layeradd",this._addAttribution,this)}_addAttribution(t){if(t.layer.getAttribution)this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",()=>this.removeAttribution(t.layer.getAttribution()))}setPrefix(t){return this.options.prefix=t,this._update(),this}addAttribution(t){if(!t)return this;if(!this._attributions[t])this._attributions[t]=0;return this._attributions[t]++,this._update(),this}removeAttribution(t){if(!t)return this;if(this._attributions[t])this._attributions[t]--,this._update();return this}_update(){if(!this._map)return;let t=Object.keys(this._attributions).filter((n)=>this._attributions[n]),e=[];if(this.options.prefix)e.push(this.options.prefix);if(t.length)e.push(t.join(", "));this._container.innerHTML=e.join(' <span aria-hidden="true">|</span> ')}}Xn.setDefaultOptions({position:"bottomright",prefix:`<a target="_blank" href="https://github.com/stacksjs/ts-maps" title="ts-maps">${cm}ts-maps</a>`});F.mergeOptions({attributionControl:!0});F.addInitHook(function(){if(this.options.attributionControl)new Xn().addTo(this)});H();Y();var _i="tsmap-control-fullscreen",Da="tsmap-pseudo-fullscreen";class Xi extends Ct{onAdd(t){let e=this.options,n=A("div",`${_i} tsmap-bar`),i=A("a",`${_i}-button`,n);return i.href="#",i.setAttribute("role","button"),i.innerHTML='<span class="tsmap-fullscreen-icon" aria-hidden="true"></span>',se(i),k(i,"click",dt),k(i,"click",this.toggle,this),this._button=i,this._updateButton(!1),this._onDocumentChange=()=>this._syncFromDocument(),document.addEventListener("fullscreenchange",this._onDocumentChange),document.addEventListener("webkitfullscreenchange",this._onDocumentChange),n}onRemove(t){if(this._onDocumentChange)document.removeEventListener("fullscreenchange",this._onDocumentChange),document.removeEventListener("webkitfullscreenchange",this._onDocumentChange),this._onDocumentChange=void 0;if(this._pseudo)this._exitPseudo()}isFullscreen(){return this._pseudo===!0||this._documentElement()===this._target()}toggle(){return this.isFullscreen()?this.exit():this.request()}request(){let t=this._target(),e=t?.requestFullscreen??t?.webkitRequestFullscreen;if(typeof e==="function")return Promise.resolve(e.call(t)).catch(()=>this._enterPseudo()),this;return this._enterPseudo(),this}exit(){if(this._pseudo)return this._exitPseudo(),this;let t=document,e=t.exitFullscreen??t.webkitExitFullscreen;if(typeof e==="function")Promise.resolve(e.call(t)).catch(()=>{});return this}_target(){return this.options.container??this._map?.getContainer()}_documentElement(){let t=document;return t.fullscreenElement??t.webkitFullscreenElement??null}_enterPseudo(){if(this._pseudo)return;this._pseudo=!0,this._target()?.classList.add(Da),this._onChanged(!0)}_exitPseudo(){if(!this._pseudo)return;this._pseudo=!1,this._target()?.classList.remove(Da),this._onChanged(!1)}_syncFromDocument(){this._onChanged(this._documentElement()===this._target())}_onChanged(t){this._updateButton(t),this._map?.invalidateSize?.(),this._map?.fire?.(t?"fullscreenstart":"fullscreenend",{fullscreen:t})}_updateButton(t){let e=this._button;if(!e)return;let n=this.options,i=t?n.titleCancel??"Exit fullscreen":n.title??"View fullscreen";if(e.title=i,e.setAttribute("aria-label",i),e.setAttribute("aria-pressed",String(t)),t)e.classList.add(`${_i}-active`);else e.classList.remove(`${_i}-active`)}}Xi.setDefaultOptions({position:"topright"});H();Y();G();Te();qn();N();G();class an extends rn{initialize(t){et(this,t)}createIcon(t){return this._createIcon("icon",t)}createShadow(t){return this._createIcon("shadow",t)}_createIcon(t,e){let n=this._getIconUrl(t);if(!n){if(t==="icon")throw Error("iconUrl not set in Icon options (see the docs).");return null}let i=this._createImg(n,e&&e.tagName==="IMG"?e:null);if(this._setIconStyles(i,t),this.options.crossOrigin||this.options.crossOrigin==="")i.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;return i}_setIconStyles(t,e){let n=this.options,i=n[`${e}Size`];if(typeof i==="number")i=[i,i];let s=v.validate(i)&&new v(i),o=e==="shadow"&&n.shadowAnchor||n.iconAnchor||s&&s.divideBy(2)._round(),r=v.validate(o)&&new v(o);if(t.className=`tsmap-marker-${e} ${n.className||""}`,r)t.style.marginLeft=`${-r.x}px`,t.style.marginTop=`${-r.y}px`;if(s)t.style.width=`${s.x}px`,t.style.height=`${s.y}px`}_createImg(t,e){return e??=document.createElement("img"),e.src=t,e}_getIconUrl(t){return pt.retina&&this.options[`${t}RetinaUrl`]||this.options[`${t}Url`]}}an.setDefaultOptions({popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1});class ln extends an{createIcon(t){let e=t&&t.tagName==="DIV"?t:document.createElement("div"),n=this.options;if(n.html instanceof Element)e.replaceChildren(),e.appendChild(n.html);else e.innerHTML=n.html!==!1?n.html:"";if(n.bgPos){let i=new v(n.bgPos);e.style.backgroundPosition=`${-i.x}px ${-i.y}px`}return this._setIconStyles(e,"icon"),e}createShadow(){return null}}ln.setDefaultOptions({iconSize:[12,12],html:!1,bgPos:null,className:"tsmap-div-icon"});N();H();Y();_t();G();Mt();var ja="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="25" height="41" viewBox="0 0 25 41"><path fill="#2b83f6" stroke="#1e5fad" stroke-width="1" d="M12.5 0C5.6 0 0 5.6 0 12.5c0 9.4 12.5 28.5 12.5 28.5S25 21.9 25 12.5C25 5.6 19.4 0 12.5 0z"/><circle cx="12.5" cy="12.5" r="5" fill="#fff"/></svg>'),hm="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="41" height="41" viewBox="0 0 41 41"><ellipse cx="20.5" cy="31" rx="14" ry="6" fill="#000" opacity="0.28"/></svg>'),Qm="data:image/svg+xml,"+encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36"><rect x="4" y="4" width="14" height="14" fill="#fff" stroke="#666" stroke-width="1.5"/><rect x="10" y="10" width="14" height="14" fill="#e8e8e8" stroke="#666" stroke-width="1.5"/><rect x="16" y="16" width="14" height="14" fill="#d0d0d0" stroke="#666" stroke-width="1.5"/></svg>');Y();function um(t){return t.startsWith("data:")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("blob:")||t.startsWith("/")}class Ie extends an{static imagePath;_getIconUrl(t){let e=super._getIconUrl(t);if(!e)return null;if(um(e))return e;if(!Ie.imagePath)Ie.imagePath=this._detectIconPath();return(this.options.imagePath||Ie.imagePath)+e}_stripUrl(t){let e=(i,s,o)=>{let r=s.exec(i);return r&&r[o]},n=e(t,/^url\((['"])?(.+)\1\)$/,2);if(!n)return null;if(n.startsWith("data:"))return"";return e(n,/^(.*)marker-icon\.svg$/,1)}_detectIconPath(){let t=A("div","tsmap-default-icon-path",document.body),e=this._stripUrl(getComputedStyle(t).backgroundImage);if(document.body.removeChild(t),e)return e;let n=document.querySelector('link[href$="ts-maps.css"]');if(!n)return"";return n.href.substring(0,n.href.length-11-1)}}Ie.setDefaultOptions({iconUrl:ja,iconRetinaUrl:ja,shadowUrl:hm,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]});Y();qn();class It extends rn{_enabled=!1;static addTo(t,e){return t.addHandler(e,this),this}initialize(...t){this._map=t[0]}enable(){if(this._enabled)return this;return this._enabled=!0,this.addHooks(),this}disable(){if(!this._enabled)return this;return this._enabled=!1,this.removeHooks(),this}enabled(){return!!this._enabled}addHooks(){}removeHooks(){}}N();H();De();Y();Pe();G();class qt extends wt{static _dragging=!1;initialize(t,e,n,i){et(this,i),this._element=t,this._dragStartTarget=e??t,this._preventOutline=n}enable(){if(this._enabled)return this;return k(this._dragStartTarget,"pointerdown",this._onDown,this),this._enabled=!0,this}disable(){if(!this._enabled)return this;if(qt._dragging===this)this.finishDrag(!0);return Z(this._dragStartTarget,"pointerdown",this._onDown,this),this._enabled=!1,this._moved=!1,this}_onDown(t){if(this._moved=!1,this._element.classList.contains("tsmap-zoom-anim"))return;if(Kt().length!==1){if(qt._dragging===this)this.finishDrag();return}if(qt._dragging||t.shiftKey||t.button!==0&&t.pointerType!=="touch")return;if(qt._dragging=this,this._preventOutline)vo(this._element);if(bo(),go(),this._moving)return;this.fire("down");let e=ml(this._element);this._startPoint=new v(t.clientX,t.clientY),this._startPos=Re(this._element),this._parentScale=xo(e),k(this._dragStartTarget,"pointermove",this._onMove,this),k(this._dragStartTarget,"pointerup pointercancel",this._onUp,this)}_onMove(t){if(Kt().length>1){this._moved=!0;return}let e=new v(t.clientX,t.clientY)._subtract(this._startPoint);if(!e.x&&!e.y)return;if(Math.abs(e.x)+Math.abs(e.y)<this.options.clickTolerance)return;if(e.x/=this._parentScale.x,e.y/=this._parentScale.y,t.cancelable)t.preventDefault();if(!this._moved)this.fire("dragstart"),this._moved=!0,this._element.ownerDocument.body.classList.add("tsmap-dragging"),this._lastTarget=t.target??t.srcElement,this._lastTarget.classList.add("tsmap-drag-target");this._newPos=this._startPos.add(e),this._moving=!0,this._lastEvent=t,this._updatePosition()}_updatePosition(){let t={originalEvent:this._lastEvent};this.fire("predrag",t),lt(this._element,this._newPos),this.fire("drag",t)}_onUp(){this.finishDrag()}finishDrag(t){if(this._element.ownerDocument.body.classList.remove("tsmap-dragging"),this._lastTarget)this._lastTarget.classList.remove("tsmap-drag-target"),this._lastTarget=null;Z(this._dragStartTarget,"pointermove",this._onMove,this),Z(this._dragStartTarget,"pointerup pointercancel",this._onUp,this),wo(),yo();let e=this._moved&&this._moving;if(this._moving=!1,qt._dragging=!1,e)this.fire("dragend",{noInertia:t,distance:this._newPos.distanceTo(this._startPos)})}}qt.setDefaultOptions({clickTolerance:3});ct();G();class ro extends It{_marker;initialize(t){super.initialize(t._map),this._marker=t}addHooks(){let t=this._marker._icon;if(!this._draggable)this._draggable=new qt(t,t,!0);this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),t.classList.add("tsmap-marker-draggable")}removeHooks(){this._draggable?.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon?.classList.remove("tsmap-marker-draggable")}moved(){return this._draggable?._moved}_adjustPan(t){let e=this._marker,n=e._map,i=e.options.autoPanSpeed,s=e.options.autoPanPadding,o=Re(e._icon),r=n.getPixelBounds(),a=n.getPixelOrigin(),l=new I(r.min._subtract(a).add(s),r.max._subtract(a).subtract(s));if(!l.contains(o)){let c=new v((Math.max(l.max.x,o.x)-l.max.x)/(r.max.x-l.max.x)-(Math.min(l.min.x,o.x)-l.min.x)/(r.min.x-l.min.x),(Math.max(l.max.y,o.y)-l.max.y)/(r.max.y-l.max.y)-(Math.min(l.min.y,o.y)-l.min.y)/(r.min.y-l.min.y)).multiplyBy(i);n.panBy(c,{animate:!1});let h=this._draggable;h._newPos._add(c),h._startPos._add(c),lt(e._icon,h._newPos),this._onDrag(t),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,t))}}_onDragStart(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup?.(),this._marker.fire("movestart").fire("dragstart")}_onPreDrag(t){if(this._marker.options.autoPan){if(this._panRequest!==void 0)cancelAnimationFrame(this._panRequest);this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,t))}}_onDrag(t){let e=this._marker,n=e._shadow,i=Re(e._icon),s=e._map.layerPointToLatLng(i);if(n)lt(n,i);e._latlng=s,t.latlng=s,t.oldLatLng=this._oldLatLng,e.fire("move",t).fire("drag",t)}_onDragEnd(t){if(this._panRequest!==void 0)cancelAnimationFrame(this._panRequest);delete this._oldLatLng,this._marker.fire("moveend").fire("dragend",t)}}class Me extends mt{initialize(t,e){et(this,e),this._latlng=new S(t)}onAdd(t){if(this._zoomAnimated=this._zoomAnimated&&t.options.markerZoomAnimation,this._zoomAnimated)t.on("zoomanim",this._animateZoom,this);this._initIcon(),this.update()}onRemove(t){if(this.dragging?.enabled())this.options.draggable=!0,this.dragging.removeHooks();if(delete this.dragging,this._zoomAnimated)t.off("zoomanim",this._animateZoom,this);this._removeIcon(),this._removeShadow()}getEvents(){return{zoom:this.update,viewreset:this.update}}getLatLng(){return this._latlng}setLatLng(t){let e=this._latlng;return this._latlng=new S(t),this.update(),this.fire("move",{oldLatLng:e,latlng:this._latlng})}setZIndexOffset(t){return this.options.zIndexOffset=t,this.update()}getIcon(){return this.options.icon}setIcon(t){if(this.options.icon=t,this._map)this._initIcon(),this.update();if(this._popup)this.bindPopup(this._popup,this._popup.options);return this}getElement(){return this._icon}update(){if(this._icon&&this._map){let t=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(t)}return this}_initIcon(){let t=this.options,e=`tsmap-zoom-${this._zoomAnimated?"animated":"hide"}`,n=t.icon.createIcon(this._icon),i=!1;if(n!==this._icon){if(this._icon)this._removeIcon();if(i=!0,t.title)n.title=t.title;if(n.tagName==="IMG")n.alt=t.alt??""}if(n.classList.add(e),t.keyboard)n.tabIndex=0,n.setAttribute("role","button");if(this._icon=n,t.riseOnHover)this.on({pointerover:this._bringToFront,pointerout:this._resetZIndex});if(t.autoPanOnFocus)k(n,"focus",this._panOnFocus,this);let s=t.icon.createShadow(this._shadow),o=!1;if(s!==this._shadow)this._removeShadow(),o=!0;if(s)s.classList.add(e),s.alt="";if(this._shadow=s,t.opacity<1)this._updateOpacity();if(i)this.getPane().appendChild(this._icon);if(this._initInteraction(),s&&o)this.getPane(t.shadowPane).appendChild(this._shadow)}_removeIcon(){if(this.options.riseOnHover)this.off({pointerover:this._bringToFront,pointerout:this._resetZIndex});if(this.options.autoPanOnFocus)Z(this._icon,"focus",this._panOnFocus,this);this._icon?.remove(),this.removeInteractiveTarget(this._icon),this._icon=null}_removeShadow(){this._shadow?.remove(),this._shadow=null}_setPos(t){if(this._icon)lt(this._icon,t);if(this._shadow)lt(this._shadow,t);this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()}_updateZIndex(t){if(this._icon)this._icon.style.zIndex=String(this._zIndex+t)}_animateZoom(t){let e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(e)}_initInteraction(){if(!this.options.interactive)return;if(this._icon.classList.add("tsmap-interactive"),this.addInteractiveTarget(this._icon),ro){let t=this.options.draggable;if(this.dragging)t=this.dragging.enabled(),this.dragging.disable();if(this.dragging=new ro(this),t)this.dragging.enable()}}setOpacity(t){if(this.options.opacity=t,this._map)this._updateOpacity();return this}_updateOpacity(){let t=this.options.opacity;if(this._icon)this._icon.style.opacity=String(t);if(this._shadow)this._shadow.style.opacity=String(t)}_bringToFront(){this._updateZIndex(this.options.riseOffset)}_resetZIndex(){this._updateZIndex(0)}_panOnFocus(){let t=this._map;if(!t)return;let e=this.options.icon.options,n=e.iconSize?new v(e.iconSize):new v(0,0),i=e.iconAnchor?new v(e.iconAnchor):new v(0,0);t.panInside(this._latlng,{paddingTopLeft:i,paddingBottomRight:n.subtract(i)})}_getPopupAnchor(){return this.options.icon.options.popupAnchor}_getTooltipAnchor(){return this.options.icon.options.tooltipAnchor}}Me.setDefaultOptions({icon:new Ie,interactive:!0,keyboard:!0,title:"",alt:"Marker",zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:"markerPane",shadowPane:"shadowPane",bubblingPointerEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10});var it="tsmap-control-geocoder";class Ji extends Ct{onAdd(t){let e=this.options;this._results=[],this._selected=-1;let n=A("div",`${it} tsmap-bar`);if(e.collapsed){let r=A("a",`${it}-toggle`,n);r.href="#",r.title=e.title??"Search for a place",r.setAttribute("role","button"),r.setAttribute("aria-label",r.title),r.setAttribute("aria-expanded","false"),r.innerHTML='<span class="tsmap-geocoder-icon" aria-hidden="true"></span>',k(r,"click",dt),k(r,"click",this._onToggle,this),this._toggle=r}let i=A("div",`${it}-form`,n),s=A("input",`${it}-input`,i);s.type="text",s.placeholder=e.placeholder??"Search",s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-label",e.title??"Search for a place"),s.autocomplete="off";let o=A("ul",`${it}-list`,n);return o.setAttribute("role","listbox"),this._input=s,this._list=o,se(n),ji(n),k(s,"input",this._onInput,this),k(s,"keydown",this._onKeyDown,this),this._setExpanded(!e.collapsed),n}onRemove(t){this._cancelPending(),this._marker?.remove(),this._marker=void 0}setQuery(t){if(this._input)this._input.value=t;return this._search(t),this}clear(){if(this._cancelPending(),this._input)this._input.value="";return this._results=[],this._selected=-1,this._renderList(),this._marker?.remove(),this._marker=void 0,this}_onToggle(){if(this._setExpanded(!this._expanded),this._expanded)this._input?.focus()}_setExpanded(t){if(this._expanded=t,t)this._container?.classList.add(`${it}-expanded`);else this._container?.classList.remove(`${it}-expanded`);this._toggle?.setAttribute("aria-expanded",String(t))}_onInput(){this._search(this._input?.value??"")}_search(t){let e=this.options,n=t.trim();if(this._cancelPending(),n.length<(e.minLength??3)){this._results=[],this._selected=-1,this._renderList();return}let i=()=>this._request(n),s=e.debounce??300;if(s>0)this._timer=setTimeout(i,s);else i()}_request(t){let e=this.options,n=e.provider??Kc(),i=typeof AbortController==="function"?new AbortController:void 0;this._abort=i,this._container?.classList.add(`${it}-busy`),n.search(t,{limit:e.limit??5,language:e.language,countries:e.countries,bbox:e.bbox,proximity:e.proximity===!1?void 0:this._map?.getCenter?.(),signal:i?.signal}).then((s)=>{if(this._abort!==i)return;this._container?.classList.remove(`${it}-busy`),this._results=s??[],this._selected=-1,this._renderList(),this._map?.fire?.("geocoderesults",{query:t,results:this._results})}).catch((s)=>{if(this._abort!==i||s?.name==="AbortError")return;this._container?.classList.remove(`${it}-busy`),this._results=[],this._renderList(),this._map?.fire?.("geocodeerror",{query:t,error:s})})}_renderList(){let t=this._list;if(!t)return;t.replaceChildren();let e=this._results.length>0;if(e)this._container?.classList.add(`${it}-open`);else this._container?.classList.remove(`${it}-open`);if(this._input?.setAttribute("aria-expanded",String(e)),!e){this._input?.removeAttribute("aria-activedescendant");return}this._results.forEach((n,i)=>{let s=A("li",`${it}-item`,t);if(s.textContent=n.text,s.id=`${it}-item-${i}`,s.setAttribute("role","option"),s.setAttribute("aria-selected",String(i===this._selected)),i===this._selected)s.classList.add(`${it}-item-active`);k(s,"click",dt),k(s,"click",()=>this.select(i),this)})}_onKeyDown(t){switch(t.key){case"ArrowDown":dt(t),this._move(1);break;case"ArrowUp":dt(t),this._move(-1);break;case"Enter":if(dt(t),this._results.length)this.select(this._selected>=0?this._selected:0);break;case"Escape":dt(t),this.clear();break}}_move(t){if(!this._results.length)return;let e=this._results.length;this._selected=(this._selected+t+e)%e,this._renderList(),this._input?.setAttribute("aria-activedescendant",`${it}-item-${this._selected}`)}select(t){let e=this._results[t],n=this._map;if(!e||!n)return this;let i=this.options,s=[e.center.lat,e.center.lng];if(e.bbox){let[o,r,a,l]=e.bbox;n.fitBounds([[r,o],[l,a]])}else{let o=i.zoom??14;if(i.flyTo!==!1&&typeof n.flyTo==="function")n.flyTo(s,o);else n.setView(s,o)}if(i.marker!==!1)if(this._marker)this._marker.setLatLng(s);else this._marker=new Me(s,{icon:new ln({className:`${it}-marker`,iconSize:[14,14],iconAnchor:[7,7]})}).addTo(n);if(this._input)this._input.value=e.text;return this._results=[],this._selected=-1,this._renderList(),n.fire?.("geocodeselect",{result:e}),this}_cancelPending(){if(this._timer!==void 0)clearTimeout(this._timer),this._timer=void 0;this._abort?.abort(),this._abort=void 0,this._container?.classList.remove(`${it}-busy`)}}Ji.setDefaultOptions({position:"topleft",placeholder:"Search",limit:5,debounce:300,minLength:3,collapsed:!1,flyTo:!0,zoom:14,marker:!0,proximity:!0});N();H();Y();class Qi extends Ct{_lastZIndex=0;_handlingClick=!1;_preventClick=!1;initialize(t,e,n){super.initialize(n),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(let[i,s]of Object.entries(t??{}))this._addLayer(s,i);for(let[i,s]of Object.entries(e??{}))this._addLayer(s,i,!0)}onAdd(t){this._initLayout(),this._update(),this._map=t,t.on("zoomend",this._checkDisabledLayers,this);for(let e of this._layers)e.layer.on("add remove",this._onLayerChange,this);if(!this.options.collapsed)t.on("resize",this._expandIfNotCollapsed,this);return this._container}addTo(t){return super.addTo(t),this._expandIfNotCollapsed()}onRemove(){this._map.off("zoomend",this._checkDisabledLayers,this);for(let t of this._layers)t.layer.off("add remove",this._onLayerChange,this);this._map.off("resize",this._expandIfNotCollapsed,this)}addBaseLayer(t,e){return this._addLayer(t,e),this._map?this._update():this}addOverlay(t,e){return this._addLayer(t,e,!0),this._map?this._update():this}removeLayer(t){t.off("add remove",this._onLayerChange,this);let e=this._getLayer(j(t));if(e)this._layers.splice(this._layers.indexOf(e),1);return this._map?this._update():this}expand(){clearTimeout(this._collapseDelayTimeout),this._container.classList.add("tsmap-control-layers-expanded"),this._section.style.height="";let t=this._map.getSize().y-(this._container.offsetTop+50);if(t<this._section.clientHeight)this._section.classList.add("tsmap-control-layers-scrollbar"),this._section.style.height=`${t}px`;else this._section.classList.remove("tsmap-control-layers-scrollbar");return this._checkDisabledLayers(),this}collapse(t){if(!t||!((t.type==="pointerleave"||t.type==="pointerout")&&t.pointerType==="touch")){if(this.options.collapseDelay>0)return this._collapseDelayTimeout=setTimeout(()=>{this._container.classList.remove("tsmap-control-layers-expanded")},this.options.collapseDelay),this;this._container.classList.remove("tsmap-control-layers-expanded")}return this}_initLayout(){let e=this._container=A("div","tsmap-control-layers"),n=this.options.collapsed;se(e),ji(e);let i=this._section=A("fieldset","tsmap-control-layers-list");if(n)this._map.on("click",this.collapse,this),k(e,{pointerenter:this._expandSafely,pointerleave:this.collapse},this);let s=this._layersLink=A("a","tsmap-control-layers-toggle",e);if(s.href="#",s.title="Layers",s.setAttribute("role","button"),k(s,{keydown(o){if(o.code==="Enter")this._expandSafely()},click(o){o.preventDefault(),this._expandSafely()}},this),!n)this.expand();this._baseLayersList=A("div","tsmap-control-layers-base",i),this._separator=A("div","tsmap-control-layers-separator",i),this._overlaysList=A("div","tsmap-control-layers-overlays",i),e.appendChild(i)}_getLayer(t){for(let e of this._layers)if(e&&j(e.layer)===t)return e}_addLayer(t,e,n){if(this._map)t.on("add remove",this._onLayerChange,this);if(this._layers.push({layer:t,name:e,overlay:n}),this.options.sortLayers)this._layers.sort((i,s)=>this.options.sortFunction(i.layer,s.layer,i.name,s.name));if(this.options.autoZIndex&&t.setZIndex)this._lastZIndex++,t.setZIndex(this._lastZIndex);this._expandIfNotCollapsed()}_update(){if(!this._container)return this;this._baseLayersList.replaceChildren(),this._overlaysList.replaceChildren(),this._layerControlInputs=[];for(let i of this._layers)this._addItem(i);let t=this._layers.some((i)=>!!i.overlay),e=this._layers.filter((i)=>!i.overlay).length,n=e>0;if(this.options.hideSingleBase)n=n&&e>1,this._baseLayersList.style.display=n?"":"none";return this._separator.style.display=t&&n?"":"none",this}_onLayerChange(t){if(!this._handlingClick)this._update();let e=this._getLayer(j(t.target)),n=e.overlay?t.type==="add"?"overlayadd":"overlayremove":t.type==="add"?"baselayerchange":null;if(n)this._map.fire(n,e)}_addItem(t){let e=document.createElement("label"),n=this._map.hasLayer(t.layer),i=document.createElement("input");if(i.type=t.overlay?"checkbox":"radio",i.className="tsmap-control-layers-selector",i.defaultChecked=n,!t.overlay)i.name=`tsmap-base-layers_${j(this)}`;this._layerControlInputs.push(i),i.layerId=j(t.layer),k(i,"click",this._onInputClick,this);let s=document.createElement("span");s.innerHTML=` ${t.name}`;let o=document.createElement("span");return e.appendChild(o),o.appendChild(i),o.appendChild(s),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(e),this._checkDisabledLayers(),e}_onInputClick(t){if(this._preventClick)return;let e=this._layerControlInputs,n=[],i=[];this._handlingClick=!0;for(let s of e){let o=this._getLayer(s.layerId).layer;if(s.checked)n.push(o);else i.push(o)}for(let s of i)if(this._map.hasLayer(s))this._map.removeLayer(s);for(let s of n)if(!this._map.hasLayer(s))this._map.addLayer(s);this._handlingClick=!1,this._refocusOnMap(t)}_checkDisabledLayers(){let t=this._layerControlInputs,e=this._map.getZoom();for(let n of t){let i=this._getLayer(n.layerId).layer;n.disabled=i.options.minZoom!==void 0&&e<i.options.minZoom||i.options.maxZoom!==void 0&&e>i.options.maxZoom}}_expandIfNotCollapsed(){if(this._map&&!this.options.collapsed)this.expand();return this}_expandSafely(){let t=this._section;this._preventClick=!0,k(t,"click",xe),this.expand(),setTimeout(()=>{Z(t,"click",xe),this._preventClick=!1})}}Qi.setDefaultOptions({collapsed:!0,collapseDelay:0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction(t,e,n,i){return n<i?-1:i<n?1:0}});H();Y();on();vt();N();_t();ct();N();Mt();class Ze extends mt{beforeAdd(t){this._renderer=t.getRenderer(this)}onAdd(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)}onRemove(){this._renderer._removePath(this)}redraw(){if(this._map)this._renderer._updatePath(this);return this}setStyle(t){if(et(this,t),this._renderer){if(this._renderer._updateStyle(this),this.options.stroke&&t&&Object.hasOwn(t,"weight"))this._updateBounds()}return this}bringToFront(){return this._renderer?._bringToFront(this),this}bringToBack(){return this._renderer?._bringToBack(this),this}getElement(){return this._path}_reset(){this._project(),this._update()}_clickTolerance(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}_project(){}_update(){}_updateBounds(){}}Ze.setDefaultOptions({stroke:!0,color:"#3388ff",weight:3,opacity:1,lineCap:"round",lineJoin:"round",dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:0.2,fillRule:"evenodd",interactive:!0,bubblingPointerEvents:!0});class cn extends Ze{initialize(t,e){et(this,e),this._latlng=new S(t),this._radius=this.options.radius}setLatLng(t){let e=this._latlng;return this._latlng=new S(t),this.redraw(),this.fire("move",{oldLatLng:e,latlng:this._latlng})}getLatLng(){return this._latlng}setRadius(t){return this.options.radius=this._radius=t,this.redraw()}getRadius(){return this._radius}setStyle(t){if(super.setStyle(t),t?.radius!==void 0)this.setRadius(t.radius);return this}_project(){this._point=this._map.latLngToLayerPoint(this._latlng),this._pxRadius=this._radius,this._updateBounds()}_updateBounds(){let t=this._pxRadius,e=this._pxRadiusY??t,n=this._clickTolerance(),i=[t+n,e+n];this._pxBounds=new I(this._point.subtract(i),this._point.add(i))}_update(){if(this._map)this._updatePath()}_updatePath(){this._renderer._updateCircle(this)}_empty(){return!!this._pxRadius&&!this._renderer._bounds.intersects(this._pxBounds)}_containsPoint(t){return t.distanceTo(this._point)<=this._pxRadius+this._clickTolerance()}}cn.setDefaultOptions({fill:!0,radius:10});class Jn extends cn{initialize(t,e){if(super.initialize(t,e),Number.isNaN(this.options.radius))throw Error("Circle radius cannot be NaN")}getBounds(){let t=[this._pxRadius,this._pxRadiusY??this._pxRadius];return new R(this._map.layerPointToLatLng(this._point.subtract(t)),this._map.layerPointToLatLng(this._point.add(t)))}_project(){let t=this._latlng.lng,e=this._latlng.lat,n=this._map,i=n.options.crs;if(i.distance===we.distance){let s=Math.PI/180,o=this._radius/we.R/s,r=n.project([e+o,t]),a=n.project([e-o,t]),l=r.add(a).divideBy(2),c=n.unproject(l).lat,h=Math.acos((Math.cos(o*s)-Math.sin(e*s)*Math.sin(c*s))/(Math.cos(e*s)*Math.cos(c*s)))/s;if(Number.isNaN(h)||h===0)h=o/Math.cos(Math.PI/180*e);this._point=l.subtract(n.getPixelOrigin()),this._pxRadius=Number.isNaN(h)?0:l.x-n.project([c,t-h]).x,this._pxRadiusY=l.y-r.y}else{let s=i.unproject(i.project(this._latlng).subtract([this._radius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._pxRadius=Math.abs(this._point.x-n.latLngToLayerPoint(s).x)}this._updateBounds()}}var gi="tsmap-control-locate";class ts extends Ct{onAdd(t){let e=this.options,n=A("div",`${gi} tsmap-bar`),i=A("a",`${gi}-button`,n);return i.href="#",i.title=e.title??"Show your location",i.setAttribute("role","button"),i.setAttribute("aria-label",i.title),i.innerHTML='<span class="tsmap-locate-icon" aria-hidden="true"></span>',se(i),k(i,"click",dt),k(i,"click",this._onClick,this),this._button=i,this._setState("idle"),t.on("dragstart zoomstart",this._stopFollowing,this),n}onRemove(t){t.off("dragstart zoomstart",this._stopFollowing,this),this._clearWatch(),this._clearMarker()}start(){return this._locate(),this}stop(){return this._clearWatch(),this._clearMarker(),this._setState("idle"),this}_onClick(){if(this._following){this.stop();return}this._locate()}_locate(){let t=typeof navigator<"u"?navigator:void 0;if(!t?.geolocation){this._setState("denied"),this._map?.fire?.("locateerror",{message:"Geolocation is not available in this browser"});return}let e=this.options;this._setState("locating");let n={enableHighAccuracy:e.enableHighAccuracy??!0,timeout:e.timeout??1e4,maximumAge:e.maximumAge??60000},i=(s)=>{this._clearWatch(),this._setState("denied"),this._map?.fire?.("locateerror",{code:s.code,message:s.message})};if(e.follow===!1){t.geolocation.getCurrentPosition((s)=>this._onPosition(s,!0),i,n);return}this._following=!0,this._watchId=t.geolocation.watchPosition((s)=>this._onPosition(s,!0),i,n)}_onPosition(t,e){let n=this.options,{latitude:i,longitude:s,accuracy:o}=t.coords,r=[i,s];if(this._setState(this._following?"active":"idle"),e&&this._map){let a=n.zoom===null?this._map.getZoom():n.zoom??16;this._selfMoving=!0;try{this._map.setView(r,a)}finally{this._selfMoving=!1}}if(n.showMarker!==!1)this._updateMarker(r,o);this._map?.fire?.("locatefound",{latlng:r,accuracy:o,position:t})}_updateMarker(t,e){let n=this._map;if(!n)return;if(this._accuracyCircle)this._accuracyCircle.setLatLng(t),this._accuracyCircle.setRadius(e);else this._accuracyCircle=new Jn(t,{radius:e,className:"tsmap-locate-accuracy",interactive:!1}).addTo(n);if(this._marker){this._marker.setLatLng(t);return}this._marker=new Me(t,{icon:new ln({className:"tsmap-locate-dot",iconSize:[16,16],iconAnchor:[8,8],html:'<span class="tsmap-locate-dot-pulse" aria-hidden="true"></span>'}),interactive:!1,keyboard:!1,zIndexOffset:1000}).addTo(n)}_clearMarker(){this._accuracyCircle?.remove(),this._accuracyCircle=void 0,this._marker?.remove(),this._marker=void 0}_stopFollowing(){if(!this._following||this._selfMoving)return;this._following=!1,this._clearWatch(),this._setState("idle")}_clearWatch(){if(this._watchId!==void 0&&typeof navigator<"u")navigator.geolocation?.clearWatch(this._watchId);this._watchId=void 0,this._following=!1}_setState(t){let e=this._button;if(!e)return;let n=this.options;for(let s of["idle","locating","active","denied"])e.classList.remove(`${gi}-${s}`);e.classList.add(`${gi}-${t}`);let i=t==="locating"?n.titleLocating??"Finding your location…":t==="active"?n.titleActive??"Following your location":t==="denied"?n.titleDenied??"Location unavailable — check browser permissions":n.title??"Show your location";e.title=i,e.setAttribute("aria-label",i),e.setAttribute("aria-pressed",String(t==="active")),e.setAttribute("data-state",t)}}ts.setDefaultOptions({position:"topright",zoom:16,follow:!0,enableHighAccuracy:!0,timeout:1e4,maximumAge:60000,showMarker:!0});H();Y();var yi="tsmap-control-navigation";class es extends Ct{onAdd(t){let e=this.options,n=A("div",`${yi} tsmap-bar`);if(e.showZoom!==!1)this._zoomInButton=this._createButton(`${yi}-zoom-in`,e.zoomInTitle??"Zoom in",'<span aria-hidden="true">+</span>',n,this._zoomIn),this._zoomOutButton=this._createButton(`${yi}-zoom-out`,e.zoomOutTitle??"Zoom out",'<span aria-hidden="true">−</span>',n,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this);if(e.showCompass!==!1){if(this._compassButton=this._createButton(`${yi}-compass`,e.compassTitle??"Reset bearing to north",'<span class="tsmap-compass-needle" aria-hidden="true"></span>',n,this._resetNorth),this._needle=this._compassButton.querySelector(".tsmap-compass-needle"),t.on("rotate rotateend",this._updateCompass,this),e.visualizePitch)t.on("pitch pitchend",this._updateCompass,this);this._updateCompass()}return n}onRemove(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this),t.off("rotate rotateend",this._updateCompass,this),t.off("pitch pitchend",this._updateCompass,this)}_zoomIn(t){let e=this._map;if(e._zoom<e.getMaxZoom())e.zoomIn(e.options.zoomDelta*(t?.shiftKey?3:1))}_zoomOut(t){let e=this._map;if(e._zoom>e.getMinZoom())e.zoomOut(e.options.zoomDelta*(t?.shiftKey?3:1))}_resetNorth(){let t=this._map,e=this.options,n=this._reducedMotion()?0:e.resetDuration??300;if(n>0)t.rotateTo(0,{animate:!0,duration:n});else t.setBearing(0);if(e.visualizePitch&&typeof t.setPitch==="function")t.setPitch(0)}_reducedMotion(){return typeof matchMedia==="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}_updateCompass(){let t=this._map,e=this._needle;if(!t||!e)return;let n=this.options,i=t.getBearing?.()??0,s=[`rotate(${-i}deg)`];if(n.visualizePitch)s.unshift(`rotateX(${t.getPitch?.()??0}deg)`);e.style.transform=s.join(" "),this._compassButton?.setAttribute("data-bearing",String(Math.round(i)))}_updateDisabled(){let t=this._map,e="tsmap-disabled";if(!t)return;for(let[n,i]of[[this._zoomOutButton,t._zoom===t.getMinZoom()],[this._zoomInButton,t._zoom===t.getMaxZoom()]]){if(!n)continue;if(i)n.classList.add("tsmap-disabled");else n.classList.remove("tsmap-disabled");n.setAttribute("aria-disabled",String(i))}}_createButton(t,e,n,i,s){let o=A("a",t,i);return o.innerHTML=n,o.href="#",o.title=e,o.setAttribute("role","button"),o.setAttribute("aria-label",e),se(o),k(o,"click",dt),k(o,"click",s,this),k(o,"click",this._refocusOnMap,this),o}}es.setDefaultOptions({position:"topright",showZoom:!0,showCompass:!0,visualizePitch:!1});Y();class ns extends Ct{onAdd(t){let n=A("div","tsmap-control-scale"),i=this.options;return this._addScales(i,"tsmap-control-scale-line",n),t.on(i.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),n}onRemove(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)}_addScales(t,e,n){if(t.metric)this._mScale=A("div",e,n);if(t.imperial)this._iScale=A("div",e,n)}_update(){let t=this._map,e=t.getSize().y/2,n=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(n)}_updateScales(t){if(this.options.metric&&t)this._updateMetric(t);if(this.options.imperial&&t)this._updateImperial(t)}_updateMetric(t){let e=this._getRoundNum(t),n=e<1000?`${e} m`:`${e/1000} km`;this._updateScale(this._mScale,n,e/t)}_updateImperial(t){let e=t*3.2808399;if(e>5280){let n=e/5280,i=this._getRoundNum(n);this._updateScale(this._iScale,`${i} mi`,i/n)}else{let n=this._getRoundNum(e);this._updateScale(this._iScale,`${n} ft`,n/e)}}_updateScale(t,e,n){t.style.width=`${Math.round(this.options.maxWidth*n)}px`,t.innerHTML=e}_getRoundNum(t){let e=10**(String(Math.floor(t)).length-1),n=t/e;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,e*n}}ns.setDefaultOptions({position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1});H();Y();st();class Qn extends Ct{onAdd(t){let n=A("div","tsmap-control-zoom tsmap-bar"),i=this.options;return this._zoomInButton=this._createButton(i.zoomInText,i.zoomInTitle,"tsmap-control-zoom-in",n,this._zoomIn),this._zoomOutButton=this._createButton(i.zoomOutText,i.zoomOutTitle,"tsmap-control-zoom-out",n,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),n}onRemove(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)}disable(){return this._disabled=!0,this._updateDisabled(),this}enable(){return this._disabled=!1,this._updateDisabled(),this}_zoomIn(t){if(!this._disabled&&this._map._zoom<this._map.getMaxZoom())this._map.zoomIn(this._map.options.zoomDelta*(t.shiftKey?3:1))}_zoomOut(t){if(!this._disabled&&this._map._zoom>this._map.getMinZoom())this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))}_createButton(t,e,n,i,s){let o=A("a",n,i);return o.innerHTML=t,o.href="#",o.title=e,o.setAttribute("role","button"),o.setAttribute("aria-label",e),se(o),k(o,"click",dt),k(o,"click",s,this),k(o,"click",this._refocusOnMap,this),o}_updateDisabled(){let t=this._map,e="tsmap-disabled";if(this._zoomInButton?.classList.remove("tsmap-disabled"),this._zoomOutButton?.classList.remove("tsmap-disabled"),this._zoomInButton?.setAttribute("aria-disabled","false"),this._zoomOutButton?.setAttribute("aria-disabled","false"),this._disabled||t._zoom===t.getMinZoom())this._zoomOutButton?.classList.add("tsmap-disabled"),this._zoomOutButton?.setAttribute("aria-disabled","true");if(this._disabled||t._zoom===t.getMaxZoom())this._zoomInButton?.classList.add("tsmap-disabled"),this._zoomInButton?.setAttribute("aria-disabled","true")}}Qn.setDefaultOptions({position:"topleft",zoomInText:'<span aria-hidden="true">+</span>',zoomInTitle:"Zoom in",zoomOutText:'<span aria-hidden="true">−</span>',zoomOutTitle:"Zoom out"});F.mergeOptions({zoomControl:!0});F.addInitHook(function(){if(this.options.zoomControl)this.zoomControl=new Qn,this.addControl(this.zoomControl)});Te();qn();Pe();N();vl();wl();H();Y();Pe();class fm extends wt{initialize(t={}){this._log=[],this._seen=new Set,this._baseline=new Map,this._options={maxEvents:t.maxEvents??500,store:t.store},this._store=this._newStore()}get store(){return this._store}get events(){return this._log}apply(t){if(this._seen.has(t.id))return{event:t,duplicate:!0,replayed:!1};let e=this._log[this._log.length-1],n=!e||Ti(e,t)<0;if(this._seen.add(t.id),n){this._log.push(t);let s=this._store.capture(t.owner,t.ring);return this.fire("applied",{event:t,result:s,replayed:!1}),{event:t,result:s,duplicate:!1,replayed:!1}}let i=dm(this._log,t);return this._log.splice(i,0,t),this._rebuild(),this.fire("applied",{event:t,replayed:!0}),{event:t,duplicate:!1,replayed:!0}}applyAll(t){return t.map((e)=>this.apply(e))}has(t){return this._seen.has(t)}confirm(t,e){let n=this._log.findIndex((r)=>r.id===t);if(n===-1)return!1;let i=this._log[n];if(i.seq===e)return!1;i.seq=e;let s=[...this._log].sort(Ti);if(!s.some((r,a)=>r!==this._log[a]))return!1;return this._log=s,this._rebuild(),this.fire("reordered",{id:t,seq:e}),!0}compact(t=this._options.maxEvents){let e=this._log.length-t;if(e<=0)return 0;let n=this._log.slice(0,e);this._log=this._log.slice(e);let i=this._newStore();for(let[s,o]of this._baseline)i.set(s,o);for(let s of n)i.capture(s.owner,s.ring);this._baseline=new Map(i.owners().map((s)=>[s,i.get(s)]));for(let s of n)this._seen.delete(s.id);return this._rebuild(),n.length}snapshot(){return{baseline:[...this._baseline.entries()].map(([t,e])=>({owner:t,territory:e})),events:this._log.map((t)=>({...t}))}}restore(t){return this._baseline=new Map((t.baseline??[]).map((e)=>[e.owner,e.territory])),this._log=[...t.events??[]].sort(Ti),this._seen=new Set(this._log.map((e)=>e.id)),this._rebuild(),this}clear(){return this._log=[],this._seen=new Set,this._baseline=new Map,this._store.clear(),this.fire("rebuilt",{}),this}_newStore(){let{TerritoryStore:t}=(Cc(),ut(Ec));return new t(this._options.store)}_rebuild(){let t=this._store;t.clear();for(let[e,n]of this._baseline)t.set(e,n);for(let e of this._log)t.capture(e.owner,e.ring);this.fire("rebuilt",{})}}function Ti(t,e){let n=t.seq,i=e.seq;if(n!==void 0&&i!==void 0){if(n!==i)return n<i?-1:1}else if(n!==void 0)return-1;else if(i!==void 0)return 1;if(t.at!==e.at)return t.at<e.at?-1:1;if(t.id===e.id)return 0;return t.id<e.id?-1:1}function dm(t,e){let n=0,i=t.length;while(n<i){let s=n+i>>1;if(Ti(t[s],e)<0)n=s+1;else i=s}return n}Bi();var lh={snapDistance:20,minArea:200,minLoopLength:120,minPoints:4};function ch(t,e,n,i){let s=e[0]-t[0],o=e[1]-t[1],r=i[0]-n[0],a=i[1]-n[1],l=s*a-o*r;if(l===0)return null;let c=n[0]-t[0],h=n[1]-t[1],u=(c*a-h*r)/l,f=(c*o-h*s)/l;if(u<=0||u>=1)return null;if(f<0||f>1)return null;return{t:u,u:f}}function hh(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]}function ao(t){let e=0;for(let n=1;n<t.length;n++)e+=zn(t[n-1],t[n]);return e}function Ri(t,e,n,i,s){if(t.length<s.minPoints+1)return null;let o=eu(t,!1);if(o<s.minLoopLength)return null;let r=Math.abs(ks(t));if(r<s.minArea)return null;return{ring:t,area:r,perimeter:o,startIndex:e,endIndex:n,closure:i}}function t_(t,e={}){let n={...lh,...e};if(t.length<n.minPoints)return null;for(let i=1;i<t.length;i++){let s=t[i-1],o=t[i];for(let r=1;r<i-1;r++){let a=ch(s,o,t[r-1],t[r]);if(!a)continue;let l=hh(s,o,a.t),c=[l,...t.slice(r,i),l],h=Ri(c,r-1,i,"crossing",n);if(h)return h}for(let r=0;r<i-1;r++){if(zn(o,t[r])>n.snapDistance)continue;let a=t.slice(r,i+1);if(ao(a)<n.minLoopLength)continue;let l=[...a,t[r]],c=Ri(l,r,i,"proximity",n);if(c)return c}}return null}class pm{_track=[];_options;_carryOver;constructor(t={}){let{carryOver:e,...n}=t;this._options={...lh,...n},this._carryOver=e??1}get track(){return this._track}get length(){return ao(this._track)}push(t){let e=this._track,n=e[e.length-1];if(n&&zn(n,t)<0.5)return null;if(e.push(t),e.length<this._options.minPoints)return null;let i=e.length-1,s=e[i-1],o=e[i];for(let r=1;r<i-1;r++){let a=ch(s,o,e[r-1],e[r]);if(!a)continue;let l=hh(s,o,a.t),c=[l,...e.slice(r,i),l],h=Ri(c,r-1,i,"crossing",this._options);if(h)return this._consume(h),h}for(let r=0;r<i-1;r++){if(zn(o,e[r])>this._options.snapDistance)continue;let a=e.slice(r,i+1);if(ao(a)<this._options.minLoopLength)continue;let l=[...a,e[r]],c=Ri(l,r,i,"proximity",this._options);if(c)return this._consume(c),c}return null}reset(){this._track=[]}_consume(t){let e=Math.max(1,this._carryOver);this._track=this._track.slice(Math.max(0,t.endIndex-e+1))}}function e_(t,e=3){if(t.length<3)return t.slice();let n=new Set([0,t.length-1]),i=(s,o)=>{let r=-1,a=e;for(let l=s+1;l<o;l++){let c=mm(t[l],t[s],t[o]);if(c>a)a=c,r=l}if(r===-1)return;n.add(r),i(s,r),i(r,o)};return i(0,t.length-1),[...n].sort((s,o)=>s-o).map((s)=>t[s])}function mm(t,e,n){let i=Math.cos(t[1]*Math.PI/180),s=(t[0]-e[0])*i,o=t[1]-e[1],r=(n[0]-e[0])*i,a=n[1]-e[1],l=r*r+a*a,c=l===0?0:(s*r+o*a)/l;c=Math.max(0,Math.min(1,c));let h=s-r*c,u=o-a*c;return Math.hypot(h,u)*111319.49}Cc();N();H();Y();ct();Mt();class er extends mt{initialize(t){et(this,t)}onAdd(t){if(!this._container)this._initContainer(),this._container.classList.add("tsmap-zoom-animated");this.getPane().appendChild(this._container),this._resizeContainer(),this._onMoveEnd()}onRemove(t){this._destroyContainer()}getEvents(){let t={viewreset:this._reset,zoom:this._onZoom,moveend:this._onMoveEnd,resize:this._resizeContainer,zoomend:this._onZoomEnd};if(this._zoomAnimated)t.zoomanim=this._onAnimZoom;if(this.options.continuous)t.move=this._onMoveEnd;return t}_onAnimZoom(t){this._updateTransform(t.center,t.zoom)}_onZoom(){this._updateTransform(this._map.getCenter(),this._map.getZoom())}_updateTransform(t,e){let n=this._map.getZoomScale(e,this._zoom),i=this._map.getSize().multiplyBy(0.5+this.options.padding),s=this._map.project(this._center,e),o=i.multiplyBy(-n)._add(s)._subtract(this._map._getNewPixelOrigin(t,e))._round();Fe(this._container,o,n)}_onMoveEnd(t){let e=this.options.padding,n=this._map.getSize(),i=this._map.containerPointToLayerPoint(n.multiplyBy(-e)).round();this._bounds=new I(i,i.add(n.multiplyBy(1+e*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled(t)}_reset(){this._onSettled(),this._updateTransform(this._center,this._zoom),this._onViewReset()}_initContainer(){this._container=A("div")}_destroyContainer(){Z(this._container),this._container.remove(),delete this._container}_resizeContainer(){let t=this.options.padding,e=this._map.getSize().multiplyBy(1+t*2).round();return this._container.style.width=`${e.x}px`,this._container.style.height=`${e.y}px`,e}_onZoomEnd(){}_onViewReset(){}_onSettled(t){}}er.setDefaultOptions({padding:0.1,continuous:!1});N();Y();_t();G();st();vt();N();Mt();class ti extends mt{initialize(t,e){et(this,e),this._layers={};for(let n of t??[])this.addLayer(n)}addLayer(t){let e=this.getLayerId(t);return this._layers[e]=t,this._map?.addLayer(t),this}removeLayer(t){let e=typeof t==="number"?t:this.getLayerId(t);if(this._map&&this._layers[e])this._map.removeLayer(this._layers[e]);return delete this._layers[e],this}hasLayer(t){return(typeof t==="number"?t:this.getLayerId(t))in this._layers}clearLayers(){return this.eachLayer(this.removeLayer,this)}onAdd(t){this.eachLayer(t.addLayer,t)}onRemove(t){this.eachLayer(t.removeLayer,t)}eachLayer(t,e){for(let n of Object.values(this._layers))t.call(e,n);return this}getLayer(t){return this._layers[t]}getLayers(){let t=[];return this.eachLayer((e)=>t.push(e)),t}setZIndex(t){return this.eachLayer((e)=>e.setZIndex?.(t))}getLayerId(t){return j(t)}}class Gt extends ti{addLayer(t){if(this.hasLayer(t))return this;return t.addEventParent(this),super.addLayer(t),this.fire("layeradd",{layer:t})}removeLayer(t){if(!this.hasLayer(t))return this;let e=typeof t==="number"?this._layers[t]:t;return e.removeEventParent(this),super.removeLayer(e),this.fire("layerremove",{layer:e})}setStyle(t){return this.eachLayer((e)=>e.setStyle?.(t))}bringToFront(){return this.eachLayer((t)=>t.bringToFront?.())}bringToBack(){return this.eachLayer((t)=>t.bringToBack?.())}getBounds(){let t=new R;for(let e of Object.values(this._layers))t.extend(e.getBounds?e.getBounds():e.getLatLng());return t}}Mt();class is extends mt{initialize(t,e){if(t instanceof S||Array.isArray(t))this._latlng=new S(t),et(this,e);else et(this,t),this._source=e;if(this.options.content)this._content=this.options.content}openOn(t){let e=arguments.length?t:this._source._map;if(!e.hasLayer(this))e.addLayer(this);return this}close(){return this._map?.removeLayer(this),this}toggle(t){if(this._map)this.close();else{if(arguments.length)this._source=t;else t=this._source;this._prepareOpen(),this.openOn(t._map)}return this}onAdd(t){if(this._zoomAnimated=t._zoomAnimated,!this._container)this._initLayout();if(t._fadeAnimated)this._container.style.opacity="0";if(clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.update(),t._fadeAnimated)this._container.style.opacity="1";if(this.bringToFront(),this.options.interactive)this._container.classList.add("tsmap-interactive"),this.addInteractiveTarget(this._container)}onRemove(t){if(t._fadeAnimated)this._container.style.opacity="0",this._removeTimeout=setTimeout(()=>this._container.remove(),200);else this._container.remove();if(this.options.interactive)this._container.classList.remove("tsmap-interactive"),this.removeInteractiveTarget(this._container)}getLatLng(){return this._latlng}setLatLng(t){if(this._latlng=new S(t),this._map)this._updatePosition(),this._adjustPan();return this}getContent(){return this._content}setContent(t){return this._content=t,this.update(),this}getElement(){return this._container}update(){if(!this._map)return;this._container.style.visibility="hidden",this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility="",this._adjustPan()}getEvents(){let t={zoom:this._updatePosition,viewreset:this._updatePosition};if(this._zoomAnimated)t.zoomanim=this._animateZoom;return t}isOpen(){return!!this._map&&this._map.hasLayer(this)}bringToFront(){if(this._map)Wn(this._container);return this}bringToBack(){if(this._map)Vn(this._container);return this}_prepareOpen(t){let e=this._source;if(!e._map)return!1;if(e instanceof Gt){e=null;for(let n of Object.values(this._source._layers))if(n._map){e=n;break}if(!e)return!1;this._source=e}if(!t)if(e.getCenter)t=e.getCenter();else if(e.getLatLng)t=e.getLatLng();else if(e.getBounds)t=e.getBounds().getCenter();else throw Error("Unable to get source layer LatLng.");if(this.setLatLng(t),this._map)this.update();return!0}_updateContent(){if(!this._content)return;let t=this._contentNode,e=typeof this._content==="function"?this._content(this._source??this):this._content;if(typeof e==="string")t.innerHTML=e;else{while(t.hasChildNodes())t.removeChild(t.firstChild);t.appendChild(e)}this.fire("contentupdate")}_updatePosition(){if(!this._map)return;let t=this._map.latLngToLayerPoint(this._latlng),e=this._getAnchor(),n=new v(this.options.offset);if(this._zoomAnimated)lt(this._container,t.add(e));else n=n.add(t).add(e);let i=this._containerBottom=-n.y,s=this._containerLeft=-Math.round(this._containerWidth/2)+n.x;this._container.style.bottom=`${i}px`,this._container.style.left=`${s}px`}_getAnchor(){return[0,0]}_initLayout(){}_updateLayout(){}_adjustPan(){}_animateZoom(t){}}is.setDefaultOptions({interactive:!1,offset:[0,0],className:"",pane:void 0,content:""});F.include({_initOverlay(t,e,n,i){let s=e;if(!(s instanceof t))s=new t(i).setContent(e);if(n)s.setLatLng(n);return s}});mt.include({_initOverlay(t,e,n,i){let s=n;if(s instanceof t)et(s,i),s._source=this;else s=e&&!i?e:new t(i,this),s.setContent(n);return s}});N();_t();_t();ct();G();N();_t();vt();ct();G();class je extends Ze{initialize(t,e){et(this,e),this._setLatLngs(t)}getLatLngs(){return this._latlngs}setLatLngs(t){return this._setLatLngs(t),this.redraw()}isEmpty(){return!this._latlngs.length}closestLayerPoint(t){t=new v(t);let e=1/0,n=null,i=Kn;for(let s of this._parts)for(let o=1,r=s.length;o<r;o++){let a=s[o-1],l=s[o],c=i(t,a,l,!0);if(c<e)e=c,n=i(t,a,l)}if(n)n.distance=Math.sqrt(e);return n}getCenter(){if(!this._map)throw Error("Must add layer to map before using getCenter()");return sh(this._defaultShape(),this._map.options.crs)}getBounds(){return this._bounds}addLatLng(t,e){let n=e??this._defaultShape(),i=new S(t);return n.push(i),this._bounds.extend(i),this.redraw()}_setLatLngs(t){this._bounds=new R,this._latlngs=this._convertLatLngs(t)}_defaultShape(){return Zt(this._latlngs)?this._latlngs:this._latlngs[0]}_convertLatLngs(t){let e=[],n=Zt(t);for(let i=0,s=t.length;i<s;i++)if(n)e[i]=new S(t[i]),this._bounds.extend(e[i]);else e[i]=this._convertLatLngs(t[i]);return e}_project(){let t=new I;if(this._rings=[],this._projectLatlngs(this._latlngs,this._rings,t),this._bounds.isValid()&&t.isValid())this._rawPxBounds=t,this._updateBounds()}_updateBounds(){let t=this._clickTolerance(),e=new v(t,t);if(!this._rawPxBounds)return;this._pxBounds=new I([this._rawPxBounds.min.subtract(e),this._rawPxBounds.max.add(e)])}_projectLatlngs(t,e,n){if(t[0]instanceof S){let s=t.map((o)=>this._map.latLngToLayerPoint(o));s.forEach((o)=>n.extend(o)),e.push(s)}else t.forEach((s)=>this._projectLatlngs(s,e,n))}_clipPoints(){let t=this._renderer._bounds;if(this._parts=[],!this._pxBounds||!this._pxBounds.intersects(t))return;if(this.options.noClip){this._parts=this._rings;return}let e=this._parts;for(let n=0,i=0,s=this._rings.length;n<s;n++){let o=this._rings[n];for(let r=0,a=o.length;r<a-1;r++){let l=ih(o[r],o[r+1],t,!!r,!0);if(!l)continue;if(e[i]??=[],e[i].push(l[0]),l[1]!==o[r+1]||r===a-2)e[i].push(l[1]),i++}}}_simplifyPoints(){let t=this._parts,e=this.options.smoothFactor;for(let n=0,i=t.length;n<i;n++)t[n]=eh(t[n],e)}_update(){if(!this._map)return;this._clipPoints(),this._simplifyPoints(),this._updatePath()}_updatePath(){this._renderer._updatePoly(this)}_containsPoint(t,e){let n=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(t))return!1;for(let i=0,s=this._parts.length;i<s;i++){let o=this._parts[i];for(let r=0,a=o.length,l=a-1;r<a;l=r++){if(!e&&r===0)continue;if(nh(t,o[l],o[r])<=n)return!0}}return!1}}je.setDefaultOptions({smoothFactor:0.5,noClip:!1});class Ue extends je{isEmpty(){return!this._latlngs.length||!this._latlngs[0].length}getCenter(){if(!this._map)throw Error("Must add layer to map before using getCenter()");return th(this._defaultShape(),this._map.options.crs)}_convertLatLngs(t){let e=super._convertLatLngs(t),n=e.length;if(n>=2&&e[0]instanceof S&&e[0].equals(e[n-1]))e.pop();return e}_setLatLngs(t){if(super._setLatLngs(t),Zt(this._latlngs))this._latlngs=[this._latlngs]}_defaultShape(){return Zt(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]}_clipPoints(){let t=this._renderer._bounds,e=this.options.weight,n=new v(e,e);if(t=new I(t.min.subtract(n),t.max.add(n)),this._parts=[],!this._pxBounds||!this._pxBounds.intersects(t))return;if(this.options.noClip){this._parts=this._rings;return}for(let i of this._rings){let s=Qc(i,t,!0);if(s.length)this._parts.push(s)}}_updatePath(){this._renderer._updatePoly(this,!0)}_containsPoint(t){let e=!1;if(!this._pxBounds||!this._pxBounds.contains(t))return!1;for(let n=0,i=this._parts.length;n<i;n++){let s=this._parts[n];for(let o=0,r=s.length,a=r-1;o<r;a=o++){let l=s[o],c=s[a];if(l.y>t.y!==c.y>t.y&&t.x<(c.x-l.x)*(t.y-l.y)/(c.y-l.y)+l.x)e=!e}}return e||super._containsPoint(t,!0)}}Ue.setDefaultOptions({fill:!0});class q extends Gt{initialize(t,e){if(super.initialize(void 0,e),t)this.addData(t)}addData(t){let e=Array.isArray(t)?t:t.features;if(e){for(let s of e)if(s.geometries||s.geometry||s.features||s.coordinates)this.addData(s);return this}let n=this.options;if(n.filter&&!n.filter(t))return this;let i=q.geometryToLayer(t,n);if(!i)return this;if(i.feature=q.asFeature(t),i.defaultOptions=i.options,this.resetStyle(i),n.onEachFeature)n.onEachFeature(t,i);return this.addLayer(i)}resetStyle(t){if(t===void 0)return this.eachLayer(this.resetStyle,this);return t.options=Object.create(t.defaultOptions),this._setLayerStyle(t,this.options.style),this}setStyle(t){return this.eachLayer((e)=>this._setLayerStyle(e,t))}_setLayerStyle(t,e){if(t.setStyle){if(typeof e==="function")e=e(t.feature);t.setStyle(e)}}static geometryToLayer(t,e){let n=t.type==="Feature"?t.geometry:t,i=n?.coordinates,s=[],o=e?.pointToLayer,r=e?.coordsToLatLng??q.coordsToLatLng,a,l;if(!i&&!n)return null;switch(n.type){case"Point":return a=r(i),q._pointToLayer(o,t,a,e);case"MultiPoint":for(let c of i)a=r(c),s.push(q._pointToLayer(o,t,a,e));return new Gt(s);case"LineString":case"MultiLineString":return l=q.coordsToLatLngs(i,n.type==="LineString"?0:1,r),new je(l,e);case"Polygon":case"MultiPolygon":return l=q.coordsToLatLngs(i,n.type==="Polygon"?1:2,r),new Ue(l,e);case"GeometryCollection":for(let c of n.geometries){let h=q.geometryToLayer({geometry:c,type:"Feature",properties:t.properties},e);if(h)s.push(h)}return new Gt(s);case"FeatureCollection":for(let c of n.features){let h=q.geometryToLayer(c,e);if(h)s.push(h)}return new Gt(s);default:throw Error("Invalid GeoJSON object.")}}static _pointToLayer(t,e,n,i){return t?t(e,n):new Me(n,i?.markersInheritOptions&&i)}static coordsToLatLng(t){return new S(t[1],t[0],t[2])}static coordsToLatLngs(t,e,n){return t.map((i)=>e?q.coordsToLatLngs(i,e-1,n):(n||q.coordsToLatLng)(i))}static latLngToCoords(t,e){let n=new S(t);return n.alt!==void 0?[Vt(n.lng,e),Vt(n.lat,e),Vt(n.alt,e)]:[Vt(n.lng,e),Vt(n.lat,e)]}static latLngsToCoords(t,e,n,i){let s=t.map((o)=>e?q.latLngsToCoords(o,Zt(o)?0:e-1,n,i):q.latLngToCoords(o,i));if(!e&&n&&s.length>0)s.push(s[0].slice());return s}static getFeature(t,e){return t.feature?{...t.feature,geometry:e}:q.asFeature(e)}static asFeature(t){if(t.type==="Feature"||t.type==="FeatureCollection")return t;return{type:"Feature",properties:{},geometry:t}}}var nr={toGeoJSON(t){return q.getFeature(this,{type:"Point",coordinates:q.latLngToCoords(this.getLatLng(),t)})}};Me.include(nr);Jn.include(nr);cn.include(nr);je.include({toGeoJSON(t){let e=!Zt(this._latlngs),n=q.latLngsToCoords(this._latlngs,e?1:0,!1,t);return q.getFeature(this,{type:`${e?"Multi":""}LineString`,coordinates:n})}});Ue.include({toGeoJSON(t){let e=!Zt(this._latlngs),n=e&&!Zt(this._latlngs[0]),i=q.latLngsToCoords(this._latlngs,n?2:e?1:0,!0,t);if(!e)i=[i];return q.getFeature(this,{type:`${n?"Multi":""}Polygon`,coordinates:i})}});ti.include({toMultiPoint(t){let e=[];return this.eachLayer((n)=>{e.push(n.toGeoJSON(t).geometry.coordinates)}),q.getFeature(this,{type:"MultiPoint",coordinates:e})},toGeoJSON(t){let e=this.feature?.geometry?.type;if(e==="MultiPoint")return this.toMultiPoint(t);let n=e==="GeometryCollection",i=[];if(this.eachLayer((s)=>{if(s.toGeoJSON){let o=s.toGeoJSON(t);if(n)i.push(o.geometry);else{let r=q.asFeature(o);if(r.type==="FeatureCollection")i.push(...r.features);else i.push(r)}}}),n)return q.getFeature(this,{geometries:i,type:"GeometryCollection"});return{type:"FeatureCollection",features:i}}});Tc();Ac();N();Bi();Mt();var Ua=["#3b82f6","#f97316","#22c55e","#e11d48","#a855f7","#eab308","#06b6d4","#ec4899"];class ir extends mt{initialize(t){if(et(this,t),this._manual=new Map,this._animations=[],this._assigned=new Map,this._ratio=1,t?.store)this.setStore(t.store)}setStore(t){return this._detachStore(),this._store=t,this._onStoreChange=()=>this.redraw(),this._onStoreCapture=(e)=>this.animateCapture(e),t.on("change",this._onStoreChange),t.on("capture",this._onStoreCapture),this.redraw()}setTerritory(t,e){return this._manual.set(t,e),this.redraw()}setOwnerStyle(t,e){let n=this.options;return n.styles={...n.styles,[t]:{...n.styles?.[t],...e}},this.redraw()}animateCapture(t){let e=this.options.captureDuration??900;if(e>0&&t.ring?.length)this._animations.push({owner:t.owner,ring:t.ring,start:Ha(),duration:e});return this.redraw()}colorFor(t){let n=this.options.styles?.[t]?.color;if(n)return n;let i=this._assigned.get(t);if(i)return i;let s=Ua[this._assigned.size%Ua.length];return this._assigned.set(t,s),s}redraw(){if(!this._map)return this;if(this._frame!==void 0)return this;if(typeof requestAnimationFrame!=="function")return this._draw(),this;return this._frame=requestAnimationFrame(()=>{this._frame=void 0,this._draw()}),this}onAdd(t){if(!this._canvas){let e=document.createElement("canvas");if(e.className="tsmap-territory-canvas",e.style)e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.pointerEvents="none";this._canvas=e,this._ctx=e.getContext("2d")}this.getPane().appendChild(this._canvas),this._resize()}onRemove(t){if(this._frame!==void 0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(this._frame);this._frame=void 0,this._detachStore();let e=this._canvas;e?.parentNode?.removeChild(e)}getEvents(){return{viewreset:this._resize,resize:this._resize,moveend:this._draw,zoomend:this._draw,zoom:this._draw,move:this._draw}}ownerAtContainerPoint(t){let e=this._map;if(!e)return null;let n=e.containerPointToLatLng(t),i=[n.lng,n.lat];if(this._store)return this._store.ownerAt(i);for(let[s,o]of this._manual)if(il(o,i))return s;return null}_detachStore(){if(!this._store)return;if(this._onStoreChange)this._store.off("change",this._onStoreChange);if(this._onStoreCapture)this._store.off("capture",this._onStoreCapture);this._store=void 0}_pixelRatio(){let t=typeof window<"u"?window.devicePixelRatio:1;return Math.min(2,Math.max(1,t||1))}_resize(){let t=this._canvas,e=this._map;if(!t||!e?.getSize)return;let n=e.getSize(),i=this._pixelRatio();if(this._ratio=i,t.width=xs(n.x,i),t.height=xs(n.y,i),t.style)t.style.width=`${n.x}px`,t.style.height=`${n.y}px`;this._draw()}_territories(){if(this._store)return this._store.owners().map((t)=>[t,this._store.get(t)]);return[...this._manual.entries()]}_draw(){let t=this._canvas,e=this._ctx,n=this._map;if(!t||!e||!n)return;let i=n.getSize();if(t.width!==xs(i.x,this._ratio)){this._resize();return}let s=n._getMapPanePos?.();if(s&&t.style)t.style.transform=`translate3d(${-s.x}px, ${-s.y}px, 0)`;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),e.setTransform(this._ratio,0,0,this._ratio,0,0);let o=this.options,r=(l)=>n.latLngToContainerPoint([l[1],l[0]]),a=this._territories();a.sort(([l],[c])=>{if(l===o.self)return 1;if(c===o.self)return-1;return 0});for(let[l,c]of a){if(c.length===0)continue;this._drawTerritory(e,l,c,r)}if(this._drawCaptures(e,r),this._animations.length>0)this.redraw()}_styleFor(t){let e=this.options,n={...e.defaultStyle,...e.styles?.[t]},i=t===e.self;return{color:this.colorFor(t),fillOpacity:n.fillOpacity??(i?0.28:0.16),weight:n.weight??(i?3:2),glow:n.glow??i,hatch:n.hatch??!1,label:n.label??!0}}_drawTerritory(t,e,n,i){let s=this._styleFor(e),o=(r)=>{t.beginPath();for(let a of r)a.forEach((l,c)=>{let h=i(l);if(c===0)t.moveTo(h.x,h.y);else t.lineTo(h.x,h.y)}),t.closePath()};for(let r of n){if(o(r),t.fillStyle=s.color,t.globalAlpha=s.fillOpacity,t.fill("evenodd"),t.globalAlpha=1,s.hatch)this._drawHatch(t,s.color);if(s.glow)t.save(),t.shadowColor=s.color,t.shadowBlur=12,t.strokeStyle=s.color,t.lineWidth=s.weight,t.stroke(),t.restore();t.strokeStyle=s.color,t.lineWidth=s.weight,t.lineJoin="round",t.stroke()}if(s.label)this._drawLabels(t,n,s.color,i)}_drawHatch(t,e){t.save(),t.clip("evenodd"),t.globalAlpha=0.35,t.strokeStyle=e,t.lineWidth=1;let n=t.canvas,i=n.width/this._ratio,s=n.height/this._ratio,o=8;t.beginPath();for(let r=-s;r<i;r+=o)t.moveTo(r,0),t.lineTo(r+s,s);t.stroke(),t.restore()}_drawLabels(t,e,n,i){let s=this.options,o=this._map,r=s.labelMinZoom??13;if((o.getZoom?.()??0)<r)return;for(let a of e){if(a.length===0)continue;let l=a[0].map(i),c=_m(l),h=c.maxX-c.minX,u=c.maxY-c.minY;if(h<70||u<34)continue;let f=nu(tl(a),{units:s.units}),d=(c.minX+c.maxX)/2,p=(c.minY+c.maxY)/2;t.save(),t.font="600 12px system-ui, -apple-system, sans-serif",t.textAlign="center",t.textBaseline="middle",t.lineWidth=3,t.strokeStyle="rgba(0, 0, 0, 0.65)",t.strokeText(f,d,p),t.fillStyle=n,t.fillText(f,d,p),t.restore()}}_drawCaptures(t,e){let n=Ha(),i=[];for(let s of this._animations){let o=(n-s.start)/s.duration;if(o>=1)continue;i.push(s);let r=1-(1-o)**3,a=this.colorFor(s.owner),l=s.ring.map(e);t.save(),t.beginPath(),l.forEach((c,h)=>{if(h===0)t.moveTo(c.x,c.y);else t.lineTo(c.x,c.y)}),t.closePath(),t.globalAlpha=(1-r)*0.5,t.fillStyle=a,t.fill("evenodd"),t.globalAlpha=1-r,t.strokeStyle=a,t.lineWidth=2+r*6,t.lineJoin="round",t.shadowColor=a,t.shadowBlur=16*(1-r),t.stroke(),t.restore()}this._animations=i}}function xs(t,e){return Math.max(1,Math.round(t*e))}function Ha(){return typeof performance<"u"&&typeof performance.now==="function"?performance.now():Date.now()}function _m(t){let e=1/0,n=1/0,i=-1/0,s=-1/0;for(let o of t){if(o.x<e)e=o.x;if(o.x>i)i=o.x;if(o.y<n)n=o.y;if(o.y>s)s=o.y}return{minX:e,minY:n,maxX:i,maxY:s}}function gm(t){return new ir(t)}N();Mt();class sr extends mt{initialize(t){et(this,t),this._track=[],this._ratio=1}setTrack(t){return this._track=t,this.redraw()}addPoint(t){return this._track.push(t),this.redraw()}clear(){return this._track=[],this.redraw()}get track(){return this._track}redraw(){if(!this._map||this._frame!==void 0)return this;if(typeof requestAnimationFrame!=="function")return this._draw(),this;return this._frame=requestAnimationFrame(()=>{this._frame=void 0,this._draw()}),this}onAdd(t){if(!this._canvas){let e=document.createElement("canvas");if(e.className="tsmap-run-trail-canvas",e.style)e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.pointerEvents="none";this._canvas=e,this._ctx=e.getContext("2d")}this.getPane().appendChild(this._canvas),this._resize()}onRemove(t){if(this._frame!==void 0&&typeof cancelAnimationFrame==="function")cancelAnimationFrame(this._frame);this._frame=void 0;let e=this._canvas;e?.parentNode?.removeChild(e)}getEvents(){return{viewreset:this._resize,resize:this._resize,move:this._draw,moveend:this._draw,zoom:this._draw,zoomend:this._draw}}_pixelRatio(){let t=typeof window<"u"?window.devicePixelRatio:1;return Math.min(2,Math.max(1,t||1))}_resize(){let t=this._canvas,e=this._map;if(!t||!e?.getSize)return;let n=e.getSize(),i=this._pixelRatio();if(this._ratio=i,t.width=Ss(n.x,i),t.height=Ss(n.y,i),t.style)t.style.width=`${n.x}px`,t.style.height=`${n.y}px`;this._draw()}_draw(){let t=this._canvas,e=this._ctx,n=this._map;if(!t||!e||!n)return;let i=n.getSize();if(t.width!==Ss(i.x,this._ratio)){this._resize();return}let s=n._getMapPanePos?.();if(s&&t.style)t.style.transform=`translate3d(${-s.x}px, ${-s.y}px, 0)`;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),e.setTransform(this._ratio,0,0,this._ratio,0,0);let o=this._track;if(o.length===0)return;let r=this.options,a=r.color??"#38bdf8",l=r.weight??4,c=r.opacity??0.95,h=o.map((u)=>{let f=n.latLngToContainerPoint([u[1],u[0]]);return{x:f.x,y:f.y}});if(r.showPotential!==!1&&h.length>=3)this._drawPotential(e,h,a,r.potentialOpacity??0.12);e.lineCap="round",e.lineJoin="round",e.strokeStyle=a,e.lineWidth=l;for(let u=1;u<h.length;u++){let f=u/(h.length-1);e.globalAlpha=c*(0.15+0.85*f**2),e.beginPath(),e.moveTo(h[u-1].x,h[u-1].y),e.lineTo(h[u].x,h[u].y),e.stroke()}if(e.globalAlpha=1,r.showHead!==!1)this._drawHead(e,h[h.length-1],a,r.pulse!==!1)}_drawPotential(t,e,n,i){t.save(),t.beginPath(),e.forEach((s,o)=>{if(o===0)t.moveTo(s.x,s.y);else t.lineTo(s.x,s.y)}),t.closePath(),t.globalAlpha=i,t.fillStyle=n,t.fill(),t.globalAlpha=i*3,t.setLineDash([6,6]),t.strokeStyle=n,t.lineWidth=1.5,t.beginPath(),t.moveTo(e[e.length-1].x,e[e.length-1].y),t.lineTo(e[0].x,e[0].y),t.stroke(),t.restore()}_drawHead(t,e,n,i){if(i){let s=ym()%2000/2000;t.save(),t.globalAlpha=(1-s)*0.45,t.fillStyle=n,t.beginPath(),t.arc(e.x,e.y,8+s*22,0,Math.PI*2),t.fill(),t.restore(),this.redraw()}t.save(),t.fillStyle=n,t.shadowColor=n,t.shadowBlur=10,t.beginPath(),t.arc(e.x,e.y,7,0,Math.PI*2),t.fill(),t.shadowBlur=0,t.fillStyle="#ffffff",t.beginPath(),t.arc(e.x,e.y,3,0,Math.PI*2),t.fill(),t.restore()}}function Ss(t,e){return Math.max(1,Math.round(t*e))}function ym(){return typeof performance<"u"&&typeof performance.now==="function"?performance.now():Date.now()}function bm(t){return new sr(t)}N();Y();vt();ct();Mt();class hn extends mt{_url;initialize(t,e,n){this._url=t,this._bounds=new R(e),et(this,n)}onAdd(){if(!this._image){if(this._initImage(),this.options.opacity<1)this._updateOpacity()}if(this.options.interactive)this._image.classList.add("tsmap-interactive"),this.addInteractiveTarget(this._image);this.getPane().appendChild(this._image),this._reset()}onRemove(){if(this._image.remove(),this.options.interactive)this.removeInteractiveTarget(this._image)}setOpacity(t){if(this.options.opacity=t,this._image)this._updateOpacity();return this}setStyle(t){if(t.opacity)this.setOpacity(t.opacity);return this}bringToFront(){if(this._map)Wn(this._image);return this}bringToBack(){if(this._map)Vn(this._image);return this}setUrl(t){if(this._url=t,this._image)this._image.src=t;return this}setBounds(t){if(this._bounds=new R(t),this._map)this._reset();return this}getEvents(){let t={zoom:this._reset,viewreset:this._reset};if(this._zoomAnimated)t.zoomanim=this._animateZoom;return t}setZIndex(t){return this.options.zIndex=t,this._updateZIndex(),this}getBounds(){return this._bounds}getElement(){return this._image}_initImage(){let t=this._url.tagName==="IMG",e=this._image=t?this._url:A("img");if(e.classList.add("tsmap-image-layer"),this._zoomAnimated)e.classList.add("tsmap-zoom-animated");if(this.options.className)e.classList.add(...Yt(this.options.className));if(e.onselectstart=Et,e.onpointermove=Et,e.onload=this.fire.bind(this,"load"),e.onerror=this._overlayOnError.bind(this),this.options.crossOrigin||this.options.crossOrigin==="")e.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin;if(e.decoding=this.options.decoding,this.options.zIndex)this._updateZIndex();if(t){this._url=e.src;return}e.src=this._url,e.alt=this.options.alt}_animateZoom(t){let e=this._map.getZoomScale(t.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;Fe(this._image,n,e)}_reset(){let t=this._image,e=new I(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=e.getSize();lt(t,e.min),t.style.width=`${n.x}px`,t.style.height=`${n.y}px`}_updateOpacity(){this._image.style.opacity=this.options.opacity}_updateZIndex(){if(this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null)this._image.style.zIndex=this.options.zIndex}_overlayOnError(){this.fire("error");let t=this.options.errorOverlayUrl;if(t&&this._url!==t)this._url=t,this._image.src=t}getCenter(){return this._bounds.getCenter()}}hn.setDefaultOptions({opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:"",decoding:"auto"});Mt();H();Y();G();st();Mt();class un extends is{openOn(t){let e=arguments.length?t:this._source._map;if(!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose)e.removeLayer(e._popup);return e._popup=this,super.openOn(e)}onAdd(t){if(super.onAdd(t),t.fire("popupopen",{popup:this}),this._source){if(this._source.fire("popupopen",{popup:this},!0),!(this._source instanceof Ze))this._source.on("preclick",be)}}onRemove(t){if(super.onRemove(t),t.fire("popupclose",{popup:this}),this._source){if(this._source.fire("popupclose",{popup:this},!0),!(this._source instanceof Ze))this._source.off("preclick",be)}}getEvents(){let t=super.getEvents();if(this.options.closeOnClick??this._map.options.closePopupOnClick)t.preclick=this.close;if(this.options.keepInView)t.moveend=this._adjustPan;return t}_initLayout(){let e=this._container=A("div",`tsmap-popup ${this.options.className||""} tsmap-zoom-animated`),n=this._wrapper=A("div","tsmap-popup-content-wrapper",e);if(this._contentNode=A("div","tsmap-popup-content",n),se(e),ji(this._contentNode),k(e,"contextmenu",be),this._tipContainer=A("div","tsmap-popup-tip-container",e),this._tip=A("div","tsmap-popup-tip",this._tipContainer),this.options.closeButton){let i=this._closeButton=A("a","tsmap-popup-close-button",e);i.setAttribute("role","button"),i.setAttribute("aria-label",this.options.closeButtonLabel),i.href="#close",i.innerHTML='<span aria-hidden="true">×</span>',k(i,"click",(s)=>{s.preventDefault(),this.close()})}if(this.options.trackResize)this._resizeObserver=new ResizeObserver((i)=>{if(!this._map)return;this._containerWidth=i[0]?.contentRect?.width,this._containerHeight=i[0]?.contentRect?.height,this._updateLayout(),this._updatePosition(),this._adjustPan()}),this._resizeObserver.observe(this._contentNode)}_updateLayout(){let t=this._contentNode,e=t.style;e.maxWidth=`${this.options.maxWidth}px`,e.minWidth=`${this.options.minWidth}px`;let n=this._containerHeight??t.offsetHeight,i=this.options.maxHeight,s="tsmap-popup-scrolled";if(i&&n>i)e.height=`${i}px`,t.classList.add(s);else t.classList.remove(s);this._containerWidth=this._container.offsetWidth,this._containerHeight=this._container.offsetHeight}_animateZoom(t){let e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),n=this._getAnchor();lt(this._container,e.add(n))}_adjustPan(){if(!this.options.autoPan)return;if(this._map._panAnim?.stop(),this._autopanning){this._autopanning=!1;return}let t=this._map,e=Number.parseInt(getComputedStyle(this._container).marginBottom,10)||0,n=this._containerHeight+e,i=this._containerWidth,s=new v(this._containerLeft,-n-this._containerBottom);s._add(Re(this._container));let o=t.layerPointToContainerPoint(s),r=new v(this.options.autoPanPadding),a=new v(this.options.autoPanPaddingTopLeft??r),l=new v(this.options.autoPanPaddingBottomRight??r),c=t.getSize(),h=0,u=0;if(o.x+i+l.x>c.x)h=o.x+i-c.x+l.x;if(o.x-h-a.x<0)h=o.x-a.x;if(o.y+n+l.y>c.y)u=o.y+n-c.y+l.y;if(o.y-u-a.y<0)u=o.y-a.y;if(h||u){if(this.options.keepInView)this._autopanning=!0;t.fire("autopanstart").panBy([h,u])}}_getAnchor(){return new v(this._source?._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}un.setDefaultOptions({pane:"popupPane",offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,closeButtonLabel:"Close popup",autoClose:!0,closeOnEscapeKey:!0,className:"",trackResize:!0});F.mergeOptions({closePopupOnClick:!0});F.include({openPopup(t,e,n){return this._initOverlay(un,t,e,n).openOn(this),this},closePopup(t){return(arguments.length?t:this._popup)?.close(),this}});mt.include({bindPopup(t,e){if(this._popup=this._initOverlay(un,this._popup,t,e),!this._popupHandlersAdded)this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0;return this},unbindPopup(){if(this._popup)this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null;return this},openPopup(t){if(this._popup){if(!(this instanceof Gt))this._popup._source=this;if(this._popup._prepareOpen(t||this._latlng))this._popup.openOn(this._map)}return this},closePopup(){return this._popup?.close(),this},togglePopup(){return this._popup?.toggle(this),this},isPopupOpen(){return this._popup?.isOpen()??!1},setPopupContent(t){return this._popup?.setContent(t),this},getPopup(){return this._popup},_openPopup(t){if(!this._popup||!this._map)return;dt(t);let e=t.propagatedFrom??t.target;if(this._popup._source===e&&!(e instanceof Ze)){if(this._map.hasLayer(this._popup))this.closePopup();else this.openPopup(t.latlng);return}this._popup._source=e,this.openPopup(t.latlng)},_movePopup(t){this._popup.setLatLng(t.latlng)},_onKeyPress(t){if(t.originalEvent.code==="Enter")this._openPopup(t)}});N();class or extends hn{_initImage(){let t=this._image=this._url;if(t.classList.add("tsmap-image-layer"),this._zoomAnimated)t.classList.add("tsmap-zoom-animated");if(this.options.className)t.classList.add(...Yt(this.options.className));t.onselectstart=Et,t.onpointermove=Et}}N();H();Y();G();st();Mt();class fn extends is{onAdd(t){if(super.onAdd(t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source)this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0)}onRemove(t){if(super.onRemove(t),t.fire("tooltipclose",{tooltip:this}),this._source)this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0)}getEvents(){let t=super.getEvents();if(!this.options.permanent)t.preclick=this.close;return t}_initLayout(){let e=`tsmap-tooltip ${this.options.className||""} tsmap-zoom-${this._zoomAnimated?"animated":"hide"}`;this._contentNode=this._container=A("div",e),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id",`tsmap-tooltip-${j(this)}`)}_updateLayout(){}_adjustPan(){}_setPosition(t){let e,n,i=this.options.direction,s=this._map,o=this._container,r=s.latLngToContainerPoint(s.getCenter()),a=s.layerPointToContainerPoint(t),{offsetWidth:l,offsetHeight:c}=o,h=new v(this.options.offset),u=this._getAnchor();if(i==="top")e=l/2,n=c;else if(i==="bottom")e=l/2,n=0;else if(i==="center")e=l/2,n=c/2;else if(i==="right")e=0,n=c/2;else if(i==="left")e=l,n=c/2;else if(a.x<r.x)i="right",e=0,n=c/2;else i="left",e=l+(h.x+u.x)*2,n=c/2;t=t.subtract(new v(e,n,!0)).add(h).add(u),o.classList.remove("tsmap-tooltip-right","tsmap-tooltip-left","tsmap-tooltip-top","tsmap-tooltip-bottom"),o.classList.add(`tsmap-tooltip-${i}`),lt(o,t)}_updatePosition(){let t=this._map.latLngToLayerPoint(this._latlng);this._setPosition(t)}setOpacity(t){if(this.options.opacity=t,this._container)this._container.style.opacity=String(t)}_animateZoom(t){let e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);this._setPosition(e)}_getAnchor(){return new v(this._source?._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}}fn.setDefaultOptions({pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:0.9});F.include({openTooltip(t,e,n){return this._initOverlay(fn,t,e,n).openOn(this),this},closeTooltip(t){return t.close(),this}});mt.include({bindTooltip(t,e){if(this._tooltip&&this.isTooltipOpen())this.unbindTooltip();if(this._tooltip=this._initOverlay(fn,this._tooltip,t,e),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this))this.openTooltip();return this},unbindTooltip(){if(this._tooltip)this._initTooltipInteractions(!0),this.closeTooltip(),this._tooltip=null;return this},_initTooltipInteractions(t){if(!t&&this._tooltipHandlersAdded)return;let e=t?"off":"on",n={remove:this.closeTooltip,move:this._moveTooltip};if(!this._tooltip.options.permanent)if(n.pointerover=this._openTooltip,n.pointerout=this.closeTooltip,n.click=this._openTooltip,this._map)this._addFocusListeners(t);else n.add=()=>this._addFocusListeners(t);else n.add=this._openTooltip;if(this._tooltip.options.sticky)n.pointermove=this._moveTooltip;this[e](n),this._tooltipHandlersAdded=!t},openTooltip(t){if(this._tooltip){if(!(this instanceof Gt))this._tooltip._source=this;if(this._tooltip._prepareOpen(t)){if(this._tooltip.openOn(this._map),this.getElement)this._setAriaDescribedByOnLayer(this);else if(this.eachLayer)this.eachLayer(this._setAriaDescribedByOnLayer,this)}}return this},closeTooltip(){if(this._tooltip)return this._tooltip.close()},toggleTooltip(){return this._tooltip?.toggle(this),this},isTooltipOpen(){return this._tooltip.isOpen()},setTooltipContent(t){return this._tooltip?.setContent(t),this},getTooltip(){return this._tooltip},_addFocusListeners(t){if(this.getElement)this._addFocusListenersOnLayer(this,t);else if(this.eachLayer)this.eachLayer((e)=>this._addFocusListenersOnLayer(e,t),this)},_addFocusListenersOnLayer(t,e){let n=typeof t.getElement==="function"&&t.getElement();if(n){let i=e?"off":"on";if(!e){if(n._tsmap_focus_handler)Z(n,"focus",n._tsmap_focus_handler,this);n._tsmap_focus_handler=()=>{if(this._tooltip)this._tooltip._source=t,this.openTooltip()}}if(n._tsmap_focus_handler)Fs[i](n,"focus",n._tsmap_focus_handler,this);if(Fs[i](n,"blur",this.closeTooltip,this),e)delete n._tsmap_focus_handler}},_setAriaDescribedByOnLayer(t){(typeof t.getElement==="function"&&t.getElement())?.setAttribute?.("aria-describedby",this._tooltip._container.id)},_openTooltip(t){if(!this._tooltip||!this._map)return;if(this._map.dragging?.moving()){if(t.type==="add"&&!this._moveEndOpensTooltip)this._moveEndOpensTooltip=!0,this._map.once("moveend",()=>{this._moveEndOpensTooltip=!1,this._openTooltip(t)});return}this._tooltip._source=t.propagatedFrom??t.target,this.openTooltip(this._tooltip.options.sticky?t.latlng:void 0)},_moveTooltip(t){let e=t.latlng;if(this._tooltip.options.sticky&&t.originalEvent){let n=this._map.pointerEventToContainerPoint(t.originalEvent),i=this._map.containerPointToLayerPoint(n);e=this._map.layerPointToLatLng(i)}this._tooltip.setLatLng(e)}});N();H();Y();class ss extends hn{_initImage(){let t=this._url.tagName==="VIDEO",e=this._image=t?this._url:A("video");if(e.classList.add("tsmap-image-layer"),this._zoomAnimated)e.classList.add("tsmap-zoom-animated");if(this.options.className)e.classList.add(...Yt(this.options.className));if(k(e,"pointerdown",(n)=>{if(e.controls)be(n)}),e.onloadeddata=this.fire.bind(this,"load"),t){let n=Array.from(e.getElementsByTagName("source")),i=n.map((s)=>s.src);this._url=n.length>0?i:[e.src];return}if(!Array.isArray(this._url))this._url=[this._url];if(!this.options.keepAspectRatio&&Object.hasOwn(e.style,"objectFit"))e.style.objectFit="fill";e.autoplay=!!this.options.autoplay,e.controls=!!this.options.controls,e.loop=!!this.options.loop,e.muted=!!this.options.muted,e.playsInline=!!this.options.playsInline;for(let n of this._url){let i=A("source");i.src=n,e.appendChild(i)}}}ss.setDefaultOptions({autoplay:!0,controls:!1,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0});$o();wc();qi();Qs();Te();ct();qi();class ei extends $e{defaultWmsParams={service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"};initialize(t,e){super.initialize(t,e);let n={...this.defaultWmsParams};for(let[o,r]of Object.entries(e??{}))if(!(o in ei.prototype.options))n[o]=r;let i=this.options.detectRetina&&pt.retina?2:1,s=this.getTileSize();n.width=s.x*i,n.height=s.y*i,this.wmsParams=n}onAdd(t){this._crs=this.options.crs??t.options.crs,this._wmsVersion=Number.parseFloat(this.wmsParams.version);let e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,super.onAdd()}getTileUrl(t){let e=this._tileCoordsToNwSe(t),n=this._crs,i=new I(n.project(e[0]),n.project(e[1])),{min:s,max:o}=i,r=(this._wmsVersion>=1.3&&this._crs===tr?[s.y,s.x,o.y,o.x]:[s.x,s.y,o.x,o.y]).join(","),a=new URL(super.getTileUrl(t));for(let[l,c]of Object.entries({...this.wmsParams,bbox:r}))a.searchParams.append(this.options.uppercase?l.toUpperCase():l,String(c));return a.toString()}setParams(t,e){if(Object.assign(this.wmsParams,t),!e)this.redraw();return this}}ei.setDefaultOptions({crs:null,uppercase:!1});N();H();ct();N();class rr extends er{initialize(t){super.initialize({...t,continuous:!1}),j(this),this._layers??={}}onAdd(t){super.onAdd(t),this.on("update",this._updatePaths,this)}onRemove(t){super.onRemove(t),this.off("update",this._updatePaths,this)}_onZoomEnd(){for(let t of Object.values(this._layers))t._project()}_updatePaths(){for(let t of Object.values(this._layers))t._update()}_onViewReset(){for(let t of Object.values(this._layers))t._reset()}_onSettled(t){this._update()}_update(){}}class ar extends rr{getEvents(){let t=super.getEvents();return t.viewprereset=this._onViewPreReset,t}_onViewPreReset(){this._postponeUpdatePaths=!0}onAdd(t){super.onAdd(t),this._draw()}onRemove(){super.onRemove(),clearTimeout(this._pointerHoverThrottleTimeout)}_initContainer(){let t=this._container=document.createElement("canvas");k(t,"pointermove",this._onPointerMove,this),k(t,"click dblclick pointerdown pointerup contextmenu",this._onClick,this),k(t,"pointerout",this._handlePointerOut,this),t._tsmap_disable_events=!0,this._ctx=t.getContext("2d")}_destroyContainer(){if(this._redrawRequest!==void 0&&this._redrawRequest!==null)cancelAnimationFrame(this._redrawRequest);this._redrawRequest=null,delete this._ctx,super._destroyContainer()}_resizeContainer(){let t=this.options.padding,e=this._map.getSize().multiplyBy(1+t*2).round();this._container.style.width=`${e.x}px`,this._container.style.height=`${e.y}px`;let n=this._ctxScale=window.devicePixelRatio;return this._container.width=n*e.x,this._container.height=n*e.y,e}_updatePaths(){if(this._postponeUpdatePaths)return;this._redrawBounds=null;for(let t of Object.values(this._layers))t._update();this._redraw()}_update(){if(this._map._animatingZoom&&this._bounds)return;let t=this._bounds,e=this._ctxScale;this._ctx.setTransform(e,0,0,e,-t.min.x*e,-t.min.y*e),this.fire("update")}_reset(){this._onSettled.bind(this)();let e=this;if(e._updateTransform(e._center,e._zoom),this._onViewReset(),this._postponeUpdatePaths)this._postponeUpdatePaths=!1,this._updatePaths()}_initPath(t){this._updateDashArray(t),this._layers[j(t)]=t;let e={layer:t,prev:this._drawLast??null,next:null};if(this._drawLast)this._drawLast.next=e;this._drawLast=e,this._drawFirst??=this._drawLast,t._order=e}_addPath(t){this._requestRedraw(t)}_removePath(t){let e=t._order,{next:n,prev:i}=e;if(n)n.prev=i;else this._drawLast=i;if(i)i.next=n;else this._drawFirst=n;delete t._order,delete this._layers[j(t)],this._requestRedraw(t)}_updatePath(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)}_updateStyle(t){this._updateDashArray(t),this._requestRedraw(t)}_updateDashArray(t){if(typeof t.options.dashArray==="string"){let e=t.options.dashArray.split(/[, ]+/);t.options._dashArray=e.map((n)=>Number(n)).filter((n)=>!Number.isNaN(n))}else t.options._dashArray=t.options.dashArray}_requestRedraw(t){if(!this._map)return;this._extendRedrawBounds(t),this._redrawRequest??=requestAnimationFrame(this._redraw.bind(this))}_extendRedrawBounds(t){if(t._pxBounds){let e=(t.options.weight??0)+1;this._redrawBounds??=new I,this._redrawBounds.extend(t._pxBounds.min.subtract([e,e])),this._redrawBounds.extend(t._pxBounds.max.add([e,e]))}}_redraw(){if(this._redrawRequest=null,this._redrawBounds)this._redrawBounds.min._floor(),this._redrawBounds.max._ceil();this._clear(),this._draw(),this._redrawBounds=null}_clear(){let t=this._redrawBounds;if(t){let e=t.getSize();this._ctx.clearRect(t.min.x,t.min.y,e.x,e.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()}_draw(){let t=this._redrawBounds;if(this._ctx.save(),t){let e=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,e.x,e.y),this._ctx.clip()}this._drawing=!0;for(let e=this._drawFirst;e;e=e.next){let n=e.layer;if(!t||n._pxBounds&&n._pxBounds.intersects(t))n._updatePath()}this._drawing=!1,this._ctx.restore()}_updatePoly(t,e){if(!this._drawing)return;let n=t._parts,i=this._ctx;if(!n.length)return;i.beginPath(),n.forEach((s)=>{if(s.forEach((o,r)=>{i[r?"lineTo":"moveTo"](o.x,o.y)}),e)i.closePath()}),this._fillStroke(i,t)}_updateCircle(t){if(!this._drawing||t._empty())return;let e=t._point,n=this._ctx,i=Math.max(Math.round(t._pxRadius),1),s=(Math.max(Math.round(t._pxRadiusY),1)||i)/i;if(s!==1)n.save(),n.scale(1,s);if(n.beginPath(),n.arc(e.x,e.y/s,i,0,Math.PI*2,!1),s!==1)n.restore();this._fillStroke(n,t)}_fillStroke(t,e){let n=e.options;if(n.fill)t.globalAlpha=n.fillOpacity,t.fillStyle=n.fillColor??n.color,t.fill(n.fillRule||"evenodd");if(n.stroke&&n.weight!==0){if(t.setLineDash)t.lineDashOffset=Number(n.dashOffset??0),t.setLineDash(n._dashArray??[]);t.globalAlpha=n.opacity,t.lineWidth=n.weight,t.strokeStyle=n.color,t.lineCap=n.lineCap,t.lineJoin=n.lineJoin,t.stroke()}}_onClick(t){let e=this._map.pointerEventToLayerPoint(t),n;for(let i=this._drawFirst;i;i=i.next){let s=i.layer;if(s.options.interactive&&s._containsPoint(e)){if(!(t.type==="click"||t.type==="preclick")||!this._map._draggableMoved(s))n=s}}this._fireEvent(n?[n]:!1,t)}_onPointerMove(t){if(!this._map||this._map.dragging.moving()||this._map._animatingZoom)return;let e=this._map.pointerEventToLayerPoint(t);this._handlePointerHover(t,e)}_handlePointerOut(t){let e=this._hoveredLayer;if(e)this._container.classList.remove("tsmap-interactive"),this._fireEvent([e],t,"pointerout"),this._hoveredLayer=null,this._pointerHoverThrottled=!1}_handlePointerHover(t,e){if(this._pointerHoverThrottled)return;let n;for(let i=this._drawFirst;i;i=i.next){let s=i.layer;if(s.options.interactive&&s._containsPoint(e))n=s}if(n!==this._hoveredLayer){if(this._handlePointerOut(t),n)this._container.classList.add("tsmap-interactive"),this._fireEvent([n],t,"pointerover"),this._hoveredLayer=n}this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,t),this._pointerHoverThrottled=!0,this._pointerHoverThrottleTimeout=setTimeout(()=>{this._pointerHoverThrottled=!1},32)}_fireEvent(t,e,n){this._map._fireDOMEvent(e,n||e.type,t||void 0)}_bringToFront(t){let e=t._order;if(!e)return;let{next:n,prev:i}=e;if(n)n.prev=i;else return;if(i)i.next=n;else if(n)this._drawFirst=n;e.prev=this._drawLast,this._drawLast.next=e,e.next=null,this._drawLast=e,this._requestRedraw(t)}_bringToBack(t){let e=t._order;if(!e)return;let{next:n,prev:i}=e;if(i)i.next=n;else return;if(n)n.prev=i;else if(i)this._drawLast=i;e.prev=null,e.next=this._drawFirst,this._drawFirst.prev=e,this._drawFirst=e,this._requestRedraw(t)}}ar.setDefaultOptions({tolerance:0});vt();class lr extends Ue{initialize(t,e){super.initialize(this._boundsToLatLngs(t),e)}setBounds(t){return this.setLatLngs(this._boundsToLatLngs(t))}_boundsToLatLngs(t){let e=new R(t);return[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}}st();Y();N();class tn extends rr{_initContainer(){this._container=tn.create("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=tn.create("g"),this._container.appendChild(this._rootGroup)}_destroyContainer(){super._destroyContainer(),delete this._rootGroup,delete this._svgSize}_resizeContainer(){let t=this.options.padding,e=this._map.getSize().multiplyBy(1+t*2).round();if(this._container.style.width=`${e.x}px`,this._container.style.height=`${e.y}px`,!this._svgSize||!this._svgSize.equals(e))this._svgSize=e,this._container.setAttribute("width",e.x),this._container.setAttribute("height",e.y);let n=this._bounds;if(n)this._container.setAttribute("viewBox",[n.min.x,n.min.y,e.x,e.y].join(" "));return e}_update(){if(this._map._animatingZoom&&this._bounds)return;let t=this._bounds,e=t.getSize();this._container.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}_initPath(t){let e=t._path=tn.create("path");if(t.options.className)e.classList.add(...Yt(t.options.className));if(t.options.interactive)e.classList.add("tsmap-interactive");this._updateStyle(t),this._layers[j(t)]=t}_addPath(t){if(!this._rootGroup)this._initContainer();this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)}_removePath(t){t._path.remove(),t.removeInteractiveTarget(t._path),delete this._layers[j(t)]}_updatePath(t){t._project(),t._update()}_updateStyle(t){let{_path:e,options:n}=t;if(!e)return;if(n.stroke){if(e.setAttribute("stroke",n.color),e.setAttribute("stroke-opacity",n.opacity),e.setAttribute("stroke-width",n.weight),e.setAttribute("stroke-linecap",n.lineCap),e.setAttribute("stroke-linejoin",n.lineJoin),n.dashArray)e.setAttribute("stroke-dasharray",n.dashArray);else e.removeAttribute("stroke-dasharray");if(n.dashOffset)e.setAttribute("stroke-dashoffset",n.dashOffset);else e.removeAttribute("stroke-dashoffset")}else e.setAttribute("stroke","none");if(n.fill)e.setAttribute("fill",n.fillColor||n.color),e.setAttribute("fill-opacity",n.fillOpacity),e.setAttribute("fill-rule",n.fillRule||"evenodd");else e.setAttribute("fill","none")}_updatePoly(t,e){this._setPath(t,tn.pointsToPath(t._parts,e))}_updateCircle(t){let e=t._point,n=Math.max(Math.round(t._pxRadius),1),i=Math.max(Math.round(t._pxRadiusY),1)||n,s=`a${n},${i} 0 1,0 `,o=t._empty()?"M0 0":`M${e.x-n},${e.y}${s}${n*2},0 ${s}${-n*2},0 `;this._setPath(t,o)}_setPath(t,e){t._path.setAttribute("d",e)}_bringToFront(t){Wn(t._path)}_bringToBack(t){Vn(t._path)}static create(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}static pointsToPath(t,e){return t.flatMap((i)=>[...i.map((s,o)=>`${(o?"L":"M")+s.x} ${s.y}`),e?"z":""]).join("")||"M0 0"}}F.include({getRenderer(t){let e=t.options.renderer??this._getPaneRenderer(t.options.pane)??this.options.renderer??this._renderer;if(!e)e=this._renderer=this._createRenderer();if(!this.hasLayer(e))this.addLayer(e);return e},_getPaneRenderer(t){if(t==="overlayPane"||t===void 0)return;let e=this._paneRenderers[t];if(e===void 0)e=this._createRenderer({pane:t}),this._paneRenderers[t]=e;return e},_createRenderer(t){return this.options.preferCanvas&&new ar(t)||new tn(t)}});st();H();Y();vt();ct();st();F.mergeOptions({boxZoom:!0});class uh extends It{_resetStateTimeout=0;_moved=!1;initialize(t){super.initialize(t),this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)}addHooks(){k(this._container,"pointerdown",this._onPointerDown,this)}removeHooks(){Z(this._container,"pointerdown",this._onPointerDown,this)}moved(){return this._moved}_destroy(){this._pane?.remove(),this._pane=void 0}_resetState(){this._resetStateTimeout=0,this._moved=!1}_clearDeferredResetState(){if(this._resetStateTimeout!==0)clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0}_onPointerDown(t){if(!t.shiftKey||t.button!==0)return!1;this._clearDeferredResetState(),this._resetState(),go(),bo(),this._startPoint=this._map.pointerEventToContainerPoint(t),k(this._container,{contextmenu:dt,pointermove:this._onPointerMove,pointerup:this._onPointerUp,keydown:this._onKeyDown},this),k(document,"keydown",this._onKeyDown,this)}_onPointerMove(t){if(!this._moved)this._moved=!0,this._box=A("div","tsmap-zoom-box",this._container),this._container.classList.add("tsmap-crosshair"),this._map.fire("boxzoomstart");this._point=this._map.pointerEventToContainerPoint(t);let e=new I(this._point,this._startPoint),n=e.getSize();lt(this._box,e.min),this._box.style.width=`${n.x}px`,this._box.style.height=`${n.y}px`}_finish(){if(this._moved)this._box?.remove(),this._container.classList.remove("tsmap-crosshair");yo(),wo(),Z(this._container,{contextmenu:dt,pointermove:this._onPointerMove,pointerup:this._onPointerUp},this),Z(document,"keydown",this._onKeyDown,this)}_onPointerUp(t){if(t.button!==0)return;if(this._finish(),!this._moved)return;this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(this._resetState.bind(this),0);let e=new R(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}_onKeyDown(t){if(t.code==="Escape")this._finish(),this._clearDeferredResetState(),this._resetState()}}F.addInitHook("addHandler","boxZoom",uh);st();F.mergeOptions({doubleClickZoom:!0});class fh extends It{addHooks(){this._map.on("dblclick",this._onDoubleClick,this)}removeHooks(){this._map.off("dblclick",this._onDoubleClick,this)}_onDoubleClick(t){let e=this._map,n=e.getZoom(),i=e.options.zoomDelta,s=t.originalEvent.shiftKey?n-i:n+i;if(e.options.doubleClickZoom==="center")e.setZoom(s);else e.setZoomAround(t.containerPoint,s)}}F.addInitHook("addHandler","doubleClickZoom",fh);vt();ct();st();F.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:0.2,worldCopyJump:!1,maxBoundsViscosity:0});class dh extends It{_positions=[];_times=[];_offsetLimit=null;_viscosity=0;_initialWorldOffset=0;_worldWidth=0;addHooks(){if(!this._draggable){let t=this._map;if(this._draggable=new qt(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump)this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this)}this._map._container.classList.add("tsmap-grab","tsmap-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]}removeHooks(){this._map._container.classList.remove("tsmap-grab","tsmap-touch-drag"),this._draggable.disable()}moved(){return this._draggable?._moved}moving(){return this._draggable?._moving}_onDragStart(){let t=this._map;if(t._stop(),t.options.maxBounds&&t.options.maxBoundsViscosity){let e=new R(t.options.maxBounds);this._offsetLimit=new I(t.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),t.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(t.getSize())),this._viscosity=Math.min(1,Math.max(0,t.options.maxBoundsViscosity))}else this._offsetLimit=null;if(t.fire("movestart").fire("dragstart"),t.options.inertia)this._positions=[],this._times=[]}_onDrag(t){if(this._map.options.inertia){let e=this._lastTime=Date.now(),n=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(n),this._times.push(e),this._prunePositions(e)}this._map.fire("move",t).fire("drag",t)}_prunePositions(t){while(this._positions.length>1&&t-this._times[0]>50)this._positions.shift(),this._times.shift()}_onZoomEnd(){let t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x}_viscousLimit(t,e){return t-(t-e)*this._viscosity}_onPreDragLimit(){if(!this._viscosity||!this._offsetLimit)return;let t=this._draggable,e=t._newPos.subtract(t._startPos),n=this._offsetLimit;if(e.x<n.min.x)e.x=this._viscousLimit(e.x,n.min.x);if(e.y<n.min.y)e.y=this._viscousLimit(e.y,n.min.y);if(e.x>n.max.x)e.x=this._viscousLimit(e.x,n.max.x);if(e.y>n.max.y)e.y=this._viscousLimit(e.y,n.max.y);t._newPos=t._startPos.add(e)}_onPreDragWrap(){let t=this._draggable,e=this._worldWidth,n=Math.round(e/2),i=this._initialWorldOffset,s=t._newPos.x,o=(s-n+i)%e+n-i,r=(s+n+i)%e-n-i,a=Math.abs(o+i)<Math.abs(r+i)?o:r;t._absPos=t._newPos.clone(),t._newPos.x=a}_onDragEnd(t){let e=this._map,n=e.options,i=!n.inertia||t.noInertia||this._times.length<2;if(e.fire("dragend",t),i)e.fire("moveend");else{this._prunePositions(Date.now());let s=this._lastPos.subtract(this._positions[0]),o=(this._lastTime-this._times[0])/1000,r=n.easeLinearity,a=s.multiplyBy(r/o),l=a.distanceTo([0,0]),c=Math.min(n.inertiaMaxSpeed,l),h=a.multiplyBy(c/l),u=c/(n.inertiaDeceleration*r),f=h.multiplyBy(-u/2).round();if(!f.x&&!f.y)e.fire("moveend");else f=e._limitOffset(f,e.options.maxBounds),requestAnimationFrame(()=>{e.panBy(f,{duration:u,easeLinearity:r,noMoveStart:!0,animate:!0})})}}}F.addInitHook("addHandler","dragging",dh);H();G();st();F.mergeOptions({keyboard:!0,keyboardPanDelta:80});class On extends It{static keyCodes={left:["ArrowLeft"],right:["ArrowRight"],down:["ArrowDown"],up:["ArrowUp"],zoomIn:["Equal","NumpadAdd","BracketRight"],zoomOut:["Minus","NumpadSubtract","Digit6","Slash"]};_panKeys={};_zoomKeys={};_focused=!1;initialize(t){super.initialize(t),this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta)}addHooks(){let t=this._map._container;if(t.tabIndex<=0)t.tabIndex=0;t.ariaKeyShortcuts=Object.values(On.keyCodes).flat().join(" "),k(t,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)}removeHooks(){this._removeHooks(),Z(this._map._container,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this)}_onPointerDown(){if(this._focused)return;let{body:t,documentElement:e}=document,n=t.scrollTop||e.scrollTop,i=t.scrollLeft||e.scrollLeft;this._map._container.focus(),window.scrollTo(i,n)}_onFocus(){this._focused=!0,this._map.fire("focus")}_onBlur(){this._focused=!1,this._map.fire("blur")}_setPanDelta(t){let e=this._panKeys={},n=On.keyCodes;for(let i of n.left)e[i]=[-1*t,0];for(let i of n.right)e[i]=[t,0];for(let i of n.down)e[i]=[0,t];for(let i of n.up)e[i]=[0,-1*t]}_setZoomDelta(t){let e=this._zoomKeys={},n=On.keyCodes;for(let i of n.zoomIn)e[i]=t;for(let i of n.zoomOut)e[i]=-t}_addHooks(){k(document,"keydown",this._onKeyDown,this)}_removeHooks(){Z(document,"keydown",this._onKeyDown,this)}_onKeyDown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=t.code,n=this._map,i;if(e in this._panKeys){if(!n._panAnim||!n._panAnim._inProgress){if(i=this._panKeys[e],t.shiftKey)i=new v(i).multiplyBy(3);if(n.options.maxBounds)i=n._limitOffset(new v(i),n.options.maxBounds);if(n.options.worldCopyJump){let s=n.wrapLatLng(n.unproject(n.project(n.getCenter()).add(i)));n.panTo(s)}else n.panBy(i)}}else if(e in this._zoomKeys)n.setZoom(n.getZoom()+(t.shiftKey?3:1)*this._zoomKeys[e]);else if(e==="Escape"&&n._popup&&n._popup.options.closeOnEscapeKey)n.closePopup?.();else return;dt(t)}}F.addInitHook("addHandler","keyboard",On);H();De();st();F.mergeOptions({pinchZoom:!0,bounceAtZoomLimits:!0});class ph extends It{_zooming=!1;_moved=!1;addHooks(){this._map._container.classList.add("tsmap-touch-zoom"),k(this._map._container,"pointerdown",this._onPointerStart,this)}removeHooks(){this._map._container.classList.remove("tsmap-touch-zoom"),Z(this._map._container,"pointerdown",this._onPointerStart,this)}_onPointerStart(t){let e=this._map,n=Kt();if(n.length!==2||e._animatingZoom||this._zooming)return;let i=e.pointerEventToContainerPoint(n[0]),s=e.pointerEventToContainerPoint(n[1]);if(this._centerPoint=e.getSize()._divideBy(2),this._startLatLng=e.containerPointToLatLng(this._centerPoint),e.options.pinchZoom!=="center")this._pinchStartLatLng=e.containerPointToLatLng(i.add(s)._divideBy(2));this._startDist=i.distanceTo(s),this._startZoom=e.getZoom(),this._moved=!1,this._zooming=!0,e._stop(),k(this._map._container,"pointermove",this._onPointerMove,this),k(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),t.preventDefault()}_onPointerMove(t){let e=Kt();if(e.length!==2||!this._zooming)return;let n=this._map,i=n.pointerEventToContainerPoint(e[0]),s=n.pointerEventToContainerPoint(e[1]),o=i.distanceTo(s)/this._startDist;this._zoom=n.getScaleZoom(o,this._startZoom);let r=this._zoom;if(!n.options.bounceAtZoomLimits&&(r<n.getMinZoom()&&o<1||r>n.getMaxZoom()&&o>1))this._zoom=n._limitZoom(this._zoom);if(n.options.pinchZoom==="center"){if(this._center=this._startLatLng,o===1)return}else{let l=i._add(s)._divideBy(2)._subtract(this._centerPoint);if(o===1&&l.x===0&&l.y===0)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(l),this._zoom)}if(!this._moved)n._moveStart(!0,!1),this._moved=!0;if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);let a=n._move.bind(n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(a.bind(this)),t.preventDefault()}_onPointerEnd(){if(!this._moved||!this._zooming){this._zooming=!1;return}if(this._zooming=!1,this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);if(Z(this._map._container,"pointermove",this._onPointerMove,this),Z(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),this._map.options.zoomAnimation)this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap);else this._map._resetView(this._center,this._map._limitZoom(this._zoom))}}F.addInitHook("addHandler","pinchZoom",ph);F.addInitHook(function(){if(this.touchZoom=this.pinchZoom,this.options.touchZoom!==void 0)console.warn("Map: touchZoom option is deprecated and will be removed in future versions. Use pinchZoom instead."),this.options.pinchZoom=this.options.touchZoom,delete this.options.touchZoom;if(this.options.pinchZoom)this.pinchZoom.enable();else this.pinchZoom.disable()});H();st();F.mergeOptions({scrollWheelZoom:!0,wheelPxPerZoomLevel:60,wheelSmoothing:0.13,wheelDebounceTime:40});class mh extends It{addHooks(){k(this._map._container,"wheel",this._onWheelScroll,this),this._targetZoom=null,this._active=!1,this._lastFrameTime=0}removeHooks(){Z(this._map._container,"wheel",this._onWheelScroll,this),this._stopFrames(),this._targetZoom=null,this._active=!1}_onWheelScroll(t){let e=this._map,n=bl(t);if(dt(t),!n)return;let i=t.ctrlKey===!0,s=e.options.wheelPxPerZoomLevel,o=n/(i?s*2:s);if(!this._active)this._anchor=e.pointerEventToContainerPoint(t),this._anchorLatLng=e.containerPointToLatLng(this._anchor),this._targetZoom=e.getZoom(),this._active=!0,e._stop(),e._moveStart(!0,!1);if(this._targetZoom=e._limitZoom(this._targetZoom+o),i){this._applyZoom(this._targetZoom),this._scheduleSettle();return}if(this._frame===void 0)this._startFrames()}_applyZoom(t){let e=this._map,n=this._anchor,i=this._anchorLatLng;if(!n||!i){e._move(e.getCenter(),t);return}let s=e.getSize().divideBy(2),o=n.subtract(s),r=e.unproject(e.project(i,t).subtract(o),t);e._move(r,t,{round:!1})}_startFrames(){this._lastFrameTime=0,this._frame=requestAnimationFrame((t)=>this._tick(t))}_stopFrames(){if(this._frame!==void 0)cancelAnimationFrame(this._frame),this._frame=void 0}_tick(t){let e=this._map,n=this._targetZoom;if(n===null){this._frame=void 0;return}let i=this._lastFrameTime?Math.min((t-this._lastFrameTime)/1000,0.1):0.016666666666666666;this._lastFrameTime=t;let s=Math.max(0.01,e.options.wheelSmoothing),o=1-Math.exp(-i/s),r=e.getZoom(),a=n-r;if(Math.abs(a)<0.001){this._applyZoom(n),this._frame=void 0,this._settle();return}this._applyZoom(r+a*o),this._frame=requestAnimationFrame((l)=>this._tick(l))}_scheduleSettle(){this._stopFrames(),this._frame=requestAnimationFrame(()=>{this._frame=void 0,setTimeout(()=>{if(this._frame===void 0&&this._active)this._settle()},120)})}_settle(){if(!this._active)return;this._active=!1,this._targetZoom=null,this._anchor=void 0,this._anchorLatLng=void 0,this._map._moveEnd(!0)}}F.addInitHook("addHandler","scrollWheelZoom",mh);Te();H();De();G();st();var wm=600;F.mergeOptions({tapHold:pt.safari&&pt.mobile,tapTolerance:15});class _h extends It{addHooks(){k(this._map._container,"pointerdown",this._onDown,this)}removeHooks(){Z(this._map._container,"pointerdown",this._onDown,this),clearTimeout(this._holdTimeout)}_onDown(t){if(clearTimeout(this._holdTimeout),Kt().length!==1||t.pointerType==="mouse")return;let e=this._map._container;this._startPos=this._newPos=new v(t.clientX,t.clientY),this._holdTimeout=setTimeout(()=>{if(this._cancel(),!this._isTapValid())return;k(e,"pointerup",xe),k(e,"pointerup pointercancel",this._cancelClickPrevent,this),this._simulateEvent("contextmenu",t)},wm),k(e,"pointerup pointercancel contextmenu",this._cancel,this),k(e,"pointermove",this._onMove,this)}_cancelClickPrevent(){let t=this._map._container;Z(t,"pointerup",xe),Z(t,"pointerup pointercancel",this._cancelClickPrevent,this)}_cancel(){clearTimeout(this._holdTimeout);let t=this._map._container;Z(t,"pointerup pointercancel contextmenu",this._cancel,this),Z(t,"pointermove",this._onMove,this)}_onMove(t){this._newPos=new v(t.clientX,t.clientY)}_isTapValid(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance}_simulateEvent(t,e){let n=new MouseEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY});n._simulated=!0,e.target.dispatchEvent(n)}}F.addInitHook("addHandler","tapHold",_h);H();De();st();F.mergeOptions({touchPitch:!0});class gh extends It{_pitching=!1;_moved=!1;addHooks(){k(this._map._container,"pointerdown",this._onPointerStart,this)}removeHooks(){Z(this._map._container,"pointerdown",this._onPointerStart,this)}_onPointerStart(t){let e=Kt();if(e.length!==2||this._pitching)return;let n=this._map,i=n.pointerEventToContainerPoint(e[0]),s=n.pointerEventToContainerPoint(e[1]);this._startX1=i.x,this._startY1=i.y,this._startX2=s.x,this._startY2=s.y,this._startPitch=n.getPitch(),this._startDist=i.distanceTo(s),this._pitching=!0,this._moved=!1,k(this._map._container,"pointermove",this._onPointerMove,this),k(this._map._container,"pointerup pointercancel",this._onPointerEnd,this)}_onPointerMove(t){let e=Kt();if(e.length!==2||!this._pitching)return;let n=this._map,i=n.pointerEventToContainerPoint(e[0]),s=n.pointerEventToContainerPoint(e[1]),o=i.y-this._startY1,r=s.y-this._startY2,a=i.x-this._startX1,l=s.x-this._startX2;if(Math.sign(o)!==Math.sign(r)&&Math.abs(o)>5&&Math.abs(r)>5)return;let c=(o+r)/2,h=(a+l)/2;if(Math.abs(h)>Math.abs(c)*1.5)return;let f=i.distanceTo(s)/this._startDist;if(Math.abs(f-1)>0.1)return;if(!this._moved&&Math.abs(c)<5)return;if(!this._moved)this._moved=!0,n.fire("pitchstart");let d=this._startPitch-c*0.3;if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);this._animRequest=requestAnimationFrame(()=>{n.setPitch(d)}),t.preventDefault()}_onPointerEnd(){if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);if(Z(this._map._container,"pointermove",this._onPointerMove,this),Z(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),this._moved)this._map.fire("pitchend");this._pitching=!1,this._moved=!1}}F.addInitHook("addHandler","touchPitch",gh);H();De();st();F.mergeOptions({touchRotate:!0});class yh extends It{_rotating=!1;_moved=!1;addHooks(){k(this._map._container,"pointerdown",this._onPointerStart,this)}removeHooks(){Z(this._map._container,"pointerdown",this._onPointerStart,this)}_onPointerStart(t){let e=Kt();if(e.length!==2||this._rotating)return;let n=this._map,i=n.pointerEventToContainerPoint(e[0]),s=n.pointerEventToContainerPoint(e[1]);if(this._startAngle=Math.atan2(s.y-i.y,s.x-i.x),this._startBearing=n.getBearing(),n.options.touchRotate==="center"){let o=n.getSize();this._pivot={x:o.x/2,y:o.y/2}}else this._pivot={x:(i.x+s.x)/2,y:(i.y+s.y)/2};this._rotating=!0,this._moved=!1,k(this._map._container,"pointermove",this._onPointerMove,this),k(this._map._container,"pointerup pointercancel",this._onPointerEnd,this)}_onPointerMove(t){let e=Kt();if(e.length!==2||!this._rotating)return;let n=this._map,i=n.pointerEventToContainerPoint(e[0]),s=n.pointerEventToContainerPoint(e[1]),r=(Math.atan2(s.y-i.y,s.x-i.x)-this._startAngle)*180/Math.PI,a=this._startBearing+r;if(!this._moved)this._moved=!0,n.fire("rotatestart");if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);this._animRequest=requestAnimationFrame(()=>{n.setBearing(a)}),t.preventDefault()}_onPointerEnd(){if(this._animRequest!==void 0)cancelAnimationFrame(this._animRequest);if(Z(this._map._container,"pointermove",this._onPointerMove,this),Z(this._map._container,"pointerup pointercancel",this._onPointerEnd,this),this._moved)this._map.fire("rotateend");this._rotating=!1,this._moved=!1}}F.addInitHook("addHandler","touchRotate",yh);$i();zo();Io();var bh={};tt(bh,{DARK:()=>wh,LIGHT:()=>vh,dark:()=>Tm,light:()=>Pm});var wh={background:"#12141a",land:"#171a21",green:"#18251c",water:"#0e1926",roadMajor:"#3a3f4b",roadMinor:"#282c35",roadCasing:"#0f1116",buildings:"#1d212a",boundary:"#2f3540",label:"#c8ccd4",labelHalo:"#0d0f13",labelMuted:"#8c93a1"},vh={background:"#f3f2ee",land:"#f7f6f2",green:"#e3ece0",water:"#c3d7e8",roadMajor:"#ffffff",roadMinor:"#ffffff",roadCasing:"#e2e0da",buildings:"#eae8e2",boundary:"#d5d2cb",label:"#3c4043",labelHalo:"#ffffff",labelMuted:"#6b7076"},vm={water:"water",landcover:"landcover",landuse:"landuse",building:"building",transportation:"transportation",transportationName:"transportation_name",boundary:"boundary",place:"place"},kt="basemap";function xm(t,e,n){let i=Array.isArray(e.tiles)?e.tiles:[e.tiles];return{version:8,name:n,sources:{[kt]:{type:"raster",tiles:i,tileSize:e.tileSize??256,minzoom:e.minzoom??0,maxzoom:e.maxzoom??19,attribution:e.attribution}},layers:[{id:"background",type:"background",paint:{"background-color":t.background}},{id:"basemap",type:"raster",source:kt,paint:{"raster-opacity":1}}]}}function Sm(t,e,n){let i=Array.isArray(e.tiles)?e.tiles:[e.tiles],s={...vm,...e.sourceLayers};return{version:8,name:n,...e.glyphs?{glyphs:e.glyphs}:{},...e.sprite?{sprite:e.sprite}:{},sources:{[kt]:{type:"vector",tiles:i,minzoom:e.minzoom??0,maxzoom:e.maxzoom??14,attribution:e.attribution}},layers:[{id:"background",type:"background",paint:{"background-color":t.background}},{id:"landcover",type:"fill",source:kt,"source-layer":s.landcover,paint:{"fill-color":t.green,"fill-opacity":0.8}},{id:"landuse",type:"fill",source:kt,"source-layer":s.landuse,paint:{"fill-color":t.land}},{id:"water",type:"fill",source:kt,"source-layer":s.water,paint:{"fill-color":t.water}},{id:"road-casing",type:"line",source:kt,"source-layer":s.transportation,minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.roadCasing,"line-width":["interpolate",["exponential",1.5],["zoom"],6,1.5,12,4,16,14,20,42]}},{id:"road-minor",type:"line",source:kt,"source-layer":s.transportation,minzoom:11,filter:["!",["in",["get","class"],["literal",["motorway","trunk","primary"]]]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.roadMinor,"line-width":["interpolate",["exponential",1.5],["zoom"],11,0.75,16,6,20,24]}},{id:"road-major",type:"line",source:kt,"source-layer":s.transportation,minzoom:6,filter:["in",["get","class"],["literal",["motorway","trunk","primary"]]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t.roadMajor,"line-width":["interpolate",["exponential",1.5],["zoom"],6,1,12,3,16,10,20,32]}},{id:"building",type:"fill",source:kt,"source-layer":s.building,minzoom:13,paint:{"fill-color":t.buildings,"fill-opacity":["interpolate",["linear"],["zoom"],13,0,15,1]}},{id:"boundary",type:"line",source:kt,"source-layer":s.boundary,filter:["<=",["get","admin_level"],4],paint:{"line-color":t.boundary,"line-width":["interpolate",["linear"],["zoom"],3,0.5,10,1.5],"line-dasharray":[3,2]}},{id:"road-label",type:"symbol",source:kt,"source-layer":s.transportationName,minzoom:12,layout:{"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],12,10,18,13],"symbol-placement":"line","text-max-angle":45,"symbol-spacing":250},paint:{"text-color":t.labelMuted,"text-halo-color":t.labelHalo,"text-halo-width":1.2}},{id:"place-label",type:"symbol",source:kt,"source-layer":s.place,layout:{"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],4,11,10,14,16,18],"text-anchor":"center","symbol-sort-key":1},paint:{"text-color":t.label,"text-halo-color":t.labelHalo,"text-halo-width":1.5}}]}}function xh(t,e,n){let i={...t,...e.palette};return e.mode==="raster"?xm(i,e,n):Sm(i,e,n)}function Tm(t){return xh(wh,t,t.name??"ts-maps dark")}function Pm(t){return xh(vh,t,t.name??"ts-maps light")}var km="0.3.1";function B(t){return(...e)=>new t(...e)}var n_=Oc,Mm=B(Me),Lm=B(an),Am=B(ln),Om=B(ti),Em=B(Gt),Sh=B(q),zm=Sh,Cm=B(sn),Im=Object.assign(B($e),{wms:B(ei)}),Fm=B(jn),Rm=B(Ii),i_=B(Ci),Nm=B(hn),$m=B(ss),Zm=B(or),Bm=B(un),Dm=B(fn),jm=B(je),Um=B(Ue),Hm=B(lr),Wm=B(Jn),Vm=B(cn),qm=Object.assign(B(Ct),{zoom:B(Qn),layers:B(Qi),attribution:B(Xn),scale:B(ns),locate:B(ts),geocoder:B(Ji),navigation:B(es),fullscreen:B(Xi)}),Th={version:km,Class:rn,Evented:wt,Handler:It,Util:Va,Browser:pt,Bounds:I,Point:v,Transformation:Be,LineUtil:Xc,PolyUtil:Jc,toBounds:$h,toPoint:Ps,toTransformation:Uh,CRS:Zi,EPSG3395:rh,EPSG3857:Pi,EPSG4326:tr,SimpleCRS:ah,LatLng:S,LatLngBounds:R,Projection:oh,toLatLng:Wh,toLatLngBounds:Hh,Animation:Po,Draggable:qt,PosAnimation:ko,Map:F,TsMap:F,Layer:mt,LayerGroup:ti,FeatureGroup:Gt,GeoJSON:q,ImageOverlay:hn,VideoOverlay:ss,SVGOverlay:or,Popup:un,Tooltip:fn,Icon:an,DefaultIcon:Ie,DivIcon:ln,Marker:Me,GridLayer:sn,TileLayer:$e,VectorTileMapLayer:jn,WMSTileLayer:ei,TerritoryLayer:ir,RunTrailLayer:sr,Polyline:je,Polygon:Ue,Rectangle:lr,Circle:Jn,CircleMarker:cn,Control:Ct,ZoomControl:Qn,AttributionControl:Xn,ScaleControl:ns,LayersControl:Qi,LocateControl:ts,GeocoderControl:Ji,NavigationControl:es,FullscreenControl:Xi,map:Oc,marker:Mm,icon:Lm,divIcon:Am,layerGroup:Om,featureGroup:Em,geoJSON:Sh,geoJson:zm,gridLayer:Cm,tileLayer:Im,vectorTileLayer:Fm,heatmapLayer:Rm,territoryLayer:gm,runTrailLayer:bm,imageOverlay:Nm,videoOverlay:$m,svgOverlay:Zm,popup:Bm,tooltip:Dm,polyline:jm,polygon:Um,rectangle:Hm,circle:Wm,circleMarker:Vm,control:qm,services:Ic,styles:bh};if(typeof window<"u")window.tsMap??=Th;var s_=Th;export{Po as Animation,Xn as AttributionControl,er as BlanketOverlay,I as Bounds,uh as BoxZoomHandler,pt as Browser,Zi as CRS,ar as Canvas,Jn as Circle,cn as CircleMarker,rn as Class,Ct as Control,Ie as DefaultIcon,ln as DivIcon,is as DivOverlay,Fs as DomEvent,Tu as DomUtil,fh as DoubleClickZoomHandler,dh as DragHandler,qt as Draggable,Ms as EARTH_RADIUS,rh as EPSG3395,Pi as EPSG3857,tr as EPSG4326,tu as EPSG900913,we as EarthCRS,wt as Evented,Gt as FeatureGroup,Xi as FullscreenControl,q as GeoJSON,Mc as GeoJSONClusterSource,xc as GeoJSONTileSource,Ji as GeocoderControl,sn as GridLayer,It as Handler,Ii as HeatmapLayer,bc as HillshadeLayer,an as Icon,hn as ImageOverlay,Ke as InvalidGeometryError,Do as KDBush,On as KeyboardHandler,S as LatLng,R as LatLngBounds,mt as Layer,ti as LayerGroup,Qi as LayersControl,Xc as LineUtil,ts as LocateControl,pm as LoopDetector,Mp as Map,Me as Marker,ro as MarkerDrag,es as NavigationControl,Ze as Path,ph as PinchZoomHandler,v as Point,Jc as PolyUtil,Ue as Polygon,je as Polyline,un as Popup,ko as PosAnimation,oh as Projection,Ga as RTree,Ci as RasterDEMLayer,lr as Rectangle,rr as Renderer,sr as RunTrailLayer,tn as SVG,or as SVGOverlay,ns as ScaleControl,mh as ScrollWheelZoomHandler,ah as SimpleCRS,_h as TapHoldHandler,Xa as TerrainSource,ir as TerritoryLayer,fm as TerritoryLog,zc as TerritoryStore,Ni as TileCache,$e as TileLayer,fn as Tooltip,Be as Transformation,F as TsMap,gh as TwoFingerPitchHandler,yh as TwoFingerRotateHandler,Va as Util,jn as VectorTileMapLayer,ss as VideoOverlay,ei as WMSTileLayer,Co as WebGLTileRenderer,Eo as WebGLUnsupportedError,Qn as ZoomControl,Gh as buildTerrainMesh,lo as cachedFetch,Wm as circle,Vm as circleMarker,Ti as compareEvents,zh as computeTileCoords,il as contains,qm as control,Oc as createMap,qh as decodeElevationGrid,po as decodeMapboxRGB,mo as decodeTerrariumRGB,s_ as default,t_ as detectLoop,Jm as deviation,ls as difference,Am as divIcon,zl as earcut,Pu as easing,Em as featureGroup,Cl as flatten,nu as formatArea,Ym as formatDistance,Sh as geoJSON,zm as geoJson,nn as getDefaultCache,Vh as getElevationDecoder,Cm as gridLayer,zn as haversine,Rm as heatmapLayer,Lm as icon,Nm as imageOverlay,Os as intersection,Xm as intersects,Om as layerGroup,n_ as map,Mm as marker,he as multiPolygonArea,Um as polygon,tl as polygonArea,jm as polyline,Bm as popup,Mr as prepareClaim,i_ as rasterDEMLayer,Hm as rectangle,Gm as resetDefaultCache,pu as resolveSelfIntersections,ks as ringArea,eu as ringPerimeter,bm as runTrailLayer,Ya as sampleElevationBilinear,Ih as saveOfflineRegion,_u as selfIntersects,Ic as services,e_ as simplifyTrack,du as splitSelfIntersecting,bh as styles,Zm as svgOverlay,gm as territoryLayer,Im as tileLayer,$h as toBounds,Wh as toLatLng,Hh as toLatLngBounds,Ps as toPoint,Uh as toTransformation,Dm as tooltip,As as union,fu as unwrapRing,uu as validateRing,Fm as vectorTileLayer,km as version,$m as videoOverlay,Km as xor}; |