@ogis/waymark-js 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,766 @@
1
+ (function(fa){typeof define=="function"&&define.amd?define(fa):fa()})(function(){"use strict";/**
2
+ * @vue/shared v3.5.13
3
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
+ * @license MIT
5
+ **//*! #__NO_SIDE_EFFECTS__ */function fa(u){const m=Object.create(null);for(const b of u.split(","))m[b]=1;return b=>b in m}const ai={},ma=[],Nn=()=>{},K_=()=>!1,ou=u=>u.charCodeAt(0)===111&&u.charCodeAt(1)===110&&(u.charCodeAt(2)>122||u.charCodeAt(2)<97),Jh=u=>u.startsWith("onUpdate:"),kr=Object.assign,Qh=(u,m)=>{const b=u.indexOf(m);b>-1&&u.splice(b,1)},Y_=Object.prototype.hasOwnProperty,ii=(u,m)=>Y_.call(u,m),Mt=Array.isArray,ga=u=>au(u)==="[object Map]",of=u=>au(u)==="[object Set]",It=u=>typeof u=="function",Bi=u=>typeof u=="string",cs=u=>typeof u=="symbol",xi=u=>u!==null&&typeof u=="object",af=u=>(xi(u)||It(u))&&It(u.then)&&It(u.catch),lf=Object.prototype.toString,au=u=>lf.call(u),J_=u=>au(u).slice(8,-1),cf=u=>au(u)==="[object Object]",ed=u=>Bi(u)&&u!=="NaN"&&u[0]!=="-"&&""+parseInt(u,10)===u,kl=fa(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),lu=u=>{const m=Object.create(null);return b=>m[b]||(m[b]=u(b))},Q_=/-(\w)/g,Vs=lu(u=>u.replace(Q_,(m,b)=>b?b.toUpperCase():"")),ey=/\B([A-Z])/g,So=lu(u=>u.replace(ey,"-$1").toLowerCase()),uf=lu(u=>u.charAt(0).toUpperCase()+u.slice(1)),td=lu(u=>u?`on${uf(u)}`:""),Us=(u,m)=>!Object.is(u,m),cu=(u,...m)=>{for(let b=0;b<u.length;b++)u[b](...m)},hf=(u,m,b,M=!1)=>{Object.defineProperty(u,m,{configurable:!0,enumerable:!1,writable:M,value:b})},id=u=>{const m=parseFloat(u);return isNaN(m)?u:m};let df;const uu=()=>df||(df=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Po(u){if(Mt(u)){const m={};for(let b=0;b<u.length;b++){const M=u[b],E=Bi(M)?ny(M):Po(M);if(E)for(const D in E)m[D]=E[D]}return m}else if(Bi(u)||xi(u))return u}const ty=/;(?![^(]*\))/g,iy=/:([^]+)/,ry=/\/\*[^]*?\*\//g;function ny(u){const m={};return u.replace(ry,"").split(ty).forEach(b=>{if(b){const M=b.split(iy);M.length>1&&(m[M[0].trim()]=M[1].trim())}}),m}function Vn(u){let m="";if(Bi(u))m=u;else if(Mt(u))for(let b=0;b<u.length;b++){const M=Vn(u[b]);M&&(m+=M+" ")}else if(xi(u))for(const b in u)u[b]&&(m+=b+" ");return m.trim()}const sy=fa("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function pf(u){return!!u||u===""}const ff=u=>!!(u&&u.__v_isRef===!0),$s=u=>Bi(u)?u:u==null?"":Mt(u)||xi(u)&&(u.toString===lf||!It(u.toString))?ff(u)?$s(u.value):JSON.stringify(u,mf,2):String(u),mf=(u,m)=>ff(m)?mf(u,m.value):ga(m)?{[`Map(${m.size})`]:[...m.entries()].reduce((b,[M,E],D)=>(b[rd(M,D)+" =>"]=E,b),{})}:of(m)?{[`Set(${m.size})`]:[...m.values()].map(b=>rd(b))}:cs(m)?rd(m):xi(m)&&!Mt(m)&&!cf(m)?String(m):m,rd=(u,m="")=>{var b;return cs(u)?`Symbol(${(b=u.description)!=null?b:m})`:u};/**
6
+ * @vue/reactivity v3.5.13
7
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
8
+ * @license MIT
9
+ **/let zr;class gf{constructor(m=!1){this.detached=m,this._active=!0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=zr,!m&&zr&&(this.index=(zr.scopes||(zr.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let m,b;if(this.scopes)for(m=0,b=this.scopes.length;m<b;m++)this.scopes[m].pause();for(m=0,b=this.effects.length;m<b;m++)this.effects[m].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let m,b;if(this.scopes)for(m=0,b=this.scopes.length;m<b;m++)this.scopes[m].resume();for(m=0,b=this.effects.length;m<b;m++)this.effects[m].resume()}}run(m){if(this._active){const b=zr;try{return zr=this,m()}finally{zr=b}}}on(){zr=this}off(){zr=this.parent}stop(m){if(this._active){this._active=!1;let b,M;for(b=0,M=this.effects.length;b<M;b++)this.effects[b].stop();for(this.effects.length=0,b=0,M=this.cleanups.length;b<M;b++)this.cleanups[b]();if(this.cleanups.length=0,this.scopes){for(b=0,M=this.scopes.length;b<M;b++)this.scopes[b].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!m){const E=this.parent.scopes.pop();E&&E!==this&&(this.parent.scopes[this.index]=E,E.index=this.index)}this.parent=void 0}}}function _f(u){return new gf(u)}function yf(){return zr}function oy(u,m=!1){zr&&zr.cleanups.push(u)}let hi;const nd=new WeakSet;class vf{constructor(m){this.fn=m,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,zr&&zr.active&&zr.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,nd.has(this)&&(nd.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||bf(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,Mf(this),wf(this);const m=hi,b=Cn;hi=this,Cn=!0;try{return this.fn()}finally{Tf(this),hi=m,Cn=b,this.flags&=-3}}stop(){if(this.flags&1){for(let m=this.deps;m;m=m.nextDep)ld(m);this.deps=this.depsTail=void 0,Mf(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?nd.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){ad(this)&&this.run()}get dirty(){return ad(this)}}let xf=0,zl,Rl;function bf(u,m=!1){if(u.flags|=8,m){u.next=Rl,Rl=u;return}u.next=zl,zl=u}function sd(){xf++}function od(){if(--xf>0)return;if(Rl){let m=Rl;for(Rl=void 0;m;){const b=m.next;m.next=void 0,m.flags&=-9,m=b}}let u;for(;zl;){let m=zl;for(zl=void 0;m;){const b=m.next;if(m.next=void 0,m.flags&=-9,m.flags&1)try{m.trigger()}catch(M){u||(u=M)}m=b}}if(u)throw u}function wf(u){for(let m=u.deps;m;m=m.nextDep)m.version=-1,m.prevActiveLink=m.dep.activeLink,m.dep.activeLink=m}function Tf(u){let m,b=u.depsTail,M=b;for(;M;){const E=M.prevDep;M.version===-1?(M===b&&(b=E),ld(M),ay(M)):m=M,M.dep.activeLink=M.prevActiveLink,M.prevActiveLink=void 0,M=E}u.deps=m,u.depsTail=b}function ad(u){for(let m=u.deps;m;m=m.nextDep)if(m.dep.version!==m.version||m.dep.computed&&(Sf(m.dep.computed)||m.dep.version!==m.version))return!0;return!!u._dirty}function Sf(u){if(u.flags&4&&!(u.flags&16)||(u.flags&=-17,u.globalVersion===Dl))return;u.globalVersion=Dl;const m=u.dep;if(u.flags|=2,m.version>0&&!u.isSSR&&u.deps&&!ad(u)){u.flags&=-3;return}const b=hi,M=Cn;hi=u,Cn=!0;try{wf(u);const E=u.fn(u._value);(m.version===0||Us(E,u._value))&&(u._value=E,m.version++)}catch(E){throw m.version++,E}finally{hi=b,Cn=M,Tf(u),u.flags&=-3}}function ld(u,m=!1){const{dep:b,prevSub:M,nextSub:E}=u;if(M&&(M.nextSub=E,u.prevSub=void 0),E&&(E.prevSub=M,u.nextSub=void 0),b.subs===u&&(b.subs=M,!M&&b.computed)){b.computed.flags&=-5;for(let D=b.computed.deps;D;D=D.nextDep)ld(D,!0)}!m&&!--b.sc&&b.map&&b.map.delete(b.key)}function ay(u){const{prevDep:m,nextDep:b}=u;m&&(m.nextDep=b,u.prevDep=void 0),b&&(b.prevDep=m,u.nextDep=void 0)}let Cn=!0;const Pf=[];function us(){Pf.push(Cn),Cn=!1}function hs(){const u=Pf.pop();Cn=u===void 0?!0:u}function Mf(u){const{cleanup:m}=u;if(u.cleanup=void 0,m){const b=hi;hi=void 0;try{m()}finally{hi=b}}}let Dl=0;class ly{constructor(m,b){this.sub=m,this.dep=b,this.version=b.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class cd{constructor(m){this.computed=m,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0}track(m){if(!hi||!Cn||hi===this.computed)return;let b=this.activeLink;if(b===void 0||b.sub!==hi)b=this.activeLink=new ly(hi,this),hi.deps?(b.prevDep=hi.depsTail,hi.depsTail.nextDep=b,hi.depsTail=b):hi.deps=hi.depsTail=b,Cf(b);else if(b.version===-1&&(b.version=this.version,b.nextDep)){const M=b.nextDep;M.prevDep=b.prevDep,b.prevDep&&(b.prevDep.nextDep=M),b.prevDep=hi.depsTail,b.nextDep=void 0,hi.depsTail.nextDep=b,hi.depsTail=b,hi.deps===b&&(hi.deps=M)}return b}trigger(m){this.version++,Dl++,this.notify(m)}notify(m){sd();try{for(let b=this.subs;b;b=b.prevSub)b.sub.notify()&&b.sub.dep.notify()}finally{od()}}}function Cf(u){if(u.dep.sc++,u.sub.flags&4){const m=u.dep.computed;if(m&&!u.dep.subs){m.flags|=20;for(let M=m.deps;M;M=M.nextDep)Cf(M)}const b=u.dep.subs;b!==u&&(u.prevSub=b,b&&(b.nextSub=u)),u.dep.subs=u}}const hu=new WeakMap,Mo=Symbol(""),ud=Symbol(""),Ll=Symbol("");function wr(u,m,b){if(Cn&&hi){let M=hu.get(u);M||hu.set(u,M=new Map);let E=M.get(b);E||(M.set(b,E=new cd),E.map=M,E.key=b),E.track()}}function ds(u,m,b,M,E,D){const T=hu.get(u);if(!T){Dl++;return}const a=V=>{V&&V.trigger()};if(sd(),m==="clear")T.forEach(a);else{const V=Mt(u),ue=V&&ed(b);if(V&&b==="length"){const oe=Number(M);T.forEach((ge,Se)=>{(Se==="length"||Se===Ll||!cs(Se)&&Se>=oe)&&a(ge)})}else switch((b!==void 0||T.has(void 0))&&a(T.get(b)),ue&&a(T.get(Ll)),m){case"add":V?ue&&a(T.get("length")):(a(T.get(Mo)),ga(u)&&a(T.get(ud)));break;case"delete":V||(a(T.get(Mo)),ga(u)&&a(T.get(ud)));break;case"set":ga(u)&&a(T.get(Mo));break}}od()}function cy(u,m){const b=hu.get(u);return b&&b.get(m)}function _a(u){const m=Ht(u);return m===u?m:(wr(m,"iterate",Ll),yn(u)?m:m.map(Tr))}function du(u){return wr(u=Ht(u),"iterate",Ll),u}const uy={__proto__:null,[Symbol.iterator](){return hd(this,Symbol.iterator,Tr)},concat(...u){return _a(this).concat(...u.map(m=>Mt(m)?_a(m):m))},entries(){return hd(this,"entries",u=>(u[1]=Tr(u[1]),u))},every(u,m){return ps(this,"every",u,m,void 0,arguments)},filter(u,m){return ps(this,"filter",u,m,b=>b.map(Tr),arguments)},find(u,m){return ps(this,"find",u,m,Tr,arguments)},findIndex(u,m){return ps(this,"findIndex",u,m,void 0,arguments)},findLast(u,m){return ps(this,"findLast",u,m,Tr,arguments)},findLastIndex(u,m){return ps(this,"findLastIndex",u,m,void 0,arguments)},forEach(u,m){return ps(this,"forEach",u,m,void 0,arguments)},includes(...u){return dd(this,"includes",u)},indexOf(...u){return dd(this,"indexOf",u)},join(u){return _a(this).join(u)},lastIndexOf(...u){return dd(this,"lastIndexOf",u)},map(u,m){return ps(this,"map",u,m,void 0,arguments)},pop(){return Fl(this,"pop")},push(...u){return Fl(this,"push",u)},reduce(u,...m){return If(this,"reduce",u,m)},reduceRight(u,...m){return If(this,"reduceRight",u,m)},shift(){return Fl(this,"shift")},some(u,m){return ps(this,"some",u,m,void 0,arguments)},splice(...u){return Fl(this,"splice",u)},toReversed(){return _a(this).toReversed()},toSorted(u){return _a(this).toSorted(u)},toSpliced(...u){return _a(this).toSpliced(...u)},unshift(...u){return Fl(this,"unshift",u)},values(){return hd(this,"values",Tr)}};function hd(u,m,b){const M=du(u),E=M[m]();return M!==u&&!yn(u)&&(E._next=E.next,E.next=()=>{const D=E._next();return D.value&&(D.value=b(D.value)),D}),E}const hy=Array.prototype;function ps(u,m,b,M,E,D){const T=du(u),a=T!==u&&!yn(u),V=T[m];if(V!==hy[m]){const ge=V.apply(u,D);return a?Tr(ge):ge}let ue=b;T!==u&&(a?ue=function(ge,Se){return b.call(this,Tr(ge),Se,u)}:b.length>2&&(ue=function(ge,Se){return b.call(this,ge,Se,u)}));const oe=V.call(T,ue,M);return a&&E?E(oe):oe}function If(u,m,b,M){const E=du(u);let D=b;return E!==u&&(yn(u)?b.length>3&&(D=function(T,a,V){return b.call(this,T,a,V,u)}):D=function(T,a,V){return b.call(this,T,Tr(a),V,u)}),E[m](D,...M)}function dd(u,m,b){const M=Ht(u);wr(M,"iterate",Ll);const E=M[m](...b);return(E===-1||E===!1)&&fd(b[0])?(b[0]=Ht(b[0]),M[m](...b)):E}function Fl(u,m,b=[]){us(),sd();const M=Ht(u)[m].apply(u,b);return od(),hs(),M}const dy=fa("__proto__,__v_isRef,__isVue"),Ef=new Set(Object.getOwnPropertyNames(Symbol).filter(u=>u!=="arguments"&&u!=="caller").map(u=>Symbol[u]).filter(cs));function py(u){cs(u)||(u=String(u));const m=Ht(this);return wr(m,"has",u),m.hasOwnProperty(u)}class Af{constructor(m=!1,b=!1){this._isReadonly=m,this._isShallow=b}get(m,b,M){if(b==="__v_skip")return m.__v_skip;const E=this._isReadonly,D=this._isShallow;if(b==="__v_isReactive")return!E;if(b==="__v_isReadonly")return E;if(b==="__v_isShallow")return D;if(b==="__v_raw")return M===(E?D?Ff:Lf:D?Df:Rf).get(m)||Object.getPrototypeOf(m)===Object.getPrototypeOf(M)?m:void 0;const T=Mt(m);if(!E){let V;if(T&&(V=uy[b]))return V;if(b==="hasOwnProperty")return py}const a=Reflect.get(m,b,bi(m)?m:M);return(cs(b)?Ef.has(b):dy(b))||(E||wr(m,"get",b),D)?a:bi(a)?T&&ed(b)?a:a.value:xi(a)?E?Bf(a):gu(a):a}}class kf extends Af{constructor(m=!1){super(!1,m)}set(m,b,M,E){let D=m[b];if(!this._isShallow){const V=Co(D);if(!yn(M)&&!Co(M)&&(D=Ht(D),M=Ht(M)),!Mt(m)&&bi(D)&&!bi(M))return V?!1:(D.value=M,!0)}const T=Mt(m)&&ed(b)?Number(b)<m.length:ii(m,b),a=Reflect.set(m,b,M,bi(m)?m:E);return m===Ht(E)&&(T?Us(M,D)&&ds(m,"set",b,M):ds(m,"add",b,M)),a}deleteProperty(m,b){const M=ii(m,b);m[b];const E=Reflect.deleteProperty(m,b);return E&&M&&ds(m,"delete",b,void 0),E}has(m,b){const M=Reflect.has(m,b);return(!cs(b)||!Ef.has(b))&&wr(m,"has",b),M}ownKeys(m){return wr(m,"iterate",Mt(m)?"length":Mo),Reflect.ownKeys(m)}}class zf extends Af{constructor(m=!1){super(!0,m)}set(m,b){return!0}deleteProperty(m,b){return!0}}const fy=new kf,my=new zf,gy=new kf(!0),_y=new zf(!0),pd=u=>u,pu=u=>Reflect.getPrototypeOf(u);function yy(u,m,b){return function(...M){const E=this.__v_raw,D=Ht(E),T=ga(D),a=u==="entries"||u===Symbol.iterator&&T,V=u==="keys"&&T,ue=E[u](...M),oe=b?pd:m?gd:Tr;return!m&&wr(D,"iterate",V?ud:Mo),{next(){const{value:ge,done:Se}=ue.next();return Se?{value:ge,done:Se}:{value:a?[oe(ge[0]),oe(ge[1])]:oe(ge),done:Se}},[Symbol.iterator](){return this}}}}function fu(u){return function(...m){return u==="delete"?!1:u==="clear"?void 0:this}}function vy(u,m){const b={get(E){const D=this.__v_raw,T=Ht(D),a=Ht(E);u||(Us(E,a)&&wr(T,"get",E),wr(T,"get",a));const{has:V}=pu(T),ue=m?pd:u?gd:Tr;if(V.call(T,E))return ue(D.get(E));if(V.call(T,a))return ue(D.get(a));D!==T&&D.get(E)},get size(){const E=this.__v_raw;return!u&&wr(Ht(E),"iterate",Mo),Reflect.get(E,"size",E)},has(E){const D=this.__v_raw,T=Ht(D),a=Ht(E);return u||(Us(E,a)&&wr(T,"has",E),wr(T,"has",a)),E===a?D.has(E):D.has(E)||D.has(a)},forEach(E,D){const T=this,a=T.__v_raw,V=Ht(a),ue=m?pd:u?gd:Tr;return!u&&wr(V,"iterate",Mo),a.forEach((oe,ge)=>E.call(D,ue(oe),ue(ge),T))}};return kr(b,u?{add:fu("add"),set:fu("set"),delete:fu("delete"),clear:fu("clear")}:{add(E){!m&&!yn(E)&&!Co(E)&&(E=Ht(E));const D=Ht(this);return pu(D).has.call(D,E)||(D.add(E),ds(D,"add",E,E)),this},set(E,D){!m&&!yn(D)&&!Co(D)&&(D=Ht(D));const T=Ht(this),{has:a,get:V}=pu(T);let ue=a.call(T,E);ue||(E=Ht(E),ue=a.call(T,E));const oe=V.call(T,E);return T.set(E,D),ue?Us(D,oe)&&ds(T,"set",E,D):ds(T,"add",E,D),this},delete(E){const D=Ht(this),{has:T,get:a}=pu(D);let V=T.call(D,E);V||(E=Ht(E),V=T.call(D,E)),a&&a.call(D,E);const ue=D.delete(E);return V&&ds(D,"delete",E,void 0),ue},clear(){const E=Ht(this),D=E.size!==0,T=E.clear();return D&&ds(E,"clear",void 0,void 0),T}}),["keys","values","entries",Symbol.iterator].forEach(E=>{b[E]=yy(E,u,m)}),b}function mu(u,m){const b=vy(u,m);return(M,E,D)=>E==="__v_isReactive"?!u:E==="__v_isReadonly"?u:E==="__v_raw"?M:Reflect.get(ii(b,E)&&E in M?b:M,E,D)}const xy={get:mu(!1,!1)},by={get:mu(!1,!0)},wy={get:mu(!0,!1)},Ty={get:mu(!0,!0)},Rf=new WeakMap,Df=new WeakMap,Lf=new WeakMap,Ff=new WeakMap;function Sy(u){switch(u){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Py(u){return u.__v_skip||!Object.isExtensible(u)?0:Sy(J_(u))}function gu(u){return Co(u)?u:_u(u,!1,fy,xy,Rf)}function My(u){return _u(u,!1,gy,by,Df)}function Bf(u){return _u(u,!0,my,wy,Lf)}function iw(u){return _u(u,!0,_y,Ty,Ff)}function _u(u,m,b,M,E){if(!xi(u)||u.__v_raw&&!(m&&u.__v_isReactive))return u;const D=E.get(u);if(D)return D;const T=Py(u);if(T===0)return u;const a=new Proxy(u,T===2?M:b);return E.set(u,a),a}function fs(u){return Co(u)?fs(u.__v_raw):!!(u&&u.__v_isReactive)}function Co(u){return!!(u&&u.__v_isReadonly)}function yn(u){return!!(u&&u.__v_isShallow)}function fd(u){return u?!!u.__v_raw:!1}function Ht(u){const m=u&&u.__v_raw;return m?Ht(m):u}function md(u){return!ii(u,"__v_skip")&&Object.isExtensible(u)&&hf(u,"__v_skip",!0),u}const Tr=u=>xi(u)?gu(u):u,gd=u=>xi(u)?Bf(u):u;function bi(u){return u?u.__v_isRef===!0:!1}function Io(u){return Of(u,!1)}function Kr(u){return Of(u,!0)}function Of(u,m){return bi(u)?u:new Cy(u,m)}class Cy{constructor(m,b){this.dep=new cd,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=b?m:Ht(m),this._value=b?m:Tr(m),this.__v_isShallow=b}get value(){return this.dep.track(),this._value}set value(m){const b=this._rawValue,M=this.__v_isShallow||yn(m)||Co(m);m=M?m:Ht(m),Us(m,b)&&(this._rawValue=m,this._value=M?m:Tr(m),this.dep.trigger())}}function dt(u){return bi(u)?u.value:u}const Iy={get:(u,m,b)=>m==="__v_raw"?u:dt(Reflect.get(u,m,b)),set:(u,m,b,M)=>{const E=u[m];return bi(E)&&!bi(b)?(E.value=b,!0):Reflect.set(u,m,b,M)}};function jf(u){return fs(u)?u:new Proxy(u,Iy)}function Ey(u){const m=Mt(u)?new Array(u.length):{};for(const b in u)m[b]=Nf(u,b);return m}class Ay{constructor(m,b,M){this._object=m,this._key=b,this._defaultValue=M,this.__v_isRef=!0,this._value=void 0}get value(){const m=this._object[this._key];return this._value=m===void 0?this._defaultValue:m}set value(m){this._object[this._key]=m}get dep(){return cy(Ht(this._object),this._key)}}class ky{constructor(m){this._getter=m,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function zy(u,m,b){return bi(u)?u:It(u)?new ky(u):xi(u)&&arguments.length>1?Nf(u,m,b):Io(u)}function Nf(u,m,b){const M=u[m];return bi(M)?M:new Ay(u,m,b)}class Ry{constructor(m,b,M){this.fn=m,this.setter=b,this._value=void 0,this.dep=new cd(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=Dl-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!b,this.isSSR=M}notify(){if(this.flags|=16,!(this.flags&8)&&hi!==this)return bf(this,!0),!0}get value(){const m=this.dep.track();return Sf(this),m&&(m.version=this.dep.version),this._value}set value(m){this.setter&&this.setter(m)}}function Dy(u,m,b=!1){let M,E;return It(u)?M=u:(M=u.get,E=u.set),new Ry(M,E,b)}const yu={},vu=new WeakMap;let Eo;function Ly(u,m=!1,b=Eo){if(b){let M=vu.get(b);M||vu.set(b,M=[]),M.push(u)}}function Fy(u,m,b=ai){const{immediate:M,deep:E,once:D,scheduler:T,augmentJob:a,call:V}=b,ue=We=>E?We:yn(We)||E===!1||E===0?ms(We,1):ms(We);let oe,ge,Se,Q,He=!1,Qe=!1;if(bi(u)?(ge=()=>u.value,He=yn(u)):fs(u)?(ge=()=>ue(u),He=!0):Mt(u)?(Qe=!0,He=u.some(We=>fs(We)||yn(We)),ge=()=>u.map(We=>{if(bi(We))return We.value;if(fs(We))return ue(We);if(It(We))return V?V(We,2):We()})):It(u)?m?ge=V?()=>V(u,2):u:ge=()=>{if(Se){us();try{Se()}finally{hs()}}const We=Eo;Eo=oe;try{return V?V(u,3,[Q]):u(Q)}finally{Eo=We}}:ge=Nn,m&&E){const We=ge,yt=E===!0?1/0:E;ge=()=>ms(We(),yt)}const Je=yf(),Ye=()=>{oe.stop(),Je&&Je.active&&Qh(Je.effects,oe)};if(D&&m){const We=m;m=(...yt)=>{We(...yt),Ye()}}let ct=Qe?new Array(u.length).fill(yu):yu;const st=We=>{if(!(!(oe.flags&1)||!oe.dirty&&!We))if(m){const yt=oe.run();if(E||He||(Qe?yt.some((Oi,mi)=>Us(Oi,ct[mi])):Us(yt,ct))){Se&&Se();const Oi=Eo;Eo=oe;try{const mi=[yt,ct===yu?void 0:Qe&&ct[0]===yu?[]:ct,Q];V?V(m,3,mi):m(...mi),ct=yt}finally{Eo=Oi}}}else oe.run()};return a&&a(st),oe=new vf(ge),oe.scheduler=T?()=>T(st,!1):st,Q=We=>Ly(We,!1,oe),Se=oe.onStop=()=>{const We=vu.get(oe);if(We){if(V)V(We,4);else for(const yt of We)yt();vu.delete(oe)}},m?M?st(!0):ct=oe.run():T?T(st.bind(null,!0),!0):oe.run(),Ye.pause=oe.pause.bind(oe),Ye.resume=oe.resume.bind(oe),Ye.stop=Ye,Ye}function ms(u,m=1/0,b){if(m<=0||!xi(u)||u.__v_skip||(b=b||new Set,b.has(u)))return u;if(b.add(u),m--,bi(u))ms(u.value,m,b);else if(Mt(u))for(let M=0;M<u.length;M++)ms(u[M],m,b);else if(of(u)||ga(u))u.forEach(M=>{ms(M,m,b)});else if(cf(u)){for(const M in u)ms(u[M],m,b);for(const M of Object.getOwnPropertySymbols(u))Object.prototype.propertyIsEnumerable.call(u,M)&&ms(u[M],m,b)}return u}/**
10
+ * @vue/runtime-core v3.5.13
11
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
12
+ * @license MIT
13
+ **/const Bl=[];let _d=!1;function rw(u,...m){if(_d)return;_d=!0,us();const b=Bl.length?Bl[Bl.length-1].component:null,M=b&&b.appContext.config.warnHandler,E=By();if(M)ya(M,b,11,[u+m.map(D=>{var T,a;return(a=(T=D.toString)==null?void 0:T.call(D))!=null?a:JSON.stringify(D)}).join(""),b&&b.proxy,E.map(({vnode:D})=>`at <${Dm(b,D.type)}>`).join(`
14
+ `),E]);else{const D=[`[Vue warn]: ${u}`,...m];E.length&&D.push(`
15
+ `,...Oy(E)),console.warn(...D)}hs(),_d=!1}function By(){let u=Bl[Bl.length-1];if(!u)return[];const m=[];for(;u;){const b=m[0];b&&b.vnode===u?b.recurseCount++:m.push({vnode:u,recurseCount:0});const M=u.component&&u.component.parent;u=M&&M.vnode}return m}function Oy(u){const m=[];return u.forEach((b,M)=>{m.push(...M===0?[]:[`
16
+ `],...jy(b))}),m}function jy({vnode:u,recurseCount:m}){const b=m>0?`... (${m} recursive calls)`:"",M=u.component?u.component.parent==null:!1,E=` at <${Dm(u.component,u.type,M)}`,D=">"+b;return u.props?[E,...Ny(u.props),D]:[E+D]}function Ny(u){const m=[],b=Object.keys(u);return b.slice(0,3).forEach(M=>{m.push(...Vf(M,u[M]))}),b.length>3&&m.push(" ..."),m}function Vf(u,m,b){return Bi(m)?(m=JSON.stringify(m),b?m:[`${u}=${m}`]):typeof m=="number"||typeof m=="boolean"||m==null?b?m:[`${u}=${m}`]:bi(m)?(m=Vf(u,Ht(m.value),!0),b?m:[`${u}=Ref<`,m,">"]):It(m)?[`${u}=fn${m.name?`<${m.name}>`:""}`]:(m=Ht(m),b?m:[`${u}=`,m])}function ya(u,m,b,M){try{return M?u(...M):u()}catch(E){xu(E,m,b)}}function Un(u,m,b,M){if(It(u)){const E=ya(u,m,b,M);return E&&af(E)&&E.catch(D=>{xu(D,m,b)}),E}if(Mt(u)){const E=[];for(let D=0;D<u.length;D++)E.push(Un(u[D],m,b,M));return E}}function xu(u,m,b,M=!0){const E=m?m.vnode:null,{errorHandler:D,throwUnhandledErrorInProduction:T}=m&&m.appContext.config||ai;if(m){let a=m.parent;const V=m.proxy,ue=`https://vuejs.org/error-reference/#runtime-${b}`;for(;a;){const oe=a.ec;if(oe){for(let ge=0;ge<oe.length;ge++)if(oe[ge](u,V,ue)===!1)return}a=a.parent}if(D){us(),ya(D,null,10,[u,V,ue]),hs();return}}Vy(u,b,E,M,T)}function Vy(u,m,b,M=!0,E=!1){if(E)throw u;console.error(u)}const Rr=[];let $n=-1;const va=[];let Gs=null,xa=0;const Uf=Promise.resolve();let bu=null;function $f(u){const m=bu||Uf;return u?m.then(this?u.bind(this):u):m}function Uy(u){let m=$n+1,b=Rr.length;for(;m<b;){const M=m+b>>>1,E=Rr[M],D=Ol(E);D<u||D===u&&E.flags&2?m=M+1:b=M}return m}function yd(u){if(!(u.flags&1)){const m=Ol(u),b=Rr[Rr.length-1];!b||!(u.flags&2)&&m>=Ol(b)?Rr.push(u):Rr.splice(Uy(m),0,u),u.flags|=1,Gf()}}function Gf(){bu||(bu=Uf.then(Hf))}function $y(u){Mt(u)?va.push(...u):Gs&&u.id===-1?Gs.splice(xa+1,0,u):u.flags&1||(va.push(u),u.flags|=1),Gf()}function Zf(u,m,b=$n+1){for(;b<Rr.length;b++){const M=Rr[b];if(M&&M.flags&2){if(u&&M.id!==u.uid)continue;Rr.splice(b,1),b--,M.flags&4&&(M.flags&=-2),M(),M.flags&4||(M.flags&=-2)}}}function qf(u){if(va.length){const m=[...new Set(va)].sort((b,M)=>Ol(b)-Ol(M));if(va.length=0,Gs){Gs.push(...m);return}for(Gs=m,xa=0;xa<Gs.length;xa++){const b=Gs[xa];b.flags&4&&(b.flags&=-2),b.flags&8||b(),b.flags&=-2}Gs=null,xa=0}}const Ol=u=>u.id==null?u.flags&2?-1:1/0:u.id;function Hf(u){try{for($n=0;$n<Rr.length;$n++){const m=Rr[$n];m&&!(m.flags&8)&&(m.flags&4&&(m.flags&=-2),ya(m,m.i,m.i?15:14),m.flags&4||(m.flags&=-2))}}finally{for(;$n<Rr.length;$n++){const m=Rr[$n];m&&(m.flags&=-2)}$n=-1,Rr.length=0,qf(),bu=null,(Rr.length||va.length)&&Hf()}}let ar=null,Wf=null;function wu(u){const m=ar;return ar=u,Wf=u&&u.type.__scopeId||null,m}function jl(u,m=ar,b){if(!m||u._n)return u;const M=(...E)=>{M._d&&Cm(-1);const D=wu(m);let T;try{T=u(...E)}finally{wu(D),M._d&&Cm(1)}return T};return M._n=!0,M._c=!0,M._d=!0,M}function Ao(u,m){if(ar===null)return u;const b=Au(ar),M=u.dirs||(u.dirs=[]);for(let E=0;E<m.length;E++){let[D,T,a,V=ai]=m[E];D&&(It(D)&&(D={mounted:D,updated:D}),D.deep&&ms(T),M.push({dir:D,instance:b,value:T,oldValue:void 0,arg:a,modifiers:V}))}return u}function ko(u,m,b,M){const E=u.dirs,D=m&&m.dirs;for(let T=0;T<E.length;T++){const a=E[T];D&&(a.oldValue=D[T].value);let V=a.dir[M];V&&(us(),Un(V,b,8,[u.el,a,u,m]),hs())}}const Gy=Symbol("_vte"),Zy=u=>u.__isTeleport;function vd(u,m){u.shapeFlag&6&&u.component?(u.transition=m,vd(u.component.subTree,m)):u.shapeFlag&128?(u.ssContent.transition=m.clone(u.ssContent),u.ssFallback.transition=m.clone(u.ssFallback)):u.transition=m}function Xf(u){u.ids=[u.ids[0]+u.ids[2]+++"-",0,0]}function Kf(u){const m=$v(),b=Kr(null);if(m){const E=m.refs===ai?m.refs={}:m.refs;Object.defineProperty(E,u,{enumerable:!0,get:()=>b.value,set:D=>b.value=D})}return b}function Tu(u,m,b,M,E=!1){if(Mt(u)){u.forEach((He,Qe)=>Tu(He,m&&(Mt(m)?m[Qe]:m),b,M,E));return}if(ba(M)&&!E){M.shapeFlag&512&&M.type.__asyncResolved&&M.component.subTree.component&&Tu(u,m,b,M.component.subTree);return}const D=M.shapeFlag&4?Au(M.component):M.el,T=E?null:D,{i:a,r:V}=u,ue=m&&m.r,oe=a.refs===ai?a.refs={}:a.refs,ge=a.setupState,Se=Ht(ge),Q=ge===ai?()=>!1:He=>ii(Se,He);if(ue!=null&&ue!==V&&(Bi(ue)?(oe[ue]=null,Q(ue)&&(ge[ue]=null)):bi(ue)&&(ue.value=null)),It(V))ya(V,a,12,[T,oe]);else{const He=Bi(V),Qe=bi(V);if(He||Qe){const Je=()=>{if(u.f){const Ye=He?Q(V)?ge[V]:oe[V]:V.value;E?Mt(Ye)&&Qh(Ye,D):Mt(Ye)?Ye.includes(D)||Ye.push(D):He?(oe[V]=[D],Q(V)&&(ge[V]=oe[V])):(V.value=[D],u.k&&(oe[u.k]=V.value))}else He?(oe[V]=T,Q(V)&&(ge[V]=T)):Qe&&(V.value=T,u.k&&(oe[u.k]=T))};T?(Je.id=-1,Yr(Je,b)):Je()}}}uu().requestIdleCallback,uu().cancelIdleCallback;const ba=u=>!!u.type.__asyncLoader,Yf=u=>u.type.__isKeepAlive;function qy(u,m){Jf(u,"a",m)}function Hy(u,m){Jf(u,"da",m)}function Jf(u,m,b=fr){const M=u.__wdc||(u.__wdc=()=>{let E=b;for(;E;){if(E.isDeactivated)return;E=E.parent}return u()});if(Su(m,M,b),b){let E=b.parent;for(;E&&E.parent;)Yf(E.parent.vnode)&&Wy(M,m,b,E),E=E.parent}}function Wy(u,m,b,M){const E=Su(m,u,M,!0);Qf(()=>{Qh(M[m],E)},b)}function Su(u,m,b=fr,M=!1){if(b){const E=b[u]||(b[u]=[]),D=m.__weh||(m.__weh=(...T)=>{us();const a=ql(b),V=Un(m,b,u,T);return a(),hs(),V});return M?E.unshift(D):E.push(D),D}}const gs=u=>(m,b=fr)=>{(!Hl||u==="sp")&&Su(u,(...M)=>m(...M),b)},Xy=gs("bm"),xd=gs("m"),Ky=gs("bu"),Yy=gs("u"),Jy=gs("bum"),Qf=gs("um"),Qy=gs("sp"),ev=gs("rtg"),tv=gs("rtc");function iv(u,m=fr){Su("ec",u,m)}const rv=Symbol.for("v-ndc");function wa(u,m,b,M){let E;const D=b,T=Mt(u);if(T||Bi(u)){const a=T&&fs(u);let V=!1;a&&(V=!yn(u),u=du(u)),E=new Array(u.length);for(let ue=0,oe=u.length;ue<oe;ue++)E[ue]=m(V?Tr(u[ue]):u[ue],ue,void 0,D)}else if(typeof u=="number"){E=new Array(u);for(let a=0;a<u;a++)E[a]=m(a+1,a,void 0,D)}else if(xi(u))if(u[Symbol.iterator])E=Array.from(u,(a,V)=>m(a,V,void 0,D));else{const a=Object.keys(u);E=new Array(a.length);for(let V=0,ue=a.length;V<ue;V++){const oe=a[V];E[V]=m(u[oe],oe,V,D)}}else E=[];return E}function nv(u,m,b={},M,E){if(ar.ce||ar.parent&&ba(ar.parent)&&ar.parent.ce)return jt(),vn(er,null,[Pi("slot",b,M)],64);let D=u[m];D&&D._c&&(D._d=!1),jt();const T=D&&em(D(b)),a=b.key||T&&T.key,V=vn(er,{key:(a&&!cs(a)?a:`_${m}`)+""},T||[],T&&u._===1?64:-2);return V.scopeId&&(V.slotScopeIds=[V.scopeId+"-s"]),D&&D._c&&(D._d=!0),V}function em(u){return u.some(m=>Ed(m)?!(m.type===Zs||m.type===er&&!em(m.children)):!0)?u:null}const bd=u=>u?km(u)?Au(u):bd(u.parent):null,Nl=kr(Object.create(null),{$:u=>u,$el:u=>u.vnode.el,$data:u=>u.data,$props:u=>u.props,$attrs:u=>u.attrs,$slots:u=>u.slots,$refs:u=>u.refs,$parent:u=>bd(u.parent),$root:u=>bd(u.root),$host:u=>u.ce,$emit:u=>u.emit,$options:u=>nm(u),$forceUpdate:u=>u.f||(u.f=()=>{yd(u.update)}),$nextTick:u=>u.n||(u.n=$f.bind(u.proxy)),$watch:u=>Cv.bind(u)}),wd=(u,m)=>u!==ai&&!u.__isScriptSetup&&ii(u,m),sv={get({_:u},m){if(m==="__v_skip")return!0;const{ctx:b,setupState:M,data:E,props:D,accessCache:T,type:a,appContext:V}=u;let ue;if(m[0]!=="$"){const Q=T[m];if(Q!==void 0)switch(Q){case 1:return M[m];case 2:return E[m];case 4:return b[m];case 3:return D[m]}else{if(wd(M,m))return T[m]=1,M[m];if(E!==ai&&ii(E,m))return T[m]=2,E[m];if((ue=u.propsOptions[0])&&ii(ue,m))return T[m]=3,D[m];if(b!==ai&&ii(b,m))return T[m]=4,b[m];Td&&(T[m]=0)}}const oe=Nl[m];let ge,Se;if(oe)return m==="$attrs"&&wr(u.attrs,"get",""),oe(u);if((ge=a.__cssModules)&&(ge=ge[m]))return ge;if(b!==ai&&ii(b,m))return T[m]=4,b[m];if(Se=V.config.globalProperties,ii(Se,m))return Se[m]},set({_:u},m,b){const{data:M,setupState:E,ctx:D}=u;return wd(E,m)?(E[m]=b,!0):M!==ai&&ii(M,m)?(M[m]=b,!0):ii(u.props,m)||m[0]==="$"&&m.slice(1)in u?!1:(D[m]=b,!0)},has({_:{data:u,setupState:m,accessCache:b,ctx:M,appContext:E,propsOptions:D}},T){let a;return!!b[T]||u!==ai&&ii(u,T)||wd(m,T)||(a=D[0])&&ii(a,T)||ii(M,T)||ii(Nl,T)||ii(E.config.globalProperties,T)},defineProperty(u,m,b){return b.get!=null?u._.accessCache[m]=0:ii(b,"value")&&this.set(u,m,b.value,null),Reflect.defineProperty(u,m,b)}};function tm(u){return Mt(u)?u.reduce((m,b)=>(m[b]=null,m),{}):u}let Td=!0;function ov(u){const m=nm(u),b=u.proxy,M=u.ctx;Td=!1,m.beforeCreate&&im(m.beforeCreate,u,"bc");const{data:E,computed:D,methods:T,watch:a,provide:V,inject:ue,created:oe,beforeMount:ge,mounted:Se,beforeUpdate:Q,updated:He,activated:Qe,deactivated:Je,beforeDestroy:Ye,beforeUnmount:ct,destroyed:st,unmounted:We,render:yt,renderTracked:Oi,renderTriggered:mi,errorCaptured:Ft,serverPrefetch:Nt,expose:Xt,inheritAttrs:Mi,components:Ci,directives:tr,filters:en}=m;if(ue&&av(ue,M,null),T)for(const St in T){const Kt=T[St];It(Kt)&&(M[St]=Kt.bind(b))}if(E){const St=E.call(b,b);xi(St)&&(u.data=gu(St))}if(Td=!0,D)for(const St in D){const Kt=D[St],Vt=It(Kt)?Kt.bind(b,b):It(Kt.get)?Kt.get.bind(b,b):Nn,Gr=!It(Kt)&&It(Kt.set)?Kt.set.bind(b):Nn,di=Sr({get:Vt,set:Gr});Object.defineProperty(M,St,{enumerable:!0,configurable:!0,get:()=>di.value,set:Zi=>di.value=Zi})}if(a)for(const St in a)rm(a[St],M,b,St);if(V){const St=It(V)?V.call(b):V;Reflect.ownKeys(St).forEach(Kt=>{pv(Kt,St[Kt])})}oe&&im(oe,u,"c");function Jt(St,Kt){Mt(Kt)?Kt.forEach(Vt=>St(Vt.bind(b))):Kt&&St(Kt.bind(b))}if(Jt(Xy,ge),Jt(xd,Se),Jt(Ky,Q),Jt(Yy,He),Jt(qy,Qe),Jt(Hy,Je),Jt(iv,Ft),Jt(tv,Oi),Jt(ev,mi),Jt(Jy,ct),Jt(Qf,We),Jt(Qy,Nt),Mt(Xt))if(Xt.length){const St=u.exposed||(u.exposed={});Xt.forEach(Kt=>{Object.defineProperty(St,Kt,{get:()=>b[Kt],set:Vt=>b[Kt]=Vt})})}else u.exposed||(u.exposed={});yt&&u.render===Nn&&(u.render=yt),Mi!=null&&(u.inheritAttrs=Mi),Ci&&(u.components=Ci),tr&&(u.directives=tr),Nt&&Xf(u)}function av(u,m,b=Nn){Mt(u)&&(u=Sd(u));for(const M in u){const E=u[M];let D;xi(E)?"default"in E?D=Ul(E.from||M,E.default,!0):D=Ul(E.from||M):D=Ul(E),bi(D)?Object.defineProperty(m,M,{enumerable:!0,configurable:!0,get:()=>D.value,set:T=>D.value=T}):m[M]=D}}function im(u,m,b){Un(Mt(u)?u.map(M=>M.bind(m.proxy)):u.bind(m.proxy),m,b)}function rm(u,m,b,M){let E=M.includes(".")?wm(b,M):()=>b[M];if(Bi(u)){const D=m[u];It(D)&&Ta(E,D)}else if(It(u))Ta(E,u.bind(b));else if(xi(u))if(Mt(u))u.forEach(D=>rm(D,m,b,M));else{const D=It(u.handler)?u.handler.bind(b):m[u.handler];It(D)&&Ta(E,D,u)}}function nm(u){const m=u.type,{mixins:b,extends:M}=m,{mixins:E,optionsCache:D,config:{optionMergeStrategies:T}}=u.appContext,a=D.get(m);let V;return a?V=a:!E.length&&!b&&!M?V=m:(V={},E.length&&E.forEach(ue=>Pu(V,ue,T,!0)),Pu(V,m,T)),xi(m)&&D.set(m,V),V}function Pu(u,m,b,M=!1){const{mixins:E,extends:D}=m;D&&Pu(u,D,b,!0),E&&E.forEach(T=>Pu(u,T,b,!0));for(const T in m)if(!(M&&T==="expose")){const a=lv[T]||b&&b[T];u[T]=a?a(u[T],m[T]):m[T]}return u}const lv={data:sm,props:om,emits:om,methods:Vl,computed:Vl,beforeCreate:Dr,created:Dr,beforeMount:Dr,mounted:Dr,beforeUpdate:Dr,updated:Dr,beforeDestroy:Dr,beforeUnmount:Dr,destroyed:Dr,unmounted:Dr,activated:Dr,deactivated:Dr,errorCaptured:Dr,serverPrefetch:Dr,components:Vl,directives:Vl,watch:uv,provide:sm,inject:cv};function sm(u,m){return m?u?function(){return kr(It(u)?u.call(this,this):u,It(m)?m.call(this,this):m)}:m:u}function cv(u,m){return Vl(Sd(u),Sd(m))}function Sd(u){if(Mt(u)){const m={};for(let b=0;b<u.length;b++)m[u[b]]=u[b];return m}return u}function Dr(u,m){return u?[...new Set([].concat(u,m))]:m}function Vl(u,m){return u?kr(Object.create(null),u,m):m}function om(u,m){return u?Mt(u)&&Mt(m)?[...new Set([...u,...m])]:kr(Object.create(null),tm(u),tm(m??{})):m}function uv(u,m){if(!u)return m;if(!m)return u;const b=kr(Object.create(null),u);for(const M in m)b[M]=Dr(u[M],m[M]);return b}function am(){return{app:null,config:{isNativeTag:K_,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let hv=0;function dv(u,m){return function(M,E=null){It(M)||(M=kr({},M)),E!=null&&!xi(E)&&(E=null);const D=am(),T=new WeakSet,a=[];let V=!1;const ue=D.app={_uid:hv++,_component:M,_props:E,_container:null,_context:D,_instance:null,version:Jv,get config(){return D.config},set config(oe){},use(oe,...ge){return T.has(oe)||(oe&&It(oe.install)?(T.add(oe),oe.install(ue,...ge)):It(oe)&&(T.add(oe),oe(ue,...ge))),ue},mixin(oe){return D.mixins.includes(oe)||D.mixins.push(oe),ue},component(oe,ge){return ge?(D.components[oe]=ge,ue):D.components[oe]},directive(oe,ge){return ge?(D.directives[oe]=ge,ue):D.directives[oe]},mount(oe,ge,Se){if(!V){const Q=ue._ceVNode||Pi(M,E);return Q.appContext=D,Se===!0?Se="svg":Se===!1&&(Se=void 0),u(Q,oe,Se),V=!0,ue._container=oe,oe.__vue_app__=ue,Au(Q.component)}},onUnmount(oe){a.push(oe)},unmount(){V&&(Un(a,ue._instance,16),u(null,ue._container),delete ue._container.__vue_app__)},provide(oe,ge){return D.provides[oe]=ge,ue},runWithContext(oe){const ge=zo;zo=ue;try{return oe()}finally{zo=ge}}};return ue}}let zo=null;function pv(u,m){if(fr){let b=fr.provides;const M=fr.parent&&fr.parent.provides;M===b&&(b=fr.provides=Object.create(M)),b[u]=m}}function Ul(u,m,b=!1){const M=fr||ar;if(M||zo){const E=zo?zo._context.provides:M?M.parent==null?M.vnode.appContext&&M.vnode.appContext.provides:M.parent.provides:void 0;if(E&&u in E)return E[u];if(arguments.length>1)return b&&It(m)?m.call(M&&M.proxy):m}}function fv(){return!!(fr||ar||zo)}const lm={},cm=()=>Object.create(lm),um=u=>Object.getPrototypeOf(u)===lm;function mv(u,m,b,M=!1){const E={},D=cm();u.propsDefaults=Object.create(null),hm(u,m,E,D);for(const T in u.propsOptions[0])T in E||(E[T]=void 0);b?u.props=M?E:My(E):u.type.props?u.props=E:u.props=D,u.attrs=D}function gv(u,m,b,M){const{props:E,attrs:D,vnode:{patchFlag:T}}=u,a=Ht(E),[V]=u.propsOptions;let ue=!1;if((M||T>0)&&!(T&16)){if(T&8){const oe=u.vnode.dynamicProps;for(let ge=0;ge<oe.length;ge++){let Se=oe[ge];if(Mu(u.emitsOptions,Se))continue;const Q=m[Se];if(V)if(ii(D,Se))Q!==D[Se]&&(D[Se]=Q,ue=!0);else{const He=Vs(Se);E[He]=Pd(V,a,He,Q,u,!1)}else Q!==D[Se]&&(D[Se]=Q,ue=!0)}}}else{hm(u,m,E,D)&&(ue=!0);let oe;for(const ge in a)(!m||!ii(m,ge)&&((oe=So(ge))===ge||!ii(m,oe)))&&(V?b&&(b[ge]!==void 0||b[oe]!==void 0)&&(E[ge]=Pd(V,a,ge,void 0,u,!0)):delete E[ge]);if(D!==a)for(const ge in D)(!m||!ii(m,ge))&&(delete D[ge],ue=!0)}ue&&ds(u.attrs,"set","")}function hm(u,m,b,M){const[E,D]=u.propsOptions;let T=!1,a;if(m)for(let V in m){if(kl(V))continue;const ue=m[V];let oe;E&&ii(E,oe=Vs(V))?!D||!D.includes(oe)?b[oe]=ue:(a||(a={}))[oe]=ue:Mu(u.emitsOptions,V)||(!(V in M)||ue!==M[V])&&(M[V]=ue,T=!0)}if(D){const V=Ht(b),ue=a||ai;for(let oe=0;oe<D.length;oe++){const ge=D[oe];b[ge]=Pd(E,V,ge,ue[ge],u,!ii(ue,ge))}}return T}function Pd(u,m,b,M,E,D){const T=u[b];if(T!=null){const a=ii(T,"default");if(a&&M===void 0){const V=T.default;if(T.type!==Function&&!T.skipFactory&&It(V)){const{propsDefaults:ue}=E;if(b in ue)M=ue[b];else{const oe=ql(E);M=ue[b]=V.call(null,m),oe()}}else M=V;E.ce&&E.ce._setProp(b,M)}T[0]&&(D&&!a?M=!1:T[1]&&(M===""||M===So(b))&&(M=!0))}return M}const _v=new WeakMap;function dm(u,m,b=!1){const M=b?_v:m.propsCache,E=M.get(u);if(E)return E;const D=u.props,T={},a=[];let V=!1;if(!It(u)){const oe=ge=>{V=!0;const[Se,Q]=dm(ge,m,!0);kr(T,Se),Q&&a.push(...Q)};!b&&m.mixins.length&&m.mixins.forEach(oe),u.extends&&oe(u.extends),u.mixins&&u.mixins.forEach(oe)}if(!D&&!V)return xi(u)&&M.set(u,ma),ma;if(Mt(D))for(let oe=0;oe<D.length;oe++){const ge=Vs(D[oe]);pm(ge)&&(T[ge]=ai)}else if(D)for(const oe in D){const ge=Vs(oe);if(pm(ge)){const Se=D[oe],Q=T[ge]=Mt(Se)||It(Se)?{type:Se}:kr({},Se),He=Q.type;let Qe=!1,Je=!0;if(Mt(He))for(let Ye=0;Ye<He.length;++Ye){const ct=He[Ye],st=It(ct)&&ct.name;if(st==="Boolean"){Qe=!0;break}else st==="String"&&(Je=!1)}else Qe=It(He)&&He.name==="Boolean";Q[0]=Qe,Q[1]=Je,(Qe||ii(Q,"default"))&&a.push(ge)}}const ue=[T,a];return xi(u)&&M.set(u,ue),ue}function pm(u){return u[0]!=="$"&&!kl(u)}const fm=u=>u[0]==="_"||u==="$stable",Md=u=>Mt(u)?u.map(Gn):[Gn(u)],yv=(u,m,b)=>{if(m._n)return m;const M=jl((...E)=>Md(m(...E)),b);return M._c=!1,M},mm=(u,m,b)=>{const M=u._ctx;for(const E in u){if(fm(E))continue;const D=u[E];if(It(D))m[E]=yv(E,D,M);else if(D!=null){const T=Md(D);m[E]=()=>T}}},gm=(u,m)=>{const b=Md(m);u.slots.default=()=>b},_m=(u,m,b)=>{for(const M in m)(b||M!=="_")&&(u[M]=m[M])},vv=(u,m,b)=>{const M=u.slots=cm();if(u.vnode.shapeFlag&32){const E=m._;E?(_m(M,m,b),b&&hf(M,"_",E,!0)):mm(m,M)}else m&&gm(u,m)},xv=(u,m,b)=>{const{vnode:M,slots:E}=u;let D=!0,T=ai;if(M.shapeFlag&32){const a=m._;a?b&&a===1?D=!1:_m(E,m,b):(D=!m.$stable,mm(m,E)),T=m}else m&&(gm(u,m),T={default:1});if(D)for(const a in E)!fm(a)&&T[a]==null&&delete E[a]},Yr=Dv;function bv(u){return wv(u)}function wv(u,m){const b=uu();b.__VUE__=!0;const{insert:M,remove:E,patchProp:D,createElement:T,createText:a,createComment:V,setText:ue,setElementText:oe,parentNode:ge,nextSibling:Se,setScopeId:Q=Nn,insertStaticContent:He}=u,Qe=(ne,le,Te,ze=null,Ae=null,Re=null,qe=void 0,$e=null,Ge=!!le.dynamicChildren)=>{if(ne===le)return;ne&&!Zl(ne,le)&&(ze=tn(ne),Zi(ne,Ae,Re,!0),ne=null),le.patchFlag===-2&&(Ge=!1,le.dynamicChildren=null);const{type:De,ref:ut,shapeFlag:Ke}=le;switch(De){case Cu:Je(ne,le,Te,ze);break;case Zs:Ye(ne,le,Te,ze);break;case Id:ne==null&&ct(le,Te,ze,qe);break;case er:Ci(ne,le,Te,ze,Ae,Re,qe,$e,Ge);break;default:Ke&1?yt(ne,le,Te,ze,Ae,Re,qe,$e,Ge):Ke&6?tr(ne,le,Te,ze,Ae,Re,qe,$e,Ge):(Ke&64||Ke&128)&&De.process(ne,le,Te,ze,Ae,Re,qe,$e,Ge,Zr)}ut!=null&&Ae&&Tu(ut,ne&&ne.ref,Re,le||ne,!le)},Je=(ne,le,Te,ze)=>{if(ne==null)M(le.el=a(le.children),Te,ze);else{const Ae=le.el=ne.el;le.children!==ne.children&&ue(Ae,le.children)}},Ye=(ne,le,Te,ze)=>{ne==null?M(le.el=V(le.children||""),Te,ze):le.el=ne.el},ct=(ne,le,Te,ze)=>{[ne.el,ne.anchor]=He(ne.children,le,Te,ze,ne.el,ne.anchor)},st=({el:ne,anchor:le},Te,ze)=>{let Ae;for(;ne&&ne!==le;)Ae=Se(ne),M(ne,Te,ze),ne=Ae;M(le,Te,ze)},We=({el:ne,anchor:le})=>{let Te;for(;ne&&ne!==le;)Te=Se(ne),E(ne),ne=Te;E(le)},yt=(ne,le,Te,ze,Ae,Re,qe,$e,Ge)=>{le.type==="svg"?qe="svg":le.type==="math"&&(qe="mathml"),ne==null?Oi(le,Te,ze,Ae,Re,qe,$e,Ge):Nt(ne,le,Ae,Re,qe,$e,Ge)},Oi=(ne,le,Te,ze,Ae,Re,qe,$e)=>{let Ge,De;const{props:ut,shapeFlag:Ke,transition:lt,dirs:mt}=ne;if(Ge=ne.el=T(ne.type,Re,ut&&ut.is,ut),Ke&8?oe(Ge,ne.children):Ke&16&&Ft(ne.children,Ge,null,ze,Ae,Cd(ne,Re),qe,$e),mt&&ko(ne,null,ze,"created"),mi(Ge,ne,ne.scopeId,qe,ze),ut){for(const Zt in ut)Zt!=="value"&&!kl(Zt)&&D(Ge,Zt,null,ut[Zt],Re,ze);"value"in ut&&D(Ge,"value",null,ut.value,Re),(De=ut.onVnodeBeforeMount)&&Zn(De,ze,ne)}mt&&ko(ne,null,ze,"beforeMount");const Ct=Tv(Ae,lt);Ct&&lt.beforeEnter(Ge),M(Ge,le,Te),((De=ut&&ut.onVnodeMounted)||Ct||mt)&&Yr(()=>{De&&Zn(De,ze,ne),Ct&&lt.enter(Ge),mt&&ko(ne,null,ze,"mounted")},Ae)},mi=(ne,le,Te,ze,Ae)=>{if(Te&&Q(ne,Te),ze)for(let Re=0;Re<ze.length;Re++)Q(ne,ze[Re]);if(Ae){let Re=Ae.subTree;if(le===Re||Mm(Re.type)&&(Re.ssContent===le||Re.ssFallback===le)){const qe=Ae.vnode;mi(ne,qe,qe.scopeId,qe.slotScopeIds,Ae.parent)}}},Ft=(ne,le,Te,ze,Ae,Re,qe,$e,Ge=0)=>{for(let De=Ge;De<ne.length;De++){const ut=ne[De]=$e?qs(ne[De]):Gn(ne[De]);Qe(null,ut,le,Te,ze,Ae,Re,qe,$e)}},Nt=(ne,le,Te,ze,Ae,Re,qe)=>{const $e=le.el=ne.el;let{patchFlag:Ge,dynamicChildren:De,dirs:ut}=le;Ge|=ne.patchFlag&16;const Ke=ne.props||ai,lt=le.props||ai;let mt;if(Te&&Ro(Te,!1),(mt=lt.onVnodeBeforeUpdate)&&Zn(mt,Te,le,ne),ut&&ko(le,ne,Te,"beforeUpdate"),Te&&Ro(Te,!0),(Ke.innerHTML&&lt.innerHTML==null||Ke.textContent&&lt.textContent==null)&&oe($e,""),De?Xt(ne.dynamicChildren,De,$e,Te,ze,Cd(le,Ae),Re):qe||Kt(ne,le,$e,null,Te,ze,Cd(le,Ae),Re,!1),Ge>0){if(Ge&16)Mi($e,Ke,lt,Te,Ae);else if(Ge&2&&Ke.class!==lt.class&&D($e,"class",null,lt.class,Ae),Ge&4&&D($e,"style",Ke.style,lt.style,Ae),Ge&8){const Ct=le.dynamicProps;for(let Zt=0;Zt<Ct.length;Zt++){const Gt=Ct[Zt],ae=Ke[Gt],B=lt[Gt];(B!==ae||Gt==="value")&&D($e,Gt,ae,B,Ae,Te)}}Ge&1&&ne.children!==le.children&&oe($e,le.children)}else!qe&&De==null&&Mi($e,Ke,lt,Te,Ae);((mt=lt.onVnodeUpdated)||ut)&&Yr(()=>{mt&&Zn(mt,Te,le,ne),ut&&ko(le,ne,Te,"updated")},ze)},Xt=(ne,le,Te,ze,Ae,Re,qe)=>{for(let $e=0;$e<le.length;$e++){const Ge=ne[$e],De=le[$e],ut=Ge.el&&(Ge.type===er||!Zl(Ge,De)||Ge.shapeFlag&70)?ge(Ge.el):Te;Qe(Ge,De,ut,null,ze,Ae,Re,qe,!0)}},Mi=(ne,le,Te,ze,Ae)=>{if(le!==Te){if(le!==ai)for(const Re in le)!kl(Re)&&!(Re in Te)&&D(ne,Re,le[Re],null,Ae,ze);for(const Re in Te){if(kl(Re))continue;const qe=Te[Re],$e=le[Re];qe!==$e&&Re!=="value"&&D(ne,Re,$e,qe,Ae,ze)}"value"in Te&&D(ne,"value",le.value,Te.value,Ae)}},Ci=(ne,le,Te,ze,Ae,Re,qe,$e,Ge)=>{const De=le.el=ne?ne.el:a(""),ut=le.anchor=ne?ne.anchor:a("");let{patchFlag:Ke,dynamicChildren:lt,slotScopeIds:mt}=le;mt&&($e=$e?$e.concat(mt):mt),ne==null?(M(De,Te,ze),M(ut,Te,ze),Ft(le.children||[],Te,ut,Ae,Re,qe,$e,Ge)):Ke>0&&Ke&64&&lt&&ne.dynamicChildren?(Xt(ne.dynamicChildren,lt,Te,Ae,Re,qe,$e),(le.key!=null||Ae&&le===Ae.subTree)&&ym(ne,le,!0)):Kt(ne,le,Te,ut,Ae,Re,qe,$e,Ge)},tr=(ne,le,Te,ze,Ae,Re,qe,$e,Ge)=>{le.slotScopeIds=$e,ne==null?le.shapeFlag&512?Ae.ctx.activate(le,Te,ze,qe,Ge):en(le,Te,ze,Ae,Re,qe,Ge):$r(ne,le,Ge)},en=(ne,le,Te,ze,Ae,Re,qe)=>{const $e=ne.component=Uv(ne,ze,Ae);if(Yf(ne)&&($e.ctx.renderer=Zr),Gv($e,!1,qe),$e.asyncDep){if(Ae&&Ae.registerDep($e,Jt,qe),!ne.el){const Ge=$e.subTree=Pi(Zs);Ye(null,Ge,le,Te)}}else Jt($e,ne,le,Te,Ae,Re,qe)},$r=(ne,le,Te)=>{const ze=le.component=ne.component;if(zv(ne,le,Te))if(ze.asyncDep&&!ze.asyncResolved){St(ze,le,Te);return}else ze.next=le,ze.update();else le.el=ne.el,ze.vnode=le},Jt=(ne,le,Te,ze,Ae,Re,qe)=>{const $e=()=>{if(ne.isMounted){let{next:Ke,bu:lt,u:mt,parent:Ct,vnode:Zt}=ne;{const U=vm(ne);if(U){Ke&&(Ke.el=Zt.el,St(ne,Ke,qe)),U.asyncDep.then(()=>{ne.isUnmounted||$e()});return}}let Gt=Ke,ae;Ro(ne,!1),Ke?(Ke.el=Zt.el,St(ne,Ke,qe)):Ke=Zt,lt&&cu(lt),(ae=Ke.props&&Ke.props.onVnodeBeforeUpdate)&&Zn(ae,Ct,Ke,Zt),Ro(ne,!0);const B=Sm(ne),j=ne.subTree;ne.subTree=B,Qe(j,B,ge(j.el),tn(j),ne,Ae,Re),Ke.el=B.el,Gt===null&&Rv(ne,B.el),mt&&Yr(mt,Ae),(ae=Ke.props&&Ke.props.onVnodeUpdated)&&Yr(()=>Zn(ae,Ct,Ke,Zt),Ae)}else{let Ke;const{el:lt,props:mt}=le,{bm:Ct,m:Zt,parent:Gt,root:ae,type:B}=ne,j=ba(le);Ro(ne,!1),Ct&&cu(Ct),!j&&(Ke=mt&&mt.onVnodeBeforeMount)&&Zn(Ke,Gt,le),Ro(ne,!0);{ae.ce&&ae.ce._injectChildStyle(B);const U=ne.subTree=Sm(ne);Qe(null,U,Te,ze,ne,Ae,Re),le.el=U.el}if(Zt&&Yr(Zt,Ae),!j&&(Ke=mt&&mt.onVnodeMounted)){const U=le;Yr(()=>Zn(Ke,Gt,U),Ae)}(le.shapeFlag&256||Gt&&ba(Gt.vnode)&&Gt.vnode.shapeFlag&256)&&ne.a&&Yr(ne.a,Ae),ne.isMounted=!0,le=Te=ze=null}};ne.scope.on();const Ge=ne.effect=new vf($e);ne.scope.off();const De=ne.update=Ge.run.bind(Ge),ut=ne.job=Ge.runIfDirty.bind(Ge);ut.i=ne,ut.id=ne.uid,Ge.scheduler=()=>yd(ut),Ro(ne,!0),De()},St=(ne,le,Te)=>{le.component=ne;const ze=ne.vnode.props;ne.vnode=le,ne.next=null,gv(ne,le.props,ze,Te),xv(ne,le.children,Te),us(),Zf(ne),hs()},Kt=(ne,le,Te,ze,Ae,Re,qe,$e,Ge=!1)=>{const De=ne&&ne.children,ut=ne?ne.shapeFlag:0,Ke=le.children,{patchFlag:lt,shapeFlag:mt}=le;if(lt>0){if(lt&128){Gr(De,Ke,Te,ze,Ae,Re,qe,$e,Ge);return}else if(lt&256){Vt(De,Ke,Te,ze,Ae,Re,qe,$e,Ge);return}}mt&8?(ut&16&&Ai(De,Ae,Re),Ke!==De&&oe(Te,Ke)):ut&16?mt&16?Gr(De,Ke,Te,ze,Ae,Re,qe,$e,Ge):Ai(De,Ae,Re,!0):(ut&8&&oe(Te,""),mt&16&&Ft(Ke,Te,ze,Ae,Re,qe,$e,Ge))},Vt=(ne,le,Te,ze,Ae,Re,qe,$e,Ge)=>{ne=ne||ma,le=le||ma;const De=ne.length,ut=le.length,Ke=Math.min(De,ut);let lt;for(lt=0;lt<Ke;lt++){const mt=le[lt]=Ge?qs(le[lt]):Gn(le[lt]);Qe(ne[lt],mt,Te,null,Ae,Re,qe,$e,Ge)}De>ut?Ai(ne,Ae,Re,!0,!1,Ke):Ft(le,Te,ze,Ae,Re,qe,$e,Ge,Ke)},Gr=(ne,le,Te,ze,Ae,Re,qe,$e,Ge)=>{let De=0;const ut=le.length;let Ke=ne.length-1,lt=ut-1;for(;De<=Ke&&De<=lt;){const mt=ne[De],Ct=le[De]=Ge?qs(le[De]):Gn(le[De]);if(Zl(mt,Ct))Qe(mt,Ct,Te,null,Ae,Re,qe,$e,Ge);else break;De++}for(;De<=Ke&&De<=lt;){const mt=ne[Ke],Ct=le[lt]=Ge?qs(le[lt]):Gn(le[lt]);if(Zl(mt,Ct))Qe(mt,Ct,Te,null,Ae,Re,qe,$e,Ge);else break;Ke--,lt--}if(De>Ke){if(De<=lt){const mt=lt+1,Ct=mt<ut?le[mt].el:ze;for(;De<=lt;)Qe(null,le[De]=Ge?qs(le[De]):Gn(le[De]),Te,Ct,Ae,Re,qe,$e,Ge),De++}}else if(De>lt)for(;De<=Ke;)Zi(ne[De],Ae,Re,!0),De++;else{const mt=De,Ct=De,Zt=new Map;for(De=Ct;De<=lt;De++){const ce=le[De]=Ge?qs(le[De]):Gn(le[De]);ce.key!=null&&Zt.set(ce.key,De)}let Gt,ae=0;const B=lt-Ct+1;let j=!1,U=0;const X=new Array(B);for(De=0;De<B;De++)X[De]=0;for(De=mt;De<=Ke;De++){const ce=ne[De];if(ae>=B){Zi(ce,Ae,Re,!0);continue}let me;if(ce.key!=null)me=Zt.get(ce.key);else for(Gt=Ct;Gt<=lt;Gt++)if(X[Gt-Ct]===0&&Zl(ce,le[Gt])){me=Gt;break}me===void 0?Zi(ce,Ae,Re,!0):(X[me-Ct]=De+1,me>=U?U=me:j=!0,Qe(ce,le[me],Te,null,Ae,Re,qe,$e,Ge),ae++)}const ie=j?Sv(X):ma;for(Gt=ie.length-1,De=B-1;De>=0;De--){const ce=Ct+De,me=le[ce],de=ce+1<ut?le[ce+1].el:ze;X[De]===0?Qe(null,me,Te,de,Ae,Re,qe,$e,Ge):j&&(Gt<0||De!==ie[Gt]?di(me,Te,de,2):Gt--)}}},di=(ne,le,Te,ze,Ae=null)=>{const{el:Re,type:qe,transition:$e,children:Ge,shapeFlag:De}=ne;if(De&6){di(ne.component.subTree,le,Te,ze);return}if(De&128){ne.suspense.move(le,Te,ze);return}if(De&64){qe.move(ne,le,Te,Zr);return}if(qe===er){M(Re,le,Te);for(let Ke=0;Ke<Ge.length;Ke++)di(Ge[Ke],le,Te,ze);M(ne.anchor,le,Te);return}if(qe===Id){st(ne,le,Te);return}if(ze!==2&&De&1&&$e)if(ze===0)$e.beforeEnter(Re),M(Re,le,Te),Yr(()=>$e.enter(Re),Ae);else{const{leave:Ke,delayLeave:lt,afterLeave:mt}=$e,Ct=()=>M(Re,le,Te),Zt=()=>{Ke(Re,()=>{Ct(),mt&&mt()})};lt?lt(Re,Ct,Zt):Zt()}else M(Re,le,Te)},Zi=(ne,le,Te,ze=!1,Ae=!1)=>{const{type:Re,props:qe,ref:$e,children:Ge,dynamicChildren:De,shapeFlag:ut,patchFlag:Ke,dirs:lt,cacheIndex:mt}=ne;if(Ke===-2&&(Ae=!1),$e!=null&&Tu($e,null,Te,ne,!0),mt!=null&&(le.renderCache[mt]=void 0),ut&256){le.ctx.deactivate(ne);return}const Ct=ut&1&&lt,Zt=!ba(ne);let Gt;if(Zt&&(Gt=qe&&qe.onVnodeBeforeUnmount)&&Zn(Gt,le,ne),ut&6)En(ne.component,Te,ze);else{if(ut&128){ne.suspense.unmount(Te,ze);return}Ct&&ko(ne,null,le,"beforeUnmount"),ut&64?ne.type.remove(ne,le,Te,Zr,ze):De&&!De.hasOnce&&(Re!==er||Ke>0&&Ke&64)?Ai(De,le,Te,!1,!0):(Re===er&&Ke&384||!Ae&&ut&16)&&Ai(Ge,le,Te),ze&&Lr(ne)}(Zt&&(Gt=qe&&qe.onVnodeUnmounted)||Ct)&&Yr(()=>{Gt&&Zn(Gt,le,ne),Ct&&ko(ne,null,le,"unmounted")},Te)},Lr=ne=>{const{type:le,el:Te,anchor:ze,transition:Ae}=ne;if(le===er){xn(Te,ze);return}if(le===Id){We(ne);return}const Re=()=>{E(Te),Ae&&!Ae.persisted&&Ae.afterLeave&&Ae.afterLeave()};if(ne.shapeFlag&1&&Ae&&!Ae.persisted){const{leave:qe,delayLeave:$e}=Ae,Ge=()=>qe(Te,Re);$e?$e(ne.el,Re,Ge):Ge()}else Re()},xn=(ne,le)=>{let Te;for(;ne!==le;)Te=Se(ne),E(ne),ne=Te;E(le)},En=(ne,le,Te)=>{const{bum:ze,scope:Ae,job:Re,subTree:qe,um:$e,m:Ge,a:De}=ne;xm(Ge),xm(De),ze&&cu(ze),Ae.stop(),Re&&(Re.flags|=8,Zi(qe,ne,le,Te)),$e&&Yr($e,le),Yr(()=>{ne.isUnmounted=!0},le),le&&le.pendingBranch&&!le.isUnmounted&&ne.asyncDep&&!ne.asyncResolved&&ne.suspenseId===le.pendingId&&(le.deps--,le.deps===0&&le.resolve())},Ai=(ne,le,Te,ze=!1,Ae=!1,Re=0)=>{for(let qe=Re;qe<ne.length;qe++)Zi(ne[qe],le,Te,ze,Ae)},tn=ne=>{if(ne.shapeFlag&6)return tn(ne.component.subTree);if(ne.shapeFlag&128)return ne.suspense.next();const le=Se(ne.anchor||ne.el),Te=le&&le[Gy];return Te?Se(Te):le};let lr=!1;const Pr=(ne,le,Te)=>{ne==null?le._vnode&&Zi(le._vnode,null,null,!0):Qe(le._vnode||null,ne,le,null,null,null,Te),le._vnode=ne,lr||(lr=!0,Zf(),qf(),lr=!1)},Zr={p:Qe,um:Zi,m:di,r:Lr,mt:en,mc:Ft,pc:Kt,pbc:Xt,n:tn,o:u};return{render:Pr,hydrate:void 0,createApp:dv(Pr)}}function Cd({type:u,props:m},b){return b==="svg"&&u==="foreignObject"||b==="mathml"&&u==="annotation-xml"&&m&&m.encoding&&m.encoding.includes("html")?void 0:b}function Ro({effect:u,job:m},b){b?(u.flags|=32,m.flags|=4):(u.flags&=-33,m.flags&=-5)}function Tv(u,m){return(!u||u&&!u.pendingBranch)&&m&&!m.persisted}function ym(u,m,b=!1){const M=u.children,E=m.children;if(Mt(M)&&Mt(E))for(let D=0;D<M.length;D++){const T=M[D];let a=E[D];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=E[D]=qs(E[D]),a.el=T.el),!b&&a.patchFlag!==-2&&ym(T,a)),a.type===Cu&&(a.el=T.el)}}function Sv(u){const m=u.slice(),b=[0];let M,E,D,T,a;const V=u.length;for(M=0;M<V;M++){const ue=u[M];if(ue!==0){if(E=b[b.length-1],u[E]<ue){m[M]=E,b.push(M);continue}for(D=0,T=b.length-1;D<T;)a=D+T>>1,u[b[a]]<ue?D=a+1:T=a;ue<u[b[D]]&&(D>0&&(m[M]=b[D-1]),b[D]=M)}}for(D=b.length,T=b[D-1];D-- >0;)b[D]=T,T=m[T];return b}function vm(u){const m=u.subTree.component;if(m)return m.asyncDep&&!m.asyncResolved?m:vm(m)}function xm(u){if(u)for(let m=0;m<u.length;m++)u[m].flags|=8}const Pv=Symbol.for("v-scx"),Mv=()=>Ul(Pv);function Ta(u,m,b){return bm(u,m,b)}function bm(u,m,b=ai){const{immediate:M,deep:E,flush:D,once:T}=b,a=kr({},b),V=m&&M||!m&&D!=="post";let ue;if(Hl){if(D==="sync"){const Q=Mv();ue=Q.__watcherHandles||(Q.__watcherHandles=[])}else if(!V){const Q=()=>{};return Q.stop=Nn,Q.resume=Nn,Q.pause=Nn,Q}}const oe=fr;a.call=(Q,He,Qe)=>Un(Q,oe,He,Qe);let ge=!1;D==="post"?a.scheduler=Q=>{Yr(Q,oe&&oe.suspense)}:D!=="sync"&&(ge=!0,a.scheduler=(Q,He)=>{He?Q():yd(Q)}),a.augmentJob=Q=>{m&&(Q.flags|=4),ge&&(Q.flags|=2,oe&&(Q.id=oe.uid,Q.i=oe))};const Se=Fy(u,m,a);return Hl&&(ue?ue.push(Se):V&&Se()),Se}function Cv(u,m,b){const M=this.proxy,E=Bi(u)?u.includes(".")?wm(M,u):()=>M[u]:u.bind(M,M);let D;It(m)?D=m:(D=m.handler,b=m);const T=ql(this),a=bm(E,D.bind(M),b);return T(),a}function wm(u,m){const b=m.split(".");return()=>{let M=u;for(let E=0;E<b.length&&M;E++)M=M[b[E]];return M}}const Iv=(u,m)=>m==="modelValue"||m==="model-value"?u.modelModifiers:u[`${m}Modifiers`]||u[`${Vs(m)}Modifiers`]||u[`${So(m)}Modifiers`];function Ev(u,m,...b){if(u.isUnmounted)return;const M=u.vnode.props||ai;let E=b;const D=m.startsWith("update:"),T=D&&Iv(M,m.slice(7));T&&(T.trim&&(E=b.map(oe=>Bi(oe)?oe.trim():oe)),T.number&&(E=b.map(id)));let a,V=M[a=td(m)]||M[a=td(Vs(m))];!V&&D&&(V=M[a=td(So(m))]),V&&Un(V,u,6,E);const ue=M[a+"Once"];if(ue){if(!u.emitted)u.emitted={};else if(u.emitted[a])return;u.emitted[a]=!0,Un(ue,u,6,E)}}function Tm(u,m,b=!1){const M=m.emitsCache,E=M.get(u);if(E!==void 0)return E;const D=u.emits;let T={},a=!1;if(!It(u)){const V=ue=>{const oe=Tm(ue,m,!0);oe&&(a=!0,kr(T,oe))};!b&&m.mixins.length&&m.mixins.forEach(V),u.extends&&V(u.extends),u.mixins&&u.mixins.forEach(V)}return!D&&!a?(xi(u)&&M.set(u,null),null):(Mt(D)?D.forEach(V=>T[V]=null):kr(T,D),xi(u)&&M.set(u,T),T)}function Mu(u,m){return!u||!ou(m)?!1:(m=m.slice(2).replace(/Once$/,""),ii(u,m[0].toLowerCase()+m.slice(1))||ii(u,So(m))||ii(u,m))}function nw(){}function Sm(u){const{type:m,vnode:b,proxy:M,withProxy:E,propsOptions:[D],slots:T,attrs:a,emit:V,render:ue,renderCache:oe,props:ge,data:Se,setupState:Q,ctx:He,inheritAttrs:Qe}=u,Je=wu(u);let Ye,ct;try{if(b.shapeFlag&4){const We=E||M,yt=We;Ye=Gn(ue.call(yt,We,oe,ge,Q,Se,He)),ct=a}else{const We=m;Ye=Gn(We.length>1?We(ge,{attrs:a,slots:T,emit:V}):We(ge,null)),ct=m.props?a:Av(a)}}catch(We){$l.length=0,xu(We,u,1),Ye=Pi(Zs)}let st=Ye;if(ct&&Qe!==!1){const We=Object.keys(ct),{shapeFlag:yt}=st;We.length&&yt&7&&(D&&We.some(Jh)&&(ct=kv(ct,D)),st=Sa(st,ct,!1,!0))}return b.dirs&&(st=Sa(st,null,!1,!0),st.dirs=st.dirs?st.dirs.concat(b.dirs):b.dirs),b.transition&&vd(st,b.transition),Ye=st,wu(Je),Ye}const Av=u=>{let m;for(const b in u)(b==="class"||b==="style"||ou(b))&&((m||(m={}))[b]=u[b]);return m},kv=(u,m)=>{const b={};for(const M in u)(!Jh(M)||!(M.slice(9)in m))&&(b[M]=u[M]);return b};function zv(u,m,b){const{props:M,children:E,component:D}=u,{props:T,children:a,patchFlag:V}=m,ue=D.emitsOptions;if(m.dirs||m.transition)return!0;if(b&&V>=0){if(V&1024)return!0;if(V&16)return M?Pm(M,T,ue):!!T;if(V&8){const oe=m.dynamicProps;for(let ge=0;ge<oe.length;ge++){const Se=oe[ge];if(T[Se]!==M[Se]&&!Mu(ue,Se))return!0}}}else return(E||a)&&(!a||!a.$stable)?!0:M===T?!1:M?T?Pm(M,T,ue):!0:!!T;return!1}function Pm(u,m,b){const M=Object.keys(m);if(M.length!==Object.keys(u).length)return!0;for(let E=0;E<M.length;E++){const D=M[E];if(m[D]!==u[D]&&!Mu(b,D))return!0}return!1}function Rv({vnode:u,parent:m},b){for(;m;){const M=m.subTree;if(M.suspense&&M.suspense.activeBranch===u&&(M.el=u.el),M===u)(u=m.vnode).el=b,m=m.parent;else break}}const Mm=u=>u.__isSuspense;function Dv(u,m){m&&m.pendingBranch?Mt(u)?m.effects.push(...u):m.effects.push(u):$y(u)}const er=Symbol.for("v-fgt"),Cu=Symbol.for("v-txt"),Zs=Symbol.for("v-cmt"),Id=Symbol.for("v-stc"),$l=[];let Jr=null;function jt(u=!1){$l.push(Jr=u?null:[])}function Lv(){$l.pop(),Jr=$l[$l.length-1]||null}let Gl=1;function Cm(u,m=!1){Gl+=u,u<0&&Jr&&m&&(Jr.hasOnce=!0)}function Im(u){return u.dynamicChildren=Gl>0?Jr||ma:null,Lv(),Gl>0&&Jr&&Jr.push(u),u}function li(u,m,b,M,E,D){return Im(Et(u,m,b,M,E,D,!0))}function vn(u,m,b,M,E){return Im(Pi(u,m,b,M,E,!0))}function Ed(u){return u?u.__v_isVNode===!0:!1}function Zl(u,m){return u.type===m.type&&u.key===m.key}const Em=({key:u})=>u??null,Iu=({ref:u,ref_key:m,ref_for:b})=>(typeof u=="number"&&(u=""+u),u!=null?Bi(u)||bi(u)||It(u)?{i:ar,r:u,k:m,f:!!b}:u:null);function Et(u,m=null,b=null,M=0,E=null,D=u===er?0:1,T=!1,a=!1){const V={__v_isVNode:!0,__v_skip:!0,type:u,props:m,key:m&&Em(m),ref:m&&Iu(m),scopeId:Wf,slotScopeIds:null,children:b,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:D,patchFlag:M,dynamicProps:E,dynamicChildren:null,appContext:null,ctx:ar};return a?(Ad(V,b),D&128&&u.normalize(V)):b&&(V.shapeFlag|=Bi(b)?8:16),Gl>0&&!T&&Jr&&(V.patchFlag>0||D&6)&&V.patchFlag!==32&&Jr.push(V),V}const Pi=Fv;function Fv(u,m=null,b=null,M=0,E=null,D=!1){if((!u||u===rv)&&(u=Zs),Ed(u)){const a=Sa(u,m,!0);return b&&Ad(a,b),Gl>0&&!D&&Jr&&(a.shapeFlag&6?Jr[Jr.indexOf(u)]=a:Jr.push(a)),a.patchFlag=-2,a}if(Yv(u)&&(u=u.__vccOpts),m){m=Bv(m);let{class:a,style:V}=m;a&&!Bi(a)&&(m.class=Vn(a)),xi(V)&&(fd(V)&&!Mt(V)&&(V=kr({},V)),m.style=Po(V))}const T=Bi(u)?1:Mm(u)?128:Zy(u)?64:xi(u)?4:It(u)?2:0;return Et(u,m,b,M,E,T,D,!0)}function Bv(u){return u?fd(u)||um(u)?kr({},u):u:null}function Sa(u,m,b=!1,M=!1){const{props:E,ref:D,patchFlag:T,children:a,transition:V}=u,ue=m?jv(E||{},m):E,oe={__v_isVNode:!0,__v_skip:!0,type:u.type,props:ue,key:ue&&Em(ue),ref:m&&m.ref?b&&D?Mt(D)?D.concat(Iu(m)):[D,Iu(m)]:Iu(m):D,scopeId:u.scopeId,slotScopeIds:u.slotScopeIds,children:a,target:u.target,targetStart:u.targetStart,targetAnchor:u.targetAnchor,staticCount:u.staticCount,shapeFlag:u.shapeFlag,patchFlag:m&&u.type!==er?T===-1?16:T|16:T,dynamicProps:u.dynamicProps,dynamicChildren:u.dynamicChildren,appContext:u.appContext,dirs:u.dirs,transition:V,component:u.component,suspense:u.suspense,ssContent:u.ssContent&&Sa(u.ssContent),ssFallback:u.ssFallback&&Sa(u.ssFallback),el:u.el,anchor:u.anchor,ctx:u.ctx,ce:u.ce};return V&&M&&vd(oe,V.clone(oe)),oe}function Ov(u=" ",m=0){return Pi(Cu,null,u,m)}function Ur(u="",m=!1){return m?(jt(),vn(Zs,null,u)):Pi(Zs,null,u)}function Gn(u){return u==null||typeof u=="boolean"?Pi(Zs):Mt(u)?Pi(er,null,u.slice()):Ed(u)?qs(u):Pi(Cu,null,String(u))}function qs(u){return u.el===null&&u.patchFlag!==-1||u.memo?u:Sa(u)}function Ad(u,m){let b=0;const{shapeFlag:M}=u;if(m==null)m=null;else if(Mt(m))b=16;else if(typeof m=="object")if(M&65){const E=m.default;E&&(E._c&&(E._d=!1),Ad(u,E()),E._c&&(E._d=!0));return}else{b=32;const E=m._;!E&&!um(m)?m._ctx=ar:E===3&&ar&&(ar.slots._===1?m._=1:(m._=2,u.patchFlag|=1024))}else It(m)?(m={default:m,_ctx:ar},b=32):(m=String(m),M&64?(b=16,m=[Ov(m)]):b=8);u.children=m,u.shapeFlag|=b}function jv(...u){const m={};for(let b=0;b<u.length;b++){const M=u[b];for(const E in M)if(E==="class")m.class!==M.class&&(m.class=Vn([m.class,M.class]));else if(E==="style")m.style=Po([m.style,M.style]);else if(ou(E)){const D=m[E],T=M[E];T&&D!==T&&!(Mt(D)&&D.includes(T))&&(m[E]=D?[].concat(D,T):T)}else E!==""&&(m[E]=M[E])}return m}function Zn(u,m,b,M=null){Un(u,m,7,[b,M])}const Nv=am();let Vv=0;function Uv(u,m,b){const M=u.type,E=(m?m.appContext:u.appContext)||Nv,D={uid:Vv++,vnode:u,type:M,parent:m,appContext:E,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new gf(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:m?m.provides:Object.create(E.provides),ids:m?m.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:dm(M,E),emitsOptions:Tm(M,E),emit:null,emitted:null,propsDefaults:ai,inheritAttrs:M.inheritAttrs,ctx:ai,data:ai,props:ai,attrs:ai,slots:ai,refs:ai,setupState:ai,setupContext:null,suspense:b,suspenseId:b?b.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return D.ctx={_:D},D.root=m?m.root:D,D.emit=Ev.bind(null,D),u.ce&&u.ce(D),D}let fr=null;const $v=()=>fr||ar;let Eu,kd;{const u=uu(),m=(b,M)=>{let E;return(E=u[b])||(E=u[b]=[]),E.push(M),D=>{E.length>1?E.forEach(T=>T(D)):E[0](D)}};Eu=m("__VUE_INSTANCE_SETTERS__",b=>fr=b),kd=m("__VUE_SSR_SETTERS__",b=>Hl=b)}const ql=u=>{const m=fr;return Eu(u),u.scope.on(),()=>{u.scope.off(),Eu(m)}},Am=()=>{fr&&fr.scope.off(),Eu(null)};function km(u){return u.vnode.shapeFlag&4}let Hl=!1;function Gv(u,m=!1,b=!1){m&&kd(m);const{props:M,children:E}=u.vnode,D=km(u);mv(u,M,D,m),vv(u,E,b);const T=D?Zv(u,m):void 0;return m&&kd(!1),T}function Zv(u,m){const b=u.type;u.accessCache=Object.create(null),u.proxy=new Proxy(u.ctx,sv);const{setup:M}=b;if(M){us();const E=u.setupContext=M.length>1?Hv(u):null,D=ql(u),T=ya(M,u,0,[u.props,E]),a=af(T);if(hs(),D(),(a||u.sp)&&!ba(u)&&Xf(u),a){if(T.then(Am,Am),m)return T.then(V=>{zm(u,V)}).catch(V=>{xu(V,u,0)});u.asyncDep=T}else zm(u,T)}else Rm(u)}function zm(u,m,b){It(m)?u.type.__ssrInlineRender?u.ssrRender=m:u.render=m:xi(m)&&(u.setupState=jf(m)),Rm(u)}function Rm(u,m,b){const M=u.type;u.render||(u.render=M.render||Nn);{const E=ql(u);us();try{ov(u)}finally{hs(),E()}}}const qv={get(u,m){return wr(u,"get",""),u[m]}};function Hv(u){const m=b=>{u.exposed=b||{}};return{attrs:new Proxy(u.attrs,qv),slots:u.slots,emit:u.emit,expose:m}}function Au(u){return u.exposed?u.exposeProxy||(u.exposeProxy=new Proxy(jf(md(u.exposed)),{get(m,b){if(b in m)return m[b];if(b in Nl)return Nl[b](u)},has(m,b){return b in m||b in Nl}})):u.proxy}const Wv=/(?:^|[-_])(\w)/g,Xv=u=>u.replace(Wv,m=>m.toUpperCase()).replace(/[-_]/g,"");function Kv(u,m=!0){return It(u)?u.displayName||u.name:u.name||m&&u.__name}function Dm(u,m,b=!1){let M=Kv(m);if(!M&&m.__file){const E=m.__file.match(/([^/\\]+)\.\w+$/);E&&(M=E[1])}if(!M&&u&&u.parent){const E=D=>{for(const T in D)if(D[T]===m)return T};M=E(u.components||u.parent.type.components)||E(u.appContext.components)}return M?Xv(M):b?"App":"Anonymous"}function Yv(u){return It(u)&&"__vccOpts"in u}const Sr=(u,m)=>Dy(u,m,Hl),Jv="3.5.13";/**
17
+ * @vue/runtime-dom v3.5.13
18
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
19
+ * @license MIT
20
+ **/let zd;const Lm=typeof window<"u"&&window.trustedTypes;if(Lm)try{zd=Lm.createPolicy("vue",{createHTML:u=>u})}catch{}const Fm=zd?u=>zd.createHTML(u):u=>u,Qv="http://www.w3.org/2000/svg",ex="http://www.w3.org/1998/Math/MathML",_s=typeof document<"u"?document:null,Bm=_s&&_s.createElement("template"),tx={insert:(u,m,b)=>{m.insertBefore(u,b||null)},remove:u=>{const m=u.parentNode;m&&m.removeChild(u)},createElement:(u,m,b,M)=>{const E=m==="svg"?_s.createElementNS(Qv,u):m==="mathml"?_s.createElementNS(ex,u):b?_s.createElement(u,{is:b}):_s.createElement(u);return u==="select"&&M&&M.multiple!=null&&E.setAttribute("multiple",M.multiple),E},createText:u=>_s.createTextNode(u),createComment:u=>_s.createComment(u),setText:(u,m)=>{u.nodeValue=m},setElementText:(u,m)=>{u.textContent=m},parentNode:u=>u.parentNode,nextSibling:u=>u.nextSibling,querySelector:u=>_s.querySelector(u),setScopeId(u,m){u.setAttribute(m,"")},insertStaticContent(u,m,b,M,E,D){const T=b?b.previousSibling:m.lastChild;if(E&&(E===D||E.nextSibling))for(;m.insertBefore(E.cloneNode(!0),b),!(E===D||!(E=E.nextSibling)););else{Bm.innerHTML=Fm(M==="svg"?`<svg>${u}</svg>`:M==="mathml"?`<math>${u}</math>`:u);const a=Bm.content;if(M==="svg"||M==="mathml"){const V=a.firstChild;for(;V.firstChild;)a.appendChild(V.firstChild);a.removeChild(V)}m.insertBefore(a,b)}return[T?T.nextSibling:m.firstChild,b?b.previousSibling:m.lastChild]}},ix=Symbol("_vtc");function rx(u,m,b){const M=u[ix];M&&(m=(m?[m,...M]:[...M]).join(" ")),m==null?u.removeAttribute("class"):b?u.setAttribute("class",m):u.className=m}const ku=Symbol("_vod"),Om=Symbol("_vsh"),Pa={beforeMount(u,{value:m},{transition:b}){u[ku]=u.style.display==="none"?"":u.style.display,b&&m?b.beforeEnter(u):Wl(u,m)},mounted(u,{value:m},{transition:b}){b&&m&&b.enter(u)},updated(u,{value:m,oldValue:b},{transition:M}){!m!=!b&&(M?m?(M.beforeEnter(u),Wl(u,!0),M.enter(u)):M.leave(u,()=>{Wl(u,!1)}):Wl(u,m))},beforeUnmount(u,{value:m}){Wl(u,m)}};function Wl(u,m){u.style.display=m?u[ku]:"none",u[Om]=!m}const nx=Symbol(""),sx=/(^|;)\s*display\s*:/;function ox(u,m,b){const M=u.style,E=Bi(b);let D=!1;if(b&&!E){if(m)if(Bi(m))for(const T of m.split(";")){const a=T.slice(0,T.indexOf(":")).trim();b[a]==null&&zu(M,a,"")}else for(const T in m)b[T]==null&&zu(M,T,"");for(const T in b)T==="display"&&(D=!0),zu(M,T,b[T])}else if(E){if(m!==b){const T=M[nx];T&&(b+=";"+T),M.cssText=b,D=sx.test(b)}}else m&&u.removeAttribute("style");ku in u&&(u[ku]=D?M.display:"",u[Om]&&(M.display="none"))}const jm=/\s*!important$/;function zu(u,m,b){if(Mt(b))b.forEach(M=>zu(u,m,M));else if(b==null&&(b=""),m.startsWith("--"))u.setProperty(m,b);else{const M=ax(u,m);jm.test(b)?u.setProperty(So(M),b.replace(jm,""),"important"):u[M]=b}}const Nm=["Webkit","Moz","ms"],Rd={};function ax(u,m){const b=Rd[m];if(b)return b;let M=Vs(m);if(M!=="filter"&&M in u)return Rd[m]=M;M=uf(M);for(let E=0;E<Nm.length;E++){const D=Nm[E]+M;if(D in u)return Rd[m]=D}return m}const Vm="http://www.w3.org/1999/xlink";function Um(u,m,b,M,E,D=sy(m)){M&&m.startsWith("xlink:")?b==null?u.removeAttributeNS(Vm,m.slice(6,m.length)):u.setAttributeNS(Vm,m,b):b==null||D&&!pf(b)?u.removeAttribute(m):u.setAttribute(m,D?"":cs(b)?String(b):b)}function $m(u,m,b,M,E){if(m==="innerHTML"||m==="textContent"){b!=null&&(u[m]=m==="innerHTML"?Fm(b):b);return}const D=u.tagName;if(m==="value"&&D!=="PROGRESS"&&!D.includes("-")){const a=D==="OPTION"?u.getAttribute("value")||"":u.value,V=b==null?u.type==="checkbox"?"on":"":String(b);(a!==V||!("_value"in u))&&(u.value=V),b==null&&u.removeAttribute(m),u._value=b;return}let T=!1;if(b===""||b==null){const a=typeof u[m];a==="boolean"?b=pf(b):b==null&&a==="string"?(b="",T=!0):a==="number"&&(b=0,T=!0)}try{u[m]=b}catch{}T&&u.removeAttribute(E||m)}function Ma(u,m,b,M){u.addEventListener(m,b,M)}function lx(u,m,b,M){u.removeEventListener(m,b,M)}const Gm=Symbol("_vei");function cx(u,m,b,M,E=null){const D=u[Gm]||(u[Gm]={}),T=D[m];if(M&&T)T.value=M;else{const[a,V]=ux(m);if(M){const ue=D[m]=px(M,E);Ma(u,a,ue,V)}else T&&(lx(u,a,T,V),D[m]=void 0)}}const Zm=/(?:Once|Passive|Capture)$/;function ux(u){let m;if(Zm.test(u)){m={};let M;for(;M=u.match(Zm);)u=u.slice(0,u.length-M[0].length),m[M[0].toLowerCase()]=!0}return[u[2]===":"?u.slice(3):So(u.slice(2)),m]}let Dd=0;const hx=Promise.resolve(),dx=()=>Dd||(hx.then(()=>Dd=0),Dd=Date.now());function px(u,m){const b=M=>{if(!M._vts)M._vts=Date.now();else if(M._vts<=b.attached)return;Un(fx(M,b.value),m,5,[M])};return b.value=u,b.attached=dx(),b}function fx(u,m){if(Mt(m)){const b=u.stopImmediatePropagation;return u.stopImmediatePropagation=()=>{b.call(u),u._stopped=!0},m.map(M=>E=>!E._stopped&&M&&M(E))}else return m}const qm=u=>u.charCodeAt(0)===111&&u.charCodeAt(1)===110&&u.charCodeAt(2)>96&&u.charCodeAt(2)<123,mx=(u,m,b,M,E,D)=>{const T=E==="svg";m==="class"?rx(u,M,T):m==="style"?ox(u,b,M):ou(m)?Jh(m)||cx(u,m,b,M,D):(m[0]==="."?(m=m.slice(1),!0):m[0]==="^"?(m=m.slice(1),!1):gx(u,m,M,T))?($m(u,m,M),!u.tagName.includes("-")&&(m==="value"||m==="checked"||m==="selected")&&Um(u,m,M,T,D,m!=="value")):u._isVueCE&&(/[A-Z]/.test(m)||!Bi(M))?$m(u,Vs(m),M,D,m):(m==="true-value"?u._trueValue=M:m==="false-value"&&(u._falseValue=M),Um(u,m,M,T))};function gx(u,m,b,M){if(M)return!!(m==="innerHTML"||m==="textContent"||m in u&&qm(m)&&It(b));if(m==="spellcheck"||m==="draggable"||m==="translate"||m==="form"||m==="list"&&u.tagName==="INPUT"||m==="type"&&u.tagName==="TEXTAREA")return!1;if(m==="width"||m==="height"){const E=u.tagName;if(E==="IMG"||E==="VIDEO"||E==="CANVAS"||E==="SOURCE")return!1}return qm(m)&&Bi(b)?!1:m in u}const Hm=u=>{const m=u.props["onUpdate:modelValue"]||!1;return Mt(m)?b=>cu(m,b):m};function _x(u){u.target.composing=!0}function Wm(u){const m=u.target;m.composing&&(m.composing=!1,m.dispatchEvent(new Event("input")))}const Ld=Symbol("_assign"),yx={created(u,{modifiers:{lazy:m,trim:b,number:M}},E){u[Ld]=Hm(E);const D=M||E.props&&E.props.type==="number";Ma(u,m?"change":"input",T=>{if(T.target.composing)return;let a=u.value;b&&(a=a.trim()),D&&(a=id(a)),u[Ld](a)}),b&&Ma(u,"change",()=>{u.value=u.value.trim()}),m||(Ma(u,"compositionstart",_x),Ma(u,"compositionend",Wm),Ma(u,"change",Wm))},mounted(u,{value:m}){u.value=m??""},beforeUpdate(u,{value:m,oldValue:b,modifiers:{lazy:M,trim:E,number:D}},T){if(u[Ld]=Hm(T),u.composing)return;const a=(D||u.type==="number")&&!/^0\d/.test(u.value)?id(u.value):u.value,V=m??"";a!==V&&(document.activeElement===u&&u.type!=="range"&&(M&&m===b||E&&u.value.trim()===V)||(u.value=V))}},vx=["ctrl","shift","alt","meta"],xx={stop:u=>u.stopPropagation(),prevent:u=>u.preventDefault(),self:u=>u.target!==u.currentTarget,ctrl:u=>!u.ctrlKey,shift:u=>!u.shiftKey,alt:u=>!u.altKey,meta:u=>!u.metaKey,left:u=>"button"in u&&u.button!==0,middle:u=>"button"in u&&u.button!==1,right:u=>"button"in u&&u.button!==2,exact:(u,m)=>vx.some(b=>u[`${b}Key`]&&!m.includes(b))},Fd=(u,m)=>{const b=u._withMods||(u._withMods={}),M=m.join(".");return b[M]||(b[M]=(E,...D)=>{for(let T=0;T<m.length;T++){const a=xx[m[T]];if(a&&a(E,m))return}return u(E,...D)})},bx=kr({patchProp:mx},tx);let Xm;function wx(){return Xm||(Xm=bv(bx))}const Tx=(...u)=>{const m=wx().createApp(...u),{mount:b}=m;return m.mount=M=>{const E=Px(M);if(!E)return;const D=m._component;!It(D)&&!D.render&&!D.template&&(D.template=E.innerHTML),E.nodeType===1&&(E.textContent="");const T=b(E,!1,Sx(E));return E instanceof Element&&(E.removeAttribute("v-cloak"),E.setAttribute("data-v-app","")),T},m};function Sx(u){if(u instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&u instanceof MathMLElement)return"mathml"}function Px(u){return Bi(u)?document.querySelector(u):u}/*!
21
+ * pinia v2.3.1
22
+ * (c) 2025 Eduardo San Martin Morote
23
+ * @license MIT
24
+ */let Km;const Ru=u=>Km=u,Ym=Symbol();function Bd(u){return u&&typeof u=="object"&&Object.prototype.toString.call(u)==="[object Object]"&&typeof u.toJSON!="function"}var Xl;(function(u){u.direct="direct",u.patchObject="patch object",u.patchFunction="patch function"})(Xl||(Xl={}));function Mx(){const u=_f(!0),m=u.run(()=>Io({}));let b=[],M=[];const E=md({install(D){Ru(E),E._a=D,D.provide(Ym,E),D.config.globalProperties.$pinia=E,M.forEach(T=>b.push(T)),M=[]},use(D){return this._a?b.push(D):M.push(D),this},_p:b,_a:null,_e:u,_s:new Map,state:m});return E}const Jm=()=>{};function Qm(u,m,b,M=Jm){u.push(m);const E=()=>{const D=u.indexOf(m);D>-1&&(u.splice(D,1),M())};return!b&&yf()&&oy(E),E}function Ca(u,...m){u.slice().forEach(b=>{b(...m)})}const Cx=u=>u(),eg=Symbol(),Od=Symbol();function jd(u,m){u instanceof Map&&m instanceof Map?m.forEach((b,M)=>u.set(M,b)):u instanceof Set&&m instanceof Set&&m.forEach(u.add,u);for(const b in m){if(!m.hasOwnProperty(b))continue;const M=m[b],E=u[b];Bd(E)&&Bd(M)&&u.hasOwnProperty(b)&&!bi(M)&&!fs(M)?u[b]=jd(E,M):u[b]=M}return u}const Ix=Symbol();function Ex(u){return!Bd(u)||!u.hasOwnProperty(Ix)}const{assign:Hs}=Object;function Ax(u){return!!(bi(u)&&u.effect)}function kx(u,m,b,M){const{state:E,actions:D,getters:T}=m,a=b.state.value[u];let V;function ue(){a||(b.state.value[u]=E?E():{});const oe=Ey(b.state.value[u]);return Hs(oe,D,Object.keys(T||{}).reduce((ge,Se)=>(ge[Se]=md(Sr(()=>{Ru(b);const Q=b._s.get(u);return T[Se].call(Q,Q)})),ge),{}))}return V=tg(u,ue,m,b,M,!0),V}function tg(u,m,b={},M,E,D){let T;const a=Hs({actions:{}},b),V={deep:!0};let ue,oe,ge=[],Se=[],Q;const He=M.state.value[u];!D&&!He&&(M.state.value[u]={}),Io({});let Qe;function Je(Ft){let Nt;ue=oe=!1,typeof Ft=="function"?(Ft(M.state.value[u]),Nt={type:Xl.patchFunction,storeId:u,events:Q}):(jd(M.state.value[u],Ft),Nt={type:Xl.patchObject,payload:Ft,storeId:u,events:Q});const Xt=Qe=Symbol();$f().then(()=>{Qe===Xt&&(ue=!0)}),oe=!0,Ca(ge,Nt,M.state.value[u])}const Ye=D?function(){const{state:Nt}=b,Xt=Nt?Nt():{};this.$patch(Mi=>{Hs(Mi,Xt)})}:Jm;function ct(){T.stop(),ge=[],Se=[],M._s.delete(u)}const st=(Ft,Nt="")=>{if(eg in Ft)return Ft[Od]=Nt,Ft;const Xt=function(){Ru(M);const Mi=Array.from(arguments),Ci=[],tr=[];function en(St){Ci.push(St)}function $r(St){tr.push(St)}Ca(Se,{args:Mi,name:Xt[Od],store:yt,after:en,onError:$r});let Jt;try{Jt=Ft.apply(this&&this.$id===u?this:yt,Mi)}catch(St){throw Ca(tr,St),St}return Jt instanceof Promise?Jt.then(St=>(Ca(Ci,St),St)).catch(St=>(Ca(tr,St),Promise.reject(St))):(Ca(Ci,Jt),Jt)};return Xt[eg]=!0,Xt[Od]=Nt,Xt},We={_p:M,$id:u,$onAction:Qm.bind(null,Se),$patch:Je,$reset:Ye,$subscribe(Ft,Nt={}){const Xt=Qm(ge,Ft,Nt.detached,()=>Mi()),Mi=T.run(()=>Ta(()=>M.state.value[u],Ci=>{(Nt.flush==="sync"?oe:ue)&&Ft({storeId:u,type:Xl.direct,events:Q},Ci)},Hs({},V,Nt)));return Xt},$dispose:ct},yt=gu(We);M._s.set(u,yt);const mi=(M._a&&M._a.runWithContext||Cx)(()=>M._e.run(()=>(T=_f()).run(()=>m({action:st}))));for(const Ft in mi){const Nt=mi[Ft];if(bi(Nt)&&!Ax(Nt)||fs(Nt))D||(He&&Ex(Nt)&&(bi(Nt)?Nt.value=He[Ft]:jd(Nt,He[Ft])),M.state.value[u][Ft]=Nt);else if(typeof Nt=="function"){const Xt=st(Nt,Ft);mi[Ft]=Xt,a.actions[Ft]=Nt}}return Hs(yt,mi),Hs(Ht(yt),mi),Object.defineProperty(yt,"$state",{get:()=>M.state.value[u],set:Ft=>{Je(Nt=>{Hs(Nt,Ft)})}}),M._p.forEach(Ft=>{Hs(yt,T.run(()=>Ft({store:yt,app:M._a,pinia:M,options:a})))}),He&&D&&b.hydrate&&b.hydrate(yt.$state,He),ue=!0,oe=!0,yt}/*! #__NO_SIDE_EFFECTS__ */function zx(u,m,b){let M,E;const D=typeof m=="function";M=u,E=D?b:m;function T(a,V){const ue=fv();return a=a||(ue?Ul(Ym,null):null),a&&Ru(a),a=Km,a._s.has(M)||(D?tg(M,m,E,a):kx(M,E,a)),a._s.get(M)}return T.$id=M,T}function qn(u){{const m=Ht(u),b={};for(const M in m){const E=m[M];E.effect?b[M]=Sr({get:()=>u[M],set(D){u[M]=D}}):(bi(E)||fs(E))&&(b[M]=zy(u,M))}return b}}const Nd={padding:{top:50,bottom:50,left:50,right:50},duration:0},Rx={duration:1e3},Dx={center:[-1.8261632,51.1788144],zoom:18,style:"https://tiles.openfreemap.org/styles/liberty",attributionControl:!1},ig=["marker","line","shape"];function rg(u={}){if(!u||!u.geometry)return null;switch(u.geometry.type){case"Point":return"marker";case"LineString":case"MultiLineString":return"line";default:return"shape"}}function Lx(u){const m={thumbnail:null,medium:null,large:null};return u.properties.image_thumbnail_url?m.thumbnail=u.properties.image_thumbnail_url:u.properties.image_medium_url?m.thumbnail=u.properties.image_medium_url:u.properties.image_large_url&&(m.thumbnail=u.properties.image_large_url),u.properties.image_medium_url?m.medium=u.properties.image_medium_url:u.properties.image_large_url&&(m.medium=u.properties.image_large_url),u.properties.image_large_url&&(m.large=u.properties.image_large_url),m}function Fx(u={}){if(!(u instanceof Bu))return null;var m={className:"waymark-marker waymark-marker-"+u.typeKey};if(typeof u.data.marker_shape<"u"&&typeof u.data.marker_size<"u"){switch(m.className+=" waymark-marker-"+u.data.marker_shape,m.className+=" waymark-marker-"+u.data.marker_size,u.data.marker_shape){case"rectangle":case"circle":case"marker":switch(u.data.marker_size){case"small":m.iconSize=[16,16];break;case"medium":m.iconSize=[25,25];break;default:case"large":m.iconSize=[32,32];break}break}u.data.marker_shape=="marker"&&(m.iconAnchor=[0,-Math.ceil(m.iconSize[1]/1.5)])}var b="background:"+u.data.marker_colour+";",M="color:"+u.data.icon_colour+";";m.html='<div class="waymark-marker-background" style="'+b+'"></div>';var E="waymark-marker-icon";switch(u.data.icon_type){case"text":E+=" waymark-icon-text",m.html+='<div style="'+M+'" class="'+E+'">'+u.data.marker_icon+"</div>";break;case"html":E+=" waymark-icon-html";var D="<div>"+u.data.marker_icon+"</div>";m.html+='<div class="'+E+'">'+D+"</div>";break;case"icon":default:E+=" waymark-icon-icon",u.data.marker_icon.indexOf("ion-")===0?(E+=" ion ",E+=" "+u.data.marker_icon):u.data.marker_icon.indexOf("fa-")===0?(E+=" fa",E+=" "+u.data.marker_icon):(E+=" ion",E+=" ion-"+u.data.marker_icon),m.html+='<i style="'+M+'" class="'+E+'"></i>';break}return m}const Du="#b42714",ng="#000000",sg="#000000",og="#000000";function Lu(u){return u&&(u=u.replace(/[^a-z0-9+]+/gi,""),u=u.toLowerCase(),u)}function ag(u){return u?"ion-eye":"ion-eye-disabled"}function Bx(u){return u?"fa-chevron-up":"fa-chevron-down"}class Fu{constructor(m){this.data=m||{}}}class Bu extends Fu{constructor(m){const b={marker_title:"Marker",marker_shape:"marker",marker_size:"large",icon_type:"icon",marker_icon:"ion-pin",marker_colour:ng,icon_colour:"#ffffff",marker_display:"1"};super({...b,...m}),this.typeKey=Lu(this.data.marker_title)||null,this.iconData=Fx(this)}getTitle(){return this.data.marker_title||"Marker"}getPrimaryColour(){return this.data.marker_colour||ng}getIconColour(){return this.data.icon_colour||"#ffffff"}}class Vd extends Fu{constructor(m){const b={line_title:"Line",line_colour:sg,line_weight:"3",line_opacity:"1",line_display:"1"};super({...b,...m}),this.typeKey=Lu(this.data.line_title)||null}getTitle(){return this.data.line_title||"Line"}getPrimaryColour(){return this.data.line_colour||sg}getLineWeight(){return parseInt(this.data.line_weight)||1}getLineOpacity(){return parseFloat(this.data.line_opacity)||1}getLineStyle(){return{color:this.getPrimaryColour(),weight:this.getLineWeight(),opacity:this.getLineOpacity()}}}class Ud extends Fu{constructor(m){const b={shape_title:"Shape",shape_colour:og,fill_opacity:"0.5",shape_display:"1"};super({...b,...m}),this.typeKey=Lu(this.data.shape_title)||null}getTitle(){return this.data.shape_title||"Shape"}getPrimaryColour(){return this.data.shape_colour||og}getFillOpacity(){return parseFloat(this.data.fill_opacity)||.5}getShapeStyle(){return{color:this.getPrimaryColour(),fillColor:this.getPrimaryColour(),fillOpacity:this.getFillOpacity()}}}class Ox{constructor(m){const b={layer_name:"Open Street Map",layer_url:"http://tile.openstreetmap.org/{z}/{x}/{y}.png",layer_attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',layer_max_zoom:"18"};this.data={...b,...m},this.id=Lu(this.data.layer_name)}addTo(m,b=!1){!m||!m.addLayer||(m.addSource(this.id,this.toSource()),m.addLayer(this.toStyle(b)))}toSource(){return{type:"raster",tiles:[this.data.layer_url],tileSize:256,maxzoom:parseInt(this.data.layer_max_zoom)||18}}toStyle(m=!1){return{id:this.id,type:"raster",source:this.id,attribution:this.data.layer_attribution||"",layout:{visibility:m?"visible":"none"}}}getTitle(){return this.data.layer_name||"Tile Layer"}}class lg{constructor(m={}){this.map_options=m.map_options||{div_id:"map"},this.mapLibreOptions={...Dx,...this.map_options.maplibre_options||{}},this.tileLayers=[],this.importTileLayers(),this.lineTypes={},this.shapeTypes={},this.markerTypes={},this.importTypes(),console.log("Config initialized with types:",{markerTypes:this.markerTypes,lineTypes:this.lineTypes,shapeTypes:this.shapeTypes})}importTileLayers(){this.map_options.hasOwnProperty("tile_layers")&&Array.isArray(this.map_options.tile_layers)&&this.map_options.tile_layers.forEach(m=>{this.tileLayers.push(new Ox(m))})}getTileLayers(){return this.tileLayers}importTypes(){ig.forEach(m=>{const b=m+"_types";this.map_options.hasOwnProperty(b)&&Array.isArray(this.map_options[b])&&this.map_options[b].forEach(M=>{switch(m){case"marker":this.markerTypes.hasOwnProperty(b)||(this.markerTypes[b]=[]),this.markerTypes[b].push(new Bu(M));break;case"line":this.lineTypes.hasOwnProperty(b)||(this.lineTypes[b]=[]),this.lineTypes[b].push(new Vd(M));break;case"shape":this.shapeTypes.hasOwnProperty(b)||(this.shapeTypes[b]=[]),this.shapeTypes[b].push(new Ud(M));break}})})}getType(m,b){if(!m)return null;switch(m){case"marker":return this.markerTypes.marker_types.find(M=>M.typeKey===b)||new Bu;case"line":return this.lineTypes.line_types.find(M=>M.typeKey===b)||new Vd;case"shape":return this.shapeTypes.shape_types.find(M=>M.typeKey===b)||new Ud;default:return null}}getMapOption(...m){if(m.length===0)return null;let b=this.map_options;for(const M of m)if(b&&b.hasOwnProperty(M))b=b[M];else return null;return JSON.parse(JSON.stringify(b))}}var Ou={exports:{}};/**
25
+ * MapLibre GL JS
26
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.7.1/LICENSE.txt
27
+ */var jx=Ou.exports,cg;function Nx(){return cg||(cg=1,function(u,m){(function(b,M){u.exports=M()})(jx,function(){var b={},M={};function E(T,a,V){if(M[T]=V,T==="index"){var ue="var sharedModule = {}; ("+M.shared+")(sharedModule); ("+M.worker+")(sharedModule);",oe={};return M.shared(oe),M.index(b,oe),typeof window<"u"&&b.setWorkerUrl(window.URL.createObjectURL(new Blob([ue],{type:"text/javascript"}))),b}}E("shared",["exports"],function(T){function a(r,t,i,s){return new(i||(i=Promise))(function(l,p){function f(w){try{y(s.next(w))}catch(S){p(S)}}function _(w){try{y(s.throw(w))}catch(S){p(S)}}function y(w){var S;w.done?l(w.value):(S=w.value,S instanceof i?S:new i(function(I){I(S)})).then(f,_)}y((s=s.apply(r,t||[])).next())})}function V(r,t){this.x=r,this.y=t}function ue(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var oe,ge;typeof SuppressedError=="function"&&SuppressedError,V.prototype={clone(){return new V(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,t){return this.clone()._rotateAround(r,t)},matMult(r){return this.clone()._matMult(r)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const t=r.x-this.x,i=r.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,t){return Math.atan2(this.x*t-this.y*r,this.x*r+this.y*t)},_matMult(r){const t=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=t,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const t=Math.cos(r),i=Math.sin(r),s=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=s,this},_rotateAround(r,t){const i=Math.cos(r),s=Math.sin(r),l=t.y+s*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-s*(this.y-t.y),this.y=l,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:V},V.convert=function(r){if(r instanceof V)return r;if(Array.isArray(r))return new V(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new V(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};var Se=function(){if(ge)return oe;function r(t,i,s,l){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(l-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=s,this.p2y=l}return ge=1,oe=r,r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,l=0;l<8;l++){var p=this.sampleCurveX(s)-t;if(Math.abs(p)<i)return s;var f=this.sampleCurveDerivativeX(s);if(Math.abs(f)<1e-6)break;s-=p/f}var _=0,y=1;for(s=t,l=0;l<20&&(p=this.sampleCurveX(s),!(Math.abs(p-t)<i));l++)t>p?_=s:y=s,s=.5*(y-_)+_;return s},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},oe}(),Q=ue(Se);let He,Qe;function Je(){return He==null&&(He=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),He}function Ye(){if(Qe==null&&(Qe=!1,Je())){const t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let s=0;s<5*5;s++){const l=4*s;t.fillStyle=`rgb(${l},${l+1},${l+2})`,t.fillRect(s%5,Math.floor(s/5),1,1)}const i=t.getImageData(0,0,5,5).data;for(let s=0;s<5*5*4;s++)if(s%4!=3&&i[s]!==s){Qe=!0;break}}}return Qe||!1}var ct=1e-6,st=typeof Float32Array<"u"?Float32Array:Array;function We(){var r=new st(9);return st!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function yt(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Oi(){var r=new st(3);return st!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function mi(r){var t=r[0],i=r[1],s=r[2];return Math.sqrt(t*t+i*i+s*s)}function Ft(r,t,i){var s=new st(3);return s[0]=r,s[1]=t,s[2]=i,s}function Nt(r,t,i){return r[0]=t[0]+i[0],r[1]=t[1]+i[1],r[2]=t[2]+i[2],r}function Xt(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r}function Mi(r,t,i){var s=t[0],l=t[1],p=t[2],f=i[0],_=i[1],y=i[2];return r[0]=l*y-p*_,r[1]=p*f-s*y,r[2]=s*_-l*f,r}var Ci,tr=mi;function en(r,t,i){var s=t[0],l=t[1],p=t[2],f=t[3];return r[0]=i[0]*s+i[4]*l+i[8]*p+i[12]*f,r[1]=i[1]*s+i[5]*l+i[9]*p+i[13]*f,r[2]=i[2]*s+i[6]*l+i[10]*p+i[14]*f,r[3]=i[3]*s+i[7]*l+i[11]*p+i[15]*f,r}function $r(){var r=new st(4);return st!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function Jt(r,t,i,s){var l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"zyx",p=Math.PI/360;t*=p,s*=p,i*=p;var f=Math.sin(t),_=Math.cos(t),y=Math.sin(i),w=Math.cos(i),S=Math.sin(s),I=Math.cos(s);switch(l){case"xyz":r[0]=f*w*I+_*y*S,r[1]=_*y*I-f*w*S,r[2]=_*w*S+f*y*I,r[3]=_*w*I-f*y*S;break;case"xzy":r[0]=f*w*I-_*y*S,r[1]=_*y*I-f*w*S,r[2]=_*w*S+f*y*I,r[3]=_*w*I+f*y*S;break;case"yxz":r[0]=f*w*I+_*y*S,r[1]=_*y*I-f*w*S,r[2]=_*w*S-f*y*I,r[3]=_*w*I+f*y*S;break;case"yzx":r[0]=f*w*I+_*y*S,r[1]=_*y*I+f*w*S,r[2]=_*w*S-f*y*I,r[3]=_*w*I-f*y*S;break;case"zxy":r[0]=f*w*I-_*y*S,r[1]=_*y*I+f*w*S,r[2]=_*w*S+f*y*I,r[3]=_*w*I-f*y*S;break;case"zyx":r[0]=f*w*I-_*y*S,r[1]=_*y*I+f*w*S,r[2]=_*w*S-f*y*I,r[3]=_*w*I+f*y*S;break;default:throw new Error("Unknown angle order "+l)}return r}function St(){var r=new st(2);return st!=Float32Array&&(r[0]=0,r[1]=0),r}function Kt(r,t){var i=new st(2);return i[0]=r,i[1]=t,i}Oi(),Ci=new st(4),st!=Float32Array&&(Ci[0]=0,Ci[1]=0,Ci[2]=0,Ci[3]=0),Oi(),Ft(1,0,0),Ft(0,1,0),$r(),$r(),We(),St();const Vt=8192;function Gr(r,t,i){return t*(Vt/(r.tileSize*Math.pow(2,i-r.tileID.overscaledZ)))}function di(r,t){return(r%t+t)%t}function Zi(r,t,i){return r*(1-i)+t*i}function Lr(r){if(r<=0)return 0;if(r>=1)return 1;const t=r*r,i=t*r;return 4*(r<.5?i:3*(r-t)+i-.75)}function xn(r,t,i,s){const l=new Q(r,t,i,s);return p=>l.solve(p)}const En=xn(.25,.1,.25,1);function Ai(r,t,i){return Math.min(i,Math.max(t,r))}function tn(r,t,i){const s=i-t,l=((r-t)%s+s)%s+t;return l===t?i:l}function lr(r,...t){for(const i of t)for(const s in i)r[s]=i[s];return r}let Pr=1;function Zr(r,t,i){const s={};for(const l in r)s[l]=t.call(this,r[l],l,r);return s}function ys(r,t,i){const s={};for(const l in r)t.call(this,r[l],l,r)&&(s[l]=r[l]);return s}function ne(r){return Array.isArray(r)?r.map(ne):typeof r=="object"&&r?Zr(r,ne):r}const le={};function Te(r){le[r]||(typeof console<"u"&&console.warn(r),le[r]=!0)}function ze(r,t,i){return(i.y-r.y)*(t.x-r.x)>(t.y-r.y)*(i.x-r.x)}function Ae(r){return typeof WorkerGlobalScope<"u"&&r!==void 0&&r instanceof WorkerGlobalScope}let Re=null;function qe(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap}const $e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function Ge(r,t,i,s,l){return a(this,void 0,void 0,function*(){if(typeof VideoFrame>"u")throw new Error("VideoFrame not supported");const p=new VideoFrame(r,{timestamp:0});try{const f=p==null?void 0:p.format;if(!f||!f.startsWith("BGR")&&!f.startsWith("RGB"))throw new Error(`Unrecognized format ${f}`);const _=f.startsWith("BGR"),y=new Uint8ClampedArray(s*l*4);if(yield p.copyTo(y,function(w,S,I,z,L){const F=4*Math.max(-S,0),N=(Math.max(0,I)-I)*z*4+F,$=4*z,H=Math.max(0,S),he=Math.max(0,I);return{rect:{x:H,y:he,width:Math.min(w.width,S+z)-H,height:Math.min(w.height,I+L)-he},layout:[{offset:N,stride:$}]}}(r,t,i,s,l)),_)for(let w=0;w<y.length;w+=4){const S=y[w];y[w]=y[w+2],y[w+2]=S}return y}finally{p.close()}})}let De,ut;function Ke(r,t,i,s){return r.addEventListener(t,i,s),{unsubscribe:()=>{r.removeEventListener(t,i,s)}}}function lt(r){return r*Math.PI/180}function mt(r){return r/Math.PI*180}const Ct={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Zt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},Gt="AbortError";function ae(){return new Error(Gt)}const B={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function j(r){return B.REGISTERED_PROTOCOLS[r.substring(0,r.indexOf("://"))]}const U="global-dispatcher";class X extends Error{constructor(t,i,s,l){super(`AJAXError: ${i} (${t}): ${s}`),this.status=t,this.statusText=i,this.url=s,this.body=l}}const ie=()=>Ae(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,ce=function(r,t){if(/:\/\//.test(r.url)&&!/^https?:|^file:/.test(r.url)){const s=j(r.url);if(s)return s(r,t);if(Ae(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,targetMapId:U},t)}if(!(/^file:/.test(i=r.url)||/^file:/.test(ie())&&!/^\w+:/.test(i))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(s,l){return a(this,void 0,void 0,function*(){const p=new Request(s.url,{method:s.method||"GET",body:s.body,credentials:s.credentials,headers:s.headers,cache:s.cache,referrer:ie(),signal:l.signal});let f,_;s.type!=="json"||p.headers.has("Accept")||p.headers.set("Accept","application/json");try{f=yield fetch(p)}catch(w){throw new X(0,w.message,s.url,new Blob)}if(!f.ok){const w=yield f.blob();throw new X(f.status,f.statusText,s.url,w)}_=s.type==="arrayBuffer"||s.type==="image"?f.arrayBuffer():s.type==="json"?f.json():f.text();const y=yield _;if(l.signal.aborted)throw ae();return{data:y,cacheControl:f.headers.get("Cache-Control"),expires:f.headers.get("Expires")}})}(r,t);if(Ae(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:r,mustQueue:!0,targetMapId:U},t)}var i;return function(s,l){return new Promise((p,f)=>{var _;const y=new XMLHttpRequest;y.open(s.method||"GET",s.url,!0),s.type!=="arrayBuffer"&&s.type!=="image"||(y.responseType="arraybuffer");for(const w in s.headers)y.setRequestHeader(w,s.headers[w]);s.type==="json"&&(y.responseType="text",!((_=s.headers)===null||_===void 0)&&_.Accept||y.setRequestHeader("Accept","application/json")),y.withCredentials=s.credentials==="include",y.onerror=()=>{f(new Error(y.statusText))},y.onload=()=>{if(!l.signal.aborted)if((y.status>=200&&y.status<300||y.status===0)&&y.response!==null){let w=y.response;if(s.type==="json")try{w=JSON.parse(y.response)}catch(S){return void f(S)}p({data:w,cacheControl:y.getResponseHeader("Cache-Control"),expires:y.getResponseHeader("Expires")})}else{const w=new Blob([y.response],{type:y.getResponseHeader("Content-Type")});f(new X(y.status,y.statusText,s.url,w))}},l.signal.addEventListener("abort",()=>{y.abort(),f(ae())}),y.send(s.body)})}(r,t)};function me(r){if(!r||r.indexOf("://")<=0||r.indexOf("data:image/")===0||r.indexOf("blob:")===0)return!0;const t=new URL(r),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function de(r,t,i){i[r]&&i[r].indexOf(t)!==-1||(i[r]=i[r]||[],i[r].push(t))}function Pe(r,t,i){if(i&&i[r]){const s=i[r].indexOf(t);s!==-1&&i[r].splice(s,1)}}class ke{constructor(t,i={}){lr(this,i),this.type=t}}class Ce extends ke{constructor(t,i={}){super("error",lr({error:t},i))}}class it{on(t,i){return this._listeners=this._listeners||{},de(t,i,this._listeners),{unsubscribe:()=>{this.off(t,i)}}}off(t,i){return Pe(t,i,this._listeners),Pe(t,i,this._oneTimeListeners),this}once(t,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},de(t,i,this._oneTimeListeners),this):new Promise(s=>this.once(t,s))}fire(t,i){typeof t=="string"&&(t=new ke(t,i||{}));const s=t.type;if(this.listens(s)){t.target=this;const l=this._listeners&&this._listeners[s]?this._listeners[s].slice():[];for(const _ of l)_.call(this,t);const p=this._oneTimeListeners&&this._oneTimeListeners[s]?this._oneTimeListeners[s].slice():[];for(const _ of p)Pe(s,_,this._oneTimeListeners),_.call(this,t);const f=this._eventedParent;f&&(lr(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),f.fire(t))}else t instanceof Ce&&console.error(t.error);return this}listens(t){return this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t)}setEventedParent(t,i){return this._eventedParent=t,this._eventedParentData=i,this}}var fe={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const _t=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function At(r,t){const i={};for(const s in r)s!=="ref"&&(i[s]=r[s]);return _t.forEach(s=>{s in t&&(i[s]=t[s])}),i}function ot(r,t){if(Array.isArray(r)){if(!Array.isArray(t)||r.length!==t.length)return!1;for(let i=0;i<r.length;i++)if(!ot(r[i],t[i]))return!1;return!0}if(typeof r=="object"&&r!==null&&t!==null){if(typeof t!="object"||Object.keys(r).length!==Object.keys(t).length)return!1;for(const i in r)if(!ot(r[i],t[i]))return!1;return!0}return r===t}function xt(r,t){r.push(t)}function oi(r,t,i){xt(i,{command:"addSource",args:[r,t[r]]})}function ji(r,t,i){xt(t,{command:"removeSource",args:[r]}),i[r]=!0}function Ni(r,t,i,s){ji(r,i,s),oi(r,t,i)}function Ii(r,t,i){let s;for(s in r[i])if(Object.prototype.hasOwnProperty.call(r[i],s)&&s!=="data"&&!ot(r[i][s],t[i][s]))return!1;for(s in t[i])if(Object.prototype.hasOwnProperty.call(t[i],s)&&s!=="data"&&!ot(r[i][s],t[i][s]))return!1;return!0}function Dt(r,t,i,s,l,p){r=r||{},t=t||{};for(const f in r)Object.prototype.hasOwnProperty.call(r,f)&&(ot(r[f],t[f])||i.push({command:p,args:[s,f,t[f],l]}));for(const f in t)Object.prototype.hasOwnProperty.call(t,f)&&!Object.prototype.hasOwnProperty.call(r,f)&&(ot(r[f],t[f])||i.push({command:p,args:[s,f,t[f],l]}))}function Ut(r){return r.id}function ki(r,t){return r[t.id]=t,r}class Fe{constructor(t,i,s,l){this.message=(t?`${t}: `:"")+s,l&&(this.identifier=l),i!=null&&i.__line__&&(this.line=i.__line__)}}function cr(r,...t){for(const i of t)for(const s in i)r[s]=i[s];return r}class gi extends Error{constructor(t,i){super(i),this.message=i,this.key=t}}class Wn{constructor(t,i=[]){this.parent=t,this.bindings={};for(const[s,l]of i)this.bindings[s]=l}concat(t){return new Wn(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Ws={kind:"null"},Ze={kind:"number"},kt={kind:"string"},Pt={kind:"boolean"},ir={kind:"color"},vs={kind:"projectionDefinition"},Xn={kind:"object"},wt={kind:"value"},Aa={kind:"collator"},Kn={kind:"formatted"},ka={kind:"padding"},bn={kind:"colorArray"},Xs={kind:"numberArray"},wi={kind:"resolvedImage"},za={kind:"variableAnchorOffsetCollection"};function Mr(r,t){return{kind:"array",itemType:r,N:t}}function ri(r){if(r.kind==="array"){const t=ri(r.itemType);return typeof r.N=="number"?`array<${t}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${t}>`}return r.kind}const Uu=[Ws,Ze,kt,Pt,ir,vs,Kn,Xn,Mr(wt),ka,Xs,bn,wi,za];function Do(r,t){if(t.kind==="error")return null;if(r.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!Do(r.itemType,t.itemType))&&(typeof r.N!="number"||r.N===t.N))return null}else{if(r.kind===t.kind)return null;if(r.kind==="value"){for(const i of Uu)if(!Do(i,t))return null}}return`Expected ${ri(r)} but found ${ri(t)} instead.`}function Kl(r,t){return t.some(i=>i.kind===r.kind)}function Yn(r,t){return t.some(i=>i==="null"?r===null:i==="array"?Array.isArray(r):i==="object"?r&&!Array.isArray(r)&&typeof r=="object":i===typeof r)}function Jn(r,t){return r.kind==="array"&&t.kind==="array"?r.itemType.kind===t.itemType.kind&&typeof r.N=="number":r.kind===t.kind}const Yl=.96422,$u=.82521,Gu=4/29,Ks=6/29,Zu=3*Ks*Ks,Zd=Ks*Ks*Ks,qd=Math.PI/180,Hd=180/Math.PI;function Jl(r){return(r%=360)<0&&(r+=360),r}function Ys([r,t,i,s]){let l,p;const f=ec((.2225045*(r=Ql(r))+.7168786*(t=Ql(t))+.0606169*(i=Ql(i)))/1);r===t&&t===i?l=p=f:(l=ec((.4360747*r+.3850649*t+.1430804*i)/Yl),p=ec((.0139322*r+.0971045*t+.7141733*i)/$u));const _=116*f-16;return[_<0?0:_,500*(l-f),200*(f-p),s]}function Ql(r){return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function ec(r){return r>Zd?Math.pow(r,1/3):r/Zu+Gu}function Js([r,t,i,s]){let l=(r+16)/116,p=isNaN(t)?l:l+t/500,f=isNaN(i)?l:l-i/200;return l=1*ic(l),p=Yl*ic(p),f=$u*ic(f),[tc(3.1338561*p-1.6168667*l-.4906146*f),tc(-.9787684*p+1.9161415*l+.033454*f),tc(.0719453*p-.2289914*l+1.4052427*f),s]}function tc(r){return(r=r<=.00304?12.92*r:1.055*Math.pow(r,1/2.4)-.055)<0?0:r>1?1:r}function ic(r){return r>Ks?r*r*r:Zu*(r-Gu)}const Wd=Object.hasOwn||function(r,t){return Object.prototype.hasOwnProperty.call(r,t)};function Qs(r,t){return Wd(r,t)?r[t]:void 0}function Lo(r){return parseInt(r.padEnd(2,r),16)/255}function rn(r,t){return zt(t?r/100:r,0,1)}function zt(r,t,i){return Math.min(Math.max(t,r),i)}function xs(r){return!r.some(Number.isNaN)}const Qn={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function An(r,t,i){return r+i*(t-r)}function bs(r,t,i){return r.map((s,l)=>An(s,t[l],i))}class Rt{constructor(t,i,s,l=1,p=!0){this.r=t,this.g=i,this.b=s,this.a=l,p||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[t,i,s,l]))}static parse(t){if(t instanceof Rt)return t;if(typeof t!="string")return;const i=function(s){if((s=s.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=Qs(Qn,s);if(l){const[f,_,y]=l;return[f/255,_/255,y/255,1]}if(s.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(s)){const f=s.length<6?1:2;let _=1;return[Lo(s.slice(_,_+=f)),Lo(s.slice(_,_+=f)),Lo(s.slice(_,_+=f)),Lo(s.slice(_,_+f)||"ff")]}if(s.startsWith("rgb")){const f=s.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(f){const[_,y,w,S,I,z,L,F,N,$,H,he]=f,ee=[S||" ",L||" ",$].join("");if(ee===" "||ee===" /"||ee===",,"||ee===",,,"){const re=[w,z,N].join(""),ve=re==="%%%"?100:re===""?255:0;if(ve){const we=[zt(+y/ve,0,1),zt(+I/ve,0,1),zt(+F/ve,0,1),H?rn(+H,he):1];if(xs(we))return we}}return}}const p=s.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[f,_,y,w,S,I,z,L,F]=p,N=[y||" ",S||" ",z].join("");if(N===" "||N===" /"||N===",,"||N===",,,"){const $=[+_,zt(+w,0,100),zt(+I,0,100),L?rn(+L,F):1];if(xs($))return function([H,he,ee,re]){function ve(we){const Ee=(we+H/30)%12,Ue=he*Math.min(ee,1-ee);return ee-Ue*Math.max(-1,Math.min(Ee-3,9-Ee,1))}return H=Jl(H),he/=100,ee/=100,[ve(0),ve(8),ve(4),re]}($)}}}(t);return i?new Rt(...i,!1):void 0}get rgb(){const{r:t,g:i,b:s,a:l}=this,p=l||1/0;return this.overwriteGetter("rgb",[t/p,i/p,s/p,l])}get hcl(){return this.overwriteGetter("hcl",function(t){const[i,s,l,p]=Ys(t),f=Math.sqrt(s*s+l*l);return[Math.round(1e4*f)?Jl(Math.atan2(l,s)*Hd):NaN,f,i,p]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Ys(this.rgb))}overwriteGetter(t,i){return Object.defineProperty(this,t,{value:i}),i}toString(){const[t,i,s,l]=this.rgb;return`rgba(${[t,i,s].map(p=>Math.round(255*p)).join(",")},${l})`}static interpolate(t,i,s,l="rgb"){switch(l){case"rgb":{const[p,f,_,y]=bs(t.rgb,i.rgb,s);return new Rt(p,f,_,y,!1)}case"hcl":{const[p,f,_,y]=t.hcl,[w,S,I,z]=i.hcl;let L,F;if(isNaN(p)||isNaN(w))isNaN(p)?isNaN(w)?L=NaN:(L=w,_!==1&&_!==0||(F=S)):(L=p,I!==1&&I!==0||(F=f));else{let ee=w-p;w>p&&ee>180?ee-=360:w<p&&p-w>180&&(ee+=360),L=p+s*ee}const[N,$,H,he]=function([ee,re,ve,we]){return ee=isNaN(ee)?0:ee*qd,Js([ve,Math.cos(ee)*re,Math.sin(ee)*re,we])}([L,F??An(f,S,s),An(_,I,s),An(y,z,s)]);return new Rt(N,$,H,he,!1)}case"lab":{const[p,f,_,y]=Js(bs(t.lab,i.lab,s));return new Rt(p,f,_,y,!1)}}}}Rt.black=new Rt(0,0,0,1),Rt.white=new Rt(1,1,1,1),Rt.transparent=new Rt(0,0,0,0),Rt.red=new Rt(1,0,0,1);class ws{constructor(t,i,s){this.sensitivity=t?i?"variant":"case":i?"accent":"base",this.locale=s,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,i){return this.collator.compare(t,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Ra=["bottom","center","top"];class Da{constructor(t,i,s,l,p,f){this.text=t,this.image=i,this.scale=s,this.fontStack=l,this.textColor=p,this.verticalAlign=f}}class mr{constructor(t){this.sections=t}static fromString(t){return new mr([new Da(t,null,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof mr?t:mr.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}}class qi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof qi)return t;if(typeof t=="number")return new qi([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const i of t)if(typeof i!="number")return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new qi(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){return new qi(bs(t.values,i.values,s))}}class gr{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof gr)return t;if(typeof t=="number")return new gr([t]);if(Array.isArray(t)){for(const i of t)if(typeof i!="number")return;return new gr(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){return new gr(bs(t.values,i.values,s))}}class zi{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof zi)return t;if(typeof t=="string"){const s=Rt.parse(t);return s?new zi([s]):void 0}if(!Array.isArray(t))return;const i=[];for(const s of t){if(typeof s!="string")return;const l=Rt.parse(s);if(!l)return;i.push(l)}return new zi(i)}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s,l="rgb"){const p=[];if(t.values.length!=i.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let f=0;f<t.values.length;f++)p.push(Rt.interpolate(t.values[f],i.values[f],s,l));return new zi(p)}}class ni extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}}const qu=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class _r{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof _r)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let i=0;i<t.length;i+=2){const s=t[i],l=t[i+1];if(typeof s!="string"||!qu.has(s)||!Array.isArray(l)||l.length!==2||typeof l[0]!="number"||typeof l[1]!="number")return}return new _r(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,i,s){const l=t.values,p=i.values;if(l.length!==p.length)throw new ni(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${i.toString()}`);const f=[];for(let _=0;_<l.length;_+=2){if(l[_]!==p[_])throw new ni(`Cannot interpolate values containing mismatched anchors. from[${_}]: ${l[_]}, to[${_}]: ${p[_]}`);f.push(l[_]);const[y,w]=l[_+1],[S,I]=p[_+1];f.push([An(y,S,s),An(w,I,s)])}return new _r(f)}}class Fr{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Fr({name:t,available:!1}):null}}class ur{constructor(t,i,s){this.from=t,this.to=i,this.transition=s}static interpolate(t,i,s){return new ur(t,i,s)}static parse(t){return t instanceof ur?t:Array.isArray(t)&&t.length===3&&typeof t[0]=="string"&&typeof t[1]=="string"&&typeof t[2]=="number"?new ur(t[0],t[1],t[2]):typeof t=="object"&&typeof t.from=="string"&&typeof t.to=="string"&&typeof t.transition=="number"?new ur(t.from,t.to,t.transition):typeof t=="string"?new ur(t,t,1):void 0}}function ci(r,t,i,s){return typeof r=="number"&&r>=0&&r<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof i=="number"&&i>=0&&i<=255?s===void 0||typeof s=="number"&&s>=0&&s<=1?null:`Invalid rgba value [${[r,t,i,s].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof s=="number"?[r,t,i,s]:[r,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ts(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof ur||r instanceof Rt||r instanceof ws||r instanceof mr||r instanceof qi||r instanceof gr||r instanceof zi||r instanceof _r||r instanceof Fr)return!0;if(Array.isArray(r)){for(const t of r)if(!Ts(t))return!1;return!0}if(typeof r=="object"){for(const t in r)if(!Ts(r[t]))return!1;return!0}return!1}function pt(r){if(r===null)return Ws;if(typeof r=="string")return kt;if(typeof r=="boolean")return Pt;if(typeof r=="number")return Ze;if(r instanceof Rt)return ir;if(r instanceof ur)return vs;if(r instanceof ws)return Aa;if(r instanceof mr)return Kn;if(r instanceof qi)return ka;if(r instanceof gr)return Xs;if(r instanceof zi)return bn;if(r instanceof _r)return za;if(r instanceof Fr)return wi;if(Array.isArray(r)){const t=r.length;let i;for(const s of r){const l=pt(s);if(i){if(i===l)continue;i=wt;break}i=l}return Mr(i||wt,t)}return Xn}function vt(r){const t=typeof r;return r===null?"":t==="string"||t==="number"||t==="boolean"?String(r):r instanceof Rt||r instanceof ur||r instanceof mr||r instanceof qi||r instanceof gr||r instanceof zi||r instanceof _r||r instanceof Fr?r.toString():JSON.stringify(r)}class kn{constructor(t,i){this.type=t,this.value=i}static parse(t,i){if(t.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ts(t[1]))return i.error("invalid value");const s=t[1];let l=pt(s);const p=i.expectedType;return l.kind!=="array"||l.N!==0||!p||p.kind!=="array"||typeof p.N=="number"&&p.N!==0||(l=p),new kn(l,s)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const $t={string:kt,number:Ze,boolean:Pt,object:Xn};class Br{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let s,l=1;const p=t[0];if(p==="array"){let _,y;if(t.length>2){const w=t[1];if(typeof w!="string"||!(w in $t)||w==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);_=$t[w],l++}else _=wt;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return i.error('The length argument to "array" must be a positive integer literal',2);y=t[2],l++}s=Mr(_,y)}else{if(!$t[p])throw new Error(`Types doesn't contain name = ${p}`);s=$t[p]}const f=[];for(;l<t.length;l++){const _=i.parse(t[l],l,wt);if(!_)return null;f.push(_)}return new Br(s,f)}evaluate(t){for(let i=0;i<this.args.length;i++){const s=this.args[i].evaluate(t);if(!Do(this.type,pt(s)))return s;if(i===this.args.length-1)throw new ni(`Expected value to be of type ${ri(this.type)}, but found ${ri(pt(s))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const wn={"to-boolean":Pt,"to-color":ir,"to-number":Ze,"to-string":kt};class Tn{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const s=t[0];if(!wn[s])throw new Error(`Can't parse ${s} as it is not part of the known types`);if((s==="to-boolean"||s==="to-string")&&t.length!==2)return i.error("Expected one argument.");const l=wn[s],p=[];for(let f=1;f<t.length;f++){const _=i.parse(t[f],f,wt);if(!_)return null;p.push(_)}return new Tn(l,p)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let i,s;for(const l of this.args){if(i=l.evaluate(t),s=null,i instanceof Rt)return i;if(typeof i=="string"){const p=t.parseColor(i);if(p)return p}else if(Array.isArray(i)&&(s=i.length<3||i.length>4?`Invalid rgba value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:ci(i[0],i[1],i[2],i[3]),!s))return new Rt(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new ni(s||`Could not parse color from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"padding":{let i;for(const s of this.args){i=s.evaluate(t);const l=qi.parse(i);if(l)return l}throw new ni(`Could not parse padding from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"numberArray":{let i;for(const s of this.args){i=s.evaluate(t);const l=gr.parse(i);if(l)return l}throw new ni(`Could not parse numberArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"colorArray":{let i;for(const s of this.args){i=s.evaluate(t);const l=zi.parse(i);if(l)return l}throw new ni(`Could not parse colorArray from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"variableAnchorOffsetCollection":{let i;for(const s of this.args){i=s.evaluate(t);const l=_r.parse(i);if(l)return l}throw new ni(`Could not parse variableAnchorOffsetCollection from value '${typeof i=="string"?i:JSON.stringify(i)}'`)}case"number":{let i=null;for(const s of this.args){if(i=s.evaluate(t),i===null)return 0;const l=Number(i);if(!isNaN(l))return l}throw new ni(`Could not convert ${JSON.stringify(i)} to number.`)}case"formatted":return mr.fromString(vt(this.args[0].evaluate(t)));case"resolvedImage":return Fr.fromString(vt(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return vt(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}const La=["Unknown","Point","LineString","Polygon"];class rc{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?La[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let i=this._parseColorCache.get(t);return i||(i=Rt.parse(t),this._parseColorCache.set(t,i)),i}}class eo{constructor(t,i,s=[],l,p=new Wn,f=[]){this.registry=t,this.path=s,this.key=s.map(_=>`[${_}]`).join(""),this.scope=p,this.errors=f,this.expectedType=l,this._isConstant=i}parse(t,i,s,l,p={}){return i?this.concat(i,s,l)._parse(t,p):this._parse(t,p)}_parse(t,i){function s(l,p,f){return f==="assert"?new Br(p,[l]):f==="coerce"?new Tn(p,[l]):l}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=t[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const p=this.registry[l];if(p){let f=p.parse(t,this);if(!f)return null;if(this.expectedType){const _=this.expectedType,y=f.type;if(_.kind!=="string"&&_.kind!=="number"&&_.kind!=="boolean"&&_.kind!=="object"&&_.kind!=="array"||y.kind!=="value"){if(_.kind==="projectionDefinition"&&["string","array"].includes(y.kind)||["color","formatted","resolvedImage"].includes(_.kind)&&["value","string"].includes(y.kind)||["padding","numberArray"].includes(_.kind)&&["value","number","array"].includes(y.kind)||_.kind==="colorArray"&&["value","string","array"].includes(y.kind)||_.kind==="variableAnchorOffsetCollection"&&["value","array"].includes(y.kind))f=s(f,_,i.typeAnnotation||"coerce");else if(this.checkSubtype(_,y))return null}else f=s(f,_,i.typeAnnotation||"assert")}if(!(f instanceof kn)&&f.type.kind!=="resolvedImage"&&this._isConstant(f)){const _=new rc;try{f=new kn(f.type,f.evaluate(_))}catch(y){return this.error(y.message),null}}return f}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,i,s){const l=typeof t=="number"?this.path.concat(t):this.path,p=s?this.scope.concat(s):this.scope;return new eo(this.registry,this._isConstant,l,i||null,p,this.errors)}error(t,...i){const s=`${this.key}${i.map(l=>`[${l}]`).join("")}`;this.errors.push(new gi(s,t))}checkSubtype(t,i){const s=Do(t,i);return s&&this.error(s),s}}class Fo{constructor(t,i){this.type=i.type,this.bindings=[].concat(t),this.result=i}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const i of this.bindings)t(i[1]);t(this.result)}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const s=[];for(let p=1;p<t.length-1;p+=2){const f=t[p];if(typeof f!="string")return i.error(`Expected string, but found ${typeof f} instead.`,p);if(/[^a-zA-Z0-9_]/.test(f))return i.error("Variable names must contain only alphanumeric characters or '_'.",p);const _=i.parse(t[p+1],p+1);if(!_)return null;s.push([f,_])}const l=i.parse(t[t.length-1],t.length-1,i.expectedType,s);return l?new Fo(s,l):null}outputDefined(){return this.result.outputDefined()}}class Fa{constructor(t,i){this.type=i.type,this.name=t,this.boundExpression=i}static parse(t,i){if(t.length!==2||typeof t[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const s=t[1];return i.scope.has(s)?new Fa(s,i.scope.get(s)):i.error(`Unknown variable "${s}". Make sure "${s}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class Ba{constructor(t,i,s){this.type=t,this.index=i,this.input=s}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,Ze),l=i.parse(t[2],2,Mr(i.expectedType||wt));return s&&l?new Ba(l.type.itemType,s,l):null}evaluate(t){const i=this.index.evaluate(t),s=this.input.evaluate(t);if(i<0)throw new ni(`Array index out of bounds: ${i} < 0.`);if(i>=s.length)throw new ni(`Array index out of bounds: ${i} > ${s.length-1}.`);if(i!==Math.floor(i))throw new ni(`Array index must be an integer, but found ${i} instead.`);return s[i]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class Oa{constructor(t,i){this.type=Pt,this.needle=t,this.haystack=i}static parse(t,i){if(t.length!==3)return i.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,wt),l=i.parse(t[2],2,wt);return s&&l?Kl(s.type,[Pt,kt,Ze,Ws,wt])?new Oa(s,l):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${ri(s.type)} instead`):null}evaluate(t){const i=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!s)return!1;if(!Yn(i,["boolean","string","number","null"]))throw new ni(`Expected first argument to be of type boolean, string, number or null, but found ${ri(pt(i))} instead.`);if(!Yn(s,["string","array"]))throw new ni(`Expected second argument to be of type array or string, but found ${ri(pt(s))} instead.`);return s.indexOf(i)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class nn{constructor(t,i,s){this.type=Ze,this.needle=t,this.haystack=i,this.fromIndex=s}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,wt),l=i.parse(t[2],2,wt);if(!s||!l)return null;if(!Kl(s.type,[Pt,kt,Ze,Ws,wt]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${ri(s.type)} instead`);if(t.length===4){const p=i.parse(t[3],3,Ze);return p?new nn(s,l,p):null}return new nn(s,l)}evaluate(t){const i=this.needle.evaluate(t),s=this.haystack.evaluate(t);if(!Yn(i,["boolean","string","number","null"]))throw new ni(`Expected first argument to be of type boolean, string, number or null, but found ${ri(pt(i))} instead.`);let l;if(this.fromIndex&&(l=this.fromIndex.evaluate(t)),Yn(s,["string"])){const p=s.indexOf(i,l);return p===-1?-1:[...s.slice(0,p)].length}if(Yn(s,["array"]))return s.indexOf(i,l);throw new ni(`Expected second argument to be of type array or string, but found ${ri(pt(s))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class Hi{constructor(t,i,s,l,p,f){this.inputType=t,this.type=i,this.input=s,this.cases=l,this.outputs=p,this.otherwise=f}static parse(t,i){if(t.length<5)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return i.error("Expected an even number of arguments.");let s,l;i.expectedType&&i.expectedType.kind!=="value"&&(l=i.expectedType);const p={},f=[];for(let w=2;w<t.length-1;w+=2){let S=t[w];const I=t[w+1];Array.isArray(S)||(S=[S]);const z=i.concat(w);if(S.length===0)return z.error("Expected at least one branch label.");for(const F of S){if(typeof F!="number"&&typeof F!="string")return z.error("Branch labels must be numbers or strings.");if(typeof F=="number"&&Math.abs(F)>Number.MAX_SAFE_INTEGER)return z.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof F=="number"&&Math.floor(F)!==F)return z.error("Numeric branch labels must be integer values.");if(s){if(z.checkSubtype(s,pt(F)))return null}else s=pt(F);if(p[String(F)]!==void 0)return z.error("Branch labels must be unique.");p[String(F)]=f.length}const L=i.parse(I,w,l);if(!L)return null;l=l||L.type,f.push(L)}const _=i.parse(t[1],1,wt);if(!_)return null;const y=i.parse(t[t.length-1],t.length-1,l);return y?_.type.kind!=="value"&&i.concat(1).checkSubtype(s,_.type)?null:new Hi(s,l,_,p,f,y):null}evaluate(t){const i=this.input.evaluate(t);return(pt(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}}class to{constructor(t,i,s){this.type=t,this.branches=i,this.otherwise=s}static parse(t,i){if(t.length<4)return i.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return i.error("Expected an odd number of arguments.");let s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const l=[];for(let f=1;f<t.length-1;f+=2){const _=i.parse(t[f],f,Pt);if(!_)return null;const y=i.parse(t[f+1],f+1,s);if(!y)return null;l.push([_,y]),s=s||y.type}const p=i.parse(t[t.length-1],t.length-1,s);if(!p)return null;if(!s)throw new Error("Can't infer output type");return new to(s,l,p)}evaluate(t){for(const[i,s]of this.branches)if(i.evaluate(t))return s.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[i,s]of this.branches)t(i),t(s);t(this.otherwise)}outputDefined(){return this.branches.every(([t,i])=>i.outputDefined())&&this.otherwise.outputDefined()}}class Bo{constructor(t,i,s,l){this.type=t,this.input=i,this.beginIndex=s,this.endIndex=l}static parse(t,i){if(t.length<=2||t.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const s=i.parse(t[1],1,wt),l=i.parse(t[2],2,Ze);if(!s||!l)return null;if(!Kl(s.type,[Mr(wt),kt,wt]))return i.error(`Expected first argument to be of type array or string, but found ${ri(s.type)} instead`);if(t.length===4){const p=i.parse(t[3],3,Ze);return p?new Bo(s.type,s,l,p):null}return new Bo(s.type,s,l)}evaluate(t){const i=this.input.evaluate(t),s=this.beginIndex.evaluate(t);let l;if(this.endIndex&&(l=this.endIndex.evaluate(t)),Yn(i,["string"]))return[...i].slice(s,l).join("");if(Yn(i,["array"]))return i.slice(s,l);throw new ni(`Expected first argument to be of type array or string, but found ${ri(pt(i))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function Ss(r,t){const i=r.length-1;let s,l,p=0,f=i,_=0;for(;p<=f;)if(_=Math.floor((p+f)/2),s=r[_],l=r[_+1],s<=t){if(_===i||t<l)return _;p=_+1}else{if(!(s>t))throw new ni("Input is not a number.");f=_-1}return 0}class Ti{constructor(t,i,s){this.type=t,this.input=i,this.labels=[],this.outputs=[];for(const[l,p]of s)this.labels.push(l),this.outputs.push(p)}static parse(t,i){if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");const s=i.parse(t[1],1,Ze);if(!s)return null;const l=[];let p=null;i.expectedType&&i.expectedType.kind!=="value"&&(p=i.expectedType);for(let f=1;f<t.length;f+=2){const _=f===1?-1/0:t[f],y=t[f+1],w=f,S=f+1;if(typeof _!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',w);if(l.length&&l[l.length-1][0]>=_)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',w);const I=i.parse(y,S,p);if(!I)return null;p=p||I.type,l.push([_,I])}return new Ti(p,s,l)}evaluate(t){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=i[0])return s[0].evaluate(t);const p=i.length;return l>=i[p-1]?s[p-1].evaluate(t):s[Ss(i,l)].evaluate(t)}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function Hu(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Oo,nc,Xd=function(){if(nc)return Oo;function r(t,i,s,l){this.cx=3*t,this.bx=3*(s-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*i,this.by=3*(l-i)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=i,this.p2x=s,this.p2y=l}return nc=1,Oo=r,r.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,i){if(i===void 0&&(i=1e-6),t<0)return 0;if(t>1)return 1;for(var s=t,l=0;l<8;l++){var p=this.sampleCurveX(s)-t;if(Math.abs(p)<i)return s;var f=this.sampleCurveDerivativeX(s);if(Math.abs(f)<1e-6)break;s-=p/f}var _=0,y=1;for(s=t,l=0;l<20&&(p=this.sampleCurveX(s),!(Math.abs(p-t)<i));l++)t>p?_=s:y=s,s=.5*(y-_)+_;return s},solve:function(t,i){return this.sampleCurveY(this.solveCurveX(t,i))}},Oo}(),io=Hu(Xd);class rr{constructor(t,i,s,l,p){this.type=t,this.operator=i,this.interpolation=s,this.input=l,this.labels=[],this.outputs=[];for(const[f,_]of p)this.labels.push(f),this.outputs.push(_)}static interpolationFactor(t,i,s,l){let p=0;if(t.name==="exponential")p=jo(i,t.base,s,l);else if(t.name==="linear")p=jo(i,1,s,l);else if(t.name==="cubic-bezier"){const f=t.controlPoints;p=new io(f[0],f[1],f[2],f[3]).solve(jo(i,1,s,l))}return p}static parse(t,i){let[s,l,p,...f]=t;if(!Array.isArray(l)||l.length===0)return i.error("Expected an interpolation type expression.",1);if(l[0]==="linear")l={name:"linear"};else if(l[0]==="exponential"){const w=l[1];if(typeof w!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);l={name:"exponential",base:w}}else{if(l[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(l[0])}`,1,0);{const w=l.slice(1);if(w.length!==4||w.some(S=>typeof S!="number"||S<0||S>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:w}}}if(t.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(p=i.parse(p,2,Ze),!p)return null;const _=[];let y=null;s!=="interpolate-hcl"&&s!=="interpolate-lab"||i.expectedType==bn?i.expectedType&&i.expectedType.kind!=="value"&&(y=i.expectedType):y=ir;for(let w=0;w<f.length;w+=2){const S=f[w],I=f[w+1],z=w+3,L=w+4;if(typeof S!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',z);if(_.length&&_[_.length-1][0]>=S)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',z);const F=i.parse(I,L,y);if(!F)return null;y=y||F.type,_.push([S,F])}return Jn(y,Ze)||Jn(y,vs)||Jn(y,ir)||Jn(y,ka)||Jn(y,Xs)||Jn(y,bn)||Jn(y,za)||Jn(y,Mr(Ze))?new rr(y,s,l,p,_):i.error(`Type ${ri(y)} is not interpolatable.`)}evaluate(t){const i=this.labels,s=this.outputs;if(i.length===1)return s[0].evaluate(t);const l=this.input.evaluate(t);if(l<=i[0])return s[0].evaluate(t);const p=i.length;if(l>=i[p-1])return s[p-1].evaluate(t);const f=Ss(i,l),_=rr.interpolationFactor(this.interpolation,l,i[f],i[f+1]),y=s[f].evaluate(t),w=s[f+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return An(y,w,_);case"color":return Rt.interpolate(y,w,_);case"padding":return qi.interpolate(y,w,_);case"colorArray":return zi.interpolate(y,w,_);case"numberArray":return gr.interpolate(y,w,_);case"variableAnchorOffsetCollection":return _r.interpolate(y,w,_);case"array":return bs(y,w,_);case"projectionDefinition":return ur.interpolate(y,w,_)}case"interpolate-hcl":switch(this.type.kind){case"color":return Rt.interpolate(y,w,_,"hcl");case"colorArray":return zi.interpolate(y,w,_,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Rt.interpolate(y,w,_,"lab");case"colorArray":return zi.interpolate(y,w,_,"lab")}}}eachChild(t){t(this.input);for(const i of this.outputs)t(i)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}}function jo(r,t,i,s){const l=s-i,p=r-i;return l===0?0:t===1?p/l:(Math.pow(t,p)-1)/(Math.pow(t,l)-1)}const Sn={color:Rt.interpolate,number:An,padding:qi.interpolate,numberArray:gr.interpolate,colorArray:zi.interpolate,variableAnchorOffsetCollection:_r.interpolate,array:bs};class No{constructor(t,i){this.type=t,this.args=i}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");let s=null;const l=i.expectedType;l&&l.kind!=="value"&&(s=l);const p=[];for(const _ of t.slice(1)){const y=i.parse(_,1+p.length,s,void 0,{typeAnnotation:"omit"});if(!y)return null;s=s||y.type,p.push(y)}if(!s)throw new Error("No output type");const f=l&&p.some(_=>Do(l,_.type));return new No(f?wt:s,p)}evaluate(t){let i,s=null,l=0;for(const p of this.args)if(l++,s=p.evaluate(t),s&&s instanceof Fr&&!s.available&&(i||(i=s.name),s=null,l===this.args.length&&(s=i)),s!==null)break;return s}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}}function Vo(r,t){return r==="=="||r==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function Uo(r,t,i,s){return s.compare(t,i)===0}function hr(r,t,i){const s=r!=="=="&&r!=="!=";return class X_{constructor(p,f,_){this.type=Pt,this.lhs=p,this.rhs=f,this.collator=_,this.hasUntypedArgument=p.type.kind==="value"||f.type.kind==="value"}static parse(p,f){if(p.length!==3&&p.length!==4)return f.error("Expected two or three arguments.");const _=p[0];let y=f.parse(p[1],1,wt);if(!y)return null;if(!Vo(_,y.type))return f.concat(1).error(`"${_}" comparisons are not supported for type '${ri(y.type)}'.`);let w=f.parse(p[2],2,wt);if(!w)return null;if(!Vo(_,w.type))return f.concat(2).error(`"${_}" comparisons are not supported for type '${ri(w.type)}'.`);if(y.type.kind!==w.type.kind&&y.type.kind!=="value"&&w.type.kind!=="value")return f.error(`Cannot compare types '${ri(y.type)}' and '${ri(w.type)}'.`);s&&(y.type.kind==="value"&&w.type.kind!=="value"?y=new Br(w.type,[y]):y.type.kind!=="value"&&w.type.kind==="value"&&(w=new Br(y.type,[w])));let S=null;if(p.length===4){if(y.type.kind!=="string"&&w.type.kind!=="string"&&y.type.kind!=="value"&&w.type.kind!=="value")return f.error("Cannot use collator to compare non-string types.");if(S=f.parse(p[3],3,Aa),!S)return null}return new X_(y,w,S)}evaluate(p){const f=this.lhs.evaluate(p),_=this.rhs.evaluate(p);if(s&&this.hasUntypedArgument){const y=pt(f),w=pt(_);if(y.kind!==w.kind||y.kind!=="string"&&y.kind!=="number")throw new ni(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${y.kind}, ${w.kind}) instead.`)}if(this.collator&&!s&&this.hasUntypedArgument){const y=pt(f),w=pt(_);if(y.kind!=="string"||w.kind!=="string")return t(p,f,_)}return this.collator?i(p,f,_,this.collator.evaluate(p)):t(p,f,_)}eachChild(p){p(this.lhs),p(this.rhs),this.collator&&p(this.collator)}outputDefined(){return!0}}}const Wu=hr("==",function(r,t,i){return t===i},Uo),ja=hr("!=",function(r,t,i){return t!==i},function(r,t,i,s){return!Uo(0,t,i,s)}),Kd=hr("<",function(r,t,i){return t<i},function(r,t,i,s){return s.compare(t,i)<0}),sc=hr(">",function(r,t,i){return t>i},function(r,t,i,s){return s.compare(t,i)>0}),Yd=hr("<=",function(r,t,i){return t<=i},function(r,t,i,s){return s.compare(t,i)<=0}),Jd=hr(">=",function(r,t,i){return t>=i},function(r,t,i,s){return s.compare(t,i)>=0});class Na{constructor(t,i,s){this.type=Aa,this.locale=s,this.caseSensitive=t,this.diacriticSensitive=i}static parse(t,i){if(t.length!==2)return i.error("Expected one argument.");const s=t[1];if(typeof s!="object"||Array.isArray(s))return i.error("Collator options argument must be an object.");const l=i.parse(s["case-sensitive"]!==void 0&&s["case-sensitive"],1,Pt);if(!l)return null;const p=i.parse(s["diacritic-sensitive"]!==void 0&&s["diacritic-sensitive"],1,Pt);if(!p)return null;let f=null;return s.locale&&(f=i.parse(s.locale,1,kt),!f)?null:new Na(l,p,f)}evaluate(t){return new ws(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class oc{constructor(t,i,s,l,p){this.type=kt,this.number=t,this.locale=i,this.currency=s,this.minFractionDigits=l,this.maxFractionDigits=p}static parse(t,i){if(t.length!==3)return i.error("Expected two arguments.");const s=i.parse(t[1],1,Ze);if(!s)return null;const l=t[2];if(typeof l!="object"||Array.isArray(l))return i.error("NumberFormat options argument must be an object.");let p=null;if(l.locale&&(p=i.parse(l.locale,1,kt),!p))return null;let f=null;if(l.currency&&(f=i.parse(l.currency,1,kt),!f))return null;let _=null;if(l["min-fraction-digits"]&&(_=i.parse(l["min-fraction-digits"],1,Ze),!_))return null;let y=null;return l["max-fraction-digits"]&&(y=i.parse(l["max-fraction-digits"],1,Ze),!y)?null:new oc(s,p,f,_,y)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ps{constructor(t){this.type=Kn,this.sections=t}static parse(t,i){if(t.length<2)return i.error("Expected at least one argument.");const s=t[1];if(!Array.isArray(s)&&typeof s=="object")return i.error("First argument must be an image or text section.");const l=[];let p=!1;for(let f=1;f<=t.length-1;++f){const _=t[f];if(p&&typeof _=="object"&&!Array.isArray(_)){p=!1;let y=null;if(_["font-scale"]&&(y=i.parse(_["font-scale"],1,Ze),!y))return null;let w=null;if(_["text-font"]&&(w=i.parse(_["text-font"],1,Mr(kt)),!w))return null;let S=null;if(_["text-color"]&&(S=i.parse(_["text-color"],1,ir),!S))return null;let I=null;if(_["vertical-align"]){if(typeof _["vertical-align"]=="string"&&!Ra.includes(_["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${_["vertical-align"]}' instead.`);if(I=i.parse(_["vertical-align"],1,kt),!I)return null}const z=l[l.length-1];z.scale=y,z.font=w,z.textColor=S,z.verticalAlign=I}else{const y=i.parse(t[f],1,wt);if(!y)return null;const w=y.type.kind;if(w!=="string"&&w!=="value"&&w!=="null"&&w!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");p=!0,l.push({content:y,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Ps(l)}evaluate(t){return new mr(this.sections.map(i=>{const s=i.content.evaluate(t);return pt(s)===wi?new Da("",s,null,null,null,i.verticalAlign?i.verticalAlign.evaluate(t):null):new Da(vt(s),null,i.scale?i.scale.evaluate(t):null,i.font?i.font.evaluate(t).join(","):null,i.textColor?i.textColor.evaluate(t):null,i.verticalAlign?i.verticalAlign.evaluate(t):null)}))}eachChild(t){for(const i of this.sections)t(i.content),i.scale&&t(i.scale),i.font&&t(i.font),i.textColor&&t(i.textColor),i.verticalAlign&&t(i.verticalAlign)}outputDefined(){return!1}}class ac{constructor(t){this.type=wi,this.input=t}static parse(t,i){if(t.length!==2)return i.error("Expected two arguments.");const s=i.parse(t[1],1,kt);return s?new ac(s):i.error("No image name provided.")}evaluate(t){const i=this.input.evaluate(t),s=Fr.fromString(i);return s&&t.availableImages&&(s.available=t.availableImages.indexOf(i)>-1),s}eachChild(t){t(this.input)}outputDefined(){return!1}}class Va{constructor(t){this.type=Ze,this.input=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=i.parse(t[1],1);return s?s.type.kind!=="array"&&s.type.kind!=="string"&&s.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${ri(s.type)} instead.`):new Va(s):null}evaluate(t){const i=this.input.evaluate(t);if(typeof i=="string")return[...i].length;if(Array.isArray(i))return i.length;throw new ni(`Expected value to be of type string or array, but found ${ri(pt(i))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const sn=8192;function Qd(r,t){const i=(180+r[0])/360,s=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,l=Math.pow(2,t.z);return[Math.round(i*l*sn),Math.round(s*l*sn)]}function Ua(r,t){const i=Math.pow(2,t.z);return[(l=(r[0]/sn+t.x)/i,360*l-180),(s=(r[1]/sn+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90)];var s,l}function $o(r,t){r[0]=Math.min(r[0],t[0]),r[1]=Math.min(r[1],t[1]),r[2]=Math.max(r[2],t[0]),r[3]=Math.max(r[3],t[1])}function Go(r,t){return!(r[0]<=t[0]||r[2]>=t[2]||r[1]<=t[1]||r[3]>=t[3])}function ep(r,t,i){const s=r[0]-t[0],l=r[1]-t[1],p=r[0]-i[0],f=r[1]-i[1];return s*f-p*l==0&&s*p<=0&&l*f<=0}function $a(r,t,i,s){return(l=[s[0]-i[0],s[1]-i[1]])[0]*(p=[t[0]-r[0],t[1]-r[1]])[1]-l[1]*p[0]!=0&&!(!Ku(r,t,i,s)||!Ku(i,s,r,t));var l,p}function tp(r,t,i){for(const s of i)for(let l=0;l<s.length-1;++l)if($a(r,t,s[l],s[l+1]))return!0;return!1}function Ms(r,t,i=!1){let s=!1;for(const _ of t)for(let y=0;y<_.length-1;y++){if(ep(r,_[y],_[y+1]))return i;(p=_[y])[1]>(l=r)[1]!=(f=_[y+1])[1]>l[1]&&l[0]<(f[0]-p[0])*(l[1]-p[1])/(f[1]-p[1])+p[0]&&(s=!s)}var l,p,f;return s}function Xu(r,t){for(const i of t)if(Ms(r,i))return!0;return!1}function lc(r,t){for(const i of r)if(!Ms(i,t))return!1;for(let i=0;i<r.length-1;++i)if(tp(r[i],r[i+1],t))return!1;return!0}function ip(r,t){for(const i of t)if(lc(r,i))return!0;return!1}function Ku(r,t,i,s){const l=s[0]-i[0],p=s[1]-i[1],f=(r[0]-i[0])*p-l*(r[1]-i[1]),_=(t[0]-i[0])*p-l*(t[1]-i[1]);return f>0&&_<0||f<0&&_>0}function cc(r,t,i){const s=[];for(let l=0;l<r.length;l++){const p=[];for(let f=0;f<r[l].length;f++){const _=Qd(r[l][f],i);$o(t,_),p.push(_)}s.push(p)}return s}function Yu(r,t,i){const s=[];for(let l=0;l<r.length;l++){const p=cc(r[l],t,i);s.push(p)}return s}function Ga(r,t,i,s){if(r[0]<i[0]||r[0]>i[2]){const l=.5*s;let p=r[0]-i[0]>l?-s:i[0]-r[0]>l?s:0;p===0&&(p=r[0]-i[2]>l?-s:i[2]-r[0]>l?s:0),r[0]+=p}$o(t,r)}function Ju(r,t,i,s){const l=Math.pow(2,s.z)*sn,p=[s.x*sn,s.y*sn],f=[];for(const _ of r)for(const y of _){const w=[y.x+p[0],y.y+p[1]];Ga(w,t,i,l),f.push(w)}return f}function Qu(r,t,i,s){const l=Math.pow(2,s.z)*sn,p=[s.x*sn,s.y*sn],f=[];for(const y of r){const w=[];for(const S of y){const I=[S.x+p[0],S.y+p[1]];$o(t,I),w.push(I)}f.push(w)}if(t[2]-t[0]<=l/2){(_=t)[0]=_[1]=1/0,_[2]=_[3]=-1/0;for(const y of f)for(const w of y)Ga(w,t,i,l)}var _;return f}class Cs{constructor(t,i){this.type=Pt,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ts(t[1])){const s=t[1];if(s.type==="FeatureCollection"){const l=[];for(const p of s.features){const{type:f,coordinates:_}=p.geometry;f==="Polygon"&&l.push(_),f==="MultiPolygon"&&l.push(..._)}if(l.length)return new Cs(s,{type:"MultiPolygon",coordinates:l})}else if(s.type==="Feature"){const l=s.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Cs(s,s.geometry)}else if(s.type==="Polygon"||s.type==="MultiPolygon")return new Cs(s,s)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(i,s){const l=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=i.canonicalID();if(s.type==="Polygon"){const _=cc(s.coordinates,p,f),y=Ju(i.geometry(),l,p,f);if(!Go(l,p))return!1;for(const w of y)if(!Ms(w,_))return!1}if(s.type==="MultiPolygon"){const _=Yu(s.coordinates,p,f),y=Ju(i.geometry(),l,p,f);if(!Go(l,p))return!1;for(const w of y)if(!Xu(w,_))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,s){const l=[1/0,1/0,-1/0,-1/0],p=[1/0,1/0,-1/0,-1/0],f=i.canonicalID();if(s.type==="Polygon"){const _=cc(s.coordinates,p,f),y=Qu(i.geometry(),l,p,f);if(!Go(l,p))return!1;for(const w of y)if(!lc(w,_))return!1}if(s.type==="MultiPolygon"){const _=Yu(s.coordinates,p,f),y=Qu(i.geometry(),l,p,f);if(!Go(l,p))return!1;for(const w of y)if(!ip(w,_))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let uc=class{constructor(r=[],t=(i,s)=>i<s?-1:i>s?1:0){if(this.data=r,this.length=this.data.length,this.compare=t,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(r){this.data.push(r),this._up(this.length++)}pop(){if(this.length===0)return;const r=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),r}peek(){return this.data[0]}_up(r){const{data:t,compare:i}=this,s=t[r];for(;r>0;){const l=r-1>>1,p=t[l];if(i(s,p)>=0)break;t[r]=p,r=l}t[r]=s}_down(r){const{data:t,compare:i}=this,s=this.length>>1,l=t[r];for(;r<s;){let p=1+(r<<1);const f=p+1;if(f<this.length&&i(t[f],t[p])<0&&(p=f),i(t[p],l)>=0)break;t[r]=t[p],r=p}t[r]=l}};function hc(r,t,i=0,s=r.length-1,l=rp){for(;s>i;){if(s-i>600){const y=s-i+1,w=t-i+1,S=Math.log(y),I=.5*Math.exp(2*S/3),z=.5*Math.sqrt(S*I*(y-I)/y)*(w-y/2<0?-1:1);hc(r,t,Math.max(i,Math.floor(t-w*I/y+z)),Math.min(s,Math.floor(t+(y-w)*I/y+z)),l)}const p=r[t];let f=i,_=s;for(Zo(r,i,t),l(r[s],p)>0&&Zo(r,i,s);f<_;){for(Zo(r,f,_),f++,_--;l(r[f],p)<0;)f++;for(;l(r[_],p)>0;)_--}l(r[i],p)===0?Zo(r,i,_):(_++,Zo(r,_,s)),_<=t&&(i=_+1),t<=_&&(s=_-1)}}function Zo(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}function rp(r,t){return r<t?-1:r>t?1:0}function qo(r,t){if(r.length<=1)return[r];const i=[];let s,l;for(const p of r){const f=np(p);f!==0&&(p.area=Math.abs(f),l===void 0&&(l=f<0),l===f<0?(s&&i.push(s),s=[p]):s.push(p))}if(s&&i.push(s),t>1)for(let p=0;p<i.length;p++)i[p].length<=t||(hc(i[p],t,1,i[p].length-1,eh),i[p]=i[p].slice(0,t));return i}function eh(r,t){return t.area-r.area}function np(r){let t=0;for(let i,s,l=0,p=r.length,f=p-1;l<p;f=l++)i=r[l],s=r[f],t+=(s.x-i.x)*(i.y+s.y);return t}const th=1/298.257223563,ih=th*(2-th),dc=Math.PI/180;class pc{constructor(t){const i=6378.137*dc*1e3,s=Math.cos(t*dc),l=1/(1-ih*(1-s*s)),p=Math.sqrt(l);this.kx=i*p*s,this.ky=i*p*l*(1-ih)}distance(t,i){const s=this.wrap(t[0]-i[0])*this.kx,l=(t[1]-i[1])*this.ky;return Math.sqrt(s*s+l*l)}pointOnLine(t,i){let s,l,p,f,_=1/0;for(let y=0;y<t.length-1;y++){let w=t[y][0],S=t[y][1],I=this.wrap(t[y+1][0]-w)*this.kx,z=(t[y+1][1]-S)*this.ky,L=0;I===0&&z===0||(L=(this.wrap(i[0]-w)*this.kx*I+(i[1]-S)*this.ky*z)/(I*I+z*z),L>1?(w=t[y+1][0],S=t[y+1][1]):L>0&&(w+=I/this.kx*L,S+=z/this.ky*L)),I=this.wrap(i[0]-w)*this.kx,z=(i[1]-S)*this.ky;const F=I*I+z*z;F<_&&(_=F,s=w,l=S,p=y,f=L)}return{point:[s,l],index:p,t:Math.max(0,Math.min(1,f))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function rh(r,t){return t[0]-r[0]}function Za(r){return r[1]-r[0]+1}function zn(r,t){return r[1]>=r[0]&&r[1]<t}function qt(r,t){if(r[0]>r[1])return[null,null];const i=Za(r);if(t){if(i===2)return[r,null];const l=Math.floor(i/2);return[[r[0],r[0]+l],[r[0]+l,r[1]]]}if(i===1)return[r,null];const s=Math.floor(i/2)-1;return[[r[0],r[0]+s],[r[0]+s+1,r[1]]]}function fc(r,t){if(!zn(t,r.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let s=t[0];s<=t[1];++s)$o(i,r[s]);return i}function mc(r){const t=[1/0,1/0,-1/0,-1/0];for(const i of r)for(const s of i)$o(t,s);return t}function nh(r){return r[0]!==-1/0&&r[1]!==-1/0&&r[2]!==1/0&&r[3]!==1/0}function gc(r,t,i){if(!nh(r)||!nh(t))return NaN;let s=0,l=0;return r[2]<t[0]&&(s=t[0]-r[2]),r[0]>t[2]&&(s=r[0]-t[2]),r[1]>t[3]&&(l=r[1]-t[3]),r[3]<t[1]&&(l=t[1]-r[3]),i.distance([0,0],[s,l])}function Is(r,t,i){const s=i.pointOnLine(t,r);return i.distance(r,s.point)}function _c(r,t,i,s,l){const p=Math.min(Is(r,[i,s],l),Is(t,[i,s],l)),f=Math.min(Is(i,[r,t],l),Is(s,[r,t],l));return Math.min(p,f)}function sp(r,t,i,s,l){if(!zn(t,r.length)||!zn(s,i.length))return 1/0;let p=1/0;for(let f=t[0];f<t[1];++f){const _=r[f],y=r[f+1];for(let w=s[0];w<s[1];++w){const S=i[w],I=i[w+1];if($a(_,y,S,I))return 0;p=Math.min(p,_c(_,y,S,I,l))}}return p}function op(r,t,i,s,l){if(!zn(t,r.length)||!zn(s,i.length))return NaN;let p=1/0;for(let f=t[0];f<=t[1];++f)for(let _=s[0];_<=s[1];++_)if(p=Math.min(p,l.distance(r[f],i[_])),p===0)return p;return p}function ap(r,t,i){if(Ms(r,t,!0))return 0;let s=1/0;for(const l of t){const p=l[0],f=l[l.length-1];if(p!==f&&(s=Math.min(s,Is(r,[f,p],i)),s===0))return s;const _=i.pointOnLine(l,r);if(s=Math.min(s,i.distance(r,_.point)),s===0)return s}return s}function lp(r,t,i,s){if(!zn(t,r.length))return NaN;for(let p=t[0];p<=t[1];++p)if(Ms(r[p],i,!0))return 0;let l=1/0;for(let p=t[0];p<t[1];++p){const f=r[p],_=r[p+1];for(const y of i)for(let w=0,S=y.length,I=S-1;w<S;I=w++){const z=y[I],L=y[w];if($a(f,_,z,L))return 0;l=Math.min(l,_c(f,_,z,L,s))}}return l}function sh(r,t){for(const i of r)for(const s of i)if(Ms(s,t,!0))return!0;return!1}function cp(r,t,i,s=1/0){const l=mc(r),p=mc(t);if(s!==1/0&&gc(l,p,i)>=s)return s;if(Go(l,p)){if(sh(r,t))return 0}else if(sh(t,r))return 0;let f=1/0;for(const _ of r)for(let y=0,w=_.length,S=w-1;y<w;S=y++){const I=_[S],z=_[y];for(const L of t)for(let F=0,N=L.length,$=N-1;F<N;$=F++){const H=L[$],he=L[F];if($a(I,z,H,he))return 0;f=Math.min(f,_c(I,z,H,he,i))}}return f}function oh(r,t,i,s,l,p){if(!p)return;const f=gc(fc(s,p),l,i);f<t&&r.push([f,p,[0,0]])}function qa(r,t,i,s,l,p,f){if(!p||!f)return;const _=gc(fc(s,p),fc(l,f),i);_<t&&r.push([_,p,f])}function Ha(r,t,i,s,l=1/0){let p=Math.min(s.distance(r[0],i[0][0]),l);if(p===0)return p;const f=new uc([[0,[0,r.length-1],[0,0]]],rh),_=mc(i);for(;f.length>0;){const y=f.pop();if(y[0]>=p)continue;const w=y[1],S=t?50:100;if(Za(w)<=S){if(!zn(w,r.length))return NaN;if(t){const I=lp(r,w,i,s);if(isNaN(I)||I===0)return I;p=Math.min(p,I)}else for(let I=w[0];I<=w[1];++I){const z=ap(r[I],i,s);if(p=Math.min(p,z),p===0)return 0}}else{const I=qt(w,t);oh(f,p,s,r,_,I[0]),oh(f,p,s,r,_,I[1])}}return p}function Wa(r,t,i,s,l,p=1/0){let f=Math.min(p,l.distance(r[0],i[0]));if(f===0)return f;const _=new uc([[0,[0,r.length-1],[0,i.length-1]]],rh);for(;_.length>0;){const y=_.pop();if(y[0]>=f)continue;const w=y[1],S=y[2],I=t?50:100,z=s?50:100;if(Za(w)<=I&&Za(S)<=z){if(!zn(w,r.length)&&zn(S,i.length))return NaN;let L;if(t&&s)L=sp(r,w,i,S,l),f=Math.min(f,L);else if(t&&!s){const F=r.slice(w[0],w[1]+1);for(let N=S[0];N<=S[1];++N)if(L=Is(i[N],F,l),f=Math.min(f,L),f===0)return f}else if(!t&&s){const F=i.slice(S[0],S[1]+1);for(let N=w[0];N<=w[1];++N)if(L=Is(r[N],F,l),f=Math.min(f,L),f===0)return f}else L=op(r,w,i,S,l),f=Math.min(f,L)}else{const L=qt(w,t),F=qt(S,s);qa(_,f,l,r,i,L[0],F[0]),qa(_,f,l,r,i,L[0],F[1]),qa(_,f,l,r,i,L[1],F[0]),qa(_,f,l,r,i,L[1],F[1])}}return f}function yc(r){return r.type==="MultiPolygon"?r.coordinates.map(t=>({type:"Polygon",coordinates:t})):r.type==="MultiLineString"?r.coordinates.map(t=>({type:"LineString",coordinates:t})):r.type==="MultiPoint"?r.coordinates.map(t=>({type:"Point",coordinates:t})):[r]}class Es{constructor(t,i){this.type=Ze,this.geojson=t,this.geometries=i}static parse(t,i){if(t.length!==2)return i.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ts(t[1])){const s=t[1];if(s.type==="FeatureCollection")return new Es(s,s.features.map(l=>yc(l.geometry)).flat());if(s.type==="Feature")return new Es(s,yc(s.geometry));if("type"in s&&"coordinates"in s)return new Es(s,yc(s))}return i.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(i,s){const l=i.geometry(),p=l.flat().map(y=>Ua([y.x,y.y],i.canonical));if(l.length===0)return NaN;const f=new pc(p[0][1]);let _=1/0;for(const y of s){switch(y.type){case"Point":_=Math.min(_,Wa(p,!1,[y.coordinates],!1,f,_));break;case"LineString":_=Math.min(_,Wa(p,!1,y.coordinates,!0,f,_));break;case"Polygon":_=Math.min(_,Ha(p,!1,y.coordinates,f,_))}if(_===0)return _}return _}(t,this.geometries);if(t.geometryType()==="LineString")return function(i,s){const l=i.geometry(),p=l.flat().map(y=>Ua([y.x,y.y],i.canonical));if(l.length===0)return NaN;const f=new pc(p[0][1]);let _=1/0;for(const y of s){switch(y.type){case"Point":_=Math.min(_,Wa(p,!0,[y.coordinates],!1,f,_));break;case"LineString":_=Math.min(_,Wa(p,!0,y.coordinates,!0,f,_));break;case"Polygon":_=Math.min(_,Ha(p,!0,y.coordinates,f,_))}if(_===0)return _}return _}(t,this.geometries);if(t.geometryType()==="Polygon")return function(i,s){const l=i.geometry();if(l.length===0||l[0].length===0)return NaN;const p=qo(l,0).map(y=>y.map(w=>w.map(S=>Ua([S.x,S.y],i.canonical)))),f=new pc(p[0][0][0][1]);let _=1/0;for(const y of s)for(const w of p){switch(y.type){case"Point":_=Math.min(_,Ha([y.coordinates],!1,w,f,_));break;case"LineString":_=Math.min(_,Ha(y.coordinates,!0,w,f,_));break;case"Polygon":_=Math.min(_,cp(w,y.coordinates,f,_))}if(_===0)return _}return _}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Ho{constructor(t){this.type=wt,this.key=t}static parse(t,i){if(t.length!==2)return i.error(`Expected 1 argument, but found ${t.length-1} instead.`);const s=t[1];return s==null?i.error("Global state property must be defined."):typeof s!="string"?i.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Ho(s)}evaluate(t){var i;const s=(i=t.globals)===null||i===void 0?void 0:i.globalState;return s&&Object.keys(s).length!==0?Qs(s,this.key):null}eachChild(){}outputDefined(){return!1}}const ro={"==":Wu,"!=":ja,">":sc,"<":Kd,">=":Jd,"<=":Yd,array:Br,at:Ba,boolean:Br,case:to,coalesce:No,collator:Na,format:Ps,image:ac,in:Oa,"index-of":nn,interpolate:rr,"interpolate-hcl":rr,"interpolate-lab":rr,length:Va,let:Fo,literal:kn,match:Hi,number:Br,"number-format":oc,object:Br,slice:Bo,step:Ti,string:Br,"to-boolean":Tn,"to-color":Tn,"to-number":Tn,"to-string":Tn,var:Fa,within:Cs,distance:Es,"global-state":Ho};class qr{constructor(t,i,s,l){this.name=t,this.type=i,this._evaluate=s,this.args=l}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,i){const s=t[0],l=qr.definitions[s];if(!l)return i.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0);const p=Array.isArray(l)?l[0]:l.type,f=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,_=f.filter(([w])=>!Array.isArray(w)||w.length===t.length-1);let y=null;for(const[w,S]of _){y=new eo(i.registry,Xa,i.path,null,i.scope);const I=[];let z=!1;for(let L=1;L<t.length;L++){const F=t[L],N=Array.isArray(w)?w[L-1]:w.type,$=y.parse(F,1+I.length,N);if(!$){z=!0;break}I.push($)}if(!z)if(Array.isArray(w)&&w.length!==I.length)y.error(`Expected ${w.length} arguments, but found ${I.length} instead.`);else{for(let L=0;L<I.length;L++){const F=Array.isArray(w)?w[L]:w.type,N=I[L];y.concat(L+1).checkSubtype(F,N.type)}if(y.errors.length===0)return new qr(s,p,S,I)}}if(_.length===1)i.errors.push(...y.errors);else{const w=(_.length?_:f).map(([I])=>{return z=I,Array.isArray(z)?`(${z.map(ri).join(", ")})`:`(${ri(z.type)}...)`;var z}).join(" | "),S=[];for(let I=1;I<t.length;I++){const z=i.parse(t[I],1+S.length);if(!z)return null;S.push(ri(z.type))}i.error(`Expected arguments of type ${w}, but found (${S.join(", ")}) instead.`)}return null}static register(t,i){qr.definitions=i;for(const s in i)t[s]=qr}}function ah(r,[t,i,s,l]){t=t.evaluate(r),i=i.evaluate(r),s=s.evaluate(r);const p=l?l.evaluate(r):1,f=ci(t,i,s,p);if(f)throw new ni(f);return new Rt(t/255,i/255,s/255,p,!1)}function lh(r,t){return r in t}function vc(r,t){const i=t[r];return i===void 0?null:i}function As(r){return{type:r}}function Xa(r){if(r instanceof Fa)return Xa(r.boundExpression);if(r instanceof qr&&r.name==="error"||r instanceof Na||r instanceof Cs||r instanceof Es||r instanceof Ho)return!1;const t=r instanceof Tn||r instanceof Br;let i=!0;return r.eachChild(s=>{i=t?i&&Xa(s):i&&s instanceof kn}),!!i&&Ka(r)&&Ya(r,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Ka(r){if(r instanceof qr&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof Cs||r instanceof Es)return!1;let t=!0;return r.eachChild(i=>{t&&!Ka(i)&&(t=!1)}),t}function Wo(r){if(r instanceof qr&&r.name==="feature-state")return!1;let t=!0;return r.eachChild(i=>{t&&!Wo(i)&&(t=!1)}),t}function Ya(r,t){if(r instanceof qr&&t.indexOf(r.name)>=0)return!1;let i=!0;return r.eachChild(s=>{i&&!Ya(s,t)&&(i=!1)}),i}function ch(r){return{result:"success",value:r}}function no(r){return{result:"error",value:r}}function es(r){return r["property-type"]==="data-driven"||r["property-type"]==="cross-faded-data-driven"}function uh(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function xc(r){return!!r.expression&&r.expression.interpolated}function Lt(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function Xo(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)&&pt(r)===Xn}function up(r){return r}function hh(r,t){const i=r.stops&&typeof r.stops[0][0]=="object",s=i||!(i||r.property!==void 0),l=r.type||(xc(t)?"exponential":"interval"),p=function(S){switch(S.type){case"color":return Rt.parse;case"padding":return qi.parse;case"numberArray":return gr.parse;case"colorArray":return zi.parse;default:return null}}(t);if(p&&((r=cr({},r)).stops&&(r.stops=r.stops.map(S=>[S[0],p(S[1])])),r.default=p(r.default?r.default:t.default)),r.colorSpace&&(f=r.colorSpace)!=="rgb"&&f!=="hcl"&&f!=="lab")throw new Error(`Unknown color space: "${r.colorSpace}"`);var f;const _=function(S){switch(S){case"exponential":return ph;case"interval":return hp;case"categorical":return dh;case"identity":return dp;default:throw new Error(`Unknown function type "${S}"`)}}(l);let y,w;if(l==="categorical"){y=Object.create(null);for(const S of r.stops)y[S[0]]=S[1];w=typeof r.stops[0][0]}if(i){const S={},I=[];for(let F=0;F<r.stops.length;F++){const N=r.stops[F],$=N[0].zoom;S[$]===void 0&&(S[$]={zoom:$,type:r.type,property:r.property,default:r.default,stops:[]},I.push($)),S[$].stops.push([N[0].value,N[1]])}const z=[];for(const F of I)z.push([S[F].zoom,hh(S[F],t)]);const L={name:"linear"};return{kind:"composite",interpolationType:L,interpolationFactor:rr.interpolationFactor.bind(void 0,L),zoomStops:z.map(F=>F[0]),evaluate:({zoom:F},N)=>ph({stops:z,base:r.base},t,F).evaluate(F,N)}}if(s){const S=l==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:S,interpolationFactor:rr.interpolationFactor.bind(void 0,S),zoomStops:r.stops.map(I=>I[0]),evaluate:({zoom:I})=>_(r,t,I,y,w)}}return{kind:"source",evaluate(S,I){const z=I&&I.properties?I.properties[r.property]:void 0;return z===void 0?ts(r.default,t.default):_(r,t,z,y,w)}}}function ts(r,t,i){return r!==void 0?r:t!==void 0?t:i!==void 0?i:void 0}function dh(r,t,i,s,l){return ts(typeof i===l?s[i]:void 0,r.default,t.default)}function hp(r,t,i){if(Lt(i)!=="number")return ts(r.default,t.default);const s=r.stops.length;if(s===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[s-1][0])return r.stops[s-1][1];const l=Ss(r.stops.map(p=>p[0]),i);return r.stops[l][1]}function ph(r,t,i){const s=r.base!==void 0?r.base:1;if(Lt(i)!=="number")return ts(r.default,t.default);const l=r.stops.length;if(l===1||i<=r.stops[0][0])return r.stops[0][1];if(i>=r.stops[l-1][0])return r.stops[l-1][1];const p=Ss(r.stops.map(S=>S[0]),i),f=function(S,I,z,L){const F=L-z,N=S-z;return F===0?0:I===1?N/F:(Math.pow(I,N)-1)/(Math.pow(I,F)-1)}(i,s,r.stops[p][0],r.stops[p+1][0]),_=r.stops[p][1],y=r.stops[p+1][1],w=Sn[t.type]||up;return typeof _.evaluate=="function"?{evaluate(...S){const I=_.evaluate.apply(void 0,S),z=y.evaluate.apply(void 0,S);if(I!==void 0&&z!==void 0)return w(I,z,f,r.colorSpace)}}:w(_,y,f,r.colorSpace)}function dp(r,t,i){switch(t.type){case"color":i=Rt.parse(i);break;case"formatted":i=mr.fromString(i.toString());break;case"resolvedImage":i=Fr.fromString(i.toString());break;case"padding":i=qi.parse(i);break;case"colorArray":i=zi.parse(i);break;case"numberArray":i=gr.parse(i);break;default:Lt(i)===t.type||t.type==="enum"&&t.values[i]||(i=void 0)}return ts(i,r.default,t.default)}qr.register(ro,{error:[{kind:"error"},[kt],(r,[t])=>{throw new ni(t.evaluate(r))}],typeof:[kt,[wt],(r,[t])=>ri(pt(t.evaluate(r)))],"to-rgba":[Mr(Ze,4),[ir],(r,[t])=>{const[i,s,l,p]=t.evaluate(r).rgb;return[255*i,255*s,255*l,p]}],rgb:[ir,[Ze,Ze,Ze],ah],rgba:[ir,[Ze,Ze,Ze,Ze],ah],has:{type:Pt,overloads:[[[kt],(r,[t])=>lh(t.evaluate(r),r.properties())],[[kt,Xn],(r,[t,i])=>lh(t.evaluate(r),i.evaluate(r))]]},get:{type:wt,overloads:[[[kt],(r,[t])=>vc(t.evaluate(r),r.properties())],[[kt,Xn],(r,[t,i])=>vc(t.evaluate(r),i.evaluate(r))]]},"feature-state":[wt,[kt],(r,[t])=>vc(t.evaluate(r),r.featureState||{})],properties:[Xn,[],r=>r.properties()],"geometry-type":[kt,[],r=>r.geometryType()],id:[wt,[],r=>r.id()],zoom:[Ze,[],r=>r.globals.zoom],"heatmap-density":[Ze,[],r=>r.globals.heatmapDensity||0],elevation:[Ze,[],r=>r.globals.elevation||0],"line-progress":[Ze,[],r=>r.globals.lineProgress||0],accumulated:[wt,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[Ze,As(Ze),(r,t)=>{let i=0;for(const s of t)i+=s.evaluate(r);return i}],"*":[Ze,As(Ze),(r,t)=>{let i=1;for(const s of t)i*=s.evaluate(r);return i}],"-":{type:Ze,overloads:[[[Ze,Ze],(r,[t,i])=>t.evaluate(r)-i.evaluate(r)],[[Ze],(r,[t])=>-t.evaluate(r)]]},"/":[Ze,[Ze,Ze],(r,[t,i])=>t.evaluate(r)/i.evaluate(r)],"%":[Ze,[Ze,Ze],(r,[t,i])=>t.evaluate(r)%i.evaluate(r)],ln2:[Ze,[],()=>Math.LN2],pi:[Ze,[],()=>Math.PI],e:[Ze,[],()=>Math.E],"^":[Ze,[Ze,Ze],(r,[t,i])=>Math.pow(t.evaluate(r),i.evaluate(r))],sqrt:[Ze,[Ze],(r,[t])=>Math.sqrt(t.evaluate(r))],log10:[Ze,[Ze],(r,[t])=>Math.log(t.evaluate(r))/Math.LN10],ln:[Ze,[Ze],(r,[t])=>Math.log(t.evaluate(r))],log2:[Ze,[Ze],(r,[t])=>Math.log(t.evaluate(r))/Math.LN2],sin:[Ze,[Ze],(r,[t])=>Math.sin(t.evaluate(r))],cos:[Ze,[Ze],(r,[t])=>Math.cos(t.evaluate(r))],tan:[Ze,[Ze],(r,[t])=>Math.tan(t.evaluate(r))],asin:[Ze,[Ze],(r,[t])=>Math.asin(t.evaluate(r))],acos:[Ze,[Ze],(r,[t])=>Math.acos(t.evaluate(r))],atan:[Ze,[Ze],(r,[t])=>Math.atan(t.evaluate(r))],min:[Ze,As(Ze),(r,t)=>Math.min(...t.map(i=>i.evaluate(r)))],max:[Ze,As(Ze),(r,t)=>Math.max(...t.map(i=>i.evaluate(r)))],abs:[Ze,[Ze],(r,[t])=>Math.abs(t.evaluate(r))],round:[Ze,[Ze],(r,[t])=>{const i=t.evaluate(r);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ze,[Ze],(r,[t])=>Math.floor(t.evaluate(r))],ceil:[Ze,[Ze],(r,[t])=>Math.ceil(t.evaluate(r))],"filter-==":[Pt,[kt,wt],(r,[t,i])=>r.properties()[t.value]===i.value],"filter-id-==":[Pt,[wt],(r,[t])=>r.id()===t.value],"filter-type-==":[Pt,[kt],(r,[t])=>r.geometryType()===t.value],"filter-<":[Pt,[kt,wt],(r,[t,i])=>{const s=r.properties()[t.value],l=i.value;return typeof s==typeof l&&s<l}],"filter-id-<":[Pt,[wt],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i<s}],"filter->":[Pt,[kt,wt],(r,[t,i])=>{const s=r.properties()[t.value],l=i.value;return typeof s==typeof l&&s>l}],"filter-id->":[Pt,[wt],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i>s}],"filter-<=":[Pt,[kt,wt],(r,[t,i])=>{const s=r.properties()[t.value],l=i.value;return typeof s==typeof l&&s<=l}],"filter-id-<=":[Pt,[wt],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i<=s}],"filter->=":[Pt,[kt,wt],(r,[t,i])=>{const s=r.properties()[t.value],l=i.value;return typeof s==typeof l&&s>=l}],"filter-id->=":[Pt,[wt],(r,[t])=>{const i=r.id(),s=t.value;return typeof i==typeof s&&i>=s}],"filter-has":[Pt,[wt],(r,[t])=>t.value in r.properties()],"filter-has-id":[Pt,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Pt,[Mr(kt)],(r,[t])=>t.value.indexOf(r.geometryType())>=0],"filter-id-in":[Pt,[Mr(wt)],(r,[t])=>t.value.indexOf(r.id())>=0],"filter-in-small":[Pt,[kt,Mr(wt)],(r,[t,i])=>i.value.indexOf(r.properties()[t.value])>=0],"filter-in-large":[Pt,[kt,Mr(wt)],(r,[t,i])=>function(s,l,p,f){for(;p<=f;){const _=p+f>>1;if(l[_]===s)return!0;l[_]>s?f=_-1:p=_+1}return!1}(r.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Pt,overloads:[[[Pt,Pt],(r,[t,i])=>t.evaluate(r)&&i.evaluate(r)],[As(Pt),(r,t)=>{for(const i of t)if(!i.evaluate(r))return!1;return!0}]]},any:{type:Pt,overloads:[[[Pt,Pt],(r,[t,i])=>t.evaluate(r)||i.evaluate(r)],[As(Pt),(r,t)=>{for(const i of t)if(i.evaluate(r))return!0;return!1}]]},"!":[Pt,[Pt],(r,[t])=>!t.evaluate(r)],"is-supported-script":[Pt,[kt],(r,[t])=>{const i=r.globals&&r.globals.isSupportedScript;return!i||i(t.evaluate(r))}],upcase:[kt,[kt],(r,[t])=>t.evaluate(r).toUpperCase()],downcase:[kt,[kt],(r,[t])=>t.evaluate(r).toLowerCase()],concat:[kt,As(wt),(r,t)=>t.map(i=>vt(i.evaluate(r))).join("")],"resolved-locale":[kt,[Aa],(r,[t])=>t.evaluate(r).resolvedLocale()]});class bc{constructor(t,i){this.expression=t,this._warningHistory={},this._evaluator=new rc,this._defaultValue=i?function(s){if(s.type==="color"&&Xo(s.default))return new Rt(0,0,0,0);switch(s.type){case"color":return Rt.parse(s.default)||null;case"padding":return qi.parse(s.default)||null;case"numberArray":return gr.parse(s.default)||null;case"colorArray":return zi.parse(s.default)||null;case"variableAnchorOffsetCollection":return _r.parse(s.default)||null;case"projectionDefinition":return ur.parse(s.default)||null;default:return s.default===void 0?null:s.default}}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null}evaluateWithoutErrorHandling(t,i,s,l,p,f){return this._evaluator.globals=t,this._evaluator.feature=i,this._evaluator.featureState=s,this._evaluator.canonical=l,this._evaluator.availableImages=p||null,this._evaluator.formattedSection=f,this.expression.evaluate(this._evaluator)}evaluate(t,i,s,l,p,f){this._evaluator.globals=t,this._evaluator.feature=i||null,this._evaluator.featureState=s||null,this._evaluator.canonical=l,this._evaluator.availableImages=p||null,this._evaluator.formattedSection=f||null;try{const _=this.expression.evaluate(this._evaluator);if(_==null||typeof _=="number"&&_!=_)return this._defaultValue;if(this._enumValues&&!(_ in this._enumValues))throw new ni(`Expected value to be one of ${Object.keys(this._enumValues).map(y=>JSON.stringify(y)).join(", ")}, but found ${JSON.stringify(_)} instead.`);return _}catch(_){return this._warningHistory[_.message]||(this._warningHistory[_.message]=!0,typeof console<"u"&&console.warn(_.message)),this._defaultValue}}}function Ja(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in ro}function Ko(r,t){const i=new eo(ro,Xa,[],t?function(l){const p={color:ir,string:kt,number:Ze,enum:kt,boolean:Pt,formatted:Kn,padding:ka,numberArray:Xs,colorArray:bn,projectionDefinition:vs,resolvedImage:wi,variableAnchorOffsetCollection:za};return l.type==="array"?Mr(p[l.value]||wt,l.length):p[l.type]}(t):void 0),s=i.parse(r,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return s?ch(new bc(s,t)):no(i.errors)}class Yo{constructor(t,i){this.kind=t,this._styleExpression=i,this.isStateDependent=t!=="constant"&&!Wo(i.expression),this.globalStateRefs=ea(i.expression)}evaluateWithoutErrorHandling(t,i,s,l,p,f){return this._styleExpression.evaluateWithoutErrorHandling(t,i,s,l,p,f)}evaluate(t,i,s,l,p,f){return this._styleExpression.evaluate(t,i,s,l,p,f)}}class wc{constructor(t,i,s,l){this.kind=t,this.zoomStops=s,this._styleExpression=i,this.isStateDependent=t!=="camera"&&!Wo(i.expression),this.globalStateRefs=ea(i.expression),this.interpolationType=l}evaluateWithoutErrorHandling(t,i,s,l,p,f){return this._styleExpression.evaluateWithoutErrorHandling(t,i,s,l,p,f)}evaluate(t,i,s,l,p,f){return this._styleExpression.evaluate(t,i,s,l,p,f)}interpolationFactor(t,i,s){return this.interpolationType?rr.interpolationFactor(this.interpolationType,t,i,s):0}}function fh(r,t){const i=Ko(r,t);if(i.result==="error")return i;const s=i.value.expression,l=Ka(s);if(!l&&!es(t))return no([new gi("","data expressions not supported")]);const p=Ya(s,["zoom"]);if(!p&&!uh(t))return no([new gi("","zoom expressions not supported")]);const f=Qo(s);return f||p?f instanceof gi?no([f]):f instanceof rr&&!xc(t)?no([new gi("",'"interpolate" expressions cannot be used with this property')]):ch(f?new wc(l?"camera":"composite",i.value,f.labels,f instanceof rr?f.interpolation:void 0):new Yo(l?"constant":"source",i.value)):no([new gi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Jo{constructor(t,i){this._parameters=t,this._specification=i,cr(this,hh(this._parameters,this._specification))}static deserialize(t){return new Jo(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Qo(r){let t=null;if(r instanceof Fo)t=Qo(r.result);else if(r instanceof No){for(const i of r.args)if(t=Qo(i),t)break}else(r instanceof Ti||r instanceof rr)&&r.input instanceof qr&&r.input.name==="zoom"&&(t=r);return t instanceof gi||r.eachChild(i=>{const s=Qo(i);s instanceof gi?t=s:!t&&s?t=new gi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&s&&t!==s&&(t=new gi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function ea(r,t=new Set){return r instanceof Ho&&t.add(r.key),r.eachChild(i=>{ea(i,t)}),t}function Qa(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const t of r.slice(1))if(!Qa(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}const Tc={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ks(r){if(r==null)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Qa(r)||(r=zs(r));const t=Ko(r,Tc);if(t.result==="error")throw new Error(t.value.map(i=>`${i.key}: ${i.message}`).join(", "));return{filter:(i,s,l)=>t.value.evaluate(i,s,{},l),needGeometry:el(r),getGlobalStateRefs:()=>ea(t.value.expression)}}function Sc(r,t){return r<t?-1:r>t?1:0}function el(r){if(!Array.isArray(r))return!1;if(r[0]==="within"||r[0]==="distance")return!0;for(let t=1;t<r.length;t++)if(el(r[t]))return!0;return!1}function zs(r){if(!r)return!0;const t=r[0];return r.length<=1?t!=="any":t==="=="?Pc(r[1],r[2],"=="):t==="!="?tl(Pc(r[1],r[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Pc(r[1],r[2],t):t==="any"?(i=r.slice(1),["any"].concat(i.map(zs))):t==="all"?["all"].concat(r.slice(1).map(zs)):t==="none"?["all"].concat(r.slice(1).map(zs).map(tl)):t==="in"?mh(r[1],r.slice(2)):t==="!in"?tl(mh(r[1],r.slice(2))):t==="has"?gh(r[1]):t!=="!has"||tl(gh(r[1]));var i}function Pc(r,t,i){switch(r){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,r,t]}}function mh(r,t){if(t.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(i=>typeof i!=typeof t[0])?["filter-in-large",r,["literal",t.sort(Sc)]]:["filter-in-small",r,["literal",t]]}}function gh(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function tl(r){return["!",r]}function Mc(r){const t=typeof r;if(t==="number"||t==="boolean"||t==="string"||r==null)return JSON.stringify(r);if(Array.isArray(r)){let l="[";for(const p of r)l+=`${Mc(p)},`;return`${l}]`}const i=Object.keys(r).sort();let s="{";for(let l=0;l<i.length;l++)s+=`${JSON.stringify(i[l])}:${Mc(r[i[l]])},`;return`${s}}`}function pp(r){let t="";for(const i of _t)t+=`/${Mc(r[i])}`;return t}function Cc(r){const t=r.value;return t?[new Fe(r.key,t,"constants have been deprecated as of v8")]:[]}function _i(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function Pn(r){if(Array.isArray(r))return r.map(Pn);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const t={};for(const i in r)t[i]=Pn(r[i]);return t}return _i(r)}function Hr(r){const t=r.key,i=r.value,s=r.valueSpec||{},l=r.objectElementValidators||{},p=r.style,f=r.styleSpec,_=r.validateSpec;let y=[];const w=Lt(i);if(w!=="object")return[new Fe(t,i,`object expected, ${w} found`)];for(const S in i){const I=S.split(".")[0],z=Qs(s,I)||s["*"];let L;if(Qs(l,I))L=l[I];else if(Qs(s,I))L=_;else if(l["*"])L=l["*"];else{if(!s["*"]){y.push(new Fe(t,i[S],`unknown property "${S}"`));continue}L=_}y=y.concat(L({key:(t&&`${t}.`)+S,value:i[S],valueSpec:z,style:p,styleSpec:f,object:i,objectKey:S,validateSpec:_},i))}for(const S in s)l[S]||s[S].required&&s[S].default===void 0&&i[S]===void 0&&y.push(new Fe(t,i,`missing required property "${S}"`));return y}function il(r){const t=r.value,i=r.valueSpec,s=r.style,l=r.styleSpec,p=r.key,f=r.arrayElementValidator||r.validateSpec;if(Lt(t)!=="array")return[new Fe(p,t,`array expected, ${Lt(t)} found`)];if(i.length&&t.length!==i.length)return[new Fe(p,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new Fe(p,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let _={type:i.value,values:i.values};l.$version<7&&(_.function=i.function),Lt(i.value)==="object"&&(_=i.value);let y=[];for(let w=0;w<t.length;w++)y=y.concat(f({array:t,arrayIndex:w,value:t[w],valueSpec:_,validateSpec:r.validateSpec,style:s,styleSpec:l,key:`${p}[${w}]`}));return y}function ta(r){const t=r.key,i=r.value,s=r.valueSpec;let l=Lt(i);return l==="number"&&i!=i&&(l="NaN"),l!=="number"?[new Fe(t,i,`number expected, ${l} found`)]:"minimum"in s&&i<s.minimum?[new Fe(t,i,`${i} is less than the minimum value ${s.minimum}`)]:"maximum"in s&&i>s.maximum?[new Fe(t,i,`${i} is greater than the maximum value ${s.maximum}`)]:[]}function _h(r){const t=r.valueSpec,i=_i(r.value.type);let s,l,p,f={};const _=i!=="categorical"&&r.value.property===void 0,y=!_,w=Lt(r.value.stops)==="array"&&Lt(r.value.stops[0])==="array"&&Lt(r.value.stops[0][0])==="object",S=Hr({key:r.key,value:r.value,valueSpec:r.styleSpec.function,validateSpec:r.validateSpec,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function(L){if(i==="identity")return[new Fe(L.key,L.value,'identity function may not have a "stops" property')];let F=[];const N=L.value;return F=F.concat(il({key:L.key,value:N,valueSpec:L.valueSpec,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec,arrayElementValidator:I})),Lt(N)==="array"&&N.length===0&&F.push(new Fe(L.key,N,"array must have at least one stop")),F},default:function(L){return L.validateSpec({key:L.key,value:L.value,valueSpec:t,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec})}}});return i==="identity"&&_&&S.push(new Fe(r.key,r.value,'missing required property "property"')),i==="identity"||r.value.stops||S.push(new Fe(r.key,r.value,'missing required property "stops"')),i==="exponential"&&r.valueSpec.expression&&!xc(r.valueSpec)&&S.push(new Fe(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(y&&!es(r.valueSpec)?S.push(new Fe(r.key,r.value,"property functions not supported")):_&&!uh(r.valueSpec)&&S.push(new Fe(r.key,r.value,"zoom functions not supported"))),i!=="categorical"&&!w||r.value.property!==void 0||S.push(new Fe(r.key,r.value,'"property" property is required')),S;function I(L){let F=[];const N=L.value,$=L.key;if(Lt(N)!=="array")return[new Fe($,N,`array expected, ${Lt(N)} found`)];if(N.length!==2)return[new Fe($,N,`array length 2 expected, length ${N.length} found`)];if(w){if(Lt(N[0])!=="object")return[new Fe($,N,`object expected, ${Lt(N[0])} found`)];if(N[0].zoom===void 0)return[new Fe($,N,"object stop key must have zoom")];if(N[0].value===void 0)return[new Fe($,N,"object stop key must have value")];if(p&&p>_i(N[0].zoom))return[new Fe($,N[0].zoom,"stop zoom values must appear in ascending order")];_i(N[0].zoom)!==p&&(p=_i(N[0].zoom),l=void 0,f={}),F=F.concat(Hr({key:`${$}[0]`,value:N[0],valueSpec:{zoom:{}},validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec,objectElementValidators:{zoom:ta,value:z}}))}else F=F.concat(z({key:`${$}[0]`,value:N[0],validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec},N));return Ja(Pn(N[1]))?F.concat([new Fe(`${$}[1]`,N[1],"expressions are not allowed in function stops.")]):F.concat(L.validateSpec({key:`${$}[1]`,value:N[1],valueSpec:t,validateSpec:L.validateSpec,style:L.style,styleSpec:L.styleSpec}))}function z(L,F){const N=Lt(L.value),$=_i(L.value),H=L.value!==null?L.value:F;if(s){if(N!==s)return[new Fe(L.key,H,`${N} stop domain type must match previous stop domain type ${s}`)]}else s=N;if(N!=="number"&&N!=="string"&&N!=="boolean")return[new Fe(L.key,H,"stop domain value must be a number, string, or boolean")];if(N!=="number"&&i!=="categorical"){let he=`number expected, ${N} found`;return es(t)&&i===void 0&&(he+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Fe(L.key,H,he)]}return i!=="categorical"||N!=="number"||isFinite($)&&Math.floor($)===$?i!=="categorical"&&N==="number"&&l!==void 0&&$<l?[new Fe(L.key,H,"stop domain values must appear in ascending order")]:(l=$,i==="categorical"&&$ in f?[new Fe(L.key,H,"stop domain values must be unique")]:(f[$]=!0,[])):[new Fe(L.key,H,`integer expected, found ${$}`)]}}function Rs(r){const t=(r.expressionContext==="property"?fh:Ko)(Pn(r.value),r.valueSpec);if(t.result==="error")return t.value.map(s=>new Fe(`${r.key}${s.key}`,r.value,s.message));const i=t.value.expression||t.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!i.outputDefined())return[new Fe(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!Wo(i))return[new Fe(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter"&&!Wo(i))return[new Fe(r.key,r.value,'"feature-state" data expressions are not supported with filters.')];if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Ya(i,["zoom","feature-state"]))return[new Fe(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!Ka(i))return[new Fe(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function rl(r){const t=r.key,i=r.value,s=Lt(i);return s!=="string"?[new Fe(t,i,`color expected, ${s} found`)]:Rt.parse(String(i))?[]:[new Fe(t,i,`color expected, "${i}" found`)]}function Rn(r){const t=r.key,i=r.value,s=r.valueSpec,l=[];return Array.isArray(s.values)?s.values.indexOf(_i(i))===-1&&l.push(new Fe(t,i,`expected one of [${s.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(s.values).indexOf(_i(i))===-1&&l.push(new Fe(t,i,`expected one of [${Object.keys(s.values).join(", ")}], ${JSON.stringify(i)} found`)),l}function Ic(r){return Qa(Pn(r.value))?Rs(cr({},r,{expressionContext:"filter",valueSpec:{value:"boolean"}})):yh(r)}function yh(r){const t=r.value,i=r.key;if(Lt(t)!=="array")return[new Fe(i,t,`array expected, ${Lt(t)} found`)];const s=r.styleSpec;let l,p=[];if(t.length<1)return[new Fe(i,t,"filter array must have at least 1 element")];switch(p=p.concat(Rn({key:`${i}[0]`,value:t[0],valueSpec:s.filter_operator,style:r.style,styleSpec:r.styleSpec})),_i(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&_i(t[1])==="$type"&&p.push(new Fe(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&p.push(new Fe(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(l=Lt(t[1]),l!=="string"&&p.push(new Fe(`${i}[1]`,t[1],`string expected, ${l} found`)));for(let f=2;f<t.length;f++)l=Lt(t[f]),_i(t[1])==="$type"?p=p.concat(Rn({key:`${i}[${f}]`,value:t[f],valueSpec:s.geometry_type,style:r.style,styleSpec:r.styleSpec})):l!=="string"&&l!=="number"&&l!=="boolean"&&p.push(new Fe(`${i}[${f}]`,t[f],`string, number, or boolean expected, ${l} found`));break;case"any":case"all":case"none":for(let f=1;f<t.length;f++)p=p.concat(yh({key:`${i}[${f}]`,value:t[f],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":l=Lt(t[1]),t.length!==2?p.push(new Fe(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):l!=="string"&&p.push(new Fe(`${i}[1]`,t[1],`string expected, ${l} found`))}return p}function vh(r,t){const i=r.key,s=r.validateSpec,l=r.style,p=r.styleSpec,f=r.value,_=r.objectKey,y=p[`${t}_${r.layerType}`];if(!y)return[];const w=_.match(/^(.*)-transition$/);if(t==="paint"&&w&&y[w[1]]&&y[w[1]].transition)return s({key:i,value:f,valueSpec:p.transition,style:l,styleSpec:p});const S=r.valueSpec||y[_];if(!S)return[new Fe(i,f,`unknown property "${_}"`)];let I;if(Lt(f)==="string"&&es(S)&&!S.tokens&&(I=/^{([^}]+)}$/.exec(f)))return[new Fe(i,f,`"${_}" does not support interpolation syntax
28
+ Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(I[1])} }\`.`)];const z=[];return r.layerType==="symbol"&&(_==="text-field"&&l&&!l.glyphs&&z.push(new Fe(i,f,'use of "text-field" requires a style "glyphs" property')),_==="text-font"&&Xo(Pn(f))&&_i(f.type)==="identity"&&z.push(new Fe(i,f,'"text-font" does not support identity functions'))),z.concat(s({key:r.key,value:f,valueSpec:S,style:l,styleSpec:p,expressionContext:"property",propertyType:t,propertyKey:_}))}function xh(r){return vh(r,"paint")}function bh(r){return vh(r,"layout")}function wh(r){let t=[];const i=r.value,s=r.key,l=r.style,p=r.styleSpec;if(Lt(i)!=="object")return[new Fe(s,i,`object expected, ${Lt(i)} found`)];i.type||i.ref||t.push(new Fe(s,i,'either "type" or "ref" is required'));let f=_i(i.type);const _=_i(i.ref);if(i.id){const y=_i(i.id);for(let w=0;w<r.arrayIndex;w++){const S=l.layers[w];_i(S.id)===y&&t.push(new Fe(s,i.id,`duplicate layer id "${i.id}", previously used at line ${S.id.__line__}`))}}if("ref"in i){let y;["type","source","source-layer","filter","layout"].forEach(w=>{w in i&&t.push(new Fe(s,i[w],`"${w}" is prohibited for ref layers`))}),l.layers.forEach(w=>{_i(w.id)===_&&(y=w)}),y?y.ref?t.push(new Fe(s,i.ref,"ref cannot reference another ref layer")):f=_i(y.type):t.push(new Fe(s,i.ref,`ref layer "${_}" not found`))}else if(f!=="background")if(i.source){const y=l.sources&&l.sources[i.source],w=y&&_i(y.type);y?w==="vector"&&f==="raster"?t.push(new Fe(s,i.source,`layer "${i.id}" requires a raster source`)):w!=="raster-dem"&&f==="hillshade"||w!=="raster-dem"&&f==="color-relief"?t.push(new Fe(s,i.source,`layer "${i.id}" requires a raster-dem source`)):w==="raster"&&f!=="raster"?t.push(new Fe(s,i.source,`layer "${i.id}" requires a vector source`)):w!=="vector"||i["source-layer"]?w==="raster-dem"&&f!=="hillshade"&&f!=="color-relief"?t.push(new Fe(s,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):f!=="line"||!i.paint||!i.paint["line-gradient"]||w==="geojson"&&y.lineMetrics||t.push(new Fe(s,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Fe(s,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Fe(s,i.source,`source "${i.source}" not found`))}else t.push(new Fe(s,i,'missing required property "source"'));return t=t.concat(Hr({key:s,value:i,valueSpec:p.layer,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,objectElementValidators:{"*":()=>[],type:()=>r.validateSpec({key:`${s}.type`,value:i.type,valueSpec:p.layer.type,style:r.style,styleSpec:r.styleSpec,validateSpec:r.validateSpec,object:i,objectKey:"type"}),filter:Ic,layout:y=>Hr({layer:i,key:y.key,value:y.value,style:y.style,styleSpec:y.styleSpec,validateSpec:y.validateSpec,objectElementValidators:{"*":w=>bh(cr({layerType:f},w))}}),paint:y=>Hr({layer:i,key:y.key,value:y.value,style:y.style,styleSpec:y.styleSpec,validateSpec:y.validateSpec,objectElementValidators:{"*":w=>xh(cr({layerType:f},w))}})}})),t}function on(r){const t=r.value,i=r.key,s=Lt(t);return s!=="string"?[new Fe(i,t,`string expected, ${s} found`)]:[]}const so={promoteId:function({key:r,value:t}){if(Lt(t)==="string")return on({key:r,value:t});{const i=[];for(const s in t)i.push(...on({key:`${r}.${s}`,value:t[s]}));return i}}};function Cr(r){const t=r.value,i=r.key,s=r.styleSpec,l=r.style,p=r.validateSpec;if(!t.type)return[new Fe(i,t,'"type" is required')];const f=_i(t.type);let _;switch(f){case"vector":case"raster":return _=Hr({key:i,value:t,valueSpec:s[`source_${f.replace("-","_")}`],style:r.style,styleSpec:s,objectElementValidators:so,validateSpec:p}),_;case"raster-dem":return _=function(y){var w;const S=(w=y.sourceName)!==null&&w!==void 0?w:"",I=y.value,z=y.styleSpec,L=z.source_raster_dem,F=y.style;let N=[];const $=Lt(I);if(I===void 0)return N;if($!=="object")return N.push(new Fe("source_raster_dem",I,`object expected, ${$} found`)),N;const H=_i(I.encoding)==="custom",he=["redFactor","greenFactor","blueFactor","baseShift"],ee=y.value.encoding?`"${y.value.encoding}"`:"Default";for(const re in I)!H&&he.includes(re)?N.push(new Fe(re,I[re],`In "${S}": "${re}" is only valid when "encoding" is set to "custom". ${ee} encoding found`)):L[re]?N=N.concat(y.validateSpec({key:re,value:I[re],valueSpec:L[re],validateSpec:y.validateSpec,style:F,styleSpec:z})):N.push(new Fe(re,I[re],`unknown property "${re}"`));return N}({sourceName:i,value:t,style:r.style,styleSpec:s,validateSpec:p}),_;case"geojson":if(_=Hr({key:i,value:t,valueSpec:s.source_geojson,style:l,styleSpec:s,validateSpec:p,objectElementValidators:so}),t.cluster)for(const y in t.clusterProperties){const[w,S]=t.clusterProperties[y],I=typeof w=="string"?[w,["accumulated"],["get",y]]:w;_.push(...Rs({key:`${i}.${y}.map`,value:S,expressionContext:"cluster-map"})),_.push(...Rs({key:`${i}.${y}.reduce`,value:I,expressionContext:"cluster-reduce"}))}return _;case"video":return Hr({key:i,value:t,valueSpec:s.source_video,style:l,validateSpec:p,styleSpec:s});case"image":return Hr({key:i,value:t,valueSpec:s.source_image,style:l,validateSpec:p,styleSpec:s});case"canvas":return[new Fe(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Rn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function oo(r){const t=r.value,i=r.styleSpec,s=i.light,l=r.style;let p=[];const f=Lt(t);if(t===void 0)return p;if(f!=="object")return p=p.concat([new Fe("light",t,`object expected, ${f} found`)]),p;for(const _ in t){const y=_.match(/^(.*)-transition$/);p=p.concat(y&&s[y[1]]&&s[y[1]].transition?r.validateSpec({key:_,value:t[_],valueSpec:i.transition,validateSpec:r.validateSpec,style:l,styleSpec:i}):s[_]?r.validateSpec({key:_,value:t[_],valueSpec:s[_],validateSpec:r.validateSpec,style:l,styleSpec:i}):[new Fe(_,t[_],`unknown property "${_}"`)])}return p}function Ec(r){const t=r.value,i=r.styleSpec,s=i.sky,l=r.style,p=Lt(t);if(t===void 0)return[];if(p!=="object")return[new Fe("sky",t,`object expected, ${p} found`)];let f=[];for(const _ in t)f=f.concat(s[_]?r.validateSpec({key:_,value:t[_],valueSpec:s[_],style:l,styleSpec:i}):[new Fe(_,t[_],`unknown property "${_}"`)]);return f}function Th(r){const t=r.value,i=r.styleSpec,s=i.terrain,l=r.style;let p=[];const f=Lt(t);if(t===void 0)return p;if(f!=="object")return p=p.concat([new Fe("terrain",t,`object expected, ${f} found`)]),p;for(const _ in t)p=p.concat(s[_]?r.validateSpec({key:_,value:t[_],valueSpec:s[_],validateSpec:r.validateSpec,style:l,styleSpec:i}):[new Fe(_,t[_],`unknown property "${_}"`)]);return p}function Sh(r){let t=[];const i=r.value,s=r.key;if(Array.isArray(i)){const l=[],p=[];for(const f in i)i[f].id&&l.includes(i[f].id)&&t.push(new Fe(s,i,`all the sprites' ids must be unique, but ${i[f].id} is duplicated`)),l.push(i[f].id),i[f].url&&p.includes(i[f].url)&&t.push(new Fe(s,i,`all the sprites' URLs must be unique, but ${i[f].url} is duplicated`)),p.push(i[f].url),t=t.concat(Hr({key:`${s}[${f}]`,value:i[f],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:r.validateSpec}));return t}return on({key:s,value:i})}function ao(r){return t=r.value,t&&t.constructor===Object?[]:[new Fe(r.key,r.value,`object expected, ${Lt(r.value)} found`)];var t}const Ac={"*":()=>[],array:il,boolean:function(r){const t=r.value,i=r.key,s=Lt(t);return s!=="boolean"?[new Fe(i,t,`boolean expected, ${s} found`)]:[]},number:ta,color:rl,constants:Cc,enum:Rn,filter:Ic,function:_h,layer:wh,object:Hr,source:Cr,light:oo,sky:Ec,terrain:Th,projection:function(r){const t=r.value,i=r.styleSpec,s=i.projection,l=r.style,p=Lt(t);if(t===void 0)return[];if(p!=="object")return[new Fe("projection",t,`object expected, ${p} found`)];let f=[];for(const _ in t)f=f.concat(s[_]?r.validateSpec({key:_,value:t[_],valueSpec:s[_],style:l,styleSpec:i}):[new Fe(_,t[_],`unknown property "${_}"`)]);return f},projectionDefinition:function(r){const t=r.key;let i=r.value;i=i instanceof String?i.valueOf():i;const s=Lt(i);return s!=="array"||function(l){return Array.isArray(l)&&l.length===3&&typeof l[0]=="string"&&typeof l[1]=="string"&&typeof l[2]=="number"}(i)||function(l){return!!["interpolate","step","literal"].includes(l[0])}(i)?["array","string"].includes(s)?[]:[new Fe(t,i,`projection expected, invalid type "${s}" found`)]:[new Fe(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:on,formatted:function(r){return on(r).length===0?[]:Rs(r)},resolvedImage:function(r){return on(r).length===0?[]:Rs(r)},padding:function(r){const t=r.key,i=r.value;if(Lt(i)==="array"){if(i.length<1||i.length>4)return[new Fe(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const s={type:"number"};let l=[];for(let p=0;p<i.length;p++)l=l.concat(r.validateSpec({key:`${t}[${p}]`,value:i[p],validateSpec:r.validateSpec,valueSpec:s}));return l}return ta({key:t,value:i,valueSpec:{}})},numberArray:function(r){const t=r.key,i=r.value;if(Lt(i)==="array"){const s={type:"number"};if(i.length<1)return[new Fe(t,i,"array length at least 1 expected, length 0 found")];let l=[];for(let p=0;p<i.length;p++)l=l.concat(r.validateSpec({key:`${t}[${p}]`,value:i[p],validateSpec:r.validateSpec,valueSpec:s}));return l}return ta({key:t,value:i,valueSpec:{}})},colorArray:function(r){const t=r.key,i=r.value;if(Lt(i)==="array"){if(i.length<1)return[new Fe(t,i,"array length at least 1 expected, length 0 found")];let s=[];for(let l=0;l<i.length;l++)s=s.concat(rl({key:`${t}[${l}]`,value:i[l]}));return s}return rl({key:t,value:i})},variableAnchorOffsetCollection:function(r){const t=r.key,i=r.value,s=Lt(i),l=r.styleSpec;if(s!=="array"||i.length<1||i.length%2!=0)return[new Fe(t,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let p=[];for(let f=0;f<i.length;f+=2)p=p.concat(Rn({key:`${t}[${f}]`,value:i[f],valueSpec:l.layout_symbol["text-anchor"]})),p=p.concat(il({key:`${t}[${f+1}]`,value:i[f+1],valueSpec:{length:2,value:"number"},validateSpec:r.validateSpec,style:r.style,styleSpec:l}));return p},sprite:Sh,state:ao};function lo(r){const t=r.value,i=r.valueSpec,s=r.styleSpec;return r.validateSpec=lo,i.expression&&Xo(_i(t))?_h(r):i.expression&&Ja(Pn(t))?Rs(r):i.type&&Ac[i.type]?Ac[i.type](r):Hr(cr({},r,{valueSpec:i.type?s[i.type]:i}))}function Ph(r){const t=r.value,i=r.key,s=on(r);return s.length||(t.indexOf("{fontstack}")===-1&&s.push(new Fe(i,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&s.push(new Fe(i,t,'"glyphs" url must include a "{range}" token'))),s}function Ir(r,t=fe){let i=[];return i=i.concat(lo({key:"",value:r,valueSpec:t.$root,styleSpec:t,style:r,validateSpec:lo,objectElementValidators:{glyphs:Ph,"*":()=>[]}})),r.constants&&(i=i.concat(Cc({key:"constants",value:r.constants}))),co(i)}function an(r){return function(t){return r({...t,validateSpec:lo})}}function co(r){return[].concat(r).sort((t,i)=>t.line-i.line)}function ln(r){return function(...t){return co(r.apply(this,t))}}Ir.source=ln(an(Cr)),Ir.sprite=ln(an(Sh)),Ir.glyphs=ln(an(Ph)),Ir.light=ln(an(oo)),Ir.sky=ln(an(Ec)),Ir.terrain=ln(an(Th)),Ir.state=ln(an(ao)),Ir.layer=ln(an(wh)),Ir.filter=ln(an(Ic)),Ir.paintProperty=ln(an(xh)),Ir.layoutProperty=ln(an(bh));const uo=Ir,fp=uo.light,ia=uo.sky,mp=uo.paintProperty,gp=uo.layoutProperty;function ra(r,t){let i=!1;if(t&&t.length)for(const s of t)r.fire(new Ce(new Error(s.message))),i=!0;return i}class na{constructor(t,i,s){const l=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const f=new Int32Array(this.arrayBuffer);t=f[0],this.d=(i=f[1])+2*(s=f[2]);for(let y=0;y<this.d*this.d;y++){const w=f[3+y],S=f[3+y+1];l.push(w===S?null:f.subarray(w,S))}const _=f[3+l.length+1];this.keys=f.subarray(f[3+l.length],_),this.bboxes=f.subarray(_),this.insert=this._insertReadonly}else{this.d=i+2*s;for(let f=0;f<this.d*this.d;f++)l.push([]);this.keys=[],this.bboxes=[]}this.n=i,this.extent=t,this.padding=s,this.scale=i/t,this.uid=0;const p=s/i*t;this.min=-p,this.max=t+p}insert(t,i,s,l,p){this._forEachCell(i,s,l,p,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(i),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(p)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,i,s,l,p,f){this.cells[p].push(f)}query(t,i,s,l,p){const f=this.min,_=this.max;if(t<=f&&i<=f&&_<=s&&_<=l&&!p)return Array.prototype.slice.call(this.keys);{const y=[];return this._forEachCell(t,i,s,l,this._queryCell,y,{},p),y}}_queryCell(t,i,s,l,p,f,_,y){const w=this.cells[p];if(w!==null){const S=this.keys,I=this.bboxes;for(let z=0;z<w.length;z++){const L=w[z];if(_[L]===void 0){const F=4*L;(y?y(I[F+0],I[F+1],I[F+2],I[F+3]):t<=I[F+2]&&i<=I[F+3]&&s>=I[F+0]&&l>=I[F+1])?(_[L]=!0,f.push(S[L])):_[L]=!1}}}}_forEachCell(t,i,s,l,p,f,_,y){const w=this._convertToCellCoord(t),S=this._convertToCellCoord(i),I=this._convertToCellCoord(s),z=this._convertToCellCoord(l);for(let L=w;L<=I;L++)for(let F=S;F<=z;F++){const N=this.d*F+L;if((!y||y(this._convertFromCellCoord(L),this._convertFromCellCoord(F),this._convertFromCellCoord(L+1),this._convertFromCellCoord(F+1)))&&p.call(this,t,i,s,l,N,f,_,y))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,i=3+this.cells.length+1+1;let s=0;for(let f=0;f<this.cells.length;f++)s+=this.cells[f].length;const l=new Int32Array(i+s+this.keys.length+this.bboxes.length);l[0]=this.extent,l[1]=this.n,l[2]=this.padding;let p=i;for(let f=0;f<t.length;f++){const _=t[f];l[3+f]=p,l.set(_,p),p+=_.length}return l[3+t.length]=p,l.set(this.keys,p),p+=this.keys.length,l[3+t.length+1]=p,l.set(this.bboxes,p),p+=this.bboxes.length,l.buffer}static serialize(t,i){const s=t.toArrayBuffer();return i&&i.push(s),{buffer:s}}static deserialize(t){return new na(t.buffer)}}const cn={};function Xe(r,t,i={}){if(cn[r])throw new Error(`${r} is already registered.`);Object.defineProperty(t,"_classRegistryKey",{value:r,writeable:!1}),cn[r]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}Xe("Object",Object),Xe("Set",Set),Xe("TransferableGridIndex",na),Xe("Color",Rt),Xe("Error",Error),Xe("AJAXError",X),Xe("ResolvedImage",Fr),Xe("StylePropertyFunction",Jo),Xe("StyleExpression",bc,{omit:["_evaluator"]}),Xe("ZoomDependentExpression",wc),Xe("ZoomConstantExpression",Yo),Xe("CompoundExpression",qr,{omit:["_evaluate"]});for(const r in ro)ro[r]._classRegistryKey||Xe(`Expression_${r}`,ro[r]);function kc(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function nl(r){return r.$name||r.constructor._classRegistryKey}function zc(r){return!function(t){if(t===null||typeof t!="object")return!1;const i=nl(t);return!(!i||i==="Object")}(r)&&(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||r instanceof Blob||r instanceof Error||kc(r)||qe(r)||ArrayBuffer.isView(r)||r instanceof ImageData)}function ho(r,t){if(zc(r))return(kc(r)||qe(r))&&t&&t.push(r),ArrayBuffer.isView(r)&&t&&t.push(r.buffer),r instanceof ImageData&&t&&t.push(r.data.buffer),r;if(Array.isArray(r)){const p=[];for(const f of r)p.push(ho(f,t));return p}if(typeof r!="object")throw new Error("can't serialize object of type "+typeof r);const i=nl(r);if(!i)throw new Error(`can't serialize object of unregistered class ${r.constructor.name}`);if(!cn[i])throw new Error(`${i} is not registered.`);const{klass:s}=cn[i],l=s.serialize?s.serialize(r,t):{};if(s.serialize){if(t&&l===t[t.length-1])throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const p in r){if(!r.hasOwnProperty(p)||cn[i].omit.indexOf(p)>=0)continue;const f=r[p];l[p]=cn[i].shallow.indexOf(p)>=0?f:ho(f,t)}r instanceof Error&&(l.message=r.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return i!=="Object"&&(l.$name=i),l}function Ds(r){if(zc(r))return r;if(Array.isArray(r))return r.map(Ds);if(typeof r!="object")throw new Error("can't deserialize object of type "+typeof r);const t=nl(r)||"Object";if(!cn[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=cn[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(r);const s=Object.create(i.prototype);for(const l of Object.keys(r)){if(l==="$name")continue;const p=r[l];s[l]=cn[t].shallow.indexOf(l)>=0?p:Ds(p)}return s}class sl{constructor(){this.first=!0}update(t,i){const s=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=s,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=s,!0):(this.lastFloorZoom>s?(this.lastIntegerZoom=s+1,this.lastIntegerZoomTime=i):this.lastFloorZoom<s&&(this.lastIntegerZoom=s,this.lastIntegerZoomTime=i),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=s,!0))}}const Bt={"Latin-1 Supplement":r=>r>=128&&r<=255,"Hangul Jamo":r=>r>=4352&&r<=4607,Khmer:r=>r>=6016&&r<=6143,"General Punctuation":r=>r>=8192&&r<=8303,"Letterlike Symbols":r=>r>=8448&&r<=8527,"Number Forms":r=>r>=8528&&r<=8591,"Miscellaneous Technical":r=>r>=8960&&r<=9215,"Control Pictures":r=>r>=9216&&r<=9279,"Optical Character Recognition":r=>r>=9280&&r<=9311,"Enclosed Alphanumerics":r=>r>=9312&&r<=9471,"Geometric Shapes":r=>r>=9632&&r<=9727,"Miscellaneous Symbols":r=>r>=9728&&r<=9983,"Miscellaneous Symbols and Arrows":r=>r>=11008&&r<=11263,"Ideographic Description Characters":r=>r>=12272&&r<=12287,"CJK Symbols and Punctuation":r=>r>=12288&&r<=12351,Hiragana:r=>r>=12352&&r<=12447,Katakana:r=>r>=12448&&r<=12543,Kanbun:r=>r>=12688&&r<=12703,"CJK Strokes":r=>r>=12736&&r<=12783,"Enclosed CJK Letters and Months":r=>r>=12800&&r<=13055,"CJK Compatibility":r=>r>=13056&&r<=13311,"Yijing Hexagram Symbols":r=>r>=19904&&r<=19967,"CJK Unified Ideographs":r=>r>=19968&&r<=40959,"Hangul Syllables":r=>r>=44032&&r<=55215,"Private Use Area":r=>r>=57344&&r<=63743,"Vertical Forms":r=>r>=65040&&r<=65055,"CJK Compatibility Forms":r=>r>=65072&&r<=65103,"Small Form Variants":r=>r>=65104&&r<=65135,"Halfwidth and Fullwidth Forms":r=>r>=65280&&r<=65519};function ol(r){for(const t of r)if(Dc(t.charCodeAt(0)))return!0;return!1}function _p(r){for(const t of r)if(!Mh(t.charCodeAt(0)))return!1;return!0}function al(r){const t=r.map(i=>{try{return new RegExp(`\\p{sc=${i}}`,"u").source}catch{return null}}).filter(i=>i);return new RegExp(t.join("|"),"u")}const yp=al(["Arab","Dupl","Mong","Ougr","Syrc"]);function Mh(r){return!yp.test(String.fromCodePoint(r))}const Rc=al(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function Dc(r){return!(r!==746&&r!==747&&(r<4352||!(Bt["CJK Compatibility Forms"](r)&&!(r>=65097&&r<=65103)||Bt["CJK Compatibility"](r)||Bt["CJK Strokes"](r)||!(!Bt["CJK Symbols and Punctuation"](r)||r>=12296&&r<=12305||r>=12308&&r<=12319||r===12336)||Bt["Enclosed CJK Letters and Months"](r)||Bt["Ideographic Description Characters"](r)||Bt.Kanbun(r)||Bt.Katakana(r)&&r!==12540||!(!Bt["Halfwidth and Fullwidth Forms"](r)||r===65288||r===65289||r===65293||r>=65306&&r<=65310||r===65339||r===65341||r===65343||r>=65371&&r<=65503||r===65507||r>=65512&&r<=65519)||!(!Bt["Small Form Variants"](r)||r>=65112&&r<=65118||r>=65123&&r<=65126)||Bt["Vertical Forms"](r)||Bt["Yijing Hexagram Symbols"](r)||new RegExp("\\p{sc=Cans}","u").test(String.fromCodePoint(r))||new RegExp("\\p{sc=Hang}","u").test(String.fromCodePoint(r))||Rc.test(String.fromCodePoint(r)))))}function Ch(r){return!(Dc(r)||function(t){return!!(Bt["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||Bt["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||Bt["Letterlike Symbols"](t)||Bt["Number Forms"](t)||Bt["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||Bt["Control Pictures"](t)&&t!==9251||Bt["Optical Character Recognition"](t)||Bt["Enclosed Alphanumerics"](t)||Bt["Geometric Shapes"](t)||Bt["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Bt["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Bt["CJK Symbols and Punctuation"](t)||Bt.Katakana(t)||Bt["Private Use Area"](t)||Bt["CJK Compatibility Forms"](t)||Bt["Small Form Variants"](t)||Bt["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(r))}const Ih=al(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Lc(r){return Ih.test(String.fromCodePoint(r))}function Eh(r,t){return!(!t&&Lc(r)||r>=2304&&r<=3583||r>=3840&&r<=4255||Bt.Khmer(r))}function Ah(r){for(const t of r)if(Lc(t.charCodeAt(0)))return!0;return!1}const un=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(r){this.pluginStatus=r.pluginStatus,this.pluginURL=r.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(r){if(un.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=r.applyArabicShaping,this.processBidirectionalText=r.processBidirectionalText,this.processStyledBidirectionalText=r.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getRTLTextPluginStatus(){return this.pluginStatus}syncState(r,t){return a(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if(r.pluginStatus!=="loading")return this.setState(r),r;const i=r.pluginURL,s=new Promise(p=>{this.loadScriptResolve=p});t(i);const l=new Promise(p=>setTimeout(()=>p(),this.TIMEOUT));if(yield Promise.race([s,l]),this.isParsed()){const p={pluginStatus:"loaded",pluginURL:i};return this.setState(p),p}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${i}`)})}};class si{constructor(t,i){this.zoom=t,i?(this.now=i.now||0,this.fadeDuration=i.fadeDuration||0,this.zoomHistory=i.zoomHistory||new sl,this.transition=i.transition||{},this.globalState=i.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new sl,this.transition={},this.globalState={})}isSupportedScript(t){return function(i,s){for(const l of i)if(!Eh(l.charCodeAt(0),s))return!1;return!0}(t,un.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,i=t-Math.floor(t),s=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:i+(1-i)*s}:{fromScale:.5,toScale:1,t:1-(1-s)*i}}}class po{constructor(t,i){this.property=t,this.value=i,this.expression=function(s,l){if(Xo(s))return new Jo(s,l);if(Ja(s)){const p=fh(s,l);if(p.result==="error")throw new Error(p.value.map(f=>`${f.key}: ${f.message}`).join(", "));return p.value}{let p=s;return l.type==="color"&&typeof s=="string"?p=Rt.parse(s):l.type!=="padding"||typeof s!="number"&&!Array.isArray(s)?l.type!=="numberArray"||typeof s!="number"&&!Array.isArray(s)?l.type!=="colorArray"||typeof s!="string"&&!Array.isArray(s)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(s)?p=_r.parse(s):l.type==="projectionDefinition"&&typeof s=="string"&&(p=ur.parse(s)):p=zi.parse(s):p=gr.parse(s):p=qi.parse(s),{globalStateRefs:new Set,kind:"constant",evaluate:()=>p}}}(i===void 0?t.specification.default:i,t.specification),this._evaluate=this.expression.evaluate}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,i,s){return this.property.possiblyEvaluate(this,t,i,s)}setGlobalState(t){this.expression.evaluate=(i,s,l,p,f,_)=>(i.globalState=t,this._evaluate.call(this.expression,i,s,l,p,f,_))}}class Fc{constructor(t){this.property=t,this.value=new po(t,void 0)}transitioned(t,i){return new Bc(this.property,this.value,i,lr({},t.transition,this.transition),t.now)}untransitioned(){return new Bc(this.property,this.value,null,{},0)}}class kh{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return ne(this._values[t].value.value)}setValue(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Fc(this._values[t].property)),this._values[t].value=new po(this._values[t].property,i===null?void 0:ne(i))}getTransition(t){return ne(this._values[t].transition)}setTransition(t,i){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Fc(this._values[t].property)),this._values[t].transition=ne(i)||void 0}serialize(){const t={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(t[i]=s);const l=this.getTransition(i);l!==void 0&&(t[`${i}-transition`]=l)}return t}transitioned(t,i){const s=new Oc(this._properties);for(const l of Object.keys(this._values))s._values[l]=this._values[l].transitioned(t,i._values[l]);return s}untransitioned(){const t=new Oc(this._properties);for(const i of Object.keys(this._values))t._values[i]=this._values[i].untransitioned();return t}}class Bc{constructor(t,i,s,l,p){this.property=t,this.value=i,this.begin=p+l.delay||0,this.end=this.begin+l.duration||0,t.specification.transition&&(l.delay||l.duration)&&(this.prior=s)}possiblyEvaluate(t,i,s){const l=t.now||0,p=this.value.possiblyEvaluate(t,i,s),f=this.prior;if(f){if(l>this.end)return this.prior=null,p;if(this.value.isDataDriven())return this.prior=null,p;if(l<this.begin)return f.possiblyEvaluate(t,i,s);{const _=(l-this.begin)/(this.end-this.begin);return this.property.interpolate(f.possiblyEvaluate(t,i,s),p,Lr(_))}}return p}}class Oc{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,i,s){const l=new ll(this._properties);for(const p of Object.keys(this._values))l._values[p]=this._values[p].possiblyEvaluate(t,i,s);return l}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class zh{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState={}}hasValue(t){return this._values[t].value!==void 0}getValue(t){return ne(this._values[t].value)}setValue(t,i){this._values[t]=new po(this._values[t].property,i===null?void 0:ne(i)),this._values[t].setGlobalState(this._globalState)}serialize(){const t={};for(const i of Object.keys(this._values)){const s=this.getValue(i);s!==void 0&&(t[i]=s)}return t}possiblyEvaluate(t,i,s){const l=new ll(this._properties);for(const p of Object.keys(this._values))l._values[p]=this._values[p].possiblyEvaluate(t,i,s);return l}setGlobalState(t){this._globalState=t;for(const i of Object.values(this._values))i.setGlobalState(t)}}class Mn{constructor(t,i,s){this.property=t,this.value=i,this.parameters=s}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,i,s,l){return this.property.evaluate(this.value,this.parameters,t,i,s,l)}}class ll{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class rt{constructor(t){this.specification=t}possiblyEvaluate(t,i){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(i)}interpolate(t,i,s){const l=Sn[this.specification.type];return l?l(t,i,s):t}}class ht{constructor(t,i){this.specification=t,this.overrides=i}possiblyEvaluate(t,i,s,l){return new Mn(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(i,null,{},s,l)}:t.expression,i)}interpolate(t,i,s){if(t.value.kind!=="constant"||i.value.kind!=="constant")return t;if(t.value.value===void 0||i.value.value===void 0)return new Mn(this,{kind:"constant",value:void 0},t.parameters);const l=Sn[this.specification.type];if(l){const p=l(t.value.value,i.value.value,s);return new Mn(this,{kind:"constant",value:p},t.parameters)}return t}evaluate(t,i,s,l,p,f){return t.kind==="constant"?t.value:t.evaluate(i,s,l,p,f)}}class cl extends ht{possiblyEvaluate(t,i,s,l){if(t.value===void 0)return new Mn(this,{kind:"constant",value:void 0},i);if(t.expression.kind==="constant"){const p=t.expression.evaluate(i,null,{},s,l),f=t.property.specification.type==="resolvedImage"&&typeof p!="string"?p.name:p,_=this._calculate(f,f,f,i);return new Mn(this,{kind:"constant",value:_},i)}if(t.expression.kind==="camera"){const p=this._calculate(t.expression.evaluate({zoom:i.zoom-1}),t.expression.evaluate({zoom:i.zoom}),t.expression.evaluate({zoom:i.zoom+1}),i);return new Mn(this,{kind:"constant",value:p},i)}return new Mn(this,t.expression,i)}evaluate(t,i,s,l,p,f){if(t.kind==="source"){const _=t.evaluate(i,s,l,p,f);return this._calculate(_,_,_,i)}return t.kind==="composite"?this._calculate(t.evaluate({zoom:Math.floor(i.zoom)-1},s,l),t.evaluate({zoom:Math.floor(i.zoom)},s,l),t.evaluate({zoom:Math.floor(i.zoom)+1},s,l),i):t.value}_calculate(t,i,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:s,to:i}}interpolate(t){return t}}class is{constructor(t){this.specification=t}possiblyEvaluate(t,i,s,l){if(t.value!==void 0){if(t.expression.kind==="constant"){const p=t.expression.evaluate(i,null,{},s,l);return this._calculate(p,p,p,i)}return this._calculate(t.expression.evaluate(new si(Math.floor(i.zoom-1),i)),t.expression.evaluate(new si(Math.floor(i.zoom),i)),t.expression.evaluate(new si(Math.floor(i.zoom+1),i)),i)}}_calculate(t,i,s,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:t,to:i}:{from:s,to:i}}interpolate(t){return t}}class ul{constructor(t){this.specification=t}possiblyEvaluate(t,i,s,l){return!!t.expression.evaluate(i,null,{},s,l)}interpolate(){return!1}}class yr{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const i in t){const s=t[i];s.specification.overridable&&this.overridableProperties.push(i);const l=this.defaultPropertyValues[i]=new po(s,void 0),p=this.defaultTransitionablePropertyValues[i]=new Fc(s);this.defaultTransitioningPropertyValues[i]=p.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=l.possiblyEvaluate({})}}}Xe("DataDrivenProperty",ht),Xe("DataConstantProperty",rt),Xe("CrossFadedDataDrivenProperty",cl),Xe("CrossFadedProperty",is),Xe("ColorRampProperty",ul);const Rh="-transition";class Wr extends it{constructor(t,i){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,this._globalState={},t.type!=="background"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=ks(t.filter)),i.layout&&(this._unevaluatedLayout=new zh(i.layout)),i.paint)){this._transitionablePaint=new kh(i.paint);for(const s in t.paint)this.setPaintProperty(s,t.paint[s],{validate:!1});for(const s in t.layout)this.setLayoutProperty(s,t.layout[s],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ll(i.paint)}}setFilter(t){this.filter=t,this._featureFilter=ks(t)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;if(this._unevaluatedLayout)for(const i in this._unevaluatedLayout._values){const s=this._unevaluatedLayout._values[i];for(const l of s.getGlobalStateRefs())t.add(l)}for(const i of this._featureFilter.getGlobalStateRefs())t.add(i);return t}getPaintAffectingGlobalStateRefs(){var t;const i=new globalThis.Map;if(this._transitionablePaint)for(const s in this._transitionablePaint._values){const l=this._transitionablePaint._values[s].value;for(const p of l.getGlobalStateRefs()){const f=(t=i.get(p))!==null&&t!==void 0?t:[];f.push({name:s,value:l.value}),i.set(p,f)}}return i}setLayoutProperty(t,i,s={}){i!=null&&this._validate(gp,`layers.${this.id}.layout.${t}`,t,i,s)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,i):this.visibility=i)}getPaintProperty(t){return t.endsWith(Rh)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,i,s={}){if(i!=null&&this._validate(mp,`layers.${this.id}.paint.${t}`,t,i,s))return!1;if(t.endsWith(Rh))return this._transitionablePaint.setTransition(t.slice(0,-11),i||void 0),!1;{const l=this._transitionablePaint._values[t],p=l.property.specification["property-type"]==="cross-faded-data-driven",f=l.value.isDataDriven(),_=l.value;this._transitionablePaint.setValue(t,i),this._handleSpecialPaintPropertyUpdate(t);const y=this._transitionablePaint._values[t].value;return y.isDataDriven()||f||p||this._handleOverridablePaintPropertyUpdate(t,_,y)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,i,s){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,i){t.globalState=this._globalState,t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,i)}setGlobalState(t){this._globalState=t,this._unevaluatedLayout&&this._unevaluatedLayout.setGlobalState(t)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),ys(t,(i,s)=>!(i===void 0||s==="layout"&&!Object.keys(i).length||s==="paint"&&!Object.keys(i).length))}_validate(t,i,s,l,p={}){return(!p||p.validate!==!1)&&ra(this,t.call(uo,{key:i,layerType:this.type,objectKey:s,value:l,styleSpec:fe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const i=this.paint.get(t);if(i instanceof Mn&&es(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}}const vp={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class sa{constructor(t,i){this._structArray=t,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Qt{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,i){return t._trim(),i&&(t.isTransferred=!0,i.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const i=Object.create(this.prototype);return i.arrayBuffer=t.arrayBuffer,i.length=t.length,i.capacity=t.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Si(r,t=1){let i=0,s=0;return{members:r.map(l=>{const p=vp[l.type].BYTES_PER_ELEMENT,f=i=hl(i,Math.max(t,p)),_=l.components||1;return s=Math.max(s,p),i+=p*_,{name:l.name,type:l.type,components:_,offset:f}}),size:hl(i,Math.max(s,t)),alignment:t}}function hl(r,t){return Math.ceil(r/t)*t}class fo extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const l=2*t;return this.int16[l+0]=i,this.int16[l+1]=s,t}}fo.prototype.bytesPerElement=4,Xe("StructArrayLayout2i4",fo);class mo extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,s)}emplace(t,i,s,l){const p=3*t;return this.int16[p+0]=i,this.int16[p+1]=s,this.int16[p+2]=l,t}}mo.prototype.bytesPerElement=6,Xe("StructArrayLayout3i6",mo);class jc extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,l){const p=this.length;return this.resize(p+1),this.emplace(p,t,i,s,l)}emplace(t,i,s,l,p){const f=4*t;return this.int16[f+0]=i,this.int16[f+1]=s,this.int16[f+2]=l,this.int16[f+3]=p,t}}jc.prototype.bytesPerElement=8,Xe("StructArrayLayout4i8",jc);class go extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f){const _=this.length;return this.resize(_+1),this.emplace(_,t,i,s,l,p,f)}emplace(t,i,s,l,p,f,_){const y=6*t;return this.int16[y+0]=i,this.int16[y+1]=s,this.int16[y+2]=l,this.int16[y+3]=p,this.int16[y+4]=f,this.int16[y+5]=_,t}}go.prototype.bytesPerElement=12,Xe("StructArrayLayout2i4i12",go);class Ls extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f){const _=this.length;return this.resize(_+1),this.emplace(_,t,i,s,l,p,f)}emplace(t,i,s,l,p,f,_){const y=4*t,w=8*t;return this.int16[y+0]=i,this.int16[y+1]=s,this.uint8[w+4]=l,this.uint8[w+5]=p,this.uint8[w+6]=f,this.uint8[w+7]=_,t}}Ls.prototype.bytesPerElement=8,Xe("StructArrayLayout2i4ub8",Ls);class oa extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const l=2*t;return this.float32[l+0]=i,this.float32[l+1]=s,t}}oa.prototype.bytesPerElement=8,Xe("StructArrayLayout2f8",oa);class dl extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f,_,y,w,S){const I=this.length;return this.resize(I+1),this.emplace(I,t,i,s,l,p,f,_,y,w,S)}emplace(t,i,s,l,p,f,_,y,w,S,I){const z=10*t;return this.uint16[z+0]=i,this.uint16[z+1]=s,this.uint16[z+2]=l,this.uint16[z+3]=p,this.uint16[z+4]=f,this.uint16[z+5]=_,this.uint16[z+6]=y,this.uint16[z+7]=w,this.uint16[z+8]=S,this.uint16[z+9]=I,t}}dl.prototype.bytesPerElement=20,Xe("StructArrayLayout10ui20",dl);class Fs extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f,_,y,w,S,I,z){const L=this.length;return this.resize(L+1),this.emplace(L,t,i,s,l,p,f,_,y,w,S,I,z)}emplace(t,i,s,l,p,f,_,y,w,S,I,z,L){const F=12*t;return this.int16[F+0]=i,this.int16[F+1]=s,this.int16[F+2]=l,this.int16[F+3]=p,this.uint16[F+4]=f,this.uint16[F+5]=_,this.uint16[F+6]=y,this.uint16[F+7]=w,this.int16[F+8]=S,this.int16[F+9]=I,this.int16[F+10]=z,this.int16[F+11]=L,t}}Fs.prototype.bytesPerElement=24,Xe("StructArrayLayout4i4ui4i24",Fs);class Nc extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,s)}emplace(t,i,s,l){const p=3*t;return this.float32[p+0]=i,this.float32[p+1]=s,this.float32[p+2]=l,t}}Nc.prototype.bytesPerElement=12,Xe("StructArrayLayout3f12",Nc);class Vc extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint32[1*t+0]=i,t}}Vc.prototype.bytesPerElement=4,Xe("StructArrayLayout1ul4",Vc);class pl extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f,_,y,w){const S=this.length;return this.resize(S+1),this.emplace(S,t,i,s,l,p,f,_,y,w)}emplace(t,i,s,l,p,f,_,y,w,S){const I=10*t,z=5*t;return this.int16[I+0]=i,this.int16[I+1]=s,this.int16[I+2]=l,this.int16[I+3]=p,this.int16[I+4]=f,this.int16[I+5]=_,this.uint32[z+3]=y,this.uint16[I+8]=w,this.uint16[I+9]=S,t}}pl.prototype.bytesPerElement=20,Xe("StructArrayLayout6i1ul2ui20",pl);class Uc extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f){const _=this.length;return this.resize(_+1),this.emplace(_,t,i,s,l,p,f)}emplace(t,i,s,l,p,f,_){const y=6*t;return this.int16[y+0]=i,this.int16[y+1]=s,this.int16[y+2]=l,this.int16[y+3]=p,this.int16[y+4]=f,this.int16[y+5]=_,t}}Uc.prototype.bytesPerElement=12,Xe("StructArrayLayout2i2i2i12",Uc);class h extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p){const f=this.length;return this.resize(f+1),this.emplace(f,t,i,s,l,p)}emplace(t,i,s,l,p,f){const _=4*t,y=8*t;return this.float32[_+0]=i,this.float32[_+1]=s,this.float32[_+2]=l,this.int16[y+6]=p,this.int16[y+7]=f,t}}h.prototype.bytesPerElement=16,Xe("StructArrayLayout2f1f2i16",h);class e extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f){const _=this.length;return this.resize(_+1),this.emplace(_,t,i,s,l,p,f)}emplace(t,i,s,l,p,f,_){const y=16*t,w=4*t,S=8*t;return this.uint8[y+0]=i,this.uint8[y+1]=s,this.float32[w+1]=l,this.float32[w+2]=p,this.int16[S+6]=f,this.int16[S+7]=_,t}}e.prototype.bytesPerElement=16,Xe("StructArrayLayout2ub2f2i16",e);class n extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,s)}emplace(t,i,s,l){const p=3*t;return this.uint16[p+0]=i,this.uint16[p+1]=s,this.uint16[p+2]=l,t}}n.prototype.bytesPerElement=6,Xe("StructArrayLayout3ui6",n);class o extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H){const he=this.length;return this.resize(he+1),this.emplace(he,t,i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H)}emplace(t,i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H,he){const ee=24*t,re=12*t,ve=48*t;return this.int16[ee+0]=i,this.int16[ee+1]=s,this.uint16[ee+2]=l,this.uint16[ee+3]=p,this.uint32[re+2]=f,this.uint32[re+3]=_,this.uint32[re+4]=y,this.uint16[ee+10]=w,this.uint16[ee+11]=S,this.uint16[ee+12]=I,this.float32[re+7]=z,this.float32[re+8]=L,this.uint8[ve+36]=F,this.uint8[ve+37]=N,this.uint8[ve+38]=$,this.uint32[re+10]=H,this.int16[ee+22]=he,t}}o.prototype.bytesPerElement=48,Xe("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",o);class c extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H,he,ee,re,ve,we,Ee,Ue,Be,Ne,nt,je){const Ve=this.length;return this.resize(Ve+1),this.emplace(Ve,t,i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H,he,ee,re,ve,we,Ee,Ue,Be,Ne,nt,je)}emplace(t,i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H,he,ee,re,ve,we,Ee,Ue,Be,Ne,nt,je,Ve){const Me=32*t,ft=16*t;return this.int16[Me+0]=i,this.int16[Me+1]=s,this.int16[Me+2]=l,this.int16[Me+3]=p,this.int16[Me+4]=f,this.int16[Me+5]=_,this.int16[Me+6]=y,this.int16[Me+7]=w,this.uint16[Me+8]=S,this.uint16[Me+9]=I,this.uint16[Me+10]=z,this.uint16[Me+11]=L,this.uint16[Me+12]=F,this.uint16[Me+13]=N,this.uint16[Me+14]=$,this.uint16[Me+15]=H,this.uint16[Me+16]=he,this.uint16[Me+17]=ee,this.uint16[Me+18]=re,this.uint16[Me+19]=ve,this.uint16[Me+20]=we,this.uint16[Me+21]=Ee,this.uint16[Me+22]=Ue,this.uint32[ft+12]=Be,this.float32[ft+13]=Ne,this.float32[ft+14]=nt,this.uint16[Me+30]=je,this.uint16[Me+31]=Ve,t}}c.prototype.bytesPerElement=64,Xe("StructArrayLayout8i15ui1ul2f2ui64",c);class d extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.float32[1*t+0]=i,t}}d.prototype.bytesPerElement=4,Xe("StructArrayLayout1f4",d);class g extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,s)}emplace(t,i,s,l){const p=3*t;return this.uint16[6*t+0]=i,this.float32[p+1]=s,this.float32[p+2]=l,t}}g.prototype.bytesPerElement=12,Xe("StructArrayLayout1ui2f12",g);class v extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,i,s)}emplace(t,i,s,l){const p=4*t;return this.uint32[2*t+0]=i,this.uint16[p+2]=s,this.uint16[p+3]=l,t}}v.prototype.bytesPerElement=8,Xe("StructArrayLayout1ul2ui8",v);class x extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,i)}emplace(t,i,s){const l=2*t;return this.uint16[l+0]=i,this.uint16[l+1]=s,t}}x.prototype.bytesPerElement=4,Xe("StructArrayLayout2ui4",x);class P extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const i=this.length;return this.resize(i+1),this.emplace(i,t)}emplace(t,i){return this.uint16[1*t+0]=i,t}}P.prototype.bytesPerElement=2,Xe("StructArrayLayout1ui2",P);class C extends Qt{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,i,s,l){const p=this.length;return this.resize(p+1),this.emplace(p,t,i,s,l)}emplace(t,i,s,l,p){const f=4*t;return this.float32[f+0]=i,this.float32[f+1]=s,this.float32[f+2]=l,this.float32[f+3]=p,t}}C.prototype.bytesPerElement=16,Xe("StructArrayLayout4f16",C);class k extends sa{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new V(this.anchorPointX,this.anchorPointY)}}k.prototype.size=20;class A extends pl{get(t){return new k(this,t)}}Xe("CollisionBoxArray",A);class R extends sa{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}R.prototype.size=48;class O extends o{get(t){return new R(this,t)}}Xe("PlacedSymbolArray",O);class Z extends sa{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Z.prototype.size=64;class G extends c{get(t){return new Z(this,t)}}Xe("SymbolInstanceArray",G);class q extends d{getoffsetX(t){return this.float32[1*t+0]}}Xe("GlyphOffsetArray",q);class W extends mo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}Xe("SymbolLineVertexArray",W);class J extends sa{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}J.prototype.size=12;class K extends g{get(t){return new J(this,t)}}Xe("TextAnchorOffsetArray",K);class te extends sa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}te.prototype.size=8;class se extends v{get(t){return new te(this,t)}}Xe("FeatureIndexArray",se);class Y extends fo{}class pe extends fo{}class be extends fo{}class _e extends go{}class ye extends Ls{}class xe extends oa{}class Le extends dl{}class Oe extends Fs{}class Ie extends Nc{}class et extends Vc{}class Tt extends Uc{}class Wt extends e{}class ei extends n{}class Yt extends x{}const pi=Si([{name:"a_pos",components:2,type:"Int16"}],4),{members:yi}=pi;class bt{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,i,s,l){const p=this.segments[this.segments.length-1];return t>bt.MAX_VERTEX_ARRAY_LENGTH&&Te(`Max vertices per segment is ${bt.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${bt.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!p||p.vertexLength+t>bt.MAX_VERTEX_ARRAY_LENGTH||p.sortKey!==l?this.createNewSegment(i,s,l):p}createNewSegment(t,i,s){const l={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0,vaos:{}};return s!==void 0&&(l.sortKey=s),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(l),l}getOrCreateLatestSegment(t,i,s){return this.prepareSegment(0,t,i,s)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const i in t.vaos)t.vaos[i].destroy()}static simpleSegment(t,i,s,l){return new bt([{vertexOffset:t,primitiveOffset:i,vertexLength:s,primitiveLength:l,vaos:{},sortKey:0}])}}function ti(r,t){return 256*(r=Ai(Math.floor(r),0,255))+Ai(Math.floor(t),0,255)}bt.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Xe("SegmentVector",bt);const Ri=Si([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Vi,Wi,vr,hn={exports:{}},rs={exports:{}},ns={exports:{}},_o=function(){if(vr)return hn.exports;vr=1;var r=(Vi||(Vi=1,rs.exports=function(i,s){var l,p,f,_,y,w,S,I;for(p=i.length-(l=3&i.length),f=s,y=3432918353,w=461845907,I=0;I<p;)S=255&i.charCodeAt(I)|(255&i.charCodeAt(++I))<<8|(255&i.charCodeAt(++I))<<16|(255&i.charCodeAt(++I))<<24,++I,f=27492+(65535&(_=5*(65535&(f=(f^=S=(65535&(S=(S=(65535&S)*y+(((S>>>16)*y&65535)<<16)&4294967295)<<15|S>>>17))*w+(((S>>>16)*w&65535)<<16)&4294967295)<<13|f>>>19))+((5*(f>>>16)&65535)<<16)&4294967295))+((58964+(_>>>16)&65535)<<16);switch(S=0,l){case 3:S^=(255&i.charCodeAt(I+2))<<16;case 2:S^=(255&i.charCodeAt(I+1))<<8;case 1:f^=S=(65535&(S=(S=(65535&(S^=255&i.charCodeAt(I)))*y+(((S>>>16)*y&65535)<<16)&4294967295)<<15|S>>>17))*w+(((S>>>16)*w&65535)<<16)&4294967295}return f^=i.length,f=2246822507*(65535&(f^=f>>>16))+((2246822507*(f>>>16)&65535)<<16)&4294967295,f=3266489909*(65535&(f^=f>>>13))+((3266489909*(f>>>16)&65535)<<16)&4294967295,(f^=f>>>16)>>>0}),rs.exports),t=(Wi||(Wi=1,ns.exports=function(i,s){for(var l,p=i.length,f=s^p,_=0;p>=4;)l=1540483477*(65535&(l=255&i.charCodeAt(_)|(255&i.charCodeAt(++_))<<8|(255&i.charCodeAt(++_))<<16|(255&i.charCodeAt(++_))<<24))+((1540483477*(l>>>16)&65535)<<16),f=1540483477*(65535&f)+((1540483477*(f>>>16)&65535)<<16)^(l=1540483477*(65535&(l^=l>>>24))+((1540483477*(l>>>16)&65535)<<16)),p-=4,++_;switch(p){case 3:f^=(255&i.charCodeAt(_+2))<<16;case 2:f^=(255&i.charCodeAt(_+1))<<8;case 1:f=1540483477*(65535&(f^=255&i.charCodeAt(_)))+((1540483477*(f>>>16)&65535)<<16)}return f=1540483477*(65535&(f^=f>>>13))+((1540483477*(f>>>16)&65535)<<16),(f^=f>>>15)>>>0}),ns.exports);return hn.exports=r,hn.exports.murmur3=r,hn.exports.murmur2=t,hn.exports}(),yo=ue(_o);class Bs{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,i,s,l){this.ids.push(Os(t)),this.positions.push(i,s,l)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const i=Os(t);let s=0,l=this.ids.length-1;for(;s<l;){const f=s+l>>1;this.ids[f]>=i?l=f:s=f+1}const p=[];for(;this.ids[s]===i;)p.push({index:this.positions[3*s],start:this.positions[3*s+1],end:this.positions[3*s+2]}),s++;return p}static serialize(t,i){const s=new Float64Array(t.ids),l=new Uint32Array(t.positions);return Er(s,l,0,s.length-1),i&&i.push(s.buffer,l.buffer),{ids:s,positions:l}}static deserialize(t){const i=new Bs;return i.ids=t.ids,i.positions=t.positions,i.indexed=!0,i}}function Os(r){const t=+r;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:yo(String(r))}function Er(r,t,i,s){for(;i<s;){const l=r[i+s>>1];let p=i-1,f=s+1;for(;;){do p++;while(r[p]<l);do f--;while(r[f]>l);if(p>=f)break;dn(r,p,f),dn(t,3*p,3*f),dn(t,3*p+1,3*f+1),dn(t,3*p+2,3*f+2)}f-i<s-f?(Er(r,t,i,f),i=f+1):(Er(r,t,f+1,s),s=f)}}function dn(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}Xe("FeaturePositionMap",Bs);class xr{constructor(t,i){this.gl=t.gl,this.location=i}}class ss extends xr{constructor(t,i){super(t,i),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Di extends xr{constructor(t,i){super(t,i),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Ui extends xr{constructor(t,i){super(t,i),this.current=Rt.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Xr=new Float32Array(16);function Li(r){return[ti(255*r.r,255*r.g),ti(255*r.b,255*r.a)]}class aa{constructor(t,i,s){this.value=t,this.uniformNames=i.map(l=>`u_${l}`),this.type=s}setUniform(t,i,s){t.set(s.constantOr(this.value))}getBinding(t,i,s){return this.type==="color"?new Ui(t,i):new ss(t,i)}}class vo{constructor(t,i){this.uniformNames=i.map(s=>`u_${s}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,i){this.pixelRatioFrom=i.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=i.tlbr,this.patternTo=t.tlbr}setUniform(t,i,s,l){const p=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;p&&t.set(p)}getBinding(t,i,s){return s.substr(0,9)==="u_pattern"?new Di(t,i):new ss(t,i)}}class Dn{constructor(t,i,s,l){this.expression=t,this.type=s,this.maxValue=0,this.paintVertexAttributes=i.map(p=>({name:`a_${p}`,type:"Float32",components:s==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(t,i,s){const l=this.paintVertexArray.length,p=this.expression.evaluate(new si(0,s),i,{},s.canonical,[],s.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(l,t,p)}updatePaintArray(t,i,s,l,p){const f=this.expression.evaluate(new si(0,p),s,l);this._setPaintValue(t,i,f)}_setPaintValue(t,i,s){if(this.type==="color"){const l=Li(s);for(let p=t;p<i;p++)this.paintVertexArray.emplace(p,l[0],l[1])}else{for(let l=t;l<i;l++)this.paintVertexArray.emplace(l,s);this.maxValue=Math.max(this.maxValue,Math.abs(s))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class pn{constructor(t,i,s,l,p,f){this.expression=t,this.uniformNames=i.map(_=>`u_${_}_t`),this.type=s,this.useIntegerZoom=l,this.zoom=p,this.maxValue=0,this.paintVertexAttributes=i.map(_=>({name:`a_${_}`,type:"Float32",components:s==="color"?4:2,offset:0})),this.paintVertexArray=new f}populatePaintArray(t,i,s){const l=this.expression.evaluate(new si(this.zoom,s),i,{},s.canonical,[],s.formattedSection),p=this.expression.evaluate(new si(this.zoom+1,s),i,{},s.canonical,[],s.formattedSection),f=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(f,t,l,p)}updatePaintArray(t,i,s,l,p){const f=this.expression.evaluate(new si(this.zoom,p),s,l),_=this.expression.evaluate(new si(this.zoom+1,p),s,l);this._setPaintValue(t,i,f,_)}_setPaintValue(t,i,s,l){if(this.type==="color"){const p=Li(s),f=Li(l);for(let _=t;_<i;_++)this.paintVertexArray.emplace(_,p[0],p[1],f[0],f[1])}else{for(let p=t;p<i;p++)this.paintVertexArray.emplace(p,s,l);this.maxValue=Math.max(this.maxValue,Math.abs(s),Math.abs(l))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,i){const s=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,l=Ai(this.expression.interpolationFactor(s,this.zoom,this.zoom+1),0,1);t.set(l)}getBinding(t,i,s){return new ss(t,i)}}class os{constructor(t,i,s,l,p,f){this.expression=t,this.type=i,this.useIntegerZoom=s,this.zoom=l,this.layerId=f,this.zoomInPaintVertexArray=new p,this.zoomOutPaintVertexArray=new p}populatePaintArray(t,i,s){const l=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(l,t,i.patterns&&i.patterns[this.layerId],s.imagePositions)}updatePaintArray(t,i,s,l,p){this._setPaintValues(t,i,s.patterns&&s.patterns[this.layerId],p.imagePositions)}_setPaintValues(t,i,s,l){if(!l||!s)return;const{min:p,mid:f,max:_}=s,y=l[p],w=l[f],S=l[_];if(y&&w&&S)for(let I=t;I<i;I++)this.zoomInPaintVertexArray.emplace(I,w.tl[0],w.tl[1],w.br[0],w.br[1],y.tl[0],y.tl[1],y.br[0],y.br[1],w.pixelRatio,y.pixelRatio),this.zoomOutPaintVertexArray.emplace(I,w.tl[0],w.tl[1],w.br[0],w.br[1],S.tl[0],S.tl[1],S.br[0],S.br[1],w.pixelRatio,S.pixelRatio)}upload(t){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,Ri.members,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,Ri.members,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class Dh{constructor(t,i,s){this.binders={},this._buffers=[];const l=[];for(const p in t.paint._values){if(!s(p))continue;const f=t.paint.get(p);if(!(f instanceof Mn&&es(f.property.specification)))continue;const _=Lh(p,t.type),y=f.value,w=f.property.specification.type,S=f.property.useIntegerZoom,I=f.property.specification["property-type"],z=I==="cross-faded"||I==="cross-faded-data-driven";if(y.kind==="constant")this.binders[p]=z?new vo(y.value,_):new aa(y.value,_,w),l.push(`/u_${p}`);else if(y.kind==="source"||z){const L=$c(p,w,"source");this.binders[p]=z?new os(y,w,S,i,L,t.id):new Dn(y,_,w,L),l.push(`/a_${p}`)}else{const L=$c(p,w,"composite");this.binders[p]=new pn(y,_,w,S,i,L),l.push(`/z_${p}`)}}this.cacheKey=l.sort().join("")}getMaxValue(t){const i=this.binders[t];return i instanceof Dn||i instanceof pn?i.maxValue:0}populatePaintArrays(t,i,s){for(const l in this.binders){const p=this.binders[l];(p instanceof Dn||p instanceof pn||p instanceof os)&&p.populatePaintArray(t,i,s)}}setConstantPatternPositions(t,i){for(const s in this.binders){const l=this.binders[s];l instanceof vo&&l.setConstantPatternPositions(t,i)}}updatePaintArrays(t,i,s,l,p){let f=!1;for(const _ in t){const y=i.getPositions(_);for(const w of y){const S=s.feature(w.index);for(const I in this.binders){const z=this.binders[I];if((z instanceof Dn||z instanceof pn||z instanceof os)&&z.expression.isStateDependent===!0){const L=l.paint.get(I);z.expression=L.value,z.updatePaintArray(w.start,w.end,S,t[_],p),f=!0}}}}return f}defines(){const t=[];for(const i in this.binders){const s=this.binders[i];(s instanceof aa||s instanceof vo)&&t.push(...s.uniformNames.map(l=>`#define HAS_UNIFORM_${l}`))}return t}getBinderAttributes(){const t=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof Dn||s instanceof pn)for(let l=0;l<s.paintVertexAttributes.length;l++)t.push(s.paintVertexAttributes[l].name);else if(s instanceof os)for(let l=0;l<Ri.members.length;l++)t.push(Ri.members[l].name)}return t}getBinderUniforms(){const t=[];for(const i in this.binders){const s=this.binders[i];if(s instanceof aa||s instanceof vo||s instanceof pn)for(const l of s.uniformNames)t.push(l)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,i){const s=[];for(const l in this.binders){const p=this.binders[l];if(p instanceof aa||p instanceof vo||p instanceof pn){for(const f of p.uniformNames)if(i[f]){const _=p.getBinding(t,i[f],f);s.push({name:f,property:l,binding:_})}}}return s}setUniforms(t,i,s,l){for(const{name:p,property:f,binding:_}of i)this.binders[f].setUniform(_,l,s.get(f),p)}updatePaintBuffers(t){this._buffers=[];for(const i in this.binders){const s=this.binders[i];if(t&&s instanceof os){const l=t.fromScale===2?s.zoomInPaintVertexBuffer:s.zoomOutPaintVertexBuffer;l&&this._buffers.push(l)}else(s instanceof Dn||s instanceof pn)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(const i in this.binders){const s=this.binders[i];(s instanceof Dn||s instanceof pn||s instanceof os)&&s.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const i=this.binders[t];(i instanceof Dn||i instanceof pn||i instanceof os)&&i.destroy()}}}class Or{constructor(t,i,s=()=>!0){this.programConfigurations={};for(const l of t)this.programConfigurations[l.id]=new Dh(l,i,s);this.needsUpload=!1,this._featureMap=new Bs,this._bufferOffset=0}populatePaintArrays(t,i,s,l){for(const p in this.programConfigurations)this.programConfigurations[p].populatePaintArrays(t,i,l);i.id!==void 0&&this._featureMap.add(i.id,s,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,i,s,l){for(const p of s)this.needsUpload=this.programConfigurations[p.id].updatePaintArrays(t,this._featureMap,i,p,l)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function Lh(r,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[r]||[r.replace(`${t}-`,"").replace(/-/g,"_")]}function $c(r,t,i){const s={color:{source:oa,composite:C},number:{source:d,composite:oa}},l=function(p){return{"line-pattern":{source:Le,composite:Le},"fill-pattern":{source:Le,composite:Le},"fill-extrusion-pattern":{source:Le,composite:Le}}[p]}(r);return l&&l[i]||s[t][i]}Xe("ConstantBinder",aa),Xe("CrossFadedConstantBinder",vo),Xe("SourceExpressionBinder",Dn),Xe("CrossFadedCompositeBinder",os),Xe("CompositeExpressionBinder",pn),Xe("ProgramConfiguration",Dh,{omit:["_buffers"]}),Xe("ProgramConfigurationSet",Or);const fl=Math.pow(2,14)-1,ml=-fl-1;function as(r){const t=Vt/r.extent,i=r.loadGeometry();for(let s=0;s<i.length;s++){const l=i[s];for(let p=0;p<l.length;p++){const f=l[p],_=Math.round(f.x*t),y=Math.round(f.y*t);f.x=Ai(_,ml,fl),f.y=Ai(y,ml,fl),(_<f.x||_>f.x+1||y<f.y||y>f.y+1)&&Te("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Ln(r,t){return{type:r.type,id:r.id,properties:r.properties,geometry:t?as(r):[]}}const mg=-32768;function ab(r,t,i,s,l){r.emplaceBack(mg+8*t+s,mg+8*i+l)}class xp{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new pe,this.indexArray=new ei,this.segments=new bt,this.programConfigurations=new Or(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){const l=this.layers[0],p=[];let f=null,_=!1,y=l.type==="heatmap";if(l.type==="circle"){const S=l;f=S.layout.get("circle-sort-key"),_=!f.isConstant(),y=y||S.paint.get("circle-pitch-alignment")==="map"}const w=y?i.subdivisionGranularity.circle:1;for(const{feature:S,id:I,index:z,sourceLayerIndex:L}of t){const F=this.layers[0]._featureFilter.needGeometry,N=Ln(S,F);if(!this.layers[0]._featureFilter.filter(new si(this.zoom,{globalState:this.globalState}),N,s))continue;const $=_?f.evaluate(N,{},s):void 0,H={id:I,properties:S.properties,type:S.type,sourceLayerIndex:L,index:z,geometry:F?N.geometry:as(S),patterns:{},sortKey:$};p.push(H)}_&&p.sort((S,I)=>S.sortKey-I.sortKey);for(const S of p){const{geometry:I,index:z,sourceLayerIndex:L}=S,F=t[z].feature;this.addFeature(S,I,z,s,w),i.featureIndex.insert(F,I,z,L,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,yi),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,i,s,l,p=1){let f;switch(p){case 1:f=[0,7];break;case 3:f=[0,2,5,7];break;case 5:f=[0,1,3,4,6,7];break;case 7:f=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${p}; valid values are 1, 3, 5, 7.`)}const _=f.length;for(const y of i)for(const w of y){const S=w.x,I=w.y;if(S<0||S>=Vt||I<0||I>=Vt)continue;const z=this.segments.prepareSegment(_*_,this.layoutVertexArray,this.indexArray,t.sortKey),L=z.vertexLength;for(let F=0;F<_;F++)for(let N=0;N<_;N++)ab(this.layoutVertexArray,S,I,f[N],f[F]);for(let F=0;F<_-1;F++)for(let N=0;N<_-1;N++){const $=L+F*_+N,H=L+(F+1)*_+N;this.indexArray.emplaceBack($,H+1,$+1),this.indexArray.emplaceBack($,H,H+1)}z.vertexLength+=_*_,z.primitiveLength+=(_-1)*(_-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:{},canonical:l,globalState:this.globalState})}}function gg(r,t){for(let i=0;i<r.length;i++)if(gl(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(gl(r,t[i]))return!0;return!!bp(r,t)}function lb(r,t,i){return!!gl(r,t)||!!wp(t,r,i)}function _g(r,t){if(r.length===1)return vg(t,r[0]);for(let i=0;i<t.length;i++){const s=t[i];for(let l=0;l<s.length;l++)if(gl(r,s[l]))return!0}for(let i=0;i<r.length;i++)if(vg(t,r[i]))return!0;for(let i=0;i<t.length;i++)if(bp(r,t[i]))return!0;return!1}function cb(r,t,i){if(r.length>1){if(bp(r,t))return!0;for(let s=0;s<t.length;s++)if(wp(t[s],r,i))return!0}for(let s=0;s<r.length;s++)if(wp(r[s],t,i))return!0;return!1}function bp(r,t){if(r.length===0||t.length===0)return!1;for(let i=0;i<r.length-1;i++){const s=r[i],l=r[i+1];for(let p=0;p<t.length-1;p++)if(ub(s,l,t[p],t[p+1]))return!0}return!1}function ub(r,t,i,s){return ze(r,i,s)!==ze(t,i,s)&&ze(r,t,i)!==ze(r,t,s)}function wp(r,t,i){const s=i*i;if(t.length===1)return r.distSqr(t[0])<s;for(let l=1;l<t.length;l++)if(yg(r,t[l-1],t[l])<s)return!0;return!1}function yg(r,t,i){const s=t.distSqr(i);if(s===0)return r.distSqr(t);const l=((r.x-t.x)*(i.x-t.x)+(r.y-t.y)*(i.y-t.y))/s;return r.distSqr(l<0?t:l>1?i:i.sub(t)._mult(l)._add(t))}function vg(r,t){let i,s,l,p=!1;for(let f=0;f<r.length;f++){i=r[f];for(let _=0,y=i.length-1;_<i.length;y=_++)s=i[_],l=i[y],s.y>t.y!=l.y>t.y&&t.x<(l.x-s.x)*(t.y-s.y)/(l.y-s.y)+s.x&&(p=!p)}return p}function gl(r,t){let i=!1;for(let s=0,l=r.length-1;s<r.length;l=s++){const p=r[s],f=r[l];p.y>t.y!=f.y>t.y&&t.x<(f.x-p.x)*(t.y-p.y)/(f.y-p.y)+p.x&&(i=!i)}return i}function hb(r,t,i){const s=i[0],l=i[2];if(r.x<s.x&&t.x<s.x||r.x>l.x&&t.x>l.x||r.y<s.y&&t.y<s.y||r.y>l.y&&t.y>l.y)return!1;const p=ze(r,t,i[0]);return p!==ze(r,t,i[1])||p!==ze(r,t,i[2])||p!==ze(r,t,i[3])}function Gc(r,t,i){const s=t.paint.get(r).value;return s.kind==="constant"?s.value:i.programConfigurations.get(t.id).getMaxValue(r)}function Fh(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function Bh(r,t,i,s,l){if(!t[0]&&!t[1])return r;const p=V.convert(t)._mult(l);i==="viewport"&&p._rotate(-s);const f=[];for(let _=0;_<r.length;_++)f.push(r[_].sub(p));return f}let xg,bg;Xe("CircleBucket",xp,{omit:["layers"]});var db={get paint(){return bg=bg||new yr({"circle-radius":new ht(fe.paint_circle["circle-radius"]),"circle-color":new ht(fe.paint_circle["circle-color"]),"circle-blur":new ht(fe.paint_circle["circle-blur"]),"circle-opacity":new ht(fe.paint_circle["circle-opacity"]),"circle-translate":new rt(fe.paint_circle["circle-translate"]),"circle-translate-anchor":new rt(fe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new rt(fe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new rt(fe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ht(fe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ht(fe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ht(fe.paint_circle["circle-stroke-opacity"])})},get layout(){return xg=xg||new yr({"circle-sort-key":new ht(fe.layout_circle["circle-sort-key"])})}};class pb extends Wr{constructor(t){super(t,db)}createBucket(t){return new xp(t)}queryRadius(t){const i=t;return Gc("circle-radius",this,i)+Gc("circle-stroke-width",this,i)+Fh(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:l,transform:p,pixelsToTileUnits:f,unwrappedTileID:_,getElevation:y}){const w=Bh(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-p.bearingInRadians,f),S=this.paint.get("circle-radius").evaluate(i,s)+this.paint.get("circle-stroke-width").evaluate(i,s),I=this.paint.get("circle-pitch-alignment")==="map",z=I?w:function(F,N,$,H){return F.map(he=>wg(he,N,$,H))}(w,p,_,y),L=I?S*f:S;for(const F of l)for(const N of F){const $=I?N:wg(N,p,_,y);let H=L;const he=p.projectTileCoordinates(N.x,N.y,_,y).signedDistanceFromCamera;if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?H*=he/p.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(H*=p.cameraToCenterDistance/he),lb(z,$,H))return!0}return!1}}function wg(r,t,i,s){const l=t.projectTileCoordinates(r.x,r.y,i,s).point;return new V((.5*l.x+.5)*t.width,(.5*-l.y+.5)*t.height)}class Tg extends xp{}let Sg;Xe("HeatmapBucket",Tg,{omit:["layers"]});var fb={get paint(){return Sg=Sg||new yr({"heatmap-radius":new ht(fe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ht(fe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new rt(fe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new ul(fe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new rt(fe.paint_heatmap["heatmap-opacity"])})}};function Tp(r,{width:t,height:i},s,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==t*i*s)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${t*i*s}`)}else l=new Uint8Array(t*i*s);return r.width=t,r.height=i,r.data=l,r}function Pg(r,{width:t,height:i},s){if(t===r.width&&i===r.height)return;const l=Tp({},{width:t,height:i},s);Sp(r,l,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,t),height:Math.min(r.height,i)},s),r.width=t,r.height=i,r.data=l.data}function Sp(r,t,i,s,l,p){if(l.width===0||l.height===0)return t;if(l.width>r.width||l.height>r.height||i.x>r.width-l.width||i.y>r.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>t.width||l.height>t.height||s.x>t.width-l.width||s.y>t.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const f=r.data,_=t.data;if(f===_)throw new Error("srcData equals dstData, so image is already copied");for(let y=0;y<l.height;y++){const w=((i.y+y)*r.width+i.x)*p,S=((s.y+y)*t.width+s.x)*p;for(let I=0;I<l.width*p;I++)_[S+I]=f[w+I]}return t}class Zc{constructor(t,i){Tp(this,t,1,i)}resize(t){Pg(this,t,1)}clone(){return new Zc({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,s,l,p){Sp(t,i,s,l,p,1)}}class jr{constructor(t,i){Tp(this,t,4,i)}resize(t){Pg(this,t,4)}replace(t,i){i?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new jr({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,i,s,l,p){Sp(t,i,s,l,p,4)}setPixel(t,i,s){const l=4*(t*this.width+i);this.data[l+0]=Math.round(255*s.r/s.a),this.data[l+1]=Math.round(255*s.g/s.a),this.data[l+2]=Math.round(255*s.b/s.a),this.data[l+3]=Math.round(255*s.a)}}function Mg(r){const t={},i=r.resolution||256,s=r.clips?r.clips.length:1,l=r.image||new jr({width:i,height:s});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const p=(f,_,y)=>{t[r.evaluationKey]=y;const w=r.expression.evaluate(t);l.setPixel(f/4/i,_/4,w)};if(r.clips)for(let f=0,_=0;f<s;++f,_+=4*i)for(let y=0,w=0;y<i;y++,w+=4){const S=y/(i-1),{start:I,end:z}=r.clips[f];p(_,w,I*(1-S)+z*S)}else for(let f=0,_=0;f<i;f++,_+=4)p(0,_,f/(i-1));return l}Xe("AlphaImage",Zc),Xe("RGBAImage",jr);const Pp="big-fb";class mb extends Wr{createBucket(t){return new Tg(t)}constructor(t){super(t,fb),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Mg({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Pp)&&this.heatmapFbos.delete(Pp)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}}let Cg;var gb={get paint(){return Cg=Cg||new yr({"hillshade-illumination-direction":new rt(fe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new rt(fe.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new rt(fe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new rt(fe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new rt(fe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new rt(fe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new rt(fe.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new rt(fe.paint_hillshade["hillshade-method"])})}};class _b extends Wr{constructor(t){super(t,gb),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,i=this.paint.get("hillshade-illumination-altitude").values,s=this.paint.get("hillshade-highlight-color").values,l=this.paint.get("hillshade-shadow-color").values;const p=Math.max(t.length,i.length,s.length,l.length);t=t.concat(Array(p-t.length).fill(t.at(-1))),i=i.concat(Array(p-i.length).fill(i.at(-1))),s=s.concat(Array(p-s.length).fill(s.at(-1))),l=l.concat(Array(p-l.length).fill(l.at(-1)));const f=i.map(lt);return{directionRadians:t.map(lt),altitudeRadians:f,shadowColor:l,highlightColor:s}}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}}let Ig;var yb={get paint(){return Ig=Ig||new yr({"color-relief-opacity":new rt(fe["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new ul(fe["paint_color-relief"]["color-relief-color"])})}};class Mp{constructor(t,i,s,l){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(i,l)}update(t,i,s){const{width:l,height:p}=t,f=!(this.size&&this.size[0]===l&&this.size[1]===p||s),{context:_}=this,{gl:y}=_;if(this.useMipmap=!!(i&&i.useMipmap),y.bindTexture(y.TEXTURE_2D,this.texture),_.pixelStoreUnpackFlipY.set(!1),_.pixelStoreUnpack.set(1),_.pixelStoreUnpackPremultiplyAlpha.set(this.format===y.RGBA&&(!i||i.premultiply!==!1)),f)this.size=[l,p],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||qe(t)?y.texImage2D(y.TEXTURE_2D,0,this.format,this.format,y.UNSIGNED_BYTE,t):y.texImage2D(y.TEXTURE_2D,0,this.format,l,p,0,this.format,y.UNSIGNED_BYTE,t.data);else{const{x:w,y:S}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||qe(t)?y.texSubImage2D(y.TEXTURE_2D,0,w,S,y.RGBA,y.UNSIGNED_BYTE,t):y.texSubImage2D(y.TEXTURE_2D,0,w,S,l,p,y.RGBA,y.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&y.generateMipmap(y.TEXTURE_2D),_.pixelStoreUnpackFlipY.setDefault(),_.pixelStoreUnpack.setDefault(),_.pixelStoreUnpackPremultiplyAlpha.setDefault()}bind(t,i,s){const{context:l}=this,{gl:p}=l;p.bindTexture(p.TEXTURE_2D,this.texture),s!==p.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=p.LINEAR),t!==this.filter&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,t),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,s||t),this.filter=t),i!==this.wrap&&(p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,i),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,i),this.wrap=i)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class Eg{constructor(t,i,s,l=1,p=1,f=1,_=0){if(this.uid=t,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(s&&!["mapbox","terrarium","custom"].includes(s))return void Te(`"${s}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;const y=this.dim=i.height-2;switch(this.data=new Uint32Array(i.data.buffer),s){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=l,this.greenFactor=p,this.blueFactor=f,this.baseShift=_;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let w=0;w<y;w++)this.data[this._idx(-1,w)]=this.data[this._idx(0,w)],this.data[this._idx(y,w)]=this.data[this._idx(y-1,w)],this.data[this._idx(w,-1)]=this.data[this._idx(w,0)],this.data[this._idx(w,y)]=this.data[this._idx(w,y-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(y,-1)]=this.data[this._idx(y-1,0)],this.data[this._idx(-1,y)]=this.data[this._idx(0,y-1)],this.data[this._idx(y,y)]=this.data[this._idx(y-1,y-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let w=0;w<y;w++)for(let S=0;S<y;S++){const I=this.get(w,S);I>this.max&&(this.max=I),I<this.min&&(this.min=I)}}get(t,i){const s=new Uint8Array(this.data.buffer),l=4*this._idx(t,i);return this.unpack(s[l],s[l+1],s[l+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,i){if(t<-1||t>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(t+1)}unpack(t,i,s){return t*this.redFactor+i*this.greenFactor+s*this.blueFactor-this.baseShift}pack(t){return Ag(t,this.getUnpackVector())}getPixels(){return new jr({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,i,s){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let l=i*this.dim,p=i*this.dim+this.dim,f=s*this.dim,_=s*this.dim+this.dim;switch(i){case-1:l=p-1;break;case 1:p=l+1}switch(s){case-1:f=_-1;break;case 1:_=f+1}const y=-i*this.dim,w=-s*this.dim;for(let S=f;S<_;S++)for(let I=l;I<p;I++)this.data[this._idx(I,S)]=t.data[this._idx(I+y,S+w)]}}function Ag(r,t){const i=t[0],s=t[1],l=t[2],p=t[3],f=Math.min(i,s,l),_=Math.round((r+p)/f);return{r:Math.floor(_*f/i)%256,g:Math.floor(_*f/s)%256,b:Math.floor(_*f/l)%256}}Xe("DEMData",Eg);class vb extends Wr{constructor(t){super(t,yb)}_createColorRamp(t){const i={elevationStops:[],colorStops:[]},s=this._transitionablePaint._values["color-relief-color"].value.expression;if(s instanceof Yo&&s._styleExpression.expression instanceof rr){this.colorRampExpression=s;const f=s._styleExpression.expression;i.elevationStops=f.labels,i.colorStops=[];for(const _ of i.elevationStops)i.colorStops.push(f.evaluate({globals:{elevation:_}}))}if(i.elevationStops.length<1&&(i.elevationStops=[0],i.colorStops=[Rt.transparent]),i.elevationStops.length<2&&(i.elevationStops.push(i.elevationStops[0]+1),i.colorStops.push(i.colorStops[0])),i.elevationStops.length<=t)return i;const l={elevationStops:[],colorStops:[]},p=(i.elevationStops.length-1)/(t-1);for(let f=0;f<i.elevationStops.length-.5;f+=p)l.elevationStops.push(i.elevationStops[Math.round(f)]),l.colorStops.push(i.colorStops[Math.round(f)]);return Te(`Too many colors in specification of ${this.id} color-relief layer, may not render properly.`),l}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,i,s){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const l=this._createColorRamp(i),p=new jr({width:l.colorStops.length,height:1}),f=new jr({width:l.colorStops.length,height:1});for(let _=0;_<l.elevationStops.length;_++){const y=Ag(l.elevationStops[_],s);f.setPixel(0,_,new Rt(y.r/255,y.g/255,y.b/255,1)),p.setPixel(0,_,l.colorStops[_])}return this.colorRampTextures={elevationTexture:new Mp(t,f,t.gl.RGBA),colorTexture:new Mp(t,p,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return this.visibility!=="none"&&!!this.colorRampTextures}}const xb=Si([{name:"a_pos",components:2,type:"Int16"}],4),{members:bb}=xb;function Cp(r,t,i){const s=i.patternDependencies;let l=!1;for(const p of t){const f=p.paint.get(`${r}-pattern`);f.isConstant()||(l=!0);const _=f.constantOr(null);_&&(l=!0,s[_.to]=!0,s[_.from]=!0)}return l}function Ip(r,t,i,s,l){const{zoom:p,globalState:f}=s,_=l.patternDependencies;for(const y of t){const w=y.paint.get(`${r}-pattern`).value;if(w.kind!=="constant"){let S=w.evaluate({zoom:p-1,globalState:f},i,{},l.availableImages),I=w.evaluate({zoom:p,globalState:f},i,{},l.availableImages),z=w.evaluate({zoom:p+1,globalState:f},i,{},l.availableImages);S=S&&S.name?S.name:S,I=I&&I.name?I.name:I,z=z&&z.name?z.name:z,_[S]=!0,_[I]=!0,_[z]=!0,i.patterns[y.id]={min:S,mid:I,max:z}}}return i}function kg(r,t,i,s,l){let p;if(l===function(f,_,y,w){let S=0;for(let I=_,z=y-w;I<y;I+=w)S+=(f[z]-f[I])*(f[I+1]+f[z+1]),z=I;return S}(r,t,i,s)>0)for(let f=t;f<i;f+=s)p=Lg(f/s|0,r[f],r[f+1],p);else for(let f=i-s;f>=t;f-=s)p=Lg(f/s|0,r[f],r[f+1],p);return p&&_l(p,p.next)&&(Xc(p),p=p.next),p}function la(r,t){if(!r)return r;t||(t=r);let i,s=r;do if(i=!1,s.steiner||!_l(s,s.next)&&Ei(s.prev,s,s.next)!==0)s=s.next;else{if(Xc(s),s=t=s.prev,s===s.next)break;i=!0}while(i||s!==t);return t}function qc(r,t,i,s,l,p,f){if(!r)return;!f&&p&&function(y,w,S,I){let z=y;do z.z===0&&(z.z=Ep(z.x,z.y,w,S,I)),z.prevZ=z.prev,z.nextZ=z.next,z=z.next;while(z!==y);z.prevZ.nextZ=null,z.prevZ=null,function(L){let F,N=1;do{let $,H=L;L=null;let he=null;for(F=0;H;){F++;let ee=H,re=0;for(let we=0;we<N&&(re++,ee=ee.nextZ,ee);we++);let ve=N;for(;re>0||ve>0&&ee;)re!==0&&(ve===0||!ee||H.z<=ee.z)?($=H,H=H.nextZ,re--):($=ee,ee=ee.nextZ,ve--),he?he.nextZ=$:L=$,$.prevZ=he,he=$;H=ee}he.nextZ=null,N*=2}while(F>1)}(z)}(r,s,l,p);let _=r;for(;r.prev!==r.next;){const y=r.prev,w=r.next;if(p?Tb(r,s,l,p):wb(r))t.push(y.i,r.i,w.i),Xc(r),r=w.next,_=w.next;else if((r=w)===_){f?f===1?qc(r=Sb(la(r),t),t,i,s,l,p,2):f===2&&Pb(r,t,i,s,l,p):qc(la(r),t,i,s,l,p,1);break}}}function wb(r){const t=r.prev,i=r,s=r.next;if(Ei(t,i,s)>=0)return!1;const l=t.x,p=i.x,f=s.x,_=t.y,y=i.y,w=s.y,S=Math.min(l,p,f),I=Math.min(_,y,w),z=Math.max(l,p,f),L=Math.max(_,y,w);let F=s.next;for(;F!==t;){if(F.x>=S&&F.x<=z&&F.y>=I&&F.y<=L&&Hc(l,_,p,y,f,w,F.x,F.y)&&Ei(F.prev,F,F.next)>=0)return!1;F=F.next}return!0}function Tb(r,t,i,s){const l=r.prev,p=r,f=r.next;if(Ei(l,p,f)>=0)return!1;const _=l.x,y=p.x,w=f.x,S=l.y,I=p.y,z=f.y,L=Math.min(_,y,w),F=Math.min(S,I,z),N=Math.max(_,y,w),$=Math.max(S,I,z),H=Ep(L,F,t,i,s),he=Ep(N,$,t,i,s);let ee=r.prevZ,re=r.nextZ;for(;ee&&ee.z>=H&&re&&re.z<=he;){if(ee.x>=L&&ee.x<=N&&ee.y>=F&&ee.y<=$&&ee!==l&&ee!==f&&Hc(_,S,y,I,w,z,ee.x,ee.y)&&Ei(ee.prev,ee,ee.next)>=0||(ee=ee.prevZ,re.x>=L&&re.x<=N&&re.y>=F&&re.y<=$&&re!==l&&re!==f&&Hc(_,S,y,I,w,z,re.x,re.y)&&Ei(re.prev,re,re.next)>=0))return!1;re=re.nextZ}for(;ee&&ee.z>=H;){if(ee.x>=L&&ee.x<=N&&ee.y>=F&&ee.y<=$&&ee!==l&&ee!==f&&Hc(_,S,y,I,w,z,ee.x,ee.y)&&Ei(ee.prev,ee,ee.next)>=0)return!1;ee=ee.prevZ}for(;re&&re.z<=he;){if(re.x>=L&&re.x<=N&&re.y>=F&&re.y<=$&&re!==l&&re!==f&&Hc(_,S,y,I,w,z,re.x,re.y)&&Ei(re.prev,re,re.next)>=0)return!1;re=re.nextZ}return!0}function Sb(r,t){let i=r;do{const s=i.prev,l=i.next.next;!_l(s,l)&&Rg(s,i,i.next,l)&&Wc(s,l)&&Wc(l,s)&&(t.push(s.i,i.i,l.i),Xc(i),Xc(i.next),i=r=l),i=i.next}while(i!==r);return la(i)}function Pb(r,t,i,s,l,p){let f=r;do{let _=f.next.next;for(;_!==f.prev;){if(f.i!==_.i&&Ab(f,_)){let y=Dg(f,_);return f=la(f,f.next),y=la(y,y.next),qc(f,t,i,s,l,p,0),void qc(y,t,i,s,l,p,0)}_=_.next}f=f.next}while(f!==r)}function Mb(r,t){let i=r.x-t.x;return i===0&&(i=r.y-t.y,i===0)&&(i=(r.next.y-r.y)/(r.next.x-r.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Cb(r,t){const i=function(l,p){let f=p;const _=l.x,y=l.y;let w,S=-1/0;if(_l(l,f))return f;do{if(_l(l,f.next))return f.next;if(y<=f.y&&y>=f.next.y&&f.next.y!==f.y){const N=f.x+(y-f.y)*(f.next.x-f.x)/(f.next.y-f.y);if(N<=_&&N>S&&(S=N,w=f.x<f.next.x?f:f.next,N===_))return w}f=f.next}while(f!==p);if(!w)return null;const I=w,z=w.x,L=w.y;let F=1/0;f=w;do{if(_>=f.x&&f.x>=z&&_!==f.x&&zg(y<L?_:S,y,z,L,y<L?S:_,y,f.x,f.y)){const N=Math.abs(y-f.y)/(_-f.x);Wc(f,l)&&(N<F||N===F&&(f.x>w.x||f.x===w.x&&Ib(w,f)))&&(w=f,F=N)}f=f.next}while(f!==I);return w}(r,t);if(!i)return t;const s=Dg(i,r);return la(s,s.next),la(i,i.next)}function Ib(r,t){return Ei(r.prev,r,t.prev)<0&&Ei(t.next,r,r.next)<0}function Ep(r,t,i,s,l){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-i)*l|0)|r<<8))|r<<4))|r<<2))|r<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-s)*l|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Eb(r){let t=r,i=r;do(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;while(t!==r);return i}function zg(r,t,i,s,l,p,f,_){return(l-f)*(t-_)>=(r-f)*(p-_)&&(r-f)*(s-_)>=(i-f)*(t-_)&&(i-f)*(p-_)>=(l-f)*(s-_)}function Hc(r,t,i,s,l,p,f,_){return!(r===f&&t===_)&&zg(r,t,i,s,l,p,f,_)}function Ab(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!function(i,s){let l=i;do{if(l.i!==i.i&&l.next.i!==i.i&&l.i!==s.i&&l.next.i!==s.i&&Rg(l,l.next,i,s))return!0;l=l.next}while(l!==i);return!1}(r,t)&&(Wc(r,t)&&Wc(t,r)&&function(i,s){let l=i,p=!1;const f=(i.x+s.x)/2,_=(i.y+s.y)/2;do l.y>_!=l.next.y>_&&l.next.y!==l.y&&f<(l.next.x-l.x)*(_-l.y)/(l.next.y-l.y)+l.x&&(p=!p),l=l.next;while(l!==i);return p}(r,t)&&(Ei(r.prev,r,t.prev)||Ei(r,t.prev,t))||_l(r,t)&&Ei(r.prev,r,r.next)>0&&Ei(t.prev,t,t.next)>0)}function Ei(r,t,i){return(t.y-r.y)*(i.x-t.x)-(t.x-r.x)*(i.y-t.y)}function _l(r,t){return r.x===t.x&&r.y===t.y}function Rg(r,t,i,s){const l=jh(Ei(r,t,i)),p=jh(Ei(r,t,s)),f=jh(Ei(i,s,r)),_=jh(Ei(i,s,t));return l!==p&&f!==_||!(l!==0||!Oh(r,i,t))||!(p!==0||!Oh(r,s,t))||!(f!==0||!Oh(i,r,s))||!(_!==0||!Oh(i,t,s))}function Oh(r,t,i){return t.x<=Math.max(r.x,i.x)&&t.x>=Math.min(r.x,i.x)&&t.y<=Math.max(r.y,i.y)&&t.y>=Math.min(r.y,i.y)}function jh(r){return r>0?1:r<0?-1:0}function Wc(r,t){return Ei(r.prev,r,r.next)<0?Ei(r,t,r.next)>=0&&Ei(r,r.prev,t)>=0:Ei(r,t,r.prev)<0||Ei(r,r.next,t)<0}function Dg(r,t){const i=Ap(r.i,r.x,r.y),s=Ap(t.i,t.x,t.y),l=r.next,p=t.prev;return r.next=t,t.prev=r,i.next=l,l.prev=i,s.next=i,i.prev=s,p.next=s,s.prev=p,s}function Lg(r,t,i,s){const l=Ap(r,t,i);return s?(l.next=s.next,l.prev=s,s.next.prev=l,s.next=l):(l.prev=l,l.next=l),l}function Xc(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Ap(r,t,i){return{i:r,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class yl{constructor(t,i){if(i>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=i}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class Nh{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}Nh.noSubdivision=new Nh({fill:new yl(0,0),line:new yl(0,0),tile:new yl(0,0),stencil:new yl(0,0),circle:1}),Xe("SubdivisionGranularityExpression",yl),Xe("SubdivisionGranularitySetting",Nh);const vl=-32768,Kc=32767;class kb{constructor(t,i){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=Vt/t,this._canonical=i}_getKey(t,i){return(t+=32768)<<16|i+32768}_vertexToIndex(t,i){if(t<-32768||i<-32768||t>32767||i>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const s=0|Math.round(t),l=0|Math.round(i),p=this._getKey(s,l);if(this._vertexDictionary.has(p))return this._vertexDictionary.get(p);const f=this._vertexBuffer.length/2;return this._vertexDictionary.set(p,f),this._vertexBuffer.push(s,l),f}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(l,p){const f=[];for(let _=0;_<p.length;_+=3){const y=p[_],w=p[_+1],S=p[_+2],I=l[2*y],z=l[2*y+1];(l[2*w]-I)*(l[2*S+1]-z)-(l[2*w+1]-z)*(l[2*S]-I)>0?(f.push(y),f.push(S),f.push(w)):(f.push(y),f.push(w),f.push(S))}return f}(this._vertexBuffer,t);const i=[],s=t.length;for(let l=0;l<s;l+=3){const p=[t[l+0],t[l+1],t[l+2]],f=[this._vertexBuffer[2*t[l+0]+0],this._vertexBuffer[2*t[l+0]+1],this._vertexBuffer[2*t[l+1]+0],this._vertexBuffer[2*t[l+1]+1],this._vertexBuffer[2*t[l+2]+0],this._vertexBuffer[2*t[l+2]+1]];let _=1/0,y=1/0,w=-1/0,S=-1/0;for(let N=0;N<3;N++){const $=f[2*N],H=f[2*N+1];_=Math.min(_,$),w=Math.max(w,$),y=Math.min(y,H),S=Math.max(S,H)}if(_===w||y===S)continue;const I=Math.floor(_/this._granularityCellSize),z=Math.ceil(w/this._granularityCellSize),L=Math.floor(y/this._granularityCellSize),F=Math.ceil(S/this._granularityCellSize);if(I!==z||L!==F)for(let N=L;N<F;N++){const $=this._scanlineGenerateVertexRingForCellRow(N,f,p);zb(this._vertexBuffer,$,i)}else i.push(...p)}return i}_scanlineGenerateVertexRingForCellRow(t,i,s){const l=t*this._granularityCellSize,p=l+this._granularityCellSize,f=[];for(let _=0;_<3;_++){const y=i[2*_],w=i[2*_+1],S=i[2*(_+1)%6],I=i[(2*(_+1)+1)%6],z=i[2*(_+2)%6],L=i[(2*(_+2)+1)%6],F=S-y,N=I-w,$=F===0,H=N===0,he=(l-w)/N,ee=(p-w)/N,re=Math.min(he,ee),ve=Math.max(he,ee);if(!H&&(re>=1||ve<=0)||H&&(w<l||w>p)){I>=l&&I<=p&&f.push(s[(_+1)%3]);continue}!H&&re>0&&f.push(this._vertexToIndex(y+F*re,w+N*re));const we=y+F*Math.max(re,0),Ee=y+F*Math.min(ve,1);$||this._generateIntraEdgeVertices(f,y,w,S,I,we,Ee),!H&&ve<1&&f.push(this._vertexToIndex(y+F*ve,w+N*ve)),(H||I>=l&&I<=p)&&f.push(s[(_+1)%3]),!H&&(I<=l||I>=p)&&this._generateInterEdgeVertices(f,y,w,S,I,z,L,Ee,l,p)}return f}_generateIntraEdgeVertices(t,i,s,l,p,f,_){const y=l-i,w=p-s,S=w===0,I=S?Math.min(i,l):Math.min(f,_),z=S?Math.max(i,l):Math.max(f,_),L=Math.floor(I/this._granularityCellSize)+1,F=Math.ceil(z/this._granularityCellSize)-1;if(S?i<l:f<_)for(let N=L;N<=F;N++){const $=N*this._granularityCellSize;t.push(this._vertexToIndex($,s+w*($-i)/y))}else for(let N=F;N>=L;N--){const $=N*this._granularityCellSize;t.push(this._vertexToIndex($,s+w*($-i)/y))}}_generateInterEdgeVertices(t,i,s,l,p,f,_,y,w,S){const I=p-s,z=f-l,L=_-p,F=(w-p)/L,N=(S-p)/L,$=Math.min(F,N),H=Math.max(F,N),he=l+z*$;let ee=Math.floor(Math.min(he,y)/this._granularityCellSize)+1,re=Math.ceil(Math.max(he,y)/this._granularityCellSize)-1,ve=y<he;const we=L===0;if(we&&(_===w||_===S))return;if(we||$>=1||H<=0){const Ue=s-_,Be=f+(i-f)*Math.min((w-_)/Ue,(S-_)/Ue);ee=Math.floor(Math.min(Be,y)/this._granularityCellSize)+1,re=Math.ceil(Math.max(Be,y)/this._granularityCellSize)-1,ve=y<Be}const Ee=I>0?S:w;if(ve)for(let Ue=ee;Ue<=re;Ue++)t.push(this._vertexToIndex(Ue*this._granularityCellSize,Ee));else for(let Ue=re;Ue>=ee;Ue--)t.push(this._vertexToIndex(Ue*this._granularityCellSize,Ee))}_generateOutline(t){const i=[];for(const s of t){const l=ca(s,this._granularity,!0),p=this._pointArrayToIndices(l),f=[];for(let _=1;_<p.length;_++)f.push(p[_-1]),f.push(p[_]);i.push(f)}return i}_handlePoles(t){let i=!1,s=!1;this._canonical&&(this._canonical.y===0&&(i=!0),this._canonical.y===(1<<this._canonical.z)-1&&(s=!0)),(i||s)&&this._fillPoles(t,i,s)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let i=0;i<t.length;i+=2){const s=t[i+1];s===vl&&(t[i+1]=-32767),s===Kc&&(t[i+1]=32766)}}_generatePoleQuad(t,i,s,l,p,f){l>p!=(f===vl)?(t.push(i),t.push(s),t.push(this._vertexToIndex(l,f)),t.push(s),t.push(this._vertexToIndex(p,f)),t.push(this._vertexToIndex(l,f))):(t.push(s),t.push(i),t.push(this._vertexToIndex(l,f)),t.push(this._vertexToIndex(p,f)),t.push(s),t.push(this._vertexToIndex(l,f)))}_fillPoles(t,i,s){const l=this._vertexBuffer,p=Vt,f=t.length;for(let _=2;_<f;_+=3){const y=t[_-2],w=t[_-1],S=t[_],I=l[2*y],z=l[2*y+1],L=l[2*w],F=l[2*w+1],N=l[2*S],$=l[2*S+1];i&&(z===0&&F===0&&this._generatePoleQuad(t,y,w,I,L,vl),F===0&&$===0&&this._generatePoleQuad(t,w,S,L,N,vl),$===0&&z===0&&this._generatePoleQuad(t,S,y,N,I,vl)),s&&(z===p&&F===p&&this._generatePoleQuad(t,y,w,I,L,Kc),F===p&&$===p&&this._generatePoleQuad(t,w,S,L,N,Kc),$===p&&z===p&&this._generatePoleQuad(t,S,y,N,I,Kc))}}_initializeVertices(t){for(let i=0;i<t.length;i+=2)this._vertexToIndex(t[i],t[i+1])}subdividePolygonInternal(t,i){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:s,holeIndices:l}=function(_){const y=[],w=[];for(const S of _)if(S.length!==0){S!==_[0]&&y.push(w.length/2);for(let I=0;I<S.length;I++)w.push(S[I].x),w.push(S[I].y)}return{flattened:w,holeIndices:y}}(t);let p;this._initializeVertices(s);try{const _=function(w,S,I=2){const z=S&&S.length,L=z?S[0]*I:w.length;let F=kg(w,0,L,I,!0);const N=[];if(!F||F.next===F.prev)return N;let $,H,he;if(z&&(F=function(ee,re,ve,we){const Ee=[];for(let Ue=0,Be=re.length;Ue<Be;Ue++){const Ne=kg(ee,re[Ue]*we,Ue<Be-1?re[Ue+1]*we:ee.length,we,!1);Ne===Ne.next&&(Ne.steiner=!0),Ee.push(Eb(Ne))}Ee.sort(Mb);for(let Ue=0;Ue<Ee.length;Ue++)ve=Cb(Ee[Ue],ve);return ve}(w,S,F,I)),w.length>80*I){$=w[0],H=w[1];let ee=$,re=H;for(let ve=I;ve<L;ve+=I){const we=w[ve],Ee=w[ve+1];we<$&&($=we),Ee<H&&(H=Ee),we>ee&&(ee=we),Ee>re&&(re=Ee)}he=Math.max(ee-$,re-H),he=he!==0?32767/he:0}return qc(F,N,I,$,H,he,0),N}(s,l),y=this._convertIndices(s,_);p=this._subdivideTrianglesScanline(y)}catch(_){console.error(_)}let f=[];return i&&(f=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(p),{verticesFlattened:this._vertexBuffer,indicesTriangles:p,indicesLineList:f}}_convertIndices(t,i){const s=[];for(let l=0;l<i.length;l++)s.push(this._vertexToIndex(t[2*i[l]],t[2*i[l]+1]));return s}_pointArrayToIndices(t){const i=[];for(let s=0;s<t.length;s++){const l=t[s];i.push(this._vertexToIndex(l.x,l.y))}return i}}function Fg(r,t,i,s=!0){return new kb(i,t).subdividePolygonInternal(r,s)}function ca(r,t,i=!1){if(!r||r.length<1)return[];if(r.length<2)return[];const s=r[0],l=r[r.length-1],p=i&&(s.x!==l.x||s.y!==l.y);if(t<2)return p?[...r,r[0]]:[...r];const f=Math.floor(Vt/t),_=[];_.push(new V(r[0].x,r[0].y));const y=r.length,w=p?y:y-1;for(let S=0;S<w;S++){const I=r[S],z=S<y-1?r[S+1]:r[0],L=I.x,F=I.y,N=z.x,$=z.y,H=L!==N,he=F!==$;if(!H&&!he)continue;const ee=N-L,re=$-F,ve=Math.abs(ee),we=Math.abs(re);let Ee=L,Ue=F;for(;;){const Ne=ee>0?(Math.floor(Ee/f)+1)*f:(Math.ceil(Ee/f)-1)*f,nt=re>0?(Math.floor(Ue/f)+1)*f:(Math.ceil(Ue/f)-1)*f,je=Math.abs(Ee-Ne),Ve=Math.abs(Ue-nt),Me=Math.abs(Ee-N),ft=Math.abs(Ue-$),gt=H?je/ve:Number.POSITIVE_INFINITY,at=he?Ve/we:Number.POSITIVE_INFINITY;if((Me<=je||!H)&&(ft<=Ve||!he))break;if(gt<at&&H||!he){Ee=Ne,Ue+=re*gt;const tt=new V(Ee,Math.round(Ue));_[_.length-1].x===tt.x&&_[_.length-1].y===tt.y||_.push(tt)}else{Ee+=ee*at,Ue=nt;const tt=new V(Math.round(Ee),Ue);_[_.length-1].x===tt.x&&_[_.length-1].y===tt.y||_.push(tt)}}const Be=new V(N,$);_[_.length-1].x===Be.x&&_[_.length-1].y===Be.y||_.push(Be)}return _}function zb(r,t,i){if(t.length===0)throw new Error("Subdivision vertex ring is empty.");let s=0,l=r[2*t[0]];for(let y=1;y<t.length;y++){const w=r[2*t[y]];w<l&&(l=w,s=y)}const p=t.length;let f=s,_=(f+1)%p;for(;;){const y=f-1>=0?f-1:p-1,w=(_+1)%p,S=r[2*t[y]],I=r[2*t[w]],z=r[2*t[f]],L=r[2*t[f]+1],F=r[2*t[_]+1];let N=!1;if(S<I)N=!0;else if(S>I)N=!1;else{const $=F-L,H=-(r[2*t[_]]-z),he=L<F?1:-1;((S-z)*$+(r[2*t[y]+1]-L)*H)*he>((I-z)*$+(r[2*t[w]+1]-L)*H)*he&&(N=!0)}if(N){const $=t[y],H=t[f],he=t[_];$!==H&&$!==he&&H!==he&&i.push(he,H,$),f--,f<0&&(f=p-1)}else{const $=t[w],H=t[f],he=t[_];$!==H&&$!==he&&H!==he&&i.push(he,H,$),_++,_>=p&&(_=0)}if(y===w)break}}function Bg(r,t,i,s,l,p,f,_,y){const w=l.length/2,S=f&&_&&y;if(w<bt.MAX_VERTEX_ARRAY_LENGTH){const I=t.prepareSegment(w,i,s),z=I.vertexLength;for(let N=0;N<p.length;N+=3)s.emplaceBack(z+p[N],z+p[N+1],z+p[N+2]);let L,F;I.vertexLength+=w,I.primitiveLength+=p.length/3,S&&(F=f.prepareSegment(w,i,_),L=F.vertexLength,F.vertexLength+=w);for(let N=0;N<l.length;N+=2)r(l[N],l[N+1]);if(S)for(let N=0;N<y.length;N++){const $=y[N];for(let H=1;H<$.length;H+=2)_.emplaceBack(L+$[H-1],L+$[H]);F.primitiveLength+=$.length/2}}else(function(I,z,L,F,N,$){const H=[];for(let we=0;we<F.length/2;we++)H.push(-1);const he={count:0};let ee=0,re=I.getOrCreateLatestSegment(z,L),ve=re.vertexLength;for(let we=2;we<N.length;we+=3){const Ee=N[we-2],Ue=N[we-1],Be=N[we];let Ne=H[Ee]<ee,nt=H[Ue]<ee,je=H[Be]<ee;re.vertexLength+((Ne?1:0)+(nt?1:0)+(je?1:0))>bt.MAX_VERTEX_ARRAY_LENGTH&&(re=I.createNewSegment(z,L),ee=he.count,Ne=!0,nt=!0,je=!0,ve=0);const Ve=Yc(H,F,$,he,Ee,Ne,re),Me=Yc(H,F,$,he,Ue,nt,re),ft=Yc(H,F,$,he,Be,je,re);L.emplaceBack(ve+Ve-ee,ve+Me-ee,ve+ft-ee),re.primitiveLength++}})(t,i,s,l,p,r),S&&function(I,z,L,F,N,$){const H=[];for(let we=0;we<F.length/2;we++)H.push(-1);const he={count:0};let ee=0,re=I.getOrCreateLatestSegment(z,L),ve=re.vertexLength;for(let we=0;we<N.length;we++){const Ee=N[we];for(let Ue=1;Ue<N[we].length;Ue+=2){const Be=Ee[Ue-1],Ne=Ee[Ue];let nt=H[Be]<ee,je=H[Ne]<ee;re.vertexLength+((nt?1:0)+(je?1:0))>bt.MAX_VERTEX_ARRAY_LENGTH&&(re=I.createNewSegment(z,L),ee=he.count,nt=!0,je=!0,ve=0);const Ve=Yc(H,F,$,he,Be,nt,re),Me=Yc(H,F,$,he,Ne,je,re);L.emplaceBack(ve+Ve-ee,ve+Me-ee),re.primitiveLength++}}}(f,i,_,l,y,r),t.forceNewSegmentOnNextPrepare(),f==null||f.forceNewSegmentOnNextPrepare()}function Yc(r,t,i,s,l,p,f){if(p){const _=s.count;return i(t[2*l],t[2*l+1]),r[l]=s.count,s.count++,f.vertexLength++,_}return r[l]}class kp{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new be,this.indexArray=new ei,this.indexArray2=new Yt,this.programConfigurations=new Or(t.layers,t.zoom),this.segments=new bt,this.segments2=new bt,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.hasPattern=Cp("fill",this.layers,i);const l=this.layers[0].layout.get("fill-sort-key"),p=!l.isConstant(),f=[];for(const{feature:_,id:y,index:w,sourceLayerIndex:S}of t){const I=this.layers[0]._featureFilter.needGeometry,z=Ln(_,I);if(!this.layers[0]._featureFilter.filter(new si(this.zoom,{globalState:this.globalState}),z,s))continue;const L=p?l.evaluate(z,{},s,i.availableImages):void 0,F={id:y,properties:_.properties,type:_.type,sourceLayerIndex:S,index:w,geometry:I?z.geometry:as(_),patterns:{},sortKey:L};f.push(F)}p&&f.sort((_,y)=>_.sortKey-y.sortKey);for(const _ of f){const{geometry:y,index:w,sourceLayerIndex:S}=_;if(this.hasPattern){const I=Ip("fill",this.layers,_,{zoom:this.zoom,globalState:this.globalState},i);this.patternFeatures.push(I)}else this.addFeature(_,y,w,s,{},i.subdivisionGranularity);i.featureIndex.insert(t[w].feature,y,w,S,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}addFeatures(t,i,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,i,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,bb),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,i,s,l,p,f){for(const _ of qo(i,500)){const y=Fg(_,l,f.fill.getGranularityForZoomLevel(l.z)),w=this.layoutVertexArray;Bg((S,I)=>{w.emplaceBack(S,I)},this.segments,this.layoutVertexArray,this.indexArray,y.verticesFlattened,y.indicesTriangles,this.segments2,this.indexArray2,y.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:p,canonical:l,globalState:this.globalState})}}let Og,jg;Xe("FillBucket",kp,{omit:["layers","patternFeatures"]});var Rb={get paint(){return jg=jg||new yr({"fill-antialias":new rt(fe.paint_fill["fill-antialias"]),"fill-opacity":new ht(fe.paint_fill["fill-opacity"]),"fill-color":new ht(fe.paint_fill["fill-color"]),"fill-outline-color":new ht(fe.paint_fill["fill-outline-color"]),"fill-translate":new rt(fe.paint_fill["fill-translate"]),"fill-translate-anchor":new rt(fe.paint_fill["fill-translate-anchor"]),"fill-pattern":new cl(fe.paint_fill["fill-pattern"])})},get layout(){return Og=Og||new yr({"fill-sort-key":new ht(fe.layout_fill["fill-sort-key"])})}};class Db extends Wr{constructor(t){super(t,Rb)}recalculate(t,i){super.recalculate(t,i);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new kp(t)}queryRadius(){return Fh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:i,transform:s,pixelsToTileUnits:l}){return _g(Bh(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-s.bearingInRadians,l),i)}isTileClipped(){return!0}}const Lb=Si([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Fb=Si([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Bb}=Lb;class xl{constructor(t,i,s,l,p){this.properties={},this.extent=s,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=l,this._values=p,t.readFields(Ob,this,i)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos,s=[];let l,p=1,f=0,_=0,y=0;for(;t.pos<i;){if(f<=0){const w=t.readVarint();p=7&w,f=w>>3}if(f--,p===1||p===2)_+=t.readSVarint(),y+=t.readSVarint(),p===1&&(l&&s.push(l),l=[]),l&&l.push(new V(_,y));else{if(p!==7)throw new Error(`unknown command ${p}`);l&&l.push(l[0].clone())}}return l&&s.push(l),s}bbox(){const t=this._pbf;t.pos=this._geometry;const i=t.readVarint()+t.pos;let s=1,l=0,p=0,f=0,_=1/0,y=-1/0,w=1/0,S=-1/0;for(;t.pos<i;){if(l<=0){const I=t.readVarint();s=7&I,l=I>>3}if(l--,s===1||s===2)p+=t.readSVarint(),f+=t.readSVarint(),p<_&&(_=p),p>y&&(y=p),f<w&&(w=f),f>S&&(S=f);else if(s!==7)throw new Error(`unknown command ${s}`)}return[_,w,y,S]}toGeoJSON(t,i,s){const l=this.extent*Math.pow(2,s),p=this.extent*t,f=this.extent*i,_=this.loadGeometry();function y(z){return[360*(z.x+p)/l-180,360/Math.PI*Math.atan(Math.exp((1-2*(z.y+f)/l)*Math.PI))-90]}function w(z){return z.map(y)}let S;if(this.type===1){const z=[];for(const F of _)z.push(F[0]);const L=w(z);S=z.length===1?{type:"Point",coordinates:L[0]}:{type:"MultiPoint",coordinates:L}}else if(this.type===2){const z=_.map(w);S=z.length===1?{type:"LineString",coordinates:z[0]}:{type:"MultiLineString",coordinates:z}}else{if(this.type!==3)throw new Error("unknown feature type");{const z=function(F){const N=F.length;if(N<=1)return[F];const $=[];let H,he;for(let ee=0;ee<N;ee++){const re=jb(F[ee]);re!==0&&(he===void 0&&(he=re<0),he===re<0?(H&&$.push(H),H=[F[ee]]):H&&H.push(F[ee]))}return H&&$.push(H),$}(_),L=[];for(const F of z)L.push(F.map(w));S=L.length===1?{type:"Polygon",coordinates:L[0]}:{type:"MultiPolygon",coordinates:L}}}const I={type:"Feature",geometry:S,properties:this.properties};return this.id!=null&&(I.id=this.id),I}}function Ob(r,t,i){r===1?t.id=i.readVarint():r===2?function(s,l){const p=s.readVarint()+s.pos;for(;s.pos<p;){const f=l._keys[s.readVarint()],_=l._values[s.readVarint()];l.properties[f]=_}}(i,t):r===3?t.type=i.readVarint():r===4&&(t._geometry=i.pos)}function jb(r){let t=0;for(let i,s,l=0,p=r.length,f=p-1;l<p;f=l++)i=r[l],s=r[f],t+=(s.x-i.x)*(i.y+s.y);return t}xl.types=["Unknown","Point","LineString","Polygon"];class Ng{constructor(t,i){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Nb,this,i),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const i=this._pbf.readVarint()+this._pbf.pos;return new xl(this._pbf,i,this.extent,this._keys,this._values)}}function Nb(r,t,i){r===15?t.version=i.readVarint():r===1?t.name=i.readString():r===5?t.extent=i.readVarint():r===2?t._features.push(i.pos):r===3?t._keys.push(i.readString()):r===4&&t._values.push(function(s){let l=null;const p=s.readVarint()+s.pos;for(;s.pos<p;){const f=s.readVarint()>>3;l=f===1?s.readString():f===2?s.readFloat():f===3?s.readDouble():f===4?s.readVarint64():f===5?s.readVarint():f===6?s.readSVarint():f===7?s.readBoolean():null}if(l==null)throw new Error("unknown feature value");return l}(i))}class Vg{constructor(t,i){this.layers=t.readFields(Vb,{},i)}}function Vb(r,t,i){if(r===3){const s=new Ng(i,i.readVarint()+i.pos);s.length&&(t[s.name]=s)}}const zp=Math.pow(2,13);function Jc(r,t,i,s,l,p,f,_){r.emplaceBack(t,i,2*Math.floor(s*zp)+f,l*zp*2,p*zp*2,Math.round(_))}class Rp{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new _e,this.centroidVertexArray=new Y,this.indexArray=new ei,this.programConfigurations=new Or(t.layers,t.zoom),this.segments=new bt,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.features=[],this.hasPattern=Cp("fill-extrusion",this.layers,i);for(const{feature:l,id:p,index:f,sourceLayerIndex:_}of t){const y=this.layers[0]._featureFilter.needGeometry,w=Ln(l,y);if(!this.layers[0]._featureFilter.filter(new si(this.zoom,{globalState:this.globalState}),w,s))continue;const S={id:p,sourceLayerIndex:_,index:f,geometry:y?w.geometry:as(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Ip("fill-extrusion",this.layers,S,{zoom:this.zoom,globalState:this.globalState},i)):this.addFeature(S,S.geometry,f,s,{},i.subdivisionGranularity),i.featureIndex.insert(l,S.geometry,f,_,this.index,!0)}}addFeatures(t,i,s){for(const l of this.features){const{geometry:p}=l;this.addFeature(l,p,l.index,i,s,t.subdivisionGranularity)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Bb),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Fb.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,i,s,l,p,f){for(const _ of qo(i,500)){const y={x:0,y:0,sampleCount:0},w=this.layoutVertexArray.length;this.processPolygon(y,l,t,_,f);const S=this.layoutVertexArray.length-w,I=Math.floor(y.x/y.sampleCount),z=Math.floor(y.y/y.sampleCount);for(let L=0;L<S;L++)this.centroidVertexArray.emplaceBack(I,z)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:p,canonical:l,globalState:this.globalState})}processPolygon(t,i,s,l,p){if(l.length<1||Ug(l[0]))return;for(const I of l)I.length!==0&&Ub(t,I);const f={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},_=p.fill.getGranularityForZoomLevel(i.z),y=xl.types[s.type]==="Polygon";for(const I of l){if(I.length===0||Ug(I))continue;const z=ca(I,_,y);this._generateSideFaces(z,f)}if(!y)return;const w=Fg(l,i,_,!1),S=this.layoutVertexArray;Bg((I,z)=>{Jc(S,I,z,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,w.verticesFlattened,w.indicesTriangles)}_generateSideFaces(t,i){let s=0;for(let l=1;l<t.length;l++){const p=t[l],f=t[l-1];if($b(p,f))continue;i.segment.vertexLength+4>bt.MAX_VERTEX_ARRAY_LENGTH&&(i.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const _=p.sub(f)._perp()._unit(),y=f.dist(p);s+y>32768&&(s=0),Jc(this.layoutVertexArray,p.x,p.y,_.x,_.y,0,0,s),Jc(this.layoutVertexArray,p.x,p.y,_.x,_.y,0,1,s),s+=y,Jc(this.layoutVertexArray,f.x,f.y,_.x,_.y,0,0,s),Jc(this.layoutVertexArray,f.x,f.y,_.x,_.y,0,1,s);const w=i.segment.vertexLength;this.indexArray.emplaceBack(w,w+2,w+1),this.indexArray.emplaceBack(w+1,w+2,w+3),i.segment.vertexLength+=4,i.segment.primitiveLength+=2}}}function Ub(r,t){for(let i=0;i<t.length;i++){const s=t[i];i===t.length-1&&t[0].x===s.x&&t[0].y===s.y||(r.x+=s.x,r.y+=s.y,r.sampleCount++)}}function $b(r,t){return r.x===t.x&&(r.x<0||r.x>Vt)||r.y===t.y&&(r.y<0||r.y>Vt)}function Ug(r){return r.every(t=>t.x<0)||r.every(t=>t.x>Vt)||r.every(t=>t.y<0)||r.every(t=>t.y>Vt)}let $g;Xe("FillExtrusionBucket",Rp,{omit:["layers","features"]});var Gb={get paint(){return $g=$g||new yr({"fill-extrusion-opacity":new rt(fe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ht(fe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new rt(fe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new rt(fe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new cl(fe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new ht(fe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ht(fe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new rt(fe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Zb extends Wr{constructor(t){super(t,Gb)}createBucket(t){return new Rp(t)}queryRadius(){return Fh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:l,transform:p,pixelsToTileUnits:f,pixelPosMatrix:_}){const y=Bh(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-p.bearingInRadians,f),w=this.paint.get("fill-extrusion-height").evaluate(i,s),S=this.paint.get("fill-extrusion-base").evaluate(i,s),I=function(L,F){const N=[];for(const $ of L){const H=[$.x,$.y,0,1];en(H,H,F),N.push(new V(H[0]/H[3],H[1]/H[3]))}return N}(y,_),z=function(L,F,N,$){const H=[],he=[],ee=$[8]*F,re=$[9]*F,ve=$[10]*F,we=$[11]*F,Ee=$[8]*N,Ue=$[9]*N,Be=$[10]*N,Ne=$[11]*N;for(const nt of L){const je=[],Ve=[];for(const Me of nt){const ft=Me.x,gt=Me.y,at=$[0]*ft+$[4]*gt+$[12],tt=$[1]*ft+$[5]*gt+$[13],Ot=$[2]*ft+$[6]*gt+$[14],vi=$[3]*ft+$[7]*gt+$[15],$i=Ot+ve,pr=vi+we,mn=at+Ee,Nr=tt+Ue,nr=Ot+Be,fi=vi+Ne,Ki=new V((at+ee)/pr,(tt+re)/pr);Ki.z=$i/pr,je.push(Ki);const sr=new V(mn/fi,Nr/fi);sr.z=nr/fi,Ve.push(sr)}H.push(je),he.push(Ve)}return[H,he]}(l,S,w,_);return function(L,F,N){let $=1/0;_g(N,F)&&($=Gg(N,F[0]));for(let H=0;H<F.length;H++){const he=F[H],ee=L[H];for(let re=0;re<he.length-1;re++){const ve=he[re],we=[ve,he[re+1],ee[re+1],ee[re],ve];gg(N,we)&&($=Math.min($,Gg(N,we)))}}return $!==1/0&&$}(z[0],z[1],I)}}function Qc(r,t){return r.x*t.x+r.y*t.y}function Gg(r,t){if(r.length===1){let i=0;const s=t[i++];let l;for(;!l||s.equals(l);)if(l=t[i++],!l)return 1/0;for(;i<t.length;i++){const p=t[i],f=r[0],_=l.sub(s),y=p.sub(s),w=f.sub(s),S=Qc(_,_),I=Qc(_,y),z=Qc(y,y),L=Qc(w,_),F=Qc(w,y),N=S*z-I*I,$=(z*L-I*F)/N,H=(S*F-I*L)/N,he=s.z*(1-$-H)+l.z*$+p.z*H;if(isFinite(he))return he}return 1/0}{let i=1/0;for(const s of t)i=Math.min(i,s.z);return i}}const qb=Si([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:Hb}=qb,Wb=Si([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:Xb}=Wb,Kb=Math.cos(Math.PI/180*37.5),Zg=Math.pow(2,14)/.5;class Dp{constructor(t){this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(i=>i.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new ye,this.layoutVertexArray2=new xe,this.indexArray=new ei,this.programConfigurations=new Or(t.layers,t.zoom),this.segments=new bt,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(t,i,s){this.hasPattern=Cp("line",this.layers,i);const l=this.layers[0].layout.get("line-sort-key"),p=!l.isConstant(),f=[];for(const{feature:_,id:y,index:w,sourceLayerIndex:S}of t){const I=this.layers[0]._featureFilter.needGeometry,z=Ln(_,I);if(!this.layers[0]._featureFilter.filter(new si(this.zoom,{globalState:this.globalState}),z,s))continue;const L=p?l.evaluate(z,{},s):void 0,F={id:y,properties:_.properties,type:_.type,sourceLayerIndex:S,index:w,geometry:I?z.geometry:as(_),patterns:{},sortKey:L};f.push(F)}p&&f.sort((_,y)=>_.sortKey-y.sortKey);for(const _ of f){const{geometry:y,index:w,sourceLayerIndex:S}=_;if(this.hasPattern){const I=Ip("line",this.layers,_,{zoom:this.zoom,globalState:this.globalState},i);this.patternFeatures.push(I)}else this.addFeature(_,y,w,s,{},i.subdivisionGranularity);i.featureIndex.insert(t[w].feature,y,w,S,this.index)}}update(t,i,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,i,this.stateDependentLayers,{imagePositions:s,globalState:this.globalState})}addFeatures(t,i,s){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,i,s,t.subdivisionGranularity)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Xb)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hb),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,i,s,l,p,f){const _=this.layers[0].layout,y=_.get("line-join").evaluate(t,{}),w=_.get("line-cap"),S=_.get("line-miter-limit"),I=_.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const z of i)this.addLine(z,t,y,w,S,I,l,f);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,s,{imagePositions:p,canonical:l,globalState:this.globalState})}addLine(t,i,s,l,p,f,_,y){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=ca(t,_?y.line.getGranularityForZoomLevel(_.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let ee=0;ee<t.length-1;ee++)this.totalDistance+=t[ee].dist(t[ee+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const w=xl.types[i.type]==="Polygon";let S=t.length;for(;S>=2&&t[S-1].equals(t[S-2]);)S--;let I=0;for(;I<S-1&&t[I].equals(t[I+1]);)I++;if(S<(w?3:2))return;s==="bevel"&&(p=1.05);const z=this.overscaling<=16?122880/(512*this.overscaling):0,L=this.segments.prepareSegment(10*S,this.layoutVertexArray,this.indexArray);let F,N,$,H,he;this.e1=this.e2=-1,w&&(F=t[S-2],he=t[I].sub(F)._unit()._perp());for(let ee=I;ee<S;ee++){if($=ee===S-1?w?t[I+1]:void 0:t[ee+1],$&&t[ee].equals($))continue;he&&(H=he),F&&(N=F),F=t[ee],he=$?$.sub(F)._unit()._perp():H,H=H||he;let re=H.add(he);re.x===0&&re.y===0||re._unit();const ve=H.x*he.x+H.y*he.y,we=re.x*he.x+re.y*he.y,Ee=we!==0?1/we:1/0,Ue=2*Math.sqrt(2-2*we),Be=we<Kb&&N&&$,Ne=H.x*he.y-H.y*he.x>0;if(Be&&ee>I){const Ve=F.dist(N);if(Ve>2*z){const Me=F.sub(F.sub(N)._mult(z/Ve)._round());this.updateDistance(N,Me),this.addCurrentVertex(Me,H,0,0,L),N=Me}}const nt=N&&$;let je=nt?s:w?"butt":l;if(nt&&je==="round"&&(Ee<f?je="miter":Ee<=2&&(je="fakeround")),je==="miter"&&Ee>p&&(je="bevel"),je==="bevel"&&(Ee>2&&(je="flipbevel"),Ee<p&&(je="miter")),N&&this.updateDistance(N,F),je==="miter")re._mult(Ee),this.addCurrentVertex(F,re,0,0,L);else if(je==="flipbevel"){if(Ee>100)re=he.mult(-1);else{const Ve=Ee*H.add(he).mag()/H.sub(he).mag();re._perp()._mult(Ve*(Ne?-1:1))}this.addCurrentVertex(F,re,0,0,L),this.addCurrentVertex(F,re.mult(-1),0,0,L)}else if(je==="bevel"||je==="fakeround"){const Ve=-Math.sqrt(Ee*Ee-1),Me=Ne?Ve:0,ft=Ne?0:Ve;if(N&&this.addCurrentVertex(F,H,Me,ft,L),je==="fakeround"){const gt=Math.round(180*Ue/Math.PI/20);for(let at=1;at<gt;at++){let tt=at/gt;if(tt!==.5){const vi=tt-.5;tt+=tt*vi*(tt-1)*((1.0904+ve*(ve*(3.55645-1.43519*ve)-3.2452))*vi*vi+(.848013+ve*(.215638*ve-1.06021)))}const Ot=he.sub(H)._mult(tt)._add(H)._unit()._mult(Ne?-1:1);this.addHalfVertex(F,Ot.x,Ot.y,!1,Ne,0,L)}}$&&this.addCurrentVertex(F,he,-Me,-ft,L)}else if(je==="butt")this.addCurrentVertex(F,re,0,0,L);else if(je==="square"){const Ve=N?1:-1;this.addCurrentVertex(F,re,Ve,Ve,L)}else je==="round"&&(N&&(this.addCurrentVertex(F,H,0,0,L),this.addCurrentVertex(F,H,1,1,L,!0)),$&&(this.addCurrentVertex(F,he,-1,-1,L,!0),this.addCurrentVertex(F,he,0,0,L)));if(Be&&ee<S-1){const Ve=F.dist($);if(Ve>2*z){const Me=F.add($.sub(F)._mult(z/Ve)._round());this.updateDistance(F,Me),this.addCurrentVertex(Me,he,0,0,L),F=Me}}}}addCurrentVertex(t,i,s,l,p,f=!1){const _=i.y*l-i.x,y=-i.y-i.x*l;this.addHalfVertex(t,i.x+i.y*s,i.y-i.x*s,f,!1,s,p),this.addHalfVertex(t,_,y,f,!0,-l,p),this.distance>Zg/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,i,s,l,p,f))}addHalfVertex({x:t,y:i},s,l,p,f,_,y){const w=.5*(this.lineClips?this.scaledDistance*(Zg-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(p?1:0),(i<<1)+(f?1:0),Math.round(63*s)+128,Math.round(63*l)+128,1+(_===0?0:_<0?-1:1)|(63&w)<<2,w>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const S=y.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,S,this.e2),y.primitiveLength++),f?this.e2=S:this.e1=S}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,i){this.distance+=t.dist(i),this.updateScaledDistance()}}let qg,Hg;Xe("LineBucket",Dp,{omit:["layers","patternFeatures"]});var Wg={get paint(){return Hg=Hg||new yr({"line-opacity":new ht(fe.paint_line["line-opacity"]),"line-color":new ht(fe.paint_line["line-color"]),"line-translate":new rt(fe.paint_line["line-translate"]),"line-translate-anchor":new rt(fe.paint_line["line-translate-anchor"]),"line-width":new ht(fe.paint_line["line-width"]),"line-gap-width":new ht(fe.paint_line["line-gap-width"]),"line-offset":new ht(fe.paint_line["line-offset"]),"line-blur":new ht(fe.paint_line["line-blur"]),"line-dasharray":new is(fe.paint_line["line-dasharray"]),"line-pattern":new cl(fe.paint_line["line-pattern"]),"line-gradient":new ul(fe.paint_line["line-gradient"])})},get layout(){return qg=qg||new yr({"line-cap":new rt(fe.layout_line["line-cap"]),"line-join":new ht(fe.layout_line["line-join"]),"line-miter-limit":new rt(fe.layout_line["line-miter-limit"]),"line-round-limit":new rt(fe.layout_line["line-round-limit"]),"line-sort-key":new ht(fe.layout_line["line-sort-key"])})}};class Yb extends ht{possiblyEvaluate(t,i){return i=new si(Math.floor(i.zoom),{now:i.now,fadeDuration:i.fadeDuration,zoomHistory:i.zoomHistory,transition:i.transition}),super.possiblyEvaluate(t,i)}evaluate(t,i,s,l){return i=lr({},i,{zoom:Math.floor(i.zoom)}),super.evaluate(t,i,s,l)}}let Vh;class Jb extends Wr{constructor(t){super(t,Wg),this.gradientVersion=0,Vh||(Vh=new Yb(Wg.paint.properties["line-width"].specification),Vh.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const i=this.gradientExpression();this.stepInterpolant=!!function(s){return s._styleExpression!==void 0}(i)&&i._styleExpression.expression instanceof Ti,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,i){super.recalculate(t,i),this.paint._values["line-floorwidth"]=Vh.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Dp(t)}queryRadius(t){const i=t,s=Xg(Gc("line-width",this,i),Gc("line-gap-width",this,i)),l=Gc("line-offset",this,i);return s/2+Math.abs(l)+Fh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:i,featureState:s,geometry:l,transform:p,pixelsToTileUnits:f}){const _=Bh(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-p.bearingInRadians,f),y=f/2*Xg(this.paint.get("line-width").evaluate(i,s),this.paint.get("line-gap-width").evaluate(i,s)),w=this.paint.get("line-offset").evaluate(i,s);return w&&(l=function(S,I){const z=[];for(let L=0;L<S.length;L++){const F=S[L],N=[];for(let $=0;$<F.length;$++){const H=F[$-1],he=F[$],ee=F[$+1],re=$===0?new V(0,0):he.sub(H)._unit()._perp(),ve=$===F.length-1?new V(0,0):ee.sub(he)._unit()._perp(),we=re._add(ve)._unit(),Ee=we.x*ve.x+we.y*ve.y;Ee!==0&&we._mult(1/Ee),N.push(we._mult(I)._add(he))}z.push(N)}return z}(l,w*f)),function(S,I,z){for(let L=0;L<I.length;L++){const F=I[L];if(S.length>=3){for(let N=0;N<F.length;N++)if(gl(S,F[N]))return!0}if(cb(S,F,z))return!0}return!1}(_,l,y)}isTileClipped(){return!0}}function Xg(r,t){return t>0?t+2*r:r}const Qb=Si([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),e1=Si([{name:"a_projected_pos",components:3,type:"Float32"}],4);Si([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const t1=Si([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Si([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Kg=Si([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),i1=Si([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function r1(r,t,i){return r.sections.forEach(s=>{s.text=function(l,p,f){const _=p.layout.get("text-transform").evaluate(f,{});return _==="uppercase"?l=l.toLocaleUpperCase():_==="lowercase"&&(l=l.toLocaleLowerCase()),un.applyArabicShaping&&(l=un.applyArabicShaping(l)),l}(s.text,t,i)}),r}Si([{name:"triangle",components:3,type:"Uint16"}]),Si([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Si([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Si([{type:"Float32",name:"offsetX"}]),Si([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Si([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const eu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Xi=24;const Lp=4294967296,Yg=1/Lp,Jg=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");class Fp{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,i,s=this.length){for(;this.pos<s;){const l=this.readVarint(),p=l>>3,f=this.pos;this.type=7&l,t(p,i,this),this.pos===f&&this.skip(l)}return i}readMessage(t,i){return this.readFields(t,i,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Lp;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Lp;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const i=this.buf;let s,l;return l=i[this.pos++],s=127&l,l<128?s:(l=i[this.pos++],s|=(127&l)<<7,l<128?s:(l=i[this.pos++],s|=(127&l)<<14,l<128?s:(l=i[this.pos++],s|=(127&l)<<21,l<128?s:(l=i[this.pos],s|=(15&l)<<28,function(p,f,_){const y=_.buf;let w,S;if(S=y[_.pos++],w=(112&S)>>4,S<128||(S=y[_.pos++],w|=(127&S)<<3,S<128)||(S=y[_.pos++],w|=(127&S)<<10,S<128)||(S=y[_.pos++],w|=(127&S)<<17,S<128)||(S=y[_.pos++],w|=(127&S)<<24,S<128)||(S=y[_.pos++],w|=(1&S)<<31,S<128))return bl(p,w,f);throw new Error("Expected varint not more than 10 bytes")}(s,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,i=this.pos;return this.pos=t,t-i>=12&&Jg?Jg.decode(this.buf.subarray(i,t)):function(s,l,p){let f="",_=l;for(;_<p;){const y=s[_];let w,S,I,z=null,L=y>239?4:y>223?3:y>191?2:1;if(_+L>p)break;L===1?y<128&&(z=y):L===2?(w=s[_+1],(192&w)==128&&(z=(31&y)<<6|63&w,z<=127&&(z=null))):L===3?(w=s[_+1],S=s[_+2],(192&w)==128&&(192&S)==128&&(z=(15&y)<<12|(63&w)<<6|63&S,(z<=2047||z>=55296&&z<=57343)&&(z=null))):L===4&&(w=s[_+1],S=s[_+2],I=s[_+3],(192&w)==128&&(192&S)==128&&(192&I)==128&&(z=(15&y)<<18|(63&w)<<12|(63&S)<<6|63&I,(z<=65535||z>=1114112)&&(z=null))),z===null?(z=65533,L=1):z>65535&&(z-=65536,f+=String.fromCharCode(z>>>10&1023|55296),z=56320|1023&z),f+=String.fromCharCode(z),_+=L}return f}(this.buf,i,t)}readBytes(){const t=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,t);return this.pos=t,i}readPackedVarint(t=[],i){const s=this.readPackedEnd();for(;this.pos<s;)t.push(this.readVarint(i));return t}readPackedSVarint(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===2?this.readVarint()+this.pos:this.pos+1}skip(t){const i=7&t;if(i===0)for(;this.buf[this.pos++]>127;);else if(i===2)this.pos=this.readVarint()+this.pos;else if(i===5)this.pos+=4;else{if(i!==1)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(t,i){this.writeVarint(t<<3|i)}realloc(t){let i=this.length||16;for(;i<this.pos+t;)i*=2;if(i!==this.length){const s=new Uint8Array(i);s.set(this.buf),this.buf=s,this.dataView=new DataView(s.buffer),this.length=i}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Yg),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*Yg),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(i,s){let l,p;if(i>=0?(l=i%4294967296|0,p=i/4294967296|0):(l=~(-i%4294967296),p=~(-i/4294967296),4294967295^l?l=l+1|0:(l=0,p=p+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(f,_,y){y.buf[y.pos++]=127&f|128,f>>>=7,y.buf[y.pos++]=127&f|128,f>>>=7,y.buf[y.pos++]=127&f|128,f>>>=7,y.buf[y.pos++]=127&f|128,y.buf[y.pos]=127&(f>>>=7)}(l,0,s),function(f,_){const y=(7&f)<<4;_.buf[_.pos++]|=y|((f>>>=3)?128:0),f&&(_.buf[_.pos++]=127&f|((f>>>=7)?128:0),f&&(_.buf[_.pos++]=127&f|((f>>>=7)?128:0),f&&(_.buf[_.pos++]=127&f|((f>>>=7)?128:0),f&&(_.buf[_.pos++]=127&f|((f>>>=7)?128:0),f&&(_.buf[_.pos++]=127&f)))))}(p,s)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const i=this.pos;this.pos=function(l,p,f){for(let _,y,w=0;w<p.length;w++){if(_=p.charCodeAt(w),_>55295&&_<57344){if(!y){_>56319||w+1===p.length?(l[f++]=239,l[f++]=191,l[f++]=189):y=_;continue}if(_<56320){l[f++]=239,l[f++]=191,l[f++]=189,y=_;continue}_=y-55296<<10|_-56320|65536,y=null}else y&&(l[f++]=239,l[f++]=191,l[f++]=189,y=null);_<128?l[f++]=_:(_<2048?l[f++]=_>>6|192:(_<65536?l[f++]=_>>12|224:(l[f++]=_>>18|240,l[f++]=_>>12&63|128),l[f++]=_>>6&63|128),l[f++]=63&_|128)}return f}(this.buf,t,this.pos);const s=this.pos-i;s>=128&&Qg(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const i=t.length;this.writeVarint(i),this.realloc(i);for(let s=0;s<i;s++)this.buf[this.pos++]=t[s]}writeRawMessage(t,i){this.pos++;const s=this.pos;t(i,this);const l=this.pos-s;l>=128&&Qg(s,l,this),this.pos=s-1,this.writeVarint(l),this.pos+=l}writeMessage(t,i,s){this.writeTag(t,2),this.writeRawMessage(i,s)}writePackedVarint(t,i){i.length&&this.writeMessage(t,n1,i)}writePackedSVarint(t,i){i.length&&this.writeMessage(t,s1,i)}writePackedBoolean(t,i){i.length&&this.writeMessage(t,l1,i)}writePackedFloat(t,i){i.length&&this.writeMessage(t,o1,i)}writePackedDouble(t,i){i.length&&this.writeMessage(t,a1,i)}writePackedFixed32(t,i){i.length&&this.writeMessage(t,c1,i)}writePackedSFixed32(t,i){i.length&&this.writeMessage(t,u1,i)}writePackedFixed64(t,i){i.length&&this.writeMessage(t,h1,i)}writePackedSFixed64(t,i){i.length&&this.writeMessage(t,d1,i)}writeBytesField(t,i){this.writeTag(t,2),this.writeBytes(i)}writeFixed32Field(t,i){this.writeTag(t,5),this.writeFixed32(i)}writeSFixed32Field(t,i){this.writeTag(t,5),this.writeSFixed32(i)}writeFixed64Field(t,i){this.writeTag(t,1),this.writeFixed64(i)}writeSFixed64Field(t,i){this.writeTag(t,1),this.writeSFixed64(i)}writeVarintField(t,i){this.writeTag(t,0),this.writeVarint(i)}writeSVarintField(t,i){this.writeTag(t,0),this.writeSVarint(i)}writeStringField(t,i){this.writeTag(t,2),this.writeString(i)}writeFloatField(t,i){this.writeTag(t,5),this.writeFloat(i)}writeDoubleField(t,i){this.writeTag(t,1),this.writeDouble(i)}writeBooleanField(t,i){this.writeVarintField(t,+i)}}function bl(r,t,i){return i?4294967296*t+(r>>>0):4294967296*(t>>>0)+(r>>>0)}function Qg(r,t,i){const s=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(s);for(let l=i.pos-1;l>=r;l--)i.buf[l+s]=i.buf[l]}function n1(r,t){for(let i=0;i<r.length;i++)t.writeVarint(r[i])}function s1(r,t){for(let i=0;i<r.length;i++)t.writeSVarint(r[i])}function o1(r,t){for(let i=0;i<r.length;i++)t.writeFloat(r[i])}function a1(r,t){for(let i=0;i<r.length;i++)t.writeDouble(r[i])}function l1(r,t){for(let i=0;i<r.length;i++)t.writeBoolean(r[i])}function c1(r,t){for(let i=0;i<r.length;i++)t.writeFixed32(r[i])}function u1(r,t){for(let i=0;i<r.length;i++)t.writeSFixed32(r[i])}function h1(r,t){for(let i=0;i<r.length;i++)t.writeFixed64(r[i])}function d1(r,t){for(let i=0;i<r.length;i++)t.writeSFixed64(r[i])}function p1(r,t,i){r===1&&i.readMessage(f1,t)}function f1(r,t,i){if(r===3){const{id:s,bitmap:l,width:p,height:f,left:_,top:y,advance:w}=i.readMessage(m1,{});t.push({id:s,bitmap:new Zc({width:p+6,height:f+6},l),metrics:{width:p,height:f,left:_,top:y,advance:w}})}}function m1(r,t,i){r===1?t.id=i.readVarint():r===2?t.bitmap=i.readBytes():r===3?t.width=i.readVarint():r===4?t.height=i.readVarint():r===5?t.left=i.readSVarint():r===6?t.top=i.readSVarint():r===7&&(t.advance=i.readVarint())}function e_(r){let t=0,i=0;for(const f of r)t+=f.w*f.h,i=Math.max(i,f.w);r.sort((f,_)=>_.h-f.h);const s=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let l=0,p=0;for(const f of r)for(let _=s.length-1;_>=0;_--){const y=s[_];if(!(f.w>y.w||f.h>y.h)){if(f.x=y.x,f.y=y.y,p=Math.max(p,f.y+f.h),l=Math.max(l,f.x+f.w),f.w===y.w&&f.h===y.h){const w=s.pop();w&&_<s.length&&(s[_]=w)}else f.h===y.h?(y.x+=f.w,y.w-=f.w):f.w===y.w?(y.y+=f.h,y.h-=f.h):(s.push({x:y.x+f.w,y:y.y,w:y.w-f.w,h:f.h}),y.y+=f.h,y.h-=f.h);break}}return{w:l,h:p,fill:t/(l*p)||0}}class Bp{constructor(t,{pixelRatio:i,version:s,stretchX:l,stretchY:p,content:f,textFitWidth:_,textFitHeight:y}){this.paddedRect=t,this.pixelRatio=i,this.stretchX=l,this.stretchY=p,this.content=f,this.version=s,this.textFitWidth=_,this.textFitHeight=y}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class t_{constructor(t,i){const s={},l={};this.haveRenderCallbacks=[];const p=[];this.addImages(t,s,p),this.addImages(i,l,p);const{w:f,h:_}=e_(p),y=new jr({width:f||1,height:_||1});for(const w in t){const S=t[w],I=s[w].paddedRect;jr.copy(S.data,y,{x:0,y:0},{x:I.x+1,y:I.y+1},S.data)}for(const w in i){const S=i[w],I=l[w].paddedRect,z=I.x+1,L=I.y+1,F=S.data.width,N=S.data.height;jr.copy(S.data,y,{x:0,y:0},{x:z,y:L},S.data),jr.copy(S.data,y,{x:0,y:N-1},{x:z,y:L-1},{width:F,height:1}),jr.copy(S.data,y,{x:0,y:0},{x:z,y:L+N},{width:F,height:1}),jr.copy(S.data,y,{x:F-1,y:0},{x:z-1,y:L},{width:1,height:N}),jr.copy(S.data,y,{x:0,y:0},{x:z+F,y:L},{width:1,height:N})}this.image=y,this.iconPositions=s,this.patternPositions=l}addImages(t,i,s){for(const l in t){const p=t[l],f={x:0,y:0,w:p.data.width+2,h:p.data.height+2};s.push(f),i[l]=new Bp(f,p),p.hasRenderCallback&&this.haveRenderCallbacks.push(l)}}patchUpdatedImages(t,i){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const s in t.updatedImages)this.patchUpdatedImage(this.iconPositions[s],t.getImage(s),i),this.patchUpdatedImage(this.patternPositions[s],t.getImage(s),i)}patchUpdatedImage(t,i,s){if(!t||!i||t.version===i.version)return;t.version=i.version;const[l,p]=t.tl;s.update(i.data,void 0,{x:l,y:p})}}var xo;Xe("ImagePosition",Bp),Xe("ImageAtlas",t_),T.ao=void 0,(xo=T.ao||(T.ao={}))[xo.none=0]="none",xo[xo.horizontal=1]="horizontal",xo[xo.vertical=2]="vertical",xo[xo.horizontalOnly=3]="horizontalOnly";class tu{constructor(){this.scale=1,this.fontStack="",this.imageName=null,this.verticalAlign="bottom"}static forText(t,i,s){const l=new tu;return l.scale=t||1,l.fontStack=i,l.verticalAlign=s||"bottom",l}static forImage(t,i){const s=new tu;return s.imageName=t,s.verticalAlign=i||"bottom",s}}class wl{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,i){const s=new wl;for(let l=0;l<t.sections.length;l++){const p=t.sections[l];p.image?s.addImageSection(p):s.addTextSection(p,i)}return s}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(){this.text=function(t){let i="";for(let s=0;s<t.length;s++){const l=t.charCodeAt(s+1)||null,p=t.charCodeAt(s-1)||null;i+=l&&Ch(l)&&!eu[t[s+1]]||p&&Ch(p)&&!eu[t[s-1]]||!eu[t[s]]?t[s]:eu[t[s]]}return i}(this.text)}trim(){let t=0;for(let s=0;s<this.text.length&&$h[this.text.charCodeAt(s)];s++)t++;let i=this.text.length;for(let s=this.text.length-1;s>=0&&s>=t&&$h[this.text.charCodeAt(s)];s--)i--;this.text=this.text.substring(t,i),this.sectionIndex=this.sectionIndex.slice(t,i)}substring(t,i){const s=new wl;return s.text=this.text.substring(t,i),s.sectionIndex=this.sectionIndex.slice(t,i),s.sections=this.sections,s}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,i)=>Math.max(t,this.sections[i].scale),0)}getMaxImageSize(t){let i=0,s=0;for(let l=0;l<this.length();l++){const p=this.getSection(l);if(p.imageName){const f=t[p.imageName];if(!f)continue;const _=f.displaySize;i=Math.max(i,_[0]),s=Math.max(s,_[1])}}return{maxImageWidth:i,maxImageHeight:s}}addTextSection(t,i){this.text+=t.text,this.sections.push(tu.forText(t.scale,t.fontStack||i,t.verticalAlign));const s=this.sections.length-1;for(let l=0;l<t.text.length;++l)this.sectionIndex.push(s)}addImageSection(t){const i=t.image?t.image.name:"";if(i.length===0)return void Te("Can't add FormattedSection with an empty image.");const s=this.getNextImageSectionCharCode();s?(this.text+=String.fromCharCode(s),this.sections.push(tu.forImage(i,t.verticalAlign)),this.sectionIndex.push(this.sections.length-1)):Te("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Uh(r,t,i,s,l,p,f,_,y,w,S,I,z,L,F){const N=wl.fromFeature(r,l);let $;I===T.ao.vertical&&N.verticalizePunctuation();const{processBidirectionalText:H,processStyledBidirectionalText:he}=un;if(H&&N.sections.length===1){$=[];const ve=H(N.toString(),Op(N,w,p,t,s,L));for(const we of ve){const Ee=new wl;Ee.text=we,Ee.sections=N.sections;for(let Ue=0;Ue<we.length;Ue++)Ee.sectionIndex.push(0);$.push(Ee)}}else if(he){$=[];const ve=he(N.text,N.sectionIndex,Op(N,w,p,t,s,L));for(const we of ve){const Ee=new wl;Ee.text=we[0],Ee.sectionIndex=we[1],Ee.sections=N.sections,$.push(Ee)}}else $=function(ve,we){const Ee=[],Ue=ve.text;let Be=0;for(const Ne of we)Ee.push(ve.substring(Be,Ne)),Be=Ne;return Be<Ue.length&&Ee.push(ve.substring(Be,Ue.length)),Ee}(N,Op(N,w,p,t,s,L));const ee=[],re={positionedLines:ee,text:N.toString(),top:S[1],bottom:S[1],left:S[0],right:S[0],writingMode:I,iconsInText:!1,verticalizable:!1};return function(ve,we,Ee,Ue,Be,Ne,nt,je,Ve,Me,ft,gt){let at=0,tt=0,Ot=0,vi=0;const $i=je==="right"?1:je==="left"?0:.5,pr=Xi/gt;let mn=0;for(const fi of Be){fi.trim();const Ki=fi.getMaxScale(),sr={positionedGlyphs:[],lineOffset:0};ve.positionedLines[mn]=sr;const or=sr.positionedGlyphs;let Ar=0;if(!fi.length()){tt+=Ne,++mn;continue}const gn=v1(Ue,fi,pr);for(let Vr=0;Vr<fi.length();Vr++){const Gi=fi.getSection(Vr),Ji=fi.getSectionIndex(Vr),Qi=fi.getCharCode(Vr),Fi=x1(Ve,ft,Qi);let ui;if(Gi.imageName){if(ve.iconsInText=!0,Gi.scale=Gi.scale*pr,ui=w1(Gi,Fi,Ki,gn,Ue),!ui)continue;Ar=Math.max(Ar,ui.imageOffset)}else if(ui=b1(Gi,Qi,Fi,gn,we,Ee),!ui)continue;const{rect:Fn,metrics:Ml,baselineOffset:Bn}=ui;or.push({glyph:Qi,imageName:Gi.imageName,x:at,y:tt+Bn+-17,vertical:Fi,scale:Gi.scale,fontStack:Gi.fontStack,sectionIndex:Ji,metrics:Ml,rect:Fn}),Fi?(ve.verticalizable=!0,at+=(Gi.imageName?Ml.advance:Xi)*Gi.scale+Me):at+=Ml.advance*Gi.scale+Me}or.length!==0&&(Ot=Math.max(at-Me,Ot),T1(or,0,or.length-1,$i)),at=0,sr.lineOffset=Math.max(Ar,(Ki-1)*Xi);const Yi=Ne*Ki+Ar;tt+=Yi,vi=Math.max(Yi,vi),++mn}const{horizontalAlign:Nr,verticalAlign:nr}=jp(nt);(function(fi,Ki,sr,or,Ar,gn,Yi,Vr,Gi){const Ji=(Ki-sr)*Ar;let Qi=0;Qi=gn!==Yi?-Vr*or- -17:-or*Gi*Yi+.5*Yi;for(const Fi of fi)for(const ui of Fi.positionedGlyphs)ui.x+=Ji,ui.y+=Qi})(ve.positionedLines,$i,Nr,nr,Ot,vi,Ne,tt,Be.length),ve.top+=-nr*tt,ve.bottom=ve.top+tt,ve.left+=-Nr*Ot,ve.right=ve.left+Ot}(re,t,i,s,$,f,_,y,I,w,z,F),!function(ve){for(const we of ve)if(we.positionedGlyphs.length!==0)return!1;return!0}(ee)&&re}const $h={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},g1={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},_1={40:!0};function i_(r,t,i,s,l,p){if(t.imageName){const f=s[t.imageName];return f?f.displaySize[0]*t.scale*Xi/p+l:0}{const f=i[t.fontStack],_=f&&f[r];return _?_.metrics.advance*t.scale+l:0}}function r_(r,t,i,s){const l=Math.pow(r-t,2);return s?r<t?l/2:2*l:l+Math.abs(i)*i}function y1(r,t,i){let s=0;return r===10&&(s-=1e4),i&&(s+=150),r!==40&&r!==65288||(s+=50),t!==41&&t!==65289||(s+=50),s}function n_(r,t,i,s,l,p){let f=null,_=r_(t,i,l,p);for(const y of s){const w=r_(t-y.x,i,l,p)+y.badness;w<=_&&(f=y,_=w)}return{index:r,x:t,priorBreak:f,badness:_}}function s_(r){return r?s_(r.priorBreak).concat(r.index):[]}function Op(r,t,i,s,l,p){if(!r)return[];const f=[],_=function(I,z,L,F,N,$){let H=0;for(let he=0;he<I.length();he++){const ee=I.getSection(he);H+=i_(I.getCharCode(he),ee,F,N,z,$)}return H/Math.max(1,Math.ceil(H/L))}(r,t,i,s,l,p),y=r.text.indexOf("​")>=0;let w=0;for(let I=0;I<r.length();I++){const z=r.getSection(I),L=r.getCharCode(I);if($h[L]||(w+=i_(L,z,s,l,t,p)),I<r.length()-1){const F=!((S=L)<11904)&&(!!Bt["CJK Compatibility Forms"](S)||!!Bt["CJK Compatibility"](S)||!!Bt["CJK Strokes"](S)||!!Bt["CJK Symbols and Punctuation"](S)||!!Bt["Enclosed CJK Letters and Months"](S)||!!Bt["Halfwidth and Fullwidth Forms"](S)||!!Bt["Ideographic Description Characters"](S)||!!Bt["Vertical Forms"](S)||Rc.test(String.fromCodePoint(S)));(g1[L]||F||z.imageName||I!==r.length()-2&&_1[r.getCharCode(I+1)])&&f.push(n_(I+1,w,_,f,y1(L,r.getCharCode(I+1),F&&y),!1))}}var S;return s_(n_(r.length(),w,_,f,0,!0))}function jp(r){let t=.5,i=.5;switch(r){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function v1(r,t,i){const s=t.getMaxScale()*Xi,{maxImageWidth:l,maxImageHeight:p}=t.getMaxImageSize(r),f=Math.max(s,p*i);return{verticalLineContentWidth:Math.max(s,l*i),horizontalLineContentHeight:f}}function o_(r){switch(r){case"top":return 0;case"center":return .5;default:return 1}}function x1(r,t,i){return!(r===T.ao.horizontal||!t&&!Dc(i)||t&&($h[i]||(s=i,new RegExp("\\p{sc=Arab}","u").test(String.fromCodePoint(s)))));var s}function b1(r,t,i,s,l,p){const f=p[r.fontStack],_=function(w,S,I,z){if(w&&w.rect)return w;const L=S[I.fontStack],F=L&&L[z];return F?{rect:null,metrics:F.metrics}:null}(f&&f[t],l,r,t);if(_===null)return null;let y;if(i)y=s.verticalLineContentWidth-r.scale*Xi;else{const w=o_(r.verticalAlign);y=(s.horizontalLineContentHeight-r.scale*Xi)*w}return{rect:_.rect,metrics:_.metrics,baselineOffset:y}}function w1(r,t,i,s,l){const p=l[r.imageName];if(!p)return null;const f=p.paddedRect,_=p.displaySize,y={width:_[0],height:_[1],left:1,top:-3,advance:t?_[1]:_[0]};let w;if(t)w=s.verticalLineContentWidth-_[1]*r.scale;else{const S=o_(r.verticalAlign);w=(s.horizontalLineContentHeight-_[1]*r.scale)*S}return{rect:f,metrics:y,baselineOffset:w,imageOffset:(t?_[0]:_[1])*r.scale-Xi*i}}function T1(r,t,i,s){if(s===0)return;const l=r[i],p=(r[i].x+l.metrics.advance*l.scale)*s;for(let f=t;f<=i;f++)r[f].x-=p}function S1(r,t,i){const{horizontalAlign:s,verticalAlign:l}=jp(i),p=t[0]-r.displaySize[0]*s,f=t[1]-r.displaySize[1]*l;return{image:r,top:f,bottom:f+r.displaySize[1],left:p,right:p+r.displaySize[0]}}function a_(r){var t,i;let s=r.left,l=r.top,p=r.right-s,f=r.bottom-l;const _=(t=r.image.textFitWidth)!==null&&t!==void 0?t:"stretchOrShrink",y=(i=r.image.textFitHeight)!==null&&i!==void 0?i:"stretchOrShrink",w=(r.image.content[2]-r.image.content[0])/(r.image.content[3]-r.image.content[1]);if(y==="proportional"){if(_==="stretchOnly"&&p/f<w||_==="proportional"){const S=Math.ceil(f*w);s*=S/p,p=S}}else if(_==="proportional"&&y==="stretchOnly"&&w!==0&&p/f>w){const S=Math.ceil(p/w);l*=S/f,f=S}return{x1:s,y1:l,x2:s+p,y2:l+f}}function l_(r,t,i,s,l,p){const f=r.image;let _;if(f.content){const $=f.content,H=f.pixelRatio||1;_=[$[0]/H,$[1]/H,f.displaySize[0]-$[2]/H,f.displaySize[1]-$[3]/H]}const y=t.left*p,w=t.right*p;let S,I,z,L;i==="width"||i==="both"?(L=l[0]+y-s[3],I=l[0]+w+s[1]):(L=l[0]+(y+w-f.displaySize[0])/2,I=L+f.displaySize[0]);const F=t.top*p,N=t.bottom*p;return i==="height"||i==="both"?(S=l[1]+F-s[0],z=l[1]+N+s[2]):(S=l[1]+(F+N-f.displaySize[1])/2,z=S+f.displaySize[1]),{image:f,top:S,right:I,bottom:z,left:L,collisionPadding:_}}const js=128,bo=32640;function c_(r,t){const{expression:i}=t;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new si(r+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:s,interpolationType:l}=i;let p=0;for(;p<s.length&&s[p]<=r;)p++;p=Math.max(0,p-1);let f=p;for(;f<s.length&&s[f]<r+1;)f++;f=Math.min(s.length-1,f);const _=s[p],y=s[f];return i.kind==="composite"?{kind:"composite",minZoom:_,maxZoom:y,interpolationType:l}:{kind:"camera",minZoom:_,maxZoom:y,minSize:i.evaluate(new si(_)),maxSize:i.evaluate(new si(y)),interpolationType:l}}}function Np(r,t,i){let s="never";const l=r.get(t);return l?s=l:r.get(i)&&(s="always"),s}const P1=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Gh(r,t,i,s,l,p,f,_,y,w,S,I,z){const L=_?Math.min(bo,Math.round(_[0])):0,F=_?Math.min(bo,Math.round(_[1])):0;r.emplaceBack(t,i,Math.round(32*s),Math.round(32*l),p,f,(L<<1)+(y?1:0),F,16*w,16*S,256*I,256*z)}function Vp(r,t,i){r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i),r.emplaceBack(t.x,t.y,i)}function M1(r){for(const t of r.sections)if(Ah(t.text))return!0;return!1}class Up{constructor(t){this.layoutVertexArray=new Oe,this.indexArray=new ei,this.programConfigurations=t,this.segments=new bt,this.dynamicLayoutVertexArray=new Ie,this.opacityVertexArray=new et,this.hasVisibleVertices=!1,this.placedSymbolArray=new O}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,i,s,l){this.isEmpty()||(s&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qb.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,e1.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,P1,!0),this.opacityVertexBuffer.itemSize=1),(s||l)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}Xe("SymbolBuffers",Up);class $p{constructor(t,i,s){this.layoutVertexArray=new t,this.layoutAttributes=i,this.indexArray=new s,this.segments=new bt,this.collisionVertexArray=new Wt}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,t1.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}Xe("CollisionBuffers",$p);class Tl{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.globalState=t.globalState,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(f=>f.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=c_(this.zoom,i["text-size"]),this.iconSizeData=c_(this.zoom,i["icon-size"]);const s=this.layers[0].layout,l=s.get("symbol-sort-key"),p=s.get("symbol-z-order");this.canOverlap=Np(s,"text-overlap","text-allow-overlap")!=="never"||Np(s,"icon-overlap","icon-allow-overlap")!=="never"||s.get("text-ignore-placement")||s.get("icon-ignore-placement"),this.sortFeaturesByKey=p!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(p==="viewport-y"||p==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,s.get("symbol-placement")==="point"&&(this.writingModes=s.get("text-writing-mode").map(f=>T.ao[f])),this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id),this.sourceID=t.sourceID}createArrays(){this.text=new Up(new Or(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Up(new Or(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new q,this.lineVertexArray=new W,this.symbolInstances=new G,this.textAnchorOffsets=new K}calculateGlyphDependencies(t,i,s,l,p){for(let f=0;f<t.length;f++)if(i[t.charCodeAt(f)]=!0,(s||l)&&p){const _=eu[t.charAt(f)];_&&(i[_.charCodeAt(0)]=!0)}}populate(t,i,s){const l=this.layers[0],p=l.layout,f=p.get("text-font"),_=p.get("text-field"),y=p.get("icon-image"),w=(_.value.kind!=="constant"||_.value.value instanceof mr&&!_.value.value.isEmpty()||_.value.value.toString().length>0)&&(f.value.kind!=="constant"||f.value.value.length>0),S=y.value.kind!=="constant"||!!y.value.value||Object.keys(y.parameters).length>0,I=p.get("symbol-sort-key");if(this.features=[],!w&&!S)return;const z=i.iconDependencies,L=i.glyphDependencies,F=i.availableImages,N=new si(this.zoom,{globalState:this.globalState});for(const{feature:$,id:H,index:he,sourceLayerIndex:ee}of t){const re=l._featureFilter.needGeometry,ve=Ln($,re);if(!l._featureFilter.filter(N,ve,s))continue;let we,Ee;if(re||(ve.geometry=as($)),w){const Be=l.getValueAndResolveTokens("text-field",ve,s,F),Ne=mr.factory(Be),nt=this.hasRTLText=this.hasRTLText||M1(Ne);(!nt||un.getRTLTextPluginStatus()==="unavailable"||nt&&un.isParsed())&&(we=r1(Ne,l,ve))}if(S){const Be=l.getValueAndResolveTokens("icon-image",ve,s,F);Ee=Be instanceof Fr?Be:Fr.fromString(Be)}if(!we&&!Ee)continue;const Ue=this.sortFeaturesByKey?I.evaluate(ve,{},s):void 0;if(this.features.push({id:H,text:we,icon:Ee,index:he,sourceLayerIndex:ee,geometry:ve.geometry,properties:$.properties,type:xl.types[$.type],sortKey:Ue}),Ee&&(z[Ee.name]=!0),we){const Be=f.evaluate(ve,{},s).join(","),Ne=p.get("text-rotation-alignment")!=="viewport"&&p.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(T.ao.vertical)>=0;for(const nt of we.sections)if(nt.image)z[nt.image.name]=!0;else{const je=ol(we.toString()),Ve=nt.fontStack||Be,Me=L[Ve]=L[Ve]||{};this.calculateGlyphDependencies(nt.text,Me,Ne,this.allowVerticalPlacement,je)}}}p.get("symbol-placement")==="line"&&(this.features=function($){const H={},he={},ee=[];let re=0;function ve(Be){ee.push($[Be]),re++}function we(Be,Ne,nt){const je=he[Be];return delete he[Be],he[Ne]=je,ee[je].geometry[0].pop(),ee[je].geometry[0]=ee[je].geometry[0].concat(nt[0]),je}function Ee(Be,Ne,nt){const je=H[Ne];return delete H[Ne],H[Be]=je,ee[je].geometry[0].shift(),ee[je].geometry[0]=nt[0].concat(ee[je].geometry[0]),je}function Ue(Be,Ne,nt){const je=nt?Ne[0][Ne[0].length-1]:Ne[0][0];return`${Be}:${je.x}:${je.y}`}for(let Be=0;Be<$.length;Be++){const Ne=$[Be],nt=Ne.geometry,je=Ne.text?Ne.text.toString():null;if(!je){ve(Be);continue}const Ve=Ue(je,nt),Me=Ue(je,nt,!0);if(Ve in he&&Me in H&&he[Ve]!==H[Me]){const ft=Ee(Ve,Me,nt),gt=we(Ve,Me,ee[ft].geometry);delete H[Ve],delete he[Me],he[Ue(je,ee[gt].geometry,!0)]=gt,ee[ft].geometry=null}else Ve in he?we(Ve,Me,nt):Me in H?Ee(Ve,Me,nt):(ve(Be),H[Ve]=re-1,he[Me]=re-1)}return ee.filter(Be=>Be.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort(($,H)=>$.sortKey-H.sortKey)}update(t,i,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:s,globalState:this.globalState}),this.icon.programConfigurations.updatePaintArrays(t,i,this.layers,{imagePositions:s,globalState:this.globalState}))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,i){const s=this.lineVertexArray.length;if(t.segment!==void 0){let l=t.dist(i[t.segment+1]),p=t.dist(i[t.segment]);const f={};for(let _=t.segment+1;_<i.length;_++)f[_]={x:i[_].x,y:i[_].y,tileUnitDistanceFromAnchor:l},_<i.length-1&&(l+=i[_+1].dist(i[_]));for(let _=t.segment||0;_>=0;_--)f[_]={x:i[_].x,y:i[_].y,tileUnitDistanceFromAnchor:p},_>0&&(p+=i[_-1].dist(i[_]));for(let _=0;_<i.length;_++){const y=f[_];this.lineVertexArray.emplaceBack(y.x,y.y,y.tileUnitDistanceFromAnchor)}}return{lineStartIndex:s,lineLength:this.lineVertexArray.length-s}}addSymbols(t,i,s,l,p,f,_,y,w,S,I,z){const L=t.indexArray,F=t.layoutVertexArray,N=t.segments.prepareSegment(4*i.length,F,L,this.canOverlap?f.sortKey:void 0),$=this.glyphOffsetArray.length,H=N.vertexLength,he=this.allowVerticalPlacement&&_===T.ao.vertical?Math.PI/2:0,ee=f.text&&f.text.sections;for(let re=0;re<i.length;re++){const{tl:ve,tr:we,bl:Ee,br:Ue,tex:Be,pixelOffsetTL:Ne,pixelOffsetBR:nt,minFontScaleX:je,minFontScaleY:Ve,glyphOffset:Me,isSDF:ft,sectionIndex:gt}=i[re],at=N.vertexLength,tt=Me[1];Gh(F,y.x,y.y,ve.x,tt+ve.y,Be.x,Be.y,s,ft,Ne.x,Ne.y,je,Ve),Gh(F,y.x,y.y,we.x,tt+we.y,Be.x+Be.w,Be.y,s,ft,nt.x,Ne.y,je,Ve),Gh(F,y.x,y.y,Ee.x,tt+Ee.y,Be.x,Be.y+Be.h,s,ft,Ne.x,nt.y,je,Ve),Gh(F,y.x,y.y,Ue.x,tt+Ue.y,Be.x+Be.w,Be.y+Be.h,s,ft,nt.x,nt.y,je,Ve),Vp(t.dynamicLayoutVertexArray,y,he),L.emplaceBack(at,at+2,at+1),L.emplaceBack(at+1,at+2,at+3),N.vertexLength+=4,N.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Me[0]),re!==i.length-1&&gt===i[re+1].sectionIndex||t.programConfigurations.populatePaintArrays(F.length,f,f.index,{imagePositions:{},canonical:z,formattedSection:ee&&ee[gt],globalState:this.globalState})}t.placedSymbolArray.emplaceBack(y.x,y.y,$,this.glyphOffsetArray.length-$,H,w,S,y.segment,s?s[0]:0,s?s[1]:0,l[0],l[1],_,0,!1,0,I)}_addCollisionDebugVertex(t,i,s,l,p,f){return i.emplaceBack(0,0),t.emplaceBack(s.x,s.y,l,p,Math.round(f.x),Math.round(f.y))}addCollisionDebugVertices(t,i,s,l,p,f,_){const y=p.segments.prepareSegment(4,p.layoutVertexArray,p.indexArray),w=y.vertexLength,S=p.layoutVertexArray,I=p.collisionVertexArray,z=_.anchorX,L=_.anchorY;this._addCollisionDebugVertex(S,I,f,z,L,new V(t,i)),this._addCollisionDebugVertex(S,I,f,z,L,new V(s,i)),this._addCollisionDebugVertex(S,I,f,z,L,new V(s,l)),this._addCollisionDebugVertex(S,I,f,z,L,new V(t,l)),y.vertexLength+=4;const F=p.indexArray;F.emplaceBack(w,w+1),F.emplaceBack(w+1,w+2),F.emplaceBack(w+2,w+3),F.emplaceBack(w+3,w),y.primitiveLength+=4}addDebugCollisionBoxes(t,i,s,l){for(let p=t;p<i;p++){const f=this.collisionBoxArray.get(p);this.addCollisionDebugVertices(f.x1,f.y1,f.x2,f.y2,l?this.textCollisionBox:this.iconCollisionBox,f.anchorPoint,s)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new $p(Tt,Kg.members,Yt),this.iconCollisionBox=new $p(Tt,Kg.members,Yt);for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.addDebugCollisionBoxes(i.textBoxStartIndex,i.textBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i,!0),this.addDebugCollisionBoxes(i.iconBoxStartIndex,i.iconBoxEndIndex,i,!1),this.addDebugCollisionBoxes(i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex,i,!1)}}_deserializeCollisionBoxesForSymbol(t,i,s,l,p,f,_,y,w){const S={};for(let I=i;I<s;I++){const z=t.get(I);S.textBox={x1:z.x1,y1:z.y1,x2:z.x2,y2:z.y2,anchorPointX:z.anchorPointX,anchorPointY:z.anchorPointY},S.textFeatureIndex=z.featureIndex;break}for(let I=l;I<p;I++){const z=t.get(I);S.verticalTextBox={x1:z.x1,y1:z.y1,x2:z.x2,y2:z.y2,anchorPointX:z.anchorPointX,anchorPointY:z.anchorPointY},S.verticalTextFeatureIndex=z.featureIndex;break}for(let I=f;I<_;I++){const z=t.get(I);S.iconBox={x1:z.x1,y1:z.y1,x2:z.x2,y2:z.y2,anchorPointX:z.anchorPointX,anchorPointY:z.anchorPointY},S.iconFeatureIndex=z.featureIndex;break}for(let I=y;I<w;I++){const z=t.get(I);S.verticalIconBox={x1:z.x1,y1:z.y1,x2:z.x2,y2:z.y2,anchorPointX:z.anchorPointX,anchorPointY:z.anchorPointY},S.verticalIconFeatureIndex=z.featureIndex;break}return S}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const s=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,s.textBoxStartIndex,s.textBoxEndIndex,s.verticalTextBoxStartIndex,s.verticalTextBoxEndIndex,s.iconBoxStartIndex,s.iconBoxEndIndex,s.verticalIconBoxStartIndex,s.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,i){const s=t.placedSymbolArray.get(i),l=s.vertexStartIndex+4*s.numGlyphs;for(let p=s.vertexStartIndex;p<l;p+=4)t.indexArray.emplaceBack(p,p+2,p+1),t.indexArray.emplaceBack(p+1,p+2,p+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(t),s=Math.cos(t),l=[],p=[],f=[];for(let _=0;_<this.symbolInstances.length;++_){f.push(_);const y=this.symbolInstances.get(_);l.push(0|Math.round(i*y.anchorX+s*y.anchorY)),p.push(y.featureIndex)}return f.sort((_,y)=>l[_]-l[y]||p[y]-p[_]),f}addToSortKeyRanges(t,i){const s=this.sortKeyRanges[this.sortKeyRanges.length-1];s&&s.sortKey===i?s.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const s=this.symbolInstances.get(i);this.featureSortOrder.push(s.featureIndex),[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((l,p,f)=>{l>=0&&f.indexOf(l)===p&&this.addIndicesForPlacedSymbol(this.text,l)}),s.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,s.verticalPlacedTextSymbolIndex),s.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.placedIconSymbolIndex),s.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,s.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let u_,h_;Xe("SymbolBucket",Tl,{omit:["layers","collisionBoxArray","features","compareText"]}),Tl.MAX_GLYPHS=65535,Tl.addDynamicAttributes=Vp;var Gp={get paint(){return h_=h_||new yr({"icon-opacity":new ht(fe.paint_symbol["icon-opacity"]),"icon-color":new ht(fe.paint_symbol["icon-color"]),"icon-halo-color":new ht(fe.paint_symbol["icon-halo-color"]),"icon-halo-width":new ht(fe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ht(fe.paint_symbol["icon-halo-blur"]),"icon-translate":new rt(fe.paint_symbol["icon-translate"]),"icon-translate-anchor":new rt(fe.paint_symbol["icon-translate-anchor"]),"text-opacity":new ht(fe.paint_symbol["text-opacity"]),"text-color":new ht(fe.paint_symbol["text-color"],{runtimeType:ir,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new ht(fe.paint_symbol["text-halo-color"]),"text-halo-width":new ht(fe.paint_symbol["text-halo-width"]),"text-halo-blur":new ht(fe.paint_symbol["text-halo-blur"]),"text-translate":new rt(fe.paint_symbol["text-translate"]),"text-translate-anchor":new rt(fe.paint_symbol["text-translate-anchor"])})},get layout(){return u_=u_||new yr({"symbol-placement":new rt(fe.layout_symbol["symbol-placement"]),"symbol-spacing":new rt(fe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new rt(fe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ht(fe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new rt(fe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new rt(fe.layout_symbol["icon-allow-overlap"]),"icon-overlap":new rt(fe.layout_symbol["icon-overlap"]),"icon-ignore-placement":new rt(fe.layout_symbol["icon-ignore-placement"]),"icon-optional":new rt(fe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new rt(fe.layout_symbol["icon-rotation-alignment"]),"icon-size":new ht(fe.layout_symbol["icon-size"]),"icon-text-fit":new rt(fe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new rt(fe.layout_symbol["icon-text-fit-padding"]),"icon-image":new ht(fe.layout_symbol["icon-image"]),"icon-rotate":new ht(fe.layout_symbol["icon-rotate"]),"icon-padding":new ht(fe.layout_symbol["icon-padding"]),"icon-keep-upright":new rt(fe.layout_symbol["icon-keep-upright"]),"icon-offset":new ht(fe.layout_symbol["icon-offset"]),"icon-anchor":new ht(fe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new rt(fe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new rt(fe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new rt(fe.layout_symbol["text-rotation-alignment"]),"text-field":new ht(fe.layout_symbol["text-field"]),"text-font":new ht(fe.layout_symbol["text-font"]),"text-size":new ht(fe.layout_symbol["text-size"]),"text-max-width":new ht(fe.layout_symbol["text-max-width"]),"text-line-height":new rt(fe.layout_symbol["text-line-height"]),"text-letter-spacing":new ht(fe.layout_symbol["text-letter-spacing"]),"text-justify":new ht(fe.layout_symbol["text-justify"]),"text-radial-offset":new ht(fe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new rt(fe.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new ht(fe.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new ht(fe.layout_symbol["text-anchor"]),"text-max-angle":new rt(fe.layout_symbol["text-max-angle"]),"text-writing-mode":new rt(fe.layout_symbol["text-writing-mode"]),"text-rotate":new ht(fe.layout_symbol["text-rotate"]),"text-padding":new rt(fe.layout_symbol["text-padding"]),"text-keep-upright":new rt(fe.layout_symbol["text-keep-upright"]),"text-transform":new ht(fe.layout_symbol["text-transform"]),"text-offset":new ht(fe.layout_symbol["text-offset"]),"text-allow-overlap":new rt(fe.layout_symbol["text-allow-overlap"]),"text-overlap":new rt(fe.layout_symbol["text-overlap"]),"text-ignore-placement":new rt(fe.layout_symbol["text-ignore-placement"]),"text-optional":new rt(fe.layout_symbol["text-optional"])})}};class d_{constructor(t){if(t.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:Ws,this.defaultValue=t}evaluate(t){if(t.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(t.formattedSection))return i.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Xe("FormatSectionOverride",d_,{omit:["defaultValue"]});class Zh extends Wr{constructor(t){super(t,Gp)}recalculate(t,i){if(super.recalculate(t,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const s=this.layout.get("text-writing-mode");if(s){const l=[];for(const p of s)l.indexOf(p)<0&&l.push(p);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,i,s,l){const p=this.layout.get(t).evaluate(i,{},s,l),f=this._unevaluatedLayout._values[t];return f.isDataDriven()||Ja(f.value)||!p?p:function(_,y){return y.replace(/{([^{}]+)}/g,(w,S)=>_&&S in _?String(_[S]):"")}(i.properties,p)}createBucket(t){return new Tl(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Gp.paint.overridableProperties){if(!Zh.hasPaintOverride(this.layout,t))continue;const i=this.paint.get(t),s=new d_(i),l=new bc(s,i.property.specification);let p=null;p=i.value.kind==="constant"||i.value.kind==="source"?new Yo("source",l):new wc("composite",l,i.value.zoomStops),this.paint._values[t]=new Mn(i.property,p,i.parameters)}}_handleOverridablePaintPropertyUpdate(t,i,s){return!(!this.layout||i.isDataDriven()||s.isDataDriven())&&Zh.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,i){const s=t.get("text-field"),l=Gp.paint.properties[i];let p=!1;const f=_=>{for(const y of _)if(l.overrides&&l.overrides.hasOverride(y))return void(p=!0)};if(s.value.kind==="constant"&&s.value.value instanceof mr)f(s.value.value.sections);else if(s.value.kind==="source"||s.value.kind==="composite"){const _=w=>{p||(w instanceof kn&&pt(w.value)===Kn?f(w.value.sections):w instanceof Ps?f(w.sections):w.eachChild(_))},y=s.value;y._styleExpression&&_(y._styleExpression.expression)}return p}}let p_;var C1={get paint(){return p_=p_||new yr({"background-color":new rt(fe.paint_background["background-color"]),"background-pattern":new is(fe.paint_background["background-pattern"]),"background-opacity":new rt(fe.paint_background["background-opacity"])})}};class I1 extends Wr{constructor(t){super(t,C1)}}let f_;var E1={get paint(){return f_=f_||new yr({"raster-opacity":new rt(fe.paint_raster["raster-opacity"]),"raster-hue-rotate":new rt(fe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new rt(fe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new rt(fe.paint_raster["raster-brightness-max"]),"raster-saturation":new rt(fe.paint_raster["raster-saturation"]),"raster-contrast":new rt(fe.paint_raster["raster-contrast"]),"raster-resampling":new rt(fe.paint_raster["raster-resampling"]),"raster-fade-duration":new rt(fe.paint_raster["raster-fade-duration"])})}};class A1 extends Wr{constructor(t){super(t,E1)}}class k1 extends Wr{constructor(t){super(t,{}),this.onAdd=i=>{this.implementation.onAdd&&this.implementation.onAdd(i,i.painter.context.gl)},this.onRemove=i=>{this.implementation.onRemove&&this.implementation.onRemove(i,i.painter.context.gl)},this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class z1{constructor(t){this._methodToThrottle=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const R1={once:!0},Zp=63710088e-1;class wo{constructor(t,i){if(isNaN(t)||isNaN(i))throw new Error(`Invalid LngLat object: (${t}, ${i})`);if(this.lng=+t,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new wo(tn(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const i=Math.PI/180,s=this.lat*i,l=t.lat*i,p=Math.sin(s)*Math.sin(l)+Math.cos(s)*Math.cos(l)*Math.cos((t.lng-this.lng)*i);return Zp*Math.acos(Math.min(p,1))}static convert(t){if(t instanceof wo)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new wo(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new wo(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const m_=2*Math.PI*Zp;function g_(r){return m_*Math.cos(r*Math.PI/180)}function __(r){return(180+r)/360}function y_(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function v_(r,t){return r/g_(t)}function qp(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function x_(r,t){return r*g_(qp(t))}class iu{constructor(t,i,s=0){this.x=+t,this.y=+i,this.z=+s}static fromLngLat(t,i=0){const s=wo.convert(t);return new iu(__(s.lng),y_(s.lat),v_(i,s.lat))}toLngLat(){return new wo(360*this.x-180,qp(this.y))}toAltitude(){return x_(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/m_*(t=qp(this.y),1/Math.cos(t*Math.PI/180));var t}}function b_(r,t,i){var s=2*Math.PI*6378137/256/Math.pow(2,i);return[r*s-2*Math.PI*6378137/2,t*s-2*Math.PI*6378137/2]}class Hp{constructor(t,i,s){if(!function(l,p,f){return!(l<0||l>25||f<0||f>=Math.pow(2,l)||p<0||p>=Math.pow(2,l))}(t,i,s))throw new Error(`x=${i}, y=${s}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=i,this.y=s,this.key=Sl(0,t,t,i,s)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,i,s){const l=(f=this.y,_=this.z,y=b_(256*(p=this.x),256*(f=Math.pow(2,_)-f-1),_),w=b_(256*(p+1),256*(f+1),_),y[0]+","+y[1]+","+w[0]+","+w[1]);var p,f,_,y,w;const S=function(I,z,L){let F,N="";for(let $=I;$>0;$--)F=1<<$-1,N+=(z&F?1:0)+(L&F?2:0);return N}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,i>1?"@2x":"").replace(/{quadkey}/g,S).replace(/{bbox-epsg-3857}/g,l)}isChildOf(t){const i=this.z-t.z;return i>0&&t.x===this.x>>i&&t.y===this.y>>i}getTilePoint(t){const i=Math.pow(2,this.z);return new V((t.x*i-this.x)*Vt,(t.y*i-this.y)*Vt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class w_{constructor(t,i){this.wrap=t,this.canonical=i,this.key=Sl(t,i.z,i.z,i.x,i.y)}}class fn{constructor(t,i,s,l,p){if(this.terrainRttPosMatrix32f=null,t<s)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${s}`);this.overscaledZ=t,this.wrap=i,this.canonical=new Hp(s,+l,+p),this.key=Sl(i,t,s,l,p)}clone(){return new fn(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?new fn(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fn(t,this.wrap,t,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(t,i){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const s=this.canonical.z-t;return t>this.canonical.z?Sl(this.wrap*+i,t,this.canonical.z,this.canonical.x,this.canonical.y):Sl(this.wrap*+i,t,t,this.canonical.x>>s,this.canonical.y>>s)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const i=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>i&&t.canonical.y===this.canonical.y>>i}children(t){if(this.overscaledZ>=t)return[new fn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,s=2*this.canonical.x,l=2*this.canonical.y;return[new fn(i,this.wrap,i,s,l),new fn(i,this.wrap,i,s+1,l),new fn(i,this.wrap,i,s,l+1),new fn(i,this.wrap,i,s+1,l+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new fn(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new fn(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new w_(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new iu(t.x-this.wrap,t.y))}}function Sl(r,t,i,s,l){(r*=2)<0&&(r=-1*r-1);const p=1<<i;return(p*p*r+p*l+s).toString(36)+i.toString(36)+t.toString(36)}function ru(r,t){return t?r.properties[t]:r.id}Xe("CanonicalTileID",Hp),Xe("OverscaledTileID",fn,{omit:["terrainRttPosMatrix32f"]});class ua{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){const i=new ua;return i.extend(t(new V(this.minX,this.minY))),i.extend(t(new V(this.maxX,this.minY))),i.extend(t(new V(this.minX,this.maxY))),i.extend(t(new V(this.maxX,this.maxY))),i}static fromPoints(t){const i=new ua;for(const s of t)i.extend(s);return i}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}}class T_{constructor(t){this._stringToNumber={},this._numberToString=[];for(let i=0;i<t.length;i++){const s=t[i];this._stringToNumber[s]=i,this._numberToString[i]=s}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class S_{constructor(t,i,s,l,p){this.type="Feature",this._vectorTileFeature=t,t._z=i,t._x=s,t._y=l,this.properties=t.properties,this.id=p}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const i in this)i!=="_geometry"&&i!=="_vectorTileFeature"&&(t[i]=this[i]);return t}}class P_{constructor(t,i){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new na(Vt,16,0),this.grid3D=new na(Vt,16,0),this.featureIndexArray=new se,this.promoteId=i}insert(t,i,s,l,p,f){const _=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(s,l,p);const y=f?this.grid3D:this.grid;for(let w=0;w<i.length;w++){const S=i[w],I=[1/0,1/0,-1/0,-1/0];for(let z=0;z<S.length;z++){const L=S[z];I[0]=Math.min(I[0],L.x),I[1]=Math.min(I[1],L.y),I[2]=Math.max(I[2],L.x),I[3]=Math.max(I[3],L.y)}I[0]<Vt&&I[1]<Vt&&I[2]>=0&&I[3]>=0&&y.insert(_,I[0],I[1],I[2],I[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Vg(new Fp(this.rawTileData)).layers,this.sourceLayerCoder=new T_(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,i,s,l){this.loadVTLayers();const p=t.params,f=Vt/t.tileSize/t.scale,_=ks(p.filter),y=t.queryGeometry,w=t.queryPadding*f,S=ua.fromPoints(y),I=this.grid.query(S.minX-w,S.minY-w,S.maxX+w,S.maxY+w),z=ua.fromPoints(t.cameraQueryGeometry).expandBy(w),L=this.grid3D.query(z.minX,z.minY,z.maxX,z.maxY,($,H,he,ee)=>function(re,ve,we,Ee,Ue){for(const Ne of re)if(ve<=Ne.x&&we<=Ne.y&&Ee>=Ne.x&&Ue>=Ne.y)return!0;const Be=[new V(ve,we),new V(ve,Ue),new V(Ee,Ue),new V(Ee,we)];if(re.length>2){for(const Ne of Be)if(gl(re,Ne))return!0}for(let Ne=0;Ne<re.length-1;Ne++)if(hb(re[Ne],re[Ne+1],Be))return!0;return!1}(t.cameraQueryGeometry,$-w,H-w,he+w,ee+w));for(const $ of L)I.push($);I.sort(D1);const F={};let N;for(let $=0;$<I.length;$++){const H=I[$];if(H===N)continue;N=H;const he=this.featureIndexArray.get(H);let ee=null;this.loadMatchingFeature(F,he.bucketIndex,he.sourceLayerIndex,he.featureIndex,_,p.layers,p.availableImages,i,s,l,(re,ve,we)=>(ee||(ee=as(re)),ve.queryIntersectsFeature({queryGeometry:y,feature:re,featureState:we,geometry:ee,zoom:this.z,transform:t.transform,pixelsToTileUnits:f,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation})))}return F}loadMatchingFeature(t,i,s,l,p,f,_,y,w,S,I){const z=this.bucketLayerIDs[i];if(f&&!z.some($=>f.has($)))return;const L=this.sourceLayerCoder.decode(s),F=this.vtLayers[L].feature(l);if(p.needGeometry){const $=Ln(F,!0);if(!p.filter(new si(this.tileID.overscaledZ),$,this.tileID.canonical))return}else if(!p.filter(new si(this.tileID.overscaledZ),F))return;const N=this.getId(F,L);for(let $=0;$<z.length;$++){const H=z[$];if(f&&!f.has(H))continue;const he=y[H];if(!he)continue;let ee={};N&&S&&(ee=S.getState(he.sourceLayer||"_geojsonTileLayer",N));const re=lr({},w[H]);re.paint=M_(re.paint,he.paint,F,ee,_),re.layout=M_(re.layout,he.layout,F,ee,_);const ve=!I||I(F,he,ee);if(!ve)continue;const we=new S_(F,this.z,this.x,this.y,N);we.layer=re;let Ee=t[H];Ee===void 0&&(Ee=t[H]=[]),Ee.push({featureIndex:l,feature:we,intersectionZ:ve})}}lookupSymbolFeatures(t,i,s,l,p,f,_,y){const w={};this.loadVTLayers();const S=ks(p);for(const I of t)this.loadMatchingFeature(w,s,l,I,S,f,_,y,i);return w}hasLayer(t){for(const i of this.bucketLayerIDs)for(const s of i)if(t===s)return!0;return!1}getId(t,i){var s;let l=t.id;return this.promoteId&&(l=t.properties[typeof this.promoteId=="string"?this.promoteId:this.promoteId[i]],typeof l=="boolean"&&(l=Number(l)),l===void 0&&(!((s=t.properties)===null||s===void 0)&&s.cluster)&&this.promoteId&&(l=Number(t.properties.cluster_id))),l}}function M_(r,t,i,s,l){return Zr(r,(p,f)=>{const _=t instanceof ll?t.get(f):null;return _&&_.evaluate?_.evaluate(i,s,l):_})}function D1(r,t){return t-r}function C_(r,t,i,s,l){const p=[];for(let f=0;f<r.length;f++){const _=r[f];let y;for(let w=0;w<_.length-1;w++){let S=_[w],I=_[w+1];S.x<t&&I.x<t||(S.x<t?S=new V(t,S.y+(t-S.x)/(I.x-S.x)*(I.y-S.y))._round():I.x<t&&(I=new V(t,S.y+(t-S.x)/(I.x-S.x)*(I.y-S.y))._round()),S.y<i&&I.y<i||(S.y<i?S=new V(S.x+(i-S.y)/(I.y-S.y)*(I.x-S.x),i)._round():I.y<i&&(I=new V(S.x+(i-S.y)/(I.y-S.y)*(I.x-S.x),i)._round()),S.x>=s&&I.x>=s||(S.x>=s?S=new V(s,S.y+(s-S.x)/(I.x-S.x)*(I.y-S.y))._round():I.x>=s&&(I=new V(s,S.y+(s-S.x)/(I.x-S.x)*(I.y-S.y))._round()),S.y>=l&&I.y>=l||(S.y>=l?S=new V(S.x+(l-S.y)/(I.y-S.y)*(I.x-S.x),l)._round():I.y>=l&&(I=new V(S.x+(l-S.y)/(I.y-S.y)*(I.x-S.x),l)._round()),y&&S.equals(y[y.length-1])||(y=[S],p.push(y)),y.push(I)))))}}return p}Xe("FeatureIndex",P_,{omit:["rawTileData","sourceLayerCoder"]});class To extends V{constructor(t,i,s,l){super(t,i),this.angle=s,l!==void 0&&(this.segment=l)}clone(){return new To(this.x,this.y,this.angle,this.segment)}}function I_(r,t,i,s,l){if(t.segment===void 0||i===0)return!0;let p=t,f=t.segment+1,_=0;for(;_>-i/2;){if(f--,f<0)return!1;_-=r[f].dist(p),p=r[f]}_+=r[f].dist(r[f+1]),f++;const y=[];let w=0;for(;_<i/2;){const S=r[f],I=r[f+1];if(!I)return!1;let z=r[f-1].angleTo(S)-S.angleTo(I);for(z=Math.abs((z+3*Math.PI)%(2*Math.PI)-Math.PI),y.push({distance:_,angleDelta:z}),w+=z;_-y[0].distance>s;)w-=y.shift().angleDelta;if(w>l)return!1;f++,_+=S.dist(I)}return!0}function E_(r){let t=0;for(let i=0;i<r.length-1;i++)t+=r[i].dist(r[i+1]);return t}function A_(r,t,i){return r?.6*t*i:0}function k_(r,t){return Math.max(r?r.right-r.left:0,t?t.right-t.left:0)}function L1(r,t,i,s,l,p){const f=A_(i,l,p),_=k_(i,s)*p;let y=0;const w=E_(r)/2;for(let S=0;S<r.length-1;S++){const I=r[S],z=r[S+1],L=I.dist(z);if(y+L>w){const F=(w-y)/L,N=Sn.number(I.x,z.x,F),$=Sn.number(I.y,z.y,F),H=new To(N,$,z.angleTo(I),S);return H._round(),!f||I_(r,H,_,f,t)?H:void 0}y+=L}}function F1(r,t,i,s,l,p,f,_,y){const w=A_(s,p,f),S=k_(s,l),I=S*f,z=r[0].x===0||r[0].x===y||r[0].y===0||r[0].y===y;return t-I<t/4&&(t=I+t/4),z_(r,z?t/2*_%t:(S/2+2*p)*f*_%t,t,w,i,I,z,!1,y)}function z_(r,t,i,s,l,p,f,_,y){const w=p/2,S=E_(r);let I=0,z=t-i,L=[];for(let F=0;F<r.length-1;F++){const N=r[F],$=r[F+1],H=N.dist($),he=$.angleTo(N);for(;z+i<I+H;){z+=i;const ee=(z-I)/H,re=Sn.number(N.x,$.x,ee),ve=Sn.number(N.y,$.y,ee);if(re>=0&&re<y&&ve>=0&&ve<y&&z-w>=0&&z+w<=S){const we=new To(re,ve,he,F);we._round(),s&&!I_(r,we,p,s,l)||L.push(we)}}I+=H}return _||L.length||f||(L=z_(r,I/2,i,s,l,p,f,!0,y)),L}function R_(r,t,i,s){const l=[],p=r.image,f=p.pixelRatio,_=p.paddedRect.w-2,y=p.paddedRect.h-2;let w={x1:r.left,y1:r.top,x2:r.right,y2:r.bottom};const S=p.stretchX||[[0,_]],I=p.stretchY||[[0,y]],z=(Me,ft)=>Me+ft[1]-ft[0],L=S.reduce(z,0),F=I.reduce(z,0),N=_-L,$=y-F;let H=0,he=L,ee=0,re=F,ve=0,we=N,Ee=0,Ue=$;if(p.content&&s){const Me=p.content,ft=Me[2]-Me[0],gt=Me[3]-Me[1];(p.textFitWidth||p.textFitHeight)&&(w=a_(r)),H=qh(S,0,Me[0]),ee=qh(I,0,Me[1]),he=qh(S,Me[0],Me[2]),re=qh(I,Me[1],Me[3]),ve=Me[0]-H,Ee=Me[1]-ee,we=ft-he,Ue=gt-re}const Be=w.x1,Ne=w.y1,nt=w.x2-Be,je=w.y2-Ne,Ve=(Me,ft,gt,at)=>{const tt=Hh(Me.stretch-H,he,nt,Be),Ot=Wh(Me.fixed-ve,we,Me.stretch,L),vi=Hh(ft.stretch-ee,re,je,Ne),$i=Wh(ft.fixed-Ee,Ue,ft.stretch,F),pr=Hh(gt.stretch-H,he,nt,Be),mn=Wh(gt.fixed-ve,we,gt.stretch,L),Nr=Hh(at.stretch-ee,re,je,Ne),nr=Wh(at.fixed-Ee,Ue,at.stretch,F),fi=new V(tt,vi),Ki=new V(pr,vi),sr=new V(pr,Nr),or=new V(tt,Nr),Ar=new V(Ot/f,$i/f),gn=new V(mn/f,nr/f),Yi=t*Math.PI/180;if(Yi){const Ji=Math.sin(Yi),Qi=Math.cos(Yi),Fi=[Qi,-Ji,Ji,Qi];fi._matMult(Fi),Ki._matMult(Fi),or._matMult(Fi),sr._matMult(Fi)}const Vr=Me.stretch+Me.fixed,Gi=ft.stretch+ft.fixed;return{tl:fi,tr:Ki,bl:or,br:sr,tex:{x:p.paddedRect.x+1+Vr,y:p.paddedRect.y+1+Gi,w:gt.stretch+gt.fixed-Vr,h:at.stretch+at.fixed-Gi},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ar,pixelOffsetBR:gn,minFontScaleX:we/f/nt,minFontScaleY:Ue/f/je,isSDF:i}};if(s&&(p.stretchX||p.stretchY)){const Me=D_(S,N,L),ft=D_(I,$,F);for(let gt=0;gt<Me.length-1;gt++){const at=Me[gt],tt=Me[gt+1];for(let Ot=0;Ot<ft.length-1;Ot++)l.push(Ve(at,ft[Ot],tt,ft[Ot+1]))}}else l.push(Ve({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:_+1},{fixed:0,stretch:y+1}));return l}function qh(r,t,i){let s=0;for(const l of r)s+=Math.max(t,Math.min(i,l[1]))-Math.max(t,Math.min(i,l[0]));return s}function D_(r,t,i){const s=[{fixed:-1,stretch:0}];for(const[l,p]of r){const f=s[s.length-1];s.push({fixed:l-f.stretch,stretch:f.stretch}),s.push({fixed:l-f.stretch,stretch:f.stretch+(p-l)})}return s.push({fixed:t+1,stretch:i}),s}function Hh(r,t,i,s){return r/t*i+s}function Wh(r,t,i,s){return r-t*i/s}Xe("Anchor",To);class Xh{constructor(t,i,s,l,p,f,_,y,w,S){var I;if(this.boxStartIndex=t.length,w){let z=f.top,L=f.bottom;const F=f.collisionPadding;F&&(z-=F[1],L+=F[3]);let N=L-z;N>0&&(N=Math.max(10,N),this.circleDiameter=N)}else{const z=!((I=f.image)===null||I===void 0)&&I.content&&(f.image.textFitWidth||f.image.textFitHeight)?a_(f):{x1:f.left,y1:f.top,x2:f.right,y2:f.bottom};z.y1=z.y1*_-y[0],z.y2=z.y2*_+y[2],z.x1=z.x1*_-y[3],z.x2=z.x2*_+y[1];const L=f.collisionPadding;if(L&&(z.x1-=L[0]*_,z.y1-=L[1]*_,z.x2+=L[2]*_,z.y2+=L[3]*_),S){const F=new V(z.x1,z.y1),N=new V(z.x2,z.y1),$=new V(z.x1,z.y2),H=new V(z.x2,z.y2),he=S*Math.PI/180;F._rotate(he),N._rotate(he),$._rotate(he),H._rotate(he),z.x1=Math.min(F.x,N.x,$.x,H.x),z.x2=Math.max(F.x,N.x,$.x,H.x),z.y1=Math.min(F.y,N.y,$.y,H.y),z.y2=Math.max(F.y,N.y,$.y,H.y)}t.emplaceBack(i.x,i.y,z.x1,z.y1,z.x2,z.y2,s,l,p)}this.boxEndIndex=t.length}}class B1{constructor(t=[],i=(s,l)=>s<l?-1:s>l?1:0){if(this.data=t,this.length=this.data.length,this.compare=i,this.length>0)for(let s=(this.length>>1)-1;s>=0;s--)this._down(s)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],i=this.data.pop();return--this.length>0&&(this.data[0]=i,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:i,compare:s}=this,l=i[t];for(;t>0;){const p=t-1>>1,f=i[p];if(s(l,f)>=0)break;i[t]=f,t=p}i[t]=l}_down(t){const{data:i,compare:s}=this,l=this.length>>1,p=i[t];for(;t<l;){let f=1+(t<<1);const _=f+1;if(_<this.length&&s(i[_],i[f])<0&&(f=_),s(i[f],p)>=0)break;i[t]=i[f],t=f}i[t]=p}}function O1(r,t=1,i=!1){const s=ua.fromPoints(r[0]),l=Math.min(s.width(),s.height());let p=l/2;const f=new B1([],j1),{minX:_,minY:y,maxX:w,maxY:S}=s;if(l===0)return new V(_,y);for(let L=_;L<w;L+=l)for(let F=y;F<S;F+=l)f.push(new Pl(L+p,F+p,p,r));let I=function(L){let F=0,N=0,$=0;const H=L[0];for(let he=0,ee=H.length,re=ee-1;he<ee;re=he++){const ve=H[he],we=H[re],Ee=ve.x*we.y-we.x*ve.y;N+=(ve.x+we.x)*Ee,$+=(ve.y+we.y)*Ee,F+=3*Ee}return new Pl(N/F,$/F,0,L)}(r),z=f.length;for(;f.length;){const L=f.pop();(L.d>I.d||!I.d)&&(I=L,i&&console.log("found best %d after %d probes",Math.round(1e4*L.d)/1e4,z)),L.max-I.d<=t||(p=L.h/2,f.push(new Pl(L.p.x-p,L.p.y-p,p,r)),f.push(new Pl(L.p.x+p,L.p.y-p,p,r)),f.push(new Pl(L.p.x-p,L.p.y+p,p,r)),f.push(new Pl(L.p.x+p,L.p.y+p,p,r)),z+=4)}return i&&(console.log(`num probes: ${z}`),console.log(`best distance: ${I.d}`)),I.p}function j1(r,t){return t.max-r.max}function Pl(r,t,i,s){this.p=new V(r,t),this.h=i,this.d=function(l,p){let f=!1,_=1/0;for(let y=0;y<p.length;y++){const w=p[y];for(let S=0,I=w.length,z=I-1;S<I;z=S++){const L=w[S],F=w[z];L.y>l.y!=F.y>l.y&&l.x<(F.x-L.x)*(l.y-L.y)/(F.y-L.y)+L.x&&(f=!f),_=Math.min(_,yg(l,L,F))}}return(f?1:-1)*Math.sqrt(_)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}var dr;T.aE=void 0,(dr=T.aE||(T.aE={}))[dr.center=1]="center",dr[dr.left=2]="left",dr[dr.right=3]="right",dr[dr.top=4]="top",dr[dr.bottom=5]="bottom",dr[dr["top-left"]=6]="top-left",dr[dr["top-right"]=7]="top-right",dr[dr["bottom-left"]=8]="bottom-left",dr[dr["bottom-right"]=9]="bottom-right";const Wp=Number.POSITIVE_INFINITY;function L_(r,t){return t[1]!==Wp?function(i,s,l){let p=0,f=0;switch(s=Math.abs(s),l=Math.abs(l),i){case"top-right":case"top-left":case"top":f=l-7;break;case"bottom-right":case"bottom-left":case"bottom":f=7-l}switch(i){case"top-right":case"bottom-right":case"right":p=-s;break;case"top-left":case"bottom-left":case"left":p=s}return[p,f]}(r,t[0],t[1]):function(i,s){let l=0,p=0;s<0&&(s=0);const f=s/Math.SQRT2;switch(i){case"top-right":case"top-left":p=f-7;break;case"bottom-right":case"bottom-left":p=7-f;break;case"bottom":p=7-s;break;case"top":p=s-7}switch(i){case"top-right":case"bottom-right":l=-f;break;case"top-left":case"bottom-left":l=f;break;case"left":l=s;break;case"right":l=-s}return[l,p]}(r,t[0])}function F_(r,t,i){var s;const l=r.layout,p=(s=l.get("text-variable-anchor-offset"))===null||s===void 0?void 0:s.evaluate(t,{},i);if(p){const _=p.values,y=[];for(let w=0;w<_.length;w+=2){const S=y[w]=_[w],I=_[w+1].map(z=>z*Xi);S.startsWith("top")?I[1]-=7:S.startsWith("bottom")&&(I[1]+=7),y[w+1]=I}return new _r(y)}const f=l.get("text-variable-anchor");if(f){let _;_=r._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(t,{},i)*Xi,Wp]:l.get("text-offset").evaluate(t,{},i).map(w=>w*Xi);const y=[];for(const w of f)y.push(w,L_(w,_));return new _r(y)}return null}function Xp(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function N1(r,t,i,s,l,p,f,_,y,w,S,I){let z=p.textMaxSize.evaluate(t,{});z===void 0&&(z=f);const L=r.layers[0].layout,F=L.get("icon-offset").evaluate(t,{},S),N=O_(i.horizontal),$=f/24,H=r.tilePixelRatio*$,he=r.tilePixelRatio*z/24,ee=r.tilePixelRatio*_,re=r.tilePixelRatio*L.get("symbol-spacing"),ve=L.get("text-padding")*r.tilePixelRatio,we=function(gt,at,tt,Ot=1){const vi=gt.get("icon-padding").evaluate(at,{},tt),$i=vi&&vi.values;return[$i[0]*Ot,$i[1]*Ot,$i[2]*Ot,$i[3]*Ot]}(L,t,S,r.tilePixelRatio),Ee=L.get("text-max-angle")/180*Math.PI,Ue=L.get("text-rotation-alignment")!=="viewport"&&L.get("symbol-placement")!=="point",Be=L.get("icon-rotation-alignment")==="map"&&L.get("symbol-placement")!=="point",Ne=L.get("symbol-placement"),nt=re/2,je=L.get("icon-text-fit");let Ve;s&&je!=="none"&&(r.allowVerticalPlacement&&i.vertical&&(Ve=l_(s,i.vertical,je,L.get("icon-text-fit-padding"),F,$)),N&&(s=l_(s,N,je,L.get("icon-text-fit-padding"),F,$)));const Me=S?I.line.getGranularityForZoomLevel(S.z):1,ft=(gt,at)=>{at.x<0||at.x>=Vt||at.y<0||at.y>=Vt||function(tt,Ot,vi,$i,pr,mn,Nr,nr,fi,Ki,sr,or,Ar,gn,Yi,Vr,Gi,Ji,Qi,Fi,ui,Fn,Ml,Bn,$1){const Cl=tt.addToLineVertexArray(Ot,vi);let ha,Il,El,Al,U_=0,$_=0,G_=0,Z_=0,nf=-1,sf=-1;const Ns={};let q_=yo("");if(tt.allowVerticalPlacement&&$i.vertical){const br=nr.layout.get("text-rotate").evaluate(ui,{},Bn)+90;El=new Xh(fi,Ot,Ki,sr,or,$i.vertical,Ar,gn,Yi,br),Nr&&(Al=new Xh(fi,Ot,Ki,sr,or,Nr,Gi,Ji,Yi,br))}if(pr){const br=nr.layout.get("icon-rotate").evaluate(ui,{}),_n=nr.layout.get("icon-text-fit")!=="none",da=R_(pr,br,Ml,_n),jn=Nr?R_(Nr,br,Ml,_n):void 0;Il=new Xh(fi,Ot,Ki,sr,or,pr,Gi,Ji,!1,br),U_=4*da.length;const pa=tt.iconSizeData;let ls=null;pa.kind==="source"?(ls=[js*nr.layout.get("icon-size").evaluate(ui,{})],ls[0]>bo&&Te(`${tt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):pa.kind==="composite"&&(ls=[js*Fn.compositeIconSizes[0].evaluate(ui,{},Bn),js*Fn.compositeIconSizes[1].evaluate(ui,{},Bn)],(ls[0]>bo||ls[1]>bo)&&Te(`${tt.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),tt.addSymbols(tt.icon,da,ls,Fi,Qi,ui,T.ao.none,Ot,Cl.lineStartIndex,Cl.lineLength,-1,Bn),nf=tt.icon.placedSymbolArray.length-1,jn&&($_=4*jn.length,tt.addSymbols(tt.icon,jn,ls,Fi,Qi,ui,T.ao.vertical,Ot,Cl.lineStartIndex,Cl.lineLength,-1,Bn),sf=tt.icon.placedSymbolArray.length-1)}const H_=Object.keys($i.horizontal);for(const br of H_){const _n=$i.horizontal[br];if(!ha){q_=yo(_n.text);const jn=nr.layout.get("text-rotate").evaluate(ui,{},Bn);ha=new Xh(fi,Ot,Ki,sr,or,_n,Ar,gn,Yi,jn)}const da=_n.positionedLines.length===1;if(G_+=B_(tt,Ot,_n,mn,nr,Yi,ui,Vr,Cl,$i.vertical?T.ao.horizontal:T.ao.horizontalOnly,da?H_:[br],Ns,nf,Fn,Bn),da)break}$i.vertical&&(Z_+=B_(tt,Ot,$i.vertical,mn,nr,Yi,ui,Vr,Cl,T.ao.vertical,["vertical"],Ns,sf,Fn,Bn));const G1=ha?ha.boxStartIndex:tt.collisionBoxArray.length,Z1=ha?ha.boxEndIndex:tt.collisionBoxArray.length,q1=El?El.boxStartIndex:tt.collisionBoxArray.length,H1=El?El.boxEndIndex:tt.collisionBoxArray.length,W1=Il?Il.boxStartIndex:tt.collisionBoxArray.length,X1=Il?Il.boxEndIndex:tt.collisionBoxArray.length,K1=Al?Al.boxStartIndex:tt.collisionBoxArray.length,Y1=Al?Al.boxEndIndex:tt.collisionBoxArray.length;let On=-1;const Yh=(br,_n)=>br&&br.circleDiameter?Math.max(br.circleDiameter,_n):_n;On=Yh(ha,On),On=Yh(El,On),On=Yh(Il,On),On=Yh(Al,On);const W_=On>-1?1:0;W_&&(On*=$1/Xi),tt.glyphOffsetArray.length>=Tl.MAX_GLYPHS&&Te("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),ui.sortKey!==void 0&&tt.addToSortKeyRanges(tt.symbolInstances.length,ui.sortKey);const J1=F_(nr,ui,Bn),[Q1,ew]=function(br,_n){const da=br.length,jn=_n==null?void 0:_n.values;if((jn==null?void 0:jn.length)>0)for(let pa=0;pa<jn.length;pa+=2){const ls=jn[pa+1];br.emplaceBack(T.aE[jn[pa]],ls[0],ls[1])}return[da,br.length]}(tt.textAnchorOffsets,J1);tt.symbolInstances.emplaceBack(Ot.x,Ot.y,Ns.right>=0?Ns.right:-1,Ns.center>=0?Ns.center:-1,Ns.left>=0?Ns.left:-1,Ns.vertical||-1,nf,sf,q_,G1,Z1,q1,H1,W1,X1,K1,Y1,Ki,G_,Z_,U_,$_,W_,0,Ar,On,Q1,ew)}(r,at,gt,i,s,l,Ve,r.layers[0],r.collisionBoxArray,t.index,t.sourceLayerIndex,r.index,H,[ve,ve,ve,ve],Ue,y,ee,we,Be,F,t,p,w,S,f)};if(Ne==="line")for(const gt of C_(t.geometry,0,0,Vt,Vt)){const at=ca(gt,Me),tt=F1(at,re,Ee,i.vertical||N,s,24,he,r.overscaling,Vt);for(const Ot of tt)N&&V1(r,N.text,nt,Ot)||ft(at,Ot)}else if(Ne==="line-center"){for(const gt of t.geometry)if(gt.length>1){const at=ca(gt,Me),tt=L1(at,Ee,i.vertical||N,s,24,he);tt&&ft(at,tt)}}else if(t.type==="Polygon")for(const gt of qo(t.geometry,0)){const at=O1(gt,16);ft(ca(gt[0],Me,!0),new To(at.x,at.y,0))}else if(t.type==="LineString")for(const gt of t.geometry){const at=ca(gt,Me);ft(at,new To(at[0].x,at[0].y,0))}else if(t.type==="Point")for(const gt of t.geometry)for(const at of gt)ft([at],new To(at.x,at.y,0))}function B_(r,t,i,s,l,p,f,_,y,w,S,I,z,L,F){const N=function(he,ee,re,ve,we,Ee,Ue,Be){const Ne=ve.layout.get("text-rotate").evaluate(Ee,{})*Math.PI/180,nt=[];for(const je of ee.positionedLines)for(const Ve of je.positionedGlyphs){if(!Ve.rect)continue;const Me=Ve.rect||{};let ft=4,gt=!0,at=1,tt=0;const Ot=(we||Be)&&Ve.vertical,vi=Ve.metrics.advance*Ve.scale/2;if(Be&&ee.verticalizable&&(tt=je.lineOffset/2-(Ve.imageName?-(Xi-Ve.metrics.width*Ve.scale)/2:(Ve.scale-1)*Xi)),Ve.imageName){const Ji=Ue[Ve.imageName];gt=Ji.sdf,at=Ji.pixelRatio,ft=1/at}const $i=we?[Ve.x+vi,Ve.y]:[0,0];let pr=we?[0,0]:[Ve.x+vi+re[0],Ve.y+re[1]-tt],mn=[0,0];Ot&&(mn=pr,pr=[0,0]);const Nr=Ve.metrics.isDoubleResolution?2:1,nr=(Ve.metrics.left-ft)*Ve.scale-vi+pr[0],fi=(-Ve.metrics.top-ft)*Ve.scale+pr[1],Ki=nr+Me.w/Nr*Ve.scale/at,sr=fi+Me.h/Nr*Ve.scale/at,or=new V(nr,fi),Ar=new V(Ki,fi),gn=new V(nr,sr),Yi=new V(Ki,sr);if(Ot){const Ji=new V(-vi,vi- -17),Qi=-Math.PI/2,Fi=12-vi,ui=new V(22-Fi,-(Ve.imageName?Fi:0)),Fn=new V(...mn);or._rotateAround(Qi,Ji)._add(ui)._add(Fn),Ar._rotateAround(Qi,Ji)._add(ui)._add(Fn),gn._rotateAround(Qi,Ji)._add(ui)._add(Fn),Yi._rotateAround(Qi,Ji)._add(ui)._add(Fn)}if(Ne){const Ji=Math.sin(Ne),Qi=Math.cos(Ne),Fi=[Qi,-Ji,Ji,Qi];or._matMult(Fi),Ar._matMult(Fi),gn._matMult(Fi),Yi._matMult(Fi)}const Vr=new V(0,0),Gi=new V(0,0);nt.push({tl:or,tr:Ar,bl:gn,br:Yi,tex:Me,writingMode:ee.writingMode,glyphOffset:$i,sectionIndex:Ve.sectionIndex,isSDF:gt,pixelOffsetTL:Vr,pixelOffsetBR:Gi,minFontScaleX:0,minFontScaleY:0})}return nt}(0,i,_,l,p,f,s,r.allowVerticalPlacement),$=r.textSizeData;let H=null;$.kind==="source"?(H=[js*l.layout.get("text-size").evaluate(f,{})],H[0]>bo&&Te(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):$.kind==="composite"&&(H=[js*L.compositeTextSizes[0].evaluate(f,{},F),js*L.compositeTextSizes[1].evaluate(f,{},F)],(H[0]>bo||H[1]>bo)&&Te(`${r.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),r.addSymbols(r.text,N,H,_,p,f,w,t,y.lineStartIndex,y.lineLength,z,F);for(const he of S)I[he]=r.text.placedSymbolArray.length-1;return 4*N.length}function O_(r){for(const t in r)return r[t];return null}function V1(r,t,i,s){const l=r.compareText;if(t in l){const p=l[t];for(let f=p.length-1;f>=0;f--)if(s.dist(p[f])<i)return!0}else l[t]=[];return l[t].push(s),!1}const j_=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Kp{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,s]=new Uint8Array(t,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const l=s>>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const p=j_[15&s];if(!p)throw new Error("Unrecognized array type.");const[f]=new Uint16Array(t,2,1),[_]=new Uint32Array(t,4,1);return new Kp(_,f,p,t)}constructor(t,i=64,s=Float64Array,l){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=s,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const p=j_.indexOf(this.ArrayType),f=2*t*this.ArrayType.BYTES_PER_ELEMENT,_=t*this.IndexArrayType.BYTES_PER_ELEMENT,y=(8-_%8)%8;if(p<0)throw new Error(`Unexpected typed array class: ${s}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+_+y,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+f+_+y),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+_+y,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+p]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=t)}add(t,i){const s=this._pos>>1;return this.ids[s]=s,this.coords[this._pos++]=t,this.coords[this._pos++]=i,s}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Yp(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,i,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:p,coords:f,nodeSize:_}=this,y=[0,p.length-1,0],w=[];for(;y.length;){const S=y.pop()||0,I=y.pop()||0,z=y.pop()||0;if(I-z<=_){for(let $=z;$<=I;$++){const H=f[2*$],he=f[2*$+1];H>=t&&H<=s&&he>=i&&he<=l&&w.push(p[$])}continue}const L=z+I>>1,F=f[2*L],N=f[2*L+1];F>=t&&F<=s&&N>=i&&N<=l&&w.push(p[L]),(S===0?t<=F:i<=N)&&(y.push(z),y.push(L-1),y.push(1-S)),(S===0?s>=F:l>=N)&&(y.push(L+1),y.push(I),y.push(1-S))}return w}within(t,i,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:p,nodeSize:f}=this,_=[0,l.length-1,0],y=[],w=s*s;for(;_.length;){const S=_.pop()||0,I=_.pop()||0,z=_.pop()||0;if(I-z<=f){for(let $=z;$<=I;$++)V_(p[2*$],p[2*$+1],t,i)<=w&&y.push(l[$]);continue}const L=z+I>>1,F=p[2*L],N=p[2*L+1];V_(F,N,t,i)<=w&&y.push(l[L]),(S===0?t-s<=F:i-s<=N)&&(_.push(z),_.push(L-1),_.push(1-S)),(S===0?t+s>=F:i+s>=N)&&(_.push(L+1),_.push(I),_.push(1-S))}return y}}function Yp(r,t,i,s,l,p){if(l-s<=i)return;const f=s+l>>1;N_(r,t,f,s,l,p),Yp(r,t,i,s,f-1,1-p),Yp(r,t,i,f+1,l,1-p)}function N_(r,t,i,s,l,p){for(;l>s;){if(l-s>600){const w=l-s+1,S=i-s+1,I=Math.log(w),z=.5*Math.exp(2*I/3),L=.5*Math.sqrt(I*z*(w-z)/w)*(S-w/2<0?-1:1);N_(r,t,i,Math.max(s,Math.floor(i-S*z/w+L)),Math.min(l,Math.floor(i+(w-S)*z/w+L)),p)}const f=t[2*i+p];let _=s,y=l;for(nu(r,t,s,i),t[2*l+p]>f&&nu(r,t,s,l);_<y;){for(nu(r,t,_,y),_++,y--;t[2*_+p]<f;)_++;for(;t[2*y+p]>f;)y--}t[2*s+p]===f?nu(r,t,s,y):(y++,nu(r,t,y,l)),y<=i&&(s=y+1),i<=y&&(l=y-1)}}function nu(r,t,i,s){Jp(r,i,s),Jp(t,2*i,2*s),Jp(t,2*i+1,2*s+1)}function Jp(r,t,i){const s=r[t];r[t]=r[i],r[i]=s}function V_(r,t,i,s){const l=r-i,p=t-s;return l*l+p*p}var Qp;T.cx=void 0,(Qp=T.cx||(T.cx={})).create="create",Qp.load="load",Qp.fullLoad="fullLoad";let Kh=null,su=[];const ef=1e3/60,tf="loadTime",rf="fullLoadTime",U1={mark(r){performance.mark(r)},frame(r){const t=r;Kh!=null&&su.push(t-Kh),Kh=t},clearMetrics(){Kh=null,su=[],performance.clearMeasures(tf),performance.clearMeasures(rf);for(const r in T.cx)performance.clearMarks(T.cx[r])},getPerformanceMetrics(){performance.measure(tf,T.cx.create,T.cx.load),performance.measure(rf,T.cx.create,T.cx.fullLoad);const r=performance.getEntriesByName(tf)[0].duration,t=performance.getEntriesByName(rf)[0].duration,i=su.length,s=1/(su.reduce((p,f)=>p+f,0)/i/1e3),l=su.filter(p=>p>ef).reduce((p,f)=>p+(f-ef)/ef,0);return{loadTime:r,fullLoadTime:t,fps:s,percentDroppedFrames:l/(i+l)*100,totalFrames:i}}};T.$=Vt,T.A=st,T.B=function([r,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:r*Math.cos(t)*Math.sin(i),y:r*Math.sin(t)*Math.sin(i),z:r*Math.cos(i)}},T.C=Sn,T.D=rt,T.E=it,T.F=si,T.G=ia,T.H=function(r){if(Re==null){const t=r.navigator?r.navigator.userAgent:null;Re=!!r.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Re},T.I=Bp,T.J=class{constructor(r,t){this.target=r,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new z1(()=>this.process()),this.subscription=Ke(this.target,"message",i=>this.receive(i),!1),this.globalScope=Ae(self)?r:window}registerMessageHandler(r,t){this.messageHandlers[r]=t}sendAsync(r,t){return new Promise((i,s)=>{const l=Math.round(1e18*Math.random()).toString(36).substring(0,10),p=t?Ke(t.signal,"abort",()=>{p==null||p.unsubscribe(),delete this.resolveRejects[l];const y={id:l,type:"<cancel>",origin:location.origin,targetMapId:r.targetMapId,sourceMapId:this.mapId};this.target.postMessage(y)},R1):null;this.resolveRejects[l]={resolve:y=>{p==null||p.unsubscribe(),i(y)},reject:y=>{p==null||p.unsubscribe(),s(y)}};const f=[],_=Object.assign(Object.assign({},r),{id:l,sourceMapId:this.mapId,origin:location.origin,data:ho(r.data,f)});this.target.postMessage(_,{transfer:f})})}receive(r){const t=r.data,i=t.id;if(!(t.origin!=="file://"&&location.origin!=="file://"&&t.origin!=="resource://android"&&location.origin!=="resource://android"&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(t.type==="<cancel>"){delete this.tasks[i];const s=this.abortControllers[i];return delete this.abortControllers[i],void(s&&s.abort())}if(Ae(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(this.taskQueue.length===0)return;const r=this.taskQueue.shift(),t=this.tasks[r];delete this.tasks[r],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(r,t)}processTask(r,t){return a(this,void 0,void 0,function*(){if(t.type==="<response>"){const l=this.resolveRejects[r];return delete this.resolveRejects[r],l?void(t.error?l.reject(Ds(t.error)):l.resolve(Ds(t.data))):void 0}if(!this.messageHandlers[t.type])return void this.completeTask(r,new Error(`Could not find a registered handler for ${t.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const i=Ds(t.data),s=new AbortController;this.abortControllers[r]=s;try{const l=yield this.messageHandlers[t.type](t.sourceMapId,i,s);this.completeTask(r,null,l)}catch(l){this.completeTask(r,l)}})}completeTask(r,t,i){const s=[];delete this.abortControllers[r];const l={id:r,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:t?ho(t):null,data:ho(i,s)};this.target.postMessage(l,{transfer:s})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},T.K=U,T.L=function(){var r=new st(16);return st!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},T.M=function(r,t,i){var s,l,p,f,_,y,w,S,I,z,L,F,N=i[0],$=i[1],H=i[2];return t===r?(r[12]=t[0]*N+t[4]*$+t[8]*H+t[12],r[13]=t[1]*N+t[5]*$+t[9]*H+t[13],r[14]=t[2]*N+t[6]*$+t[10]*H+t[14],r[15]=t[3]*N+t[7]*$+t[11]*H+t[15]):(l=t[1],p=t[2],f=t[3],_=t[4],y=t[5],w=t[6],S=t[7],I=t[8],z=t[9],L=t[10],F=t[11],r[0]=s=t[0],r[1]=l,r[2]=p,r[3]=f,r[4]=_,r[5]=y,r[6]=w,r[7]=S,r[8]=I,r[9]=z,r[10]=L,r[11]=F,r[12]=s*N+_*$+I*H+t[12],r[13]=l*N+y*$+z*H+t[13],r[14]=p*N+w*$+L*H+t[14],r[15]=f*N+S*$+F*H+t[15]),r},T.N=function(r,t,i){var s=i[0],l=i[1],p=i[2];return r[0]=t[0]*s,r[1]=t[1]*s,r[2]=t[2]*s,r[3]=t[3]*s,r[4]=t[4]*l,r[5]=t[5]*l,r[6]=t[6]*l,r[7]=t[7]*l,r[8]=t[8]*p,r[9]=t[9]*p,r[10]=t[10]*p,r[11]=t[11]*p,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},T.O=function(r,t,i){var s=t[0],l=t[1],p=t[2],f=t[3],_=t[4],y=t[5],w=t[6],S=t[7],I=t[8],z=t[9],L=t[10],F=t[11],N=t[12],$=t[13],H=t[14],he=t[15],ee=i[0],re=i[1],ve=i[2],we=i[3];return r[0]=ee*s+re*_+ve*I+we*N,r[1]=ee*l+re*y+ve*z+we*$,r[2]=ee*p+re*w+ve*L+we*H,r[3]=ee*f+re*S+ve*F+we*he,r[4]=(ee=i[4])*s+(re=i[5])*_+(ve=i[6])*I+(we=i[7])*N,r[5]=ee*l+re*y+ve*z+we*$,r[6]=ee*p+re*w+ve*L+we*H,r[7]=ee*f+re*S+ve*F+we*he,r[8]=(ee=i[8])*s+(re=i[9])*_+(ve=i[10])*I+(we=i[11])*N,r[9]=ee*l+re*y+ve*z+we*$,r[10]=ee*p+re*w+ve*L+we*H,r[11]=ee*f+re*S+ve*F+we*he,r[12]=(ee=i[12])*s+(re=i[13])*_+(ve=i[14])*I+(we=i[15])*N,r[13]=ee*l+re*y+ve*z+we*$,r[14]=ee*p+re*w+ve*L+we*H,r[15]=ee*f+re*S+ve*F+we*he,r},T.P=V,T.Q=function(r,t){const i={};for(let s=0;s<t.length;s++){const l=t[s];l in r&&(i[l]=r[l])}return i},T.R=jr,T.S=wo,T.T=Mp,T.U=y_,T.V=__,T.W=Je,T.X=Ye,T.Y=Ge,T.Z=fn,T._=a,T.a=B,T.a$=tr,T.a0=function(r,t){var i,s,l,p,f;if(!r)return t??{};if(!t)return r;let _=Object.assign({},r);if(t.removeAll&&(_={removeAll:!0}),t.remove){const y=new Set(t.remove);_.add&&(_.add=_.add.filter(S=>!y.has(S.id))),_.update&&(_.update=_.update.filter(S=>!y.has(S.id)));const w=new Set(((i=r.add)!==null&&i!==void 0?i:[]).map(S=>S.id));t.remove=t.remove.filter(S=>!w.has(S))}if(t.remove){const y=new Set(_.remove?_.remove.concat(t.remove):t.remove);_.remove=Array.from(y.values())}if(t.add){const y=_.add?_.add.concat(t.add):t.add,w=new Map(y.map(S=>[S.id,S]));_.add=Array.from(w.values())}if(t.update){const y=new Map((s=_.update)===null||s===void 0?void 0:s.map(w=>[w.id,w]));for(const w of t.update){const S=(l=y.get(w.id))!==null&&l!==void 0?l:{id:w.id};w.newGeometry&&(S.newGeometry=w.newGeometry),w.addOrUpdateProperties&&(S.addOrUpdateProperties=((p=S.addOrUpdateProperties)!==null&&p!==void 0?p:[]).concat(w.addOrUpdateProperties)),w.removeProperties&&(S.removeProperties=((f=S.removeProperties)!==null&&f!==void 0?f:[]).concat(w.removeProperties)),w.removeAllProperties&&(S.removeAllProperties=!0),y.set(w.id,S)}_.update=Array.from(y.values())}return _.remove&&_.add&&(_.remove=_.remove.filter(y=>_.add.findIndex(w=>w.id===y)===-1)),_},T.a1=iu,T.a2=ua,T.a3=25,T.a4=Hp,T.a5=r=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const s of r){const l=window.document.createElement("source");me(s)||(t.crossOrigin="Anonymous"),l.src=s,t.appendChild(l)}})},T.a6=Fe,T.a7=function(){return Pr++},T.a8=A,T.a9=Tl,T.aA=function(r){let t=1/0,i=1/0,s=-1/0,l=-1/0;for(const p of r)t=Math.min(t,p.x),i=Math.min(i,p.y),s=Math.max(s,p.x),l=Math.max(l,p.y);return[t,i,s,l]},T.aB=Xi,T.aC=Gr,T.aD=function(r,t,i,s,l=!1){if(!i[0]&&!i[1])return[0,0];const p=l?s==="map"?-r.bearingInRadians:0:s==="viewport"?r.bearingInRadians:0;if(p){const f=Math.sin(p),_=Math.cos(p);i=[i[0]*_-i[1]*f,i[0]*f+i[1]*_]}return[l?i[0]:Gr(t,i[0],r.zoom),l?i[1]:Gr(t,i[1],r.zoom)]},T.aF=Np,T.aG=Xp,T.aH=jp,T.aI=Kp,T.aJ=Si,T.aK=Nh,T.aL=Y,T.aM=bt,T.aN=ei,T.aO=tn,T.aP=mt,T.aQ=x_,T.aR=Xt,T.aS=Nt,T.aT=function(r){var t=new st(3);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t},T.aU=function(r,t,i){return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],r},T.aV=function(r,t){var i=t[0],s=t[1],l=t[2],p=i*i+s*s+l*l;return p>0&&(p=1/Math.sqrt(p)),r[0]=t[0]*p,r[1]=t[1]*p,r[2]=t[2]*p,r},T.aW=Mi,T.aX=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]},T.aY=function(r,t,i){return r[0]=t[0]*i[0],r[1]=t[1]*i[1],r[2]=t[2]*i[2],r[3]=t[3]*i[3],r},T.aZ=mi,T.a_=function(r,t,i){const s=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return s===0?null:(-(r[0]*i[0]+r[1]*i[1]+r[2]*i[2])-i[3])/s},T.aa=ks,T.ab=Ln,T.ac=S_,T.ad=function(r){const t={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,s,l,p)=>{const f=l||p;return t[s]=!f||f.toLowerCase(),""}),t["max-age"]){const i=parseInt(t["max-age"],10);isNaN(i)?delete t["max-age"]:t["max-age"]=i}return t},T.ae=lt,T.af=function(r){return Math.pow(2,r)},T.ag=yt,T.ah=Ai,T.ai=85.051129,T.aj=v_,T.ak=function(r){return Math.log(r)/Math.LN2},T.al=function(r){var t=r[0],i=r[1];return t*t+i*i},T.am=function(r,t){const i=[];for(const s in r)s in t||i.push(s);return i},T.an=function(r,t){let i=0,s=0;if(r.kind==="constant")s=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:l,minZoom:p,maxZoom:f}=r,_=l?Ai(rr.interpolationFactor(l,t,p,f),0,1):0;r.kind==="camera"?s=Sn.number(r.minSize,r.maxSize,_):i=_}return{uSizeT:i,uSize:s}},T.ap=function(r,{uSize:t,uSizeT:i},{lowerSize:s,upperSize:l}){return r.kind==="source"?s/js:r.kind==="composite"?Sn.number(s/js,l/js,i):t},T.aq=function(r,t){var i=t[0],s=t[1],l=t[2],p=t[3],f=t[4],_=t[5],y=t[6],w=t[7],S=t[8],I=t[9],z=t[10],L=t[11],F=t[12],N=t[13],$=t[14],H=t[15],he=i*_-s*f,ee=i*y-l*f,re=i*w-p*f,ve=s*y-l*_,we=s*w-p*_,Ee=l*w-p*y,Ue=S*N-I*F,Be=S*$-z*F,Ne=S*H-L*F,nt=I*$-z*N,je=I*H-L*N,Ve=z*H-L*$,Me=he*Ve-ee*je+re*nt+ve*Ne-we*Be+Ee*Ue;return Me?(r[0]=(_*Ve-y*je+w*nt)*(Me=1/Me),r[1]=(l*je-s*Ve-p*nt)*Me,r[2]=(N*Ee-$*we+H*ve)*Me,r[3]=(z*we-I*Ee-L*ve)*Me,r[4]=(y*Ne-f*Ve-w*Be)*Me,r[5]=(i*Ve-l*Ne+p*Be)*Me,r[6]=($*re-F*Ee-H*ee)*Me,r[7]=(S*Ee-z*re+L*ee)*Me,r[8]=(f*je-_*Ne+w*Ue)*Me,r[9]=(s*Ne-i*je-p*Ue)*Me,r[10]=(F*we-N*re+H*he)*Me,r[11]=(I*re-S*we-L*he)*Me,r[12]=(_*Be-f*nt-y*Ue)*Me,r[13]=(i*nt-s*Be+l*Ue)*Me,r[14]=(N*ee-F*ve-$*he)*Me,r[15]=(S*ve-I*ee+z*he)*Me,r):null},T.ar=St,T.as=function(r){var t=r[0],i=r[1];return Math.sqrt(t*t+i*i)},T.at=function(r){return r[0]=0,r[1]=0,r},T.au=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r},T.av=Vp,T.aw=en,T.ax=function(r,t,i,s){const l=t.y-r.y,p=t.x-r.x,f=s.y-i.y,_=s.x-i.x,y=f*p-_*l;if(y===0)return null;const w=(_*(r.y-i.y)-f*(r.x-i.x))/y;return new V(r.x+w*p,r.y+w*l)},T.ay=C_,T.az=gg,T.b=qe,T.b$=class extends h{},T.b0=function(r,t,i){return r[0]=t[0]*i,r[1]=t[1]*i,r[2]=t[2]*i,r[3]=t[3]*i,r},T.b1=function(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3]},T.b2=w_,T.b3=Sl,T.b4=function(r,t,i,s,l){var p=1/Math.tan(t/2);if(r[0]=p/i,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=p,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,l!=null&&l!==1/0){var f=1/(s-l);r[10]=(l+s)*f,r[14]=2*l*s*f}else r[10]=-1,r[14]=-2*s;return r},T.b5=function(r){var t=new st(16);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],t},T.b6=function(r,t,i){var s=Math.sin(i),l=Math.cos(i),p=t[0],f=t[1],_=t[2],y=t[3],w=t[4],S=t[5],I=t[6],z=t[7];return t!==r&&(r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=p*l+w*s,r[1]=f*l+S*s,r[2]=_*l+I*s,r[3]=y*l+z*s,r[4]=w*l-p*s,r[5]=S*l-f*s,r[6]=I*l-_*s,r[7]=z*l-y*s,r},T.b7=function(r,t,i){var s=Math.sin(i),l=Math.cos(i),p=t[4],f=t[5],_=t[6],y=t[7],w=t[8],S=t[9],I=t[10],z=t[11];return t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[4]=p*l+w*s,r[5]=f*l+S*s,r[6]=_*l+I*s,r[7]=y*l+z*s,r[8]=w*l-p*s,r[9]=S*l-f*s,r[10]=I*l-_*s,r[11]=z*l-y*s,r},T.b8=function(){const r=new Float32Array(16);return yt(r),r},T.b9=function(){const r=new Float64Array(16);return yt(r),r},T.bA=function(r,t){const i=di(r,360),s=di(t,360),l=s-i,p=s>i?l-360:l+360;return Math.abs(l)<Math.abs(p)?l:p},T.bB=function(r){return r[0]=0,r[1]=0,r[2]=0,r},T.bC=function(r,t,i,s){const l=Math.sqrt(r*r+t*t),p=Math.sqrt(i*i+s*s);r/=l,t/=l,i/=p,s/=p;const f=Math.acos(r*i+t*s);return-t*i+r*s>0?f:-f},T.bD=function(r,t){const i=di(r,2*Math.PI),s=di(t,2*Math.PI);return Math.min(Math.abs(i-s),Math.abs(i-s+2*Math.PI),Math.abs(i-s-2*Math.PI))},T.bE=function(){const r={},t=fe.$version;for(const i in fe.$root){const s=fe.$root[i];if(s.required){let l=null;l=i==="version"?t:s.type==="array"?[]:{},l!=null&&(r[i]=l)}}return r},T.bF=sl,T.bG=ie,T.bH=function r(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let s=0;s<t.length;s++)if(!r(t[s],i[s]))return!1;return!0}if(typeof t=="object"&&t!==null&&i!==null){if(typeof i!="object"||Object.keys(t).length!==Object.keys(i).length)return!1;for(const s in t)if(!r(t[s],i[s]))return!1;return!0}return t===i},T.bI=function(r){r=r.slice();const t=Object.create(null);for(let i=0;i<r.length;i++)t[r[i].id]=r[i];for(let i=0;i<r.length;i++)"ref"in r[i]&&(r[i]=At(r[i],t[r[i].ref]));return r},T.bJ=function(r){if(r.type==="custom")return new k1(r);switch(r.type){case"background":return new I1(r);case"circle":return new pb(r);case"color-relief":return new vb(r);case"fill":return new Db(r);case"fill-extrusion":return new Zb(r);case"heatmap":return new mb(r);case"hillshade":return new _b(r);case"line":return new Jb(r);case"raster":return new A1(r);case"symbol":return new Zh(r)}},T.bK=ne,T.bL=function(r,t){if(!r)return[{command:"setStyle",args:[t]}];let i=[];try{if(!ot(r.version,t.version))return[{command:"setStyle",args:[t]}];ot(r.center,t.center)||i.push({command:"setCenter",args:[t.center]}),ot(r.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),ot(r.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),ot(r.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),ot(r.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),ot(r.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),ot(r.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),ot(r.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),ot(r.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),ot(r.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),ot(r.light,t.light)||i.push({command:"setLight",args:[t.light]}),ot(r.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),ot(r.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),ot(r.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const s={},l=[];(function(f,_,y,w){let S;for(S in _=_||{},f=f||{})Object.prototype.hasOwnProperty.call(f,S)&&(Object.prototype.hasOwnProperty.call(_,S)||ji(S,y,w));for(S in _)Object.prototype.hasOwnProperty.call(_,S)&&(Object.prototype.hasOwnProperty.call(f,S)?ot(f[S],_[S])||(f[S].type==="geojson"&&_[S].type==="geojson"&&Ii(f,_,S)?xt(y,{command:"setGeoJSONSourceData",args:[S,_[S].data]}):Ni(S,_,y,w)):oi(S,_,y))})(r.sources,t.sources,l,s);const p=[];r.layers&&r.layers.forEach(f=>{"source"in f&&s[f.source]?i.push({command:"removeLayer",args:[f.id]}):p.push(f)}),i=i.concat(l),function(f,_,y){_=_||[];const w=(f=f||[]).map(Ut),S=_.map(Ut),I=f.reduce(ki,{}),z=_.reduce(ki,{}),L=w.slice(),F=Object.create(null);let N,$,H,he,ee;for(let re=0,ve=0;re<w.length;re++)N=w[re],Object.prototype.hasOwnProperty.call(z,N)?ve++:(xt(y,{command:"removeLayer",args:[N]}),L.splice(L.indexOf(N,ve),1));for(let re=0,ve=0;re<S.length;re++)N=S[S.length-1-re],L[L.length-1-re]!==N&&(Object.prototype.hasOwnProperty.call(I,N)?(xt(y,{command:"removeLayer",args:[N]}),L.splice(L.lastIndexOf(N,L.length-ve),1)):ve++,he=L[L.length-re],xt(y,{command:"addLayer",args:[z[N],he]}),L.splice(L.length-re,0,N),F[N]=!0);for(let re=0;re<S.length;re++)if(N=S[re],$=I[N],H=z[N],!F[N]&&!ot($,H))if(ot($.source,H.source)&&ot($["source-layer"],H["source-layer"])&&ot($.type,H.type)){for(ee in Dt($.layout,H.layout,y,N,null,"setLayoutProperty"),Dt($.paint,H.paint,y,N,null,"setPaintProperty"),ot($.filter,H.filter)||xt(y,{command:"setFilter",args:[N,H.filter]}),ot($.minzoom,H.minzoom)&&ot($.maxzoom,H.maxzoom)||xt(y,{command:"setLayerZoomRange",args:[N,H.minzoom,H.maxzoom]}),$)Object.prototype.hasOwnProperty.call($,ee)&&ee!=="layout"&&ee!=="paint"&&ee!=="filter"&&ee!=="metadata"&&ee!=="minzoom"&&ee!=="maxzoom"&&(ee.indexOf("paint.")===0?Dt($[ee],H[ee],y,N,ee.slice(6),"setPaintProperty"):ot($[ee],H[ee])||xt(y,{command:"setLayerProperty",args:[N,ee,H[ee]]}));for(ee in H)Object.prototype.hasOwnProperty.call(H,ee)&&!Object.prototype.hasOwnProperty.call($,ee)&&ee!=="layout"&&ee!=="paint"&&ee!=="filter"&&ee!=="metadata"&&ee!=="minzoom"&&ee!=="maxzoom"&&(ee.indexOf("paint.")===0?Dt($[ee],H[ee],y,N,ee.slice(6),"setPaintProperty"):ot($[ee],H[ee])||xt(y,{command:"setLayerProperty",args:[N,ee,H[ee]]}))}else xt(y,{command:"removeLayer",args:[N]}),he=L[L.lastIndexOf(N)+1],xt(y,{command:"addLayer",args:[H,he]})}(p,t.layers,i)}catch(s){console.warn("Unable to compute style diff:",s),i=[{command:"setStyle",args:[t]}]}return i},T.bM=function(r){const t=[],i=r.id;return i===void 0&&t.push({message:`layers.${i}: missing required property "id"`}),r.render===void 0&&t.push({message:`layers.${i}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},T.bN=Zr,T.bO=ys,T.bP=class extends xr{constructor(r,t){super(r,t),this.current=0}set(r){this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r))}},T.bQ=Ui,T.bR=class extends xr{constructor(r,t){super(r,t),this.current=Xr}set(r){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}},T.bS=Di,T.bT=class extends xr{constructor(r,t){super(r,t),this.current=[0,0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2]))}},T.bU=class extends xr{constructor(r,t){super(r,t),this.current=[0,0]}set(r){r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1]))}},T.bV=We,T.bW=function(r,t){var i=Math.sin(t),s=Math.cos(t);return r[0]=s,r[1]=i,r[2]=0,r[3]=-i,r[4]=s,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},T.bX=function(r,t,i){var s=t[0],l=t[1],p=t[2];return r[0]=s*i[0]+l*i[3]+p*i[6],r[1]=s*i[1]+l*i[4]+p*i[7],r[2]=s*i[2]+l*i[5]+p*i[8],r},T.bY=function(r,t,i,s,l,p,f){var _=1/(t-i),y=1/(s-l),w=1/(p-f);return r[0]=-2*_,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*y,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*w,r[11]=0,r[12]=(t+i)*_,r[13]=(l+s)*y,r[14]=(f+p)*w,r[15]=1,r},T.bZ=class extends xr{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(4*r.length);for(let i=0;i<r.length;i++)t[4*i]=r[i].r,t[4*i+1]=r[i].g,t[4*i+2]=r[i].b,t[4*i+3]=r[i].a;this.gl.uniform4fv(this.location,t)}}},T.b_=class extends xr{constructor(r,t){super(r,t),this.current=new Array}set(r){if(r!=this.current){this.current=r;const t=new Float32Array(r);this.gl.uniform1fv(this.location,t)}}},T.ba=function(){return new Float64Array(16)},T.bb=function(r,t,i){const s=new Float64Array(4);return Jt(s,r,t-90,i),s},T.bc=function(r,t,i,s){var l,p,f,_,y,w=t[0],S=t[1],I=t[2],z=t[3],L=i[0],F=i[1],N=i[2],$=i[3];return(p=w*L+S*F+I*N+z*$)<0&&(p=-p,L=-L,F=-F,N=-N,$=-$),1-p>ct?(l=Math.acos(p),f=Math.sin(l),_=Math.sin((1-s)*l)/f,y=Math.sin(s*l)/f):(_=1-s,y=s),r[0]=_*w+y*L,r[1]=_*S+y*F,r[2]=_*I+y*N,r[3]=_*z+y*$,r},T.bd=function(r){const t=new Float64Array(9);var i,s,l,p,f,_,y,w,S,I,z,L,F,N,$,H,he,ee;I=(l=(s=r)[0])*(y=l+l),z=(p=s[1])*y,F=(f=s[2])*y,N=f*(w=p+p),H=(_=s[3])*y,he=_*w,ee=_*(S=f+f),(i=t)[0]=1-(L=p*w)-($=f*S),i[3]=z-ee,i[6]=F+he,i[1]=z+ee,i[4]=1-I-$,i[7]=N-H,i[2]=F-he,i[5]=N+H,i[8]=1-I-L;const re=mt(-Math.asin(Ai(t[2],-1,1)));let ve,we;return Math.hypot(t[5],t[8])<.001?(ve=0,we=-mt(Math.atan2(t[3],t[4]))):(ve=mt(t[5]===0&&t[8]===0?0:Math.atan2(t[5],t[8])),we=mt(t[1]===0&&t[0]===0?0:Math.atan2(t[1],t[0]))),{roll:ve,pitch:re+90,bearing:we}},T.be=function(r,t){return r.roll==t.roll&&r.pitch==t.pitch&&r.bearing==t.bearing},T.bf=Rt,T.bg=ss,T.bh=vl,T.bi=Kc,T.bj=yl,T.bk=Zi,T.bl=Lr,T.bm=ur,T.bn=function(r,t,i,s,l){return Zi(s,l,Ai((r-t)/(i-t),0,1))},T.bo=di,T.bp=function(){return new Float64Array(3)},T.bq=function(r,t,i,s){return r[0]=t[0]+i[0]*s,r[1]=t[1]+i[1]*s,r[2]=t[2]+i[2]*s,r},T.br=Jt,T.bs=function(r,t,i){var s=i[0],l=i[1],p=i[2],f=i[3],_=t[0],y=t[1],w=t[2],S=l*w-p*y,I=p*_-s*w,z=s*y-l*_;return r[0]=_+f*(S+=S)+l*(z+=z)-p*(I+=I),r[1]=y+f*I+p*S-s*z,r[2]=w+f*z+s*I-l*S,r},T.bt=function(r,t,i){const s=(l=[r[0],r[1],r[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((S=l[8])*(f=l[4])-(_=l[5])*(w=l[7]))+l[1]*(-S*(p=l[3])+_*(y=l[6]))+l[2]*(w*p-f*y);var l,p,f,_,y,w,S;if(s===0)return null;const I=Mi([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),z=Mi([],[i[0],i[1],i[2]],[r[0],r[1],r[2]]),L=Mi([],[r[0],r[1],r[2]],[t[0],t[1],t[2]]),F=Xt([],I,-r[3]);return Nt(F,F,Xt([],z,-t[3])),Nt(F,F,Xt([],L,-i[3])),Xt(F,F,1/s),F},T.bu=Zp,T.bv=function(){return new Float64Array(4)},T.bw=function(r,t,i,s){var l=[],p=[];return l[0]=t[0]-i[0],l[1]=t[1]-i[1],l[2]=t[2]-i[2],p[0]=l[0]*Math.cos(s)-l[1]*Math.sin(s),p[1]=l[0]*Math.sin(s)+l[1]*Math.cos(s),p[2]=l[2],r[0]=p[0]+i[0],r[1]=p[1]+i[1],r[2]=p[2]+i[2],r},T.bx=function(r,t,i,s){var l=[],p=[];return l[0]=t[0]-i[0],l[1]=t[1]-i[1],l[2]=t[2]-i[2],p[0]=l[0],p[1]=l[1]*Math.cos(s)-l[2]*Math.sin(s),p[2]=l[1]*Math.sin(s)+l[2]*Math.cos(s),r[0]=p[0]+i[0],r[1]=p[1]+i[1],r[2]=p[2]+i[2],r},T.by=function(r,t,i,s){var l=[],p=[];return l[0]=t[0]-i[0],l[1]=t[1]-i[1],l[2]=t[2]-i[2],p[0]=l[2]*Math.sin(s)+l[0]*Math.cos(s),p[1]=l[1],p[2]=l[2]*Math.cos(s)-l[0]*Math.sin(s),r[0]=p[0]+i[0],r[1]=p[1]+i[1],r[2]=p[2]+i[2],r},T.bz=function(r,t,i){var s=Math.sin(i),l=Math.cos(i),p=t[0],f=t[1],_=t[2],y=t[3],w=t[8],S=t[9],I=t[10],z=t[11];return t!==r&&(r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=p*l-w*s,r[1]=f*l-S*s,r[2]=_*l-I*s,r[3]=y*l-z*s,r[8]=p*s+w*l,r[9]=f*s+S*l,r[10]=_*s+I*l,r[11]=y*s+z*l,r},T.c=ae,T.c0=i1,T.c1=class extends n{},T.c2=Pp,T.c3=function(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))},T.c4=Mg,T.c5=function(r,t,i){var s=t[0],l=t[1],p=t[2],f=i[3]*s+i[7]*l+i[11]*p+i[15];return r[0]=(i[0]*s+i[4]*l+i[8]*p+i[12])/(f=f||1),r[1]=(i[1]*s+i[5]*l+i[9]*p+i[13])/f,r[2]=(i[2]*s+i[6]*l+i[10]*p+i[14])/f,r},T.c6=class extends jc{},T.c7=class extends P{},T.c8=function(r,t){return r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]&&r[3]===t[3]&&r[4]===t[4]&&r[5]===t[5]&&r[6]===t[6]&&r[7]===t[7]&&r[8]===t[8]&&r[9]===t[9]&&r[10]===t[10]&&r[11]===t[11]&&r[12]===t[12]&&r[13]===t[13]&&r[14]===t[14]&&r[15]===t[15]},T.c9=function(r,t){var i=r[0],s=r[1],l=r[2],p=r[3],f=r[4],_=r[5],y=r[6],w=r[7],S=r[8],I=r[9],z=r[10],L=r[11],F=r[12],N=r[13],$=r[14],H=r[15],he=t[0],ee=t[1],re=t[2],ve=t[3],we=t[4],Ee=t[5],Ue=t[6],Be=t[7],Ne=t[8],nt=t[9],je=t[10],Ve=t[11],Me=t[12],ft=t[13],gt=t[14],at=t[15];return Math.abs(i-he)<=ct*Math.max(1,Math.abs(i),Math.abs(he))&&Math.abs(s-ee)<=ct*Math.max(1,Math.abs(s),Math.abs(ee))&&Math.abs(l-re)<=ct*Math.max(1,Math.abs(l),Math.abs(re))&&Math.abs(p-ve)<=ct*Math.max(1,Math.abs(p),Math.abs(ve))&&Math.abs(f-we)<=ct*Math.max(1,Math.abs(f),Math.abs(we))&&Math.abs(_-Ee)<=ct*Math.max(1,Math.abs(_),Math.abs(Ee))&&Math.abs(y-Ue)<=ct*Math.max(1,Math.abs(y),Math.abs(Ue))&&Math.abs(w-Be)<=ct*Math.max(1,Math.abs(w),Math.abs(Be))&&Math.abs(S-Ne)<=ct*Math.max(1,Math.abs(S),Math.abs(Ne))&&Math.abs(I-nt)<=ct*Math.max(1,Math.abs(I),Math.abs(nt))&&Math.abs(z-je)<=ct*Math.max(1,Math.abs(z),Math.abs(je))&&Math.abs(L-Ve)<=ct*Math.max(1,Math.abs(L),Math.abs(Ve))&&Math.abs(F-Me)<=ct*Math.max(1,Math.abs(F),Math.abs(Me))&&Math.abs(N-ft)<=ct*Math.max(1,Math.abs(N),Math.abs(ft))&&Math.abs($-gt)<=ct*Math.max(1,Math.abs($),Math.abs(gt))&&Math.abs(H-at)<=ct*Math.max(1,Math.abs(H),Math.abs(at))},T.cA=function(r,t){B.REGISTERED_PROTOCOLS[r]=t},T.cB=function(r){delete B.REGISTERED_PROTOCOLS[r]},T.cC=function(r,t){const i={};for(let l=0;l<r.length;l++){const p=t&&t[r[l].id]||pp(r[l]);t&&(t[r[l].id]=p);let f=i[p];f||(f=i[p]=[]),f.push(r[l])}const s=[];for(const l in i)s.push(i[l]);return s},T.cD=Xe,T.cE=T_,T.cF=P_,T.cG=t_,T.cH=function(r){r.bucket.createArrays(),r.bucket.tilePixelRatio=Vt/(512*r.bucket.overscaling),r.bucket.compareText={},r.bucket.iconsNeedLinear=!1;const t=r.bucket.layers[0],i=t.layout,s=t._unevaluatedLayout._values,l={layoutIconSize:s["icon-size"].possiblyEvaluate(new si(r.bucket.zoom+1),r.canonical),layoutTextSize:s["text-size"].possiblyEvaluate(new si(r.bucket.zoom+1),r.canonical),textMaxSize:s["text-size"].possiblyEvaluate(new si(18))};if(r.bucket.textSizeData.kind==="composite"){const{minZoom:w,maxZoom:S}=r.bucket.textSizeData;l.compositeTextSizes=[s["text-size"].possiblyEvaluate(new si(w),r.canonical),s["text-size"].possiblyEvaluate(new si(S),r.canonical)]}if(r.bucket.iconSizeData.kind==="composite"){const{minZoom:w,maxZoom:S}=r.bucket.iconSizeData;l.compositeIconSizes=[s["icon-size"].possiblyEvaluate(new si(w),r.canonical),s["icon-size"].possiblyEvaluate(new si(S),r.canonical)]}const p=i.get("text-line-height")*Xi,f=i.get("text-rotation-alignment")!=="viewport"&&i.get("symbol-placement")!=="point",_=i.get("text-keep-upright"),y=i.get("text-size");for(const w of r.bucket.features){const S=i.get("text-font").evaluate(w,{},r.canonical).join(","),I=y.evaluate(w,{},r.canonical),z=l.layoutTextSize.evaluate(w,{},r.canonical),L=l.layoutIconSize.evaluate(w,{},r.canonical),F={horizontal:{},vertical:void 0},N=w.text;let $,H=[0,0];if(N){const re=N.toString(),ve=i.get("text-letter-spacing").evaluate(w,{},r.canonical)*Xi,we=_p(re)?ve:0,Ee=i.get("text-anchor").evaluate(w,{},r.canonical),Ue=F_(t,w,r.canonical);if(!Ue){const je=i.get("text-radial-offset").evaluate(w,{},r.canonical);H=je?L_(Ee,[je*Xi,Wp]):i.get("text-offset").evaluate(w,{},r.canonical).map(Ve=>Ve*Xi)}let Be=f?"center":i.get("text-justify").evaluate(w,{},r.canonical);const Ne=i.get("symbol-placement")==="point"?i.get("text-max-width").evaluate(w,{},r.canonical)*Xi:1/0,nt=()=>{r.bucket.allowVerticalPlacement&&ol(re)&&(F.vertical=Uh(N,r.glyphMap,r.glyphPositions,r.imagePositions,S,Ne,p,Ee,"left",we,H,T.ao.vertical,!0,z,I))};if(!f&&Ue){const je=new Set;if(Be==="auto")for(let Me=0;Me<Ue.values.length;Me+=2)je.add(Xp(Ue.values[Me]));else je.add(Be);let Ve=!1;for(const Me of je)if(!F.horizontal[Me])if(Ve)F.horizontal[Me]=F.horizontal[0];else{const ft=Uh(N,r.glyphMap,r.glyphPositions,r.imagePositions,S,Ne,p,"center",Me,we,H,T.ao.horizontal,!1,z,I);ft&&(F.horizontal[Me]=ft,Ve=ft.positionedLines.length===1)}nt()}else{Be==="auto"&&(Be=Xp(Ee));const je=Uh(N,r.glyphMap,r.glyphPositions,r.imagePositions,S,Ne,p,Ee,Be,we,H,T.ao.horizontal,!1,z,I);je&&(F.horizontal[Be]=je),nt(),ol(re)&&f&&_&&(F.vertical=Uh(N,r.glyphMap,r.glyphPositions,r.imagePositions,S,Ne,p,Ee,Be,we,H,T.ao.vertical,!1,z,I))}}let he=!1;if(w.icon&&w.icon.name){const re=r.imageMap[w.icon.name];re&&($=S1(r.imagePositions[w.icon.name],i.get("icon-offset").evaluate(w,{},r.canonical),i.get("icon-anchor").evaluate(w,{},r.canonical)),he=!!re.sdf,r.bucket.sdfIcons===void 0?r.bucket.sdfIcons=he:r.bucket.sdfIcons!==he&&Te("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(re.pixelRatio!==r.bucket.pixelRatio||i.get("icon-rotate").constantOr(1)!==0)&&(r.bucket.iconsNeedLinear=!0))}const ee=O_(F.horizontal)||F.vertical;r.bucket.iconsInText=!!ee&&ee.iconsInText,(ee||$)&&N1(r.bucket,w,F,$,r.imageMap,l,z,L,H,he,r.canonical,r.subdivisionGranularity)}r.showCollisionBoxes&&r.bucket.generateCollisionDebugBuffers()},T.cI=Dp,T.cJ=kp,T.cK=Rp,T.cL=Vg,T.cM=Fp,T.cN=class{constructor(r){this._marks={start:[r.url,"start"].join("#"),end:[r.url,"end"].join("#"),measure:r.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let r=performance.getEntriesByName(this._marks.measure);return r.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),r=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),r}},T.cO=function(r,t,i,s,l){return a(this,void 0,void 0,function*(){if(Ye())try{return yield Ge(r,t,i,s,l)}catch{}return function(p,f,_,y,w){const S=p.width,I=p.height;De&&ut||(De=new OffscreenCanvas(S,I),ut=De.getContext("2d",{willReadFrequently:!0})),De.width=S,De.height=I,ut.drawImage(p,0,0,S,I);const z=ut.getImageData(f,_,y,w);return ut.clearRect(0,0,S,I),z.data}(r,t,i,s,l)})},T.cP=Eg,T.cQ=ue,T.cR=Ng,T.cS=xl,T.cT=Ko,T.cU=function(r,t){const i=new Map;if(r!=null)if(r.type==="Feature")i.set(ru(r,t),r);else for(const s of r.features)i.set(ru(s,t),s);return i},T.cV=function(r,t){if(r==null)return!0;if(r.type==="Feature")return ru(r,t)!=null;if(r.type==="FeatureCollection"){const i=new Set;for(const s of r.features){const l=ru(s,t);if(l==null||i.has(l))return!1;i.add(l)}return!0}return!1},T.cW=function(r,t,i){var s,l,p,f;if(t.removeAll&&r.clear(),t.remove)for(const _ of t.remove)r.delete(_);if(t.add)for(const _ of t.add){const y=ru(_,i);y!=null&&r.set(y,_)}if(t.update)for(const _ of t.update){let y=r.get(_.id);if(y==null)continue;const w=!_.removeAllProperties&&(((s=_.removeProperties)===null||s===void 0?void 0:s.length)>0||((l=_.addOrUpdateProperties)===null||l===void 0?void 0:l.length)>0);if((_.newGeometry||_.removeAllProperties||w)&&(y=Object.assign({},y),r.set(_.id,y),w&&(y.properties=Object.assign({},y.properties))),_.newGeometry&&(y.geometry=_.newGeometry),_.removeAllProperties)y.properties={};else if(((p=_.removeProperties)===null||p===void 0?void 0:p.length)>0)for(const S of _.removeProperties)Object.prototype.hasOwnProperty.call(y.properties,S)&&delete y.properties[S];if(((f=_.addOrUpdateProperties)===null||f===void 0?void 0:f.length)>0)for(const{key:S,value:I}of _.addOrUpdateProperties)y.properties[S]=I}},T.cX=un,T.ca=function(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r},T.cb=r=>r.type==="symbol",T.cc=r=>r.type==="circle",T.cd=r=>r.type==="heatmap",T.ce=r=>r.type==="line",T.cf=r=>r.type==="fill",T.cg=r=>r.type==="fill-extrusion",T.ch=r=>r.type==="hillshade",T.ci=r=>r.type==="color-relief",T.cj=r=>r.type==="raster",T.ck=r=>r.type==="background",T.cl=r=>r.type==="custom",T.cm=xn,T.cn=function(r,t,i){const s=Kt(t.x-i.x,t.y-i.y),l=Kt(r.x-i.x,r.y-i.y);var p,f;return mt(Math.atan2(s[0]*l[1]-s[1]*l[0],(p=s)[0]*(f=l)[0]+p[1]*f[1]))},T.co=En,T.cp=function(r,t){return Zt[t]&&(r instanceof MouseEvent||r instanceof WheelEvent)},T.cq=function(r,t){return Ct[t]&&"touches"in r},T.cr=function(r){return Ct[r]||Zt[r]},T.cs=function(r,t,i){var s=t[0],l=t[1];return r[0]=i[0]*s+i[4]*l+i[12],r[1]=i[1]*s+i[5]*l+i[13],r},T.ct=function(r,t){const{x:i,y:s}=iu.fromLngLat(t);return!(r<0||r>25||s<0||s>=1||i<0||i>=1)},T.cu=function(r,t){return r[0]=t[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=t[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=t[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},T.cv=class extends mo{},T.cw=U1,T.cy=function(r){return r.message===Gt},T.cz=X,T.d=me,T.e=lr,T.f=r=>a(void 0,void 0,void 0,function*(){if(r.byteLength===0)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(r)],{type:"image/png"});try{return createImageBitmap(t)}catch(i){throw new Error(`Could not load image because of ${i.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),T.g=j,T.h=r=>new Promise((t,i)=>{const s=new Image;s.onload=()=>{t(s),URL.revokeObjectURL(s.src),s.onload=null,window.requestAnimationFrame(()=>{s.src=$e})},s.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const l=new Blob([new Uint8Array(r)],{type:"image/png"});s.src=r.byteLength?URL.createObjectURL(l):$e}),T.i=Ae,T.j=(r,t)=>ce(lr(r,{type:"json"}),t),T.k=Ce,T.l=ke,T.m=ce,T.n=(r,t)=>ce(lr(r,{type:"arrayBuffer"}),t),T.o=function(r){return new Fp(r).readFields(p1,[])},T.p=e_,T.q=Zc,T.r=yr,T.s=Ke,T.t=kh,T.u=Bt,T.v=fe,T.w=Te,T.x=fp,T.y=ra,T.z=uo}),E("worker",["./shared"],function(T){class a{constructor(B){this.keyCache={},B&&this.replace(B)}replace(B){this._layerConfigs={},this._layers={},this.update(B,[])}update(B,j){for(const X of B){this._layerConfigs[X.id]=X;const ie=this._layers[X.id]=T.bJ(X);ie._featureFilter=T.aa(ie.filter),this.keyCache[X.id]&&delete this.keyCache[X.id]}for(const X of j)delete this.keyCache[X],delete this._layerConfigs[X],delete this._layers[X];this.familiesBySource={};const U=T.cC(Object.values(this._layerConfigs),this.keyCache);for(const X of U){const ie=X.map(Ce=>this._layers[Ce.id]),ce=ie[0];if(ce.visibility==="none")continue;const me=ce.source||"";let de=this.familiesBySource[me];de||(de=this.familiesBySource[me]={});const Pe=ce.sourceLayer||"_geojsonTileLayer";let ke=de[Pe];ke||(ke=de[Pe]=[]),ke.push(ie)}}}class V{constructor(B){const j={},U=[];for(const me in B){const de=B[me],Pe=j[me]={};for(const ke in de){const Ce=de[+ke];if(!Ce||Ce.bitmap.width===0||Ce.bitmap.height===0)continue;const it={x:0,y:0,w:Ce.bitmap.width+2,h:Ce.bitmap.height+2};U.push(it),Pe[ke]={rect:it,metrics:Ce.metrics}}}const{w:X,h:ie}=T.p(U),ce=new T.q({width:X||1,height:ie||1});for(const me in B){const de=B[me];for(const Pe in de){const ke=de[+Pe];if(!ke||ke.bitmap.width===0||ke.bitmap.height===0)continue;const Ce=j[me][Pe].rect;T.q.copy(ke.bitmap,ce,{x:0,y:0},{x:Ce.x+1,y:Ce.y+1},ke.bitmap)}}this.image=ce,this.positions=j}}T.cD("GlyphAtlas",V);class ue{constructor(B){this.tileID=new T.Z(B.tileID.overscaledZ,B.tileID.wrap,B.tileID.canonical.z,B.tileID.canonical.x,B.tileID.canonical.y),this.uid=B.uid,this.zoom=B.zoom,this.pixelRatio=B.pixelRatio,this.tileSize=B.tileSize,this.source=B.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=B.showCollisionBoxes,this.collectResourceTiming=!!B.collectResourceTiming,this.returnDependencies=!!B.returnDependencies,this.promoteId=B.promoteId,this.inFlightDependencies=[],this.globalState=B.globalState}parse(B,j,U,X,ie){return T._(this,void 0,void 0,function*(){this.status="parsing",this.data=B,this.collisionBoxArray=new T.a8;const ce=new T.cE(Object.keys(B.layers).sort()),me=new T.cF(this.tileID,this.promoteId);me.bucketLayerIDs=[];const de={},Pe={featureIndex:me,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:U,subdivisionGranularity:ie},ke=j.familiesBySource[this.source];for(const Dt in ke){const Ut=B.layers[Dt];if(!Ut)continue;Ut.version===1&&T.w(`Vector tile source "${this.source}" layer "${Dt}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const ki=ce.encode(Dt),Fe=[];for(let cr=0;cr<Ut.length;cr++){const gi=Ut.feature(cr),Wn=me.getId(gi,Dt);Fe.push({feature:gi,id:Wn,index:cr,sourceLayerIndex:ki})}for(const cr of ke[Dt]){const gi=cr[0];gi.source!==this.source&&T.w(`layer.source = ${gi.source} does not equal this.source = ${this.source}`),gi.minzoom&&this.zoom<Math.floor(gi.minzoom)||gi.maxzoom&&this.zoom>=gi.maxzoom||gi.visibility!=="none"&&(oe(cr,this.zoom,U,this.globalState),(de[gi.id]=gi.createBucket({index:me.bucketLayerIDs.length,layers:cr,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:ki,sourceID:this.source,globalState:this.globalState})).populate(Fe,Pe,this.tileID.canonical),me.bucketLayerIDs.push(cr.map(Wn=>Wn.id)))}}const Ce=T.bN(Pe.glyphDependencies,Dt=>Object.keys(Dt).map(Number));this.inFlightDependencies.forEach(Dt=>Dt==null?void 0:Dt.abort()),this.inFlightDependencies=[];let it=Promise.resolve({});if(Object.keys(Ce).length){const Dt=new AbortController;this.inFlightDependencies.push(Dt),it=X.sendAsync({type:"GG",data:{stacks:Ce,source:this.source,tileID:this.tileID,type:"glyphs"}},Dt)}const fe=Object.keys(Pe.iconDependencies);let _t=Promise.resolve({});if(fe.length){const Dt=new AbortController;this.inFlightDependencies.push(Dt),_t=X.sendAsync({type:"GI",data:{icons:fe,source:this.source,tileID:this.tileID,type:"icons"}},Dt)}const At=Object.keys(Pe.patternDependencies);let ot=Promise.resolve({});if(At.length){const Dt=new AbortController;this.inFlightDependencies.push(Dt),ot=X.sendAsync({type:"GI",data:{icons:At,source:this.source,tileID:this.tileID,type:"patterns"}},Dt)}const[xt,oi,ji]=yield Promise.all([it,_t,ot]),Ni=new V(xt),Ii=new T.cG(oi,ji);for(const Dt in de){const Ut=de[Dt];Ut instanceof T.a9?(oe(Ut.layers,this.zoom,U,this.globalState),T.cH({bucket:Ut,glyphMap:xt,glyphPositions:Ni.positions,imageMap:oi,imagePositions:Ii.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:Pe.subdivisionGranularity})):Ut.hasPattern&&(Ut instanceof T.cI||Ut instanceof T.cJ||Ut instanceof T.cK)&&(oe(Ut.layers,this.zoom,U,this.globalState),Ut.addFeatures(Pe,this.tileID.canonical,Ii.patternPositions))}return this.status="done",{buckets:Object.values(de).filter(Dt=>!Dt.isEmpty()),featureIndex:me,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ni.image,imageAtlas:Ii,glyphMap:this.returnDependencies?xt:null,iconMap:this.returnDependencies?oi:null,glyphPositions:this.returnDependencies?Ni.positions:null}})}}function oe(ae,B,j,U){const X=new T.F(B);for(const ie of ae)ie.setGlobalState(U),ie.recalculate(X,j)}class ge{constructor(B,j,U){this.actor=B,this.layerIndex=j,this.availableImages=U,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(B,j){return T._(this,void 0,void 0,function*(){const U=yield T.n(B.request,j);try{return{vectorTile:new T.cL(new T.cM(U.data)),rawData:U.data,cacheControl:U.cacheControl,expires:U.expires}}catch(X){const ie=new Uint8Array(U.data);let ce=`Unable to parse the tile at ${B.request.url}, `;throw ce+=ie[0]===31&&ie[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${X.message}`,new Error(ce)}})}loadTile(B){return T._(this,void 0,void 0,function*(){const j=B.uid,U=!!(B&&B.request&&B.request.collectResourceTiming)&&new T.cN(B.request),X=new ue(B);this.loading[j]=X;const ie=new AbortController;X.abort=ie;try{const ce=yield this.loadVectorTile(B,ie);if(delete this.loading[j],!ce)return null;const me=ce.rawData,de={};ce.expires&&(de.expires=ce.expires),ce.cacheControl&&(de.cacheControl=ce.cacheControl);const Pe={};if(U){const Ce=U.finish();Ce&&(Pe.resourceTiming=JSON.parse(JSON.stringify(Ce)))}X.vectorTile=ce.vectorTile;const ke=X.parse(ce.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity);this.loaded[j]=X,this.fetching[j]={rawTileData:me,cacheControl:de,resourceTiming:Pe};try{const Ce=yield ke;return T.e({rawTileData:me.slice(0)},Ce,de,Pe)}finally{delete this.fetching[j]}}catch(ce){throw delete this.loading[j],X.status="done",this.loaded[j]=X,ce}})}reloadTile(B){return T._(this,void 0,void 0,function*(){const j=B.uid;if(!this.loaded||!this.loaded[j])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const U=this.loaded[j];if(U.showCollisionBoxes=B.showCollisionBoxes,U.globalState=B.globalState,U.status==="parsing"){const X=yield U.parse(U.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity);let ie;if(this.fetching[j]){const{rawTileData:ce,cacheControl:me,resourceTiming:de}=this.fetching[j];delete this.fetching[j],ie=T.e({rawTileData:ce.slice(0)},X,me,de)}else ie=X;return ie}if(U.status==="done"&&U.vectorTile)return U.parse(U.vectorTile,this.layerIndex,this.availableImages,this.actor,B.subdivisionGranularity)})}abortTile(B){return T._(this,void 0,void 0,function*(){const j=this.loading,U=B.uid;j&&j[U]&&j[U].abort&&(j[U].abort.abort(),delete j[U])})}removeTile(B){return T._(this,void 0,void 0,function*(){this.loaded&&this.loaded[B.uid]&&delete this.loaded[B.uid]})}}class Se{constructor(){this.loaded={}}loadTile(B){return T._(this,void 0,void 0,function*(){const{uid:j,encoding:U,rawImageData:X,redFactor:ie,greenFactor:ce,blueFactor:me,baseShift:de}=B,Pe=X.width+2,ke=X.height+2,Ce=T.b(X)?new T.R({width:Pe,height:ke},yield T.cO(X,-1,-1,Pe,ke)):X,it=new T.cP(j,Ce,U,ie,ce,me,de);return this.loaded=this.loaded||{},this.loaded[j]=it,it})}removeTile(B){const j=this.loaded,U=B.uid;j&&j[U]&&delete j[U]}}var Q,He,Qe=function(){if(He)return Q;function ae(j,U){if(j.length!==0){B(j[0],U);for(var X=1;X<j.length;X++)B(j[X],!U)}}function B(j,U){for(var X=0,ie=0,ce=0,me=j.length,de=me-1;ce<me;de=ce++){var Pe=(j[ce][0]-j[de][0])*(j[de][1]+j[ce][1]),ke=X+Pe;ie+=Math.abs(X)>=Math.abs(Pe)?X-ke+Pe:Pe-ke+X,X=ke}X+ie>=0!=!!U&&j.reverse()}return He=1,Q=function j(U,X){var ie,ce=U&&U.type;if(ce==="FeatureCollection")for(ie=0;ie<U.features.length;ie++)j(U.features[ie],X);else if(ce==="GeometryCollection")for(ie=0;ie<U.geometries.length;ie++)j(U.geometries[ie],X);else if(ce==="Feature")j(U.geometry,X);else if(ce==="Polygon")ae(U.coordinates,X);else if(ce==="MultiPolygon")for(ie=0;ie<U.coordinates.length;ie++)ae(U.coordinates[ie],X);return U}}(),Je=T.cQ(Qe);class Ye extends T.cS{constructor(B,j){super(new T.cM,0,j,[],[]),this.feature=B,this.type=B.type,this.properties=B.tags?B.tags:{},"id"in B&&(typeof B.id=="string"?this.id=parseInt(B.id,10):typeof B.id!="number"||isNaN(B.id)||(this.id=B.id))}loadGeometry(){const B=[],j=this.feature.type===1?[this.feature.geometry]:this.feature.geometry;for(const U of j){const X=[];for(const ie of U)X.push(new T.P(ie[0],ie[1]));B.push(X)}return B}}class ct extends T.cR{constructor(B,j){super(new T.cM),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=j?j.version:1,this.extent=j?j.extent:4096,this.length=B.length,this.features=B}feature(B){return new Ye(this.features[B],this.extent)}}function st(ae,B){B.writeVarintField(15,ae.version||1),B.writeStringField(1,ae.name||""),B.writeVarintField(5,ae.extent||4096);const j={keys:[],values:[],keycache:{},valuecache:{}};for(let ie=0;ie<ae.length;ie++)j.feature=ae.feature(ie),B.writeMessage(2,We,j);const U=j.keys;for(const ie of U)B.writeStringField(3,ie);const X=j.values;for(const ie of X)B.writeMessage(4,Nt,ie)}function We(ae,B){if(!ae.feature)return;const j=ae.feature;j.id!==void 0&&B.writeVarintField(1,j.id),B.writeMessage(2,yt,ae),B.writeVarintField(3,j.type),B.writeMessage(4,Ft,j)}function yt(ae,B){var j;for(const U in(j=ae.feature)==null?void 0:j.properties){let X=ae.feature.properties[U],ie=ae.keycache[U];if(X===null)continue;ie===void 0&&(ae.keys.push(U),ie=ae.keys.length-1,ae.keycache[U]=ie),B.writeVarint(ie),typeof X!="string"&&typeof X!="boolean"&&typeof X!="number"&&(X=JSON.stringify(X));const ce=typeof X+":"+X;let me=ae.valuecache[ce];me===void 0&&(ae.values.push(X),me=ae.values.length-1,ae.valuecache[ce]=me),B.writeVarint(me)}}function Oi(ae,B){return(B<<3)+(7&ae)}function mi(ae){return ae<<1^ae>>31}function Ft(ae,B){const j=ae.loadGeometry(),U=ae.type;let X=0,ie=0;for(const ce of j){let me=1;U===1&&(me=ce.length),B.writeVarint(Oi(1,me));const de=U===3?ce.length-1:ce.length;for(let Pe=0;Pe<de;Pe++){Pe===1&&U!==1&&B.writeVarint(Oi(2,de-1));const ke=ce[Pe].x-X,Ce=ce[Pe].y-ie;B.writeVarint(mi(ke)),B.writeVarint(mi(Ce)),X+=ke,ie+=Ce}ae.type===3&&B.writeVarint(Oi(7,1))}}function Nt(ae,B){const j=typeof ae;j==="string"?B.writeStringField(1,ae):j==="boolean"?B.writeBooleanField(7,ae):j==="number"&&(ae%1!=0?B.writeDoubleField(3,ae):ae<0?B.writeSVarintField(6,ae):B.writeVarintField(5,ae))}const Xt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ae=>ae},Mi=Math.fround||(Ci=new Float32Array(1),ae=>(Ci[0]=+ae,Ci[0]));var Ci;class tr{constructor(B){this.options=Object.assign(Object.create(Xt),B),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(B){const{log:j,minZoom:U,maxZoom:X}=this.options;j&&console.time("total time");const ie=`prepare ${B.length} points`;j&&console.time(ie),this.points=B;const ce=[];for(let de=0;de<B.length;de++){const Pe=B[de];if(!Pe.geometry)continue;const[ke,Ce]=Pe.geometry.coordinates,it=Mi(Jt(ke)),fe=Mi(St(Ce));ce.push(it,fe,1/0,de,-1,1),this.options.reduce&&ce.push(0)}let me=this.trees[X+1]=this._createTree(ce);j&&console.timeEnd(ie);for(let de=X;de>=U;de--){const Pe=+Date.now();me=this.trees[de]=this._createTree(this._cluster(me,de)),j&&console.log("z%d: %d clusters in %dms",de,me.numItems,+Date.now()-Pe)}return j&&console.timeEnd("total time"),this}getClusters(B,j){let U=((B[0]+180)%360+360)%360-180;const X=Math.max(-90,Math.min(90,B[1]));let ie=B[2]===180?180:((B[2]+180)%360+360)%360-180;const ce=Math.max(-90,Math.min(90,B[3]));if(B[2]-B[0]>=360)U=-180,ie=180;else if(U>ie){const Ce=this.getClusters([U,X,180,ce],j),it=this.getClusters([-180,X,ie,ce],j);return Ce.concat(it)}const me=this.trees[this._limitZoom(j)],de=me.range(Jt(U),St(ce),Jt(ie),St(X)),Pe=me.data,ke=[];for(const Ce of de){const it=this.stride*Ce;ke.push(Pe[it+5]>1?en(Pe,it,this.clusterProps):this.points[Pe[it+3]])}return ke}getChildren(B){const j=this._getOriginId(B),U=this._getOriginZoom(B),X="No cluster with the specified id.",ie=this.trees[U];if(!ie)throw new Error(X);const ce=ie.data;if(j*this.stride>=ce.length)throw new Error(X);const me=this.options.radius/(this.options.extent*Math.pow(2,U-1)),de=ie.within(ce[j*this.stride],ce[j*this.stride+1],me),Pe=[];for(const ke of de){const Ce=ke*this.stride;ce[Ce+4]===B&&Pe.push(ce[Ce+5]>1?en(ce,Ce,this.clusterProps):this.points[ce[Ce+3]])}if(Pe.length===0)throw new Error(X);return Pe}getLeaves(B,j,U){const X=[];return this._appendLeaves(X,B,j=j||10,U=U||0,0),X}getTile(B,j,U){const X=this.trees[this._limitZoom(B)],ie=Math.pow(2,B),{extent:ce,radius:me}=this.options,de=me/ce,Pe=(U-de)/ie,ke=(U+1+de)/ie,Ce={features:[]};return this._addTileFeatures(X.range((j-de)/ie,Pe,(j+1+de)/ie,ke),X.data,j,U,ie,Ce),j===0&&this._addTileFeatures(X.range(1-de/ie,Pe,1,ke),X.data,ie,U,ie,Ce),j===ie-1&&this._addTileFeatures(X.range(0,Pe,de/ie,ke),X.data,-1,U,ie,Ce),Ce.features.length?Ce:null}getClusterExpansionZoom(B){let j=this._getOriginZoom(B)-1;for(;j<=this.options.maxZoom;){const U=this.getChildren(B);if(j++,U.length!==1)break;B=U[0].properties.cluster_id}return j}_appendLeaves(B,j,U,X,ie){const ce=this.getChildren(j);for(const me of ce){const de=me.properties;if(de&&de.cluster?ie+de.point_count<=X?ie+=de.point_count:ie=this._appendLeaves(B,de.cluster_id,U,X,ie):ie<X?ie++:B.push(me),B.length===U)break}return ie}_createTree(B){const j=new T.aI(B.length/this.stride|0,this.options.nodeSize,Float32Array);for(let U=0;U<B.length;U+=this.stride)j.add(B[U],B[U+1]);return j.finish(),j.data=B,j}_addTileFeatures(B,j,U,X,ie,ce){for(const me of B){const de=me*this.stride,Pe=j[de+5]>1;let ke,Ce,it;if(Pe)ke=$r(j,de,this.clusterProps),Ce=j[de],it=j[de+1];else{const At=this.points[j[de+3]];ke=At.properties;const[ot,xt]=At.geometry.coordinates;Ce=Jt(ot),it=St(xt)}const fe={type:1,geometry:[[Math.round(this.options.extent*(Ce*ie-U)),Math.round(this.options.extent*(it*ie-X))]],tags:ke};let _t;_t=Pe||this.options.generateId?j[de+3]:this.points[j[de+3]].id,_t!==void 0&&(fe.id=_t),ce.features.push(fe)}}_limitZoom(B){return Math.max(this.options.minZoom,Math.min(Math.floor(+B),this.options.maxZoom+1))}_cluster(B,j){const{radius:U,extent:X,reduce:ie,minPoints:ce}=this.options,me=U/(X*Math.pow(2,j)),de=B.data,Pe=[],ke=this.stride;for(let Ce=0;Ce<de.length;Ce+=ke){if(de[Ce+2]<=j)continue;de[Ce+2]=j;const it=de[Ce],fe=de[Ce+1],_t=B.within(de[Ce],de[Ce+1],me),At=de[Ce+5];let ot=At;for(const xt of _t){const oi=xt*ke;de[oi+2]>j&&(ot+=de[oi+5])}if(ot>At&&ot>=ce){let xt,oi=it*At,ji=fe*At,Ni=-1;const Ii=(Ce/ke<<5)+(j+1)+this.points.length;for(const Dt of _t){const Ut=Dt*ke;if(de[Ut+2]<=j)continue;de[Ut+2]=j;const ki=de[Ut+5];oi+=de[Ut]*ki,ji+=de[Ut+1]*ki,de[Ut+4]=Ii,ie&&(xt||(xt=this._map(de,Ce,!0),Ni=this.clusterProps.length,this.clusterProps.push(xt)),ie(xt,this._map(de,Ut)))}de[Ce+4]=Ii,Pe.push(oi/ot,ji/ot,1/0,Ii,-1,ot),ie&&Pe.push(Ni)}else{for(let xt=0;xt<ke;xt++)Pe.push(de[Ce+xt]);if(ot>1)for(const xt of _t){const oi=xt*ke;if(!(de[oi+2]<=j)){de[oi+2]=j;for(let ji=0;ji<ke;ji++)Pe.push(de[oi+ji])}}}}return Pe}_getOriginId(B){return B-this.points.length>>5}_getOriginZoom(B){return(B-this.points.length)%32}_map(B,j,U){if(B[j+5]>1){const ce=this.clusterProps[B[j+6]];return U?Object.assign({},ce):ce}const X=this.points[B[j+3]].properties,ie=this.options.map(X);return U&&ie===X?Object.assign({},ie):ie}}function en(ae,B,j){return{type:"Feature",id:ae[B+3],properties:$r(ae,B,j),geometry:{type:"Point",coordinates:[(U=ae[B],360*(U-.5)),Kt(ae[B+1])]}};var U}function $r(ae,B,j){const U=ae[B+5],X=U>=1e4?`${Math.round(U/1e3)}k`:U>=1e3?Math.round(U/100)/10+"k":U,ie=ae[B+6],ce=ie===-1?{}:Object.assign({},j[ie]);return Object.assign(ce,{cluster:!0,cluster_id:ae[B+3],point_count:U,point_count_abbreviated:X})}function Jt(ae){return ae/360+.5}function St(ae){const B=Math.sin(ae*Math.PI/180),j=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return j<0?0:j>1?1:j}function Kt(ae){const B=(180-360*ae)*Math.PI/180;return 360*Math.atan(Math.exp(B))/Math.PI-90}function Vt(ae,B,j,U){let X=U;const ie=B+(j-B>>1);let ce,me=j-B;const de=ae[B],Pe=ae[B+1],ke=ae[j],Ce=ae[j+1];for(let it=B+3;it<j;it+=3){const fe=Gr(ae[it],ae[it+1],de,Pe,ke,Ce);if(fe>X)ce=it,X=fe;else if(fe===X){const _t=Math.abs(it-ie);_t<me&&(ce=it,me=_t)}}X>U&&(ce-B>3&&Vt(ae,B,ce,U),ae[ce+2]=X,j-ce>3&&Vt(ae,ce,j,U))}function Gr(ae,B,j,U,X,ie){let ce=X-j,me=ie-U;if(ce!==0||me!==0){const de=((ae-j)*ce+(B-U)*me)/(ce*ce+me*me);de>1?(j=X,U=ie):de>0&&(j+=ce*de,U+=me*de)}return ce=ae-j,me=B-U,ce*ce+me*me}function di(ae,B,j,U){const X={id:ae??null,type:B,geometry:j,tags:U,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(B==="Point"||B==="MultiPoint"||B==="LineString")Zi(X,j);else if(B==="Polygon")Zi(X,j[0]);else if(B==="MultiLineString")for(const ie of j)Zi(X,ie);else if(B==="MultiPolygon")for(const ie of j)Zi(X,ie[0]);return X}function Zi(ae,B){for(let j=0;j<B.length;j+=3)ae.minX=Math.min(ae.minX,B[j]),ae.minY=Math.min(ae.minY,B[j+1]),ae.maxX=Math.max(ae.maxX,B[j]),ae.maxY=Math.max(ae.maxY,B[j+1])}function Lr(ae,B,j,U){if(!B.geometry)return;const X=B.geometry.coordinates;if(X&&X.length===0)return;const ie=B.geometry.type,ce=Math.pow(j.tolerance/((1<<j.maxZoom)*j.extent),2);let me=[],de=B.id;if(j.promoteId?de=B.properties[j.promoteId]:j.generateId&&(de=U||0),ie==="Point")xn(X,me);else if(ie==="MultiPoint")for(const Pe of X)xn(Pe,me);else if(ie==="LineString")En(X,me,ce,!1);else if(ie==="MultiLineString"){if(j.lineMetrics){for(const Pe of X)me=[],En(Pe,me,ce,!1),ae.push(di(de,"LineString",me,B.properties));return}Ai(X,me,ce,!1)}else if(ie==="Polygon")Ai(X,me,ce,!0);else{if(ie!=="MultiPolygon"){if(ie==="GeometryCollection"){for(const Pe of B.geometry.geometries)Lr(ae,{id:de,geometry:Pe,properties:B.properties},j,U);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const Pe of X){const ke=[];Ai(Pe,ke,ce,!0),me.push(ke)}}ae.push(di(de,ie,me,B.properties))}function xn(ae,B){B.push(tn(ae[0]),lr(ae[1]),0)}function En(ae,B,j,U){let X,ie,ce=0;for(let de=0;de<ae.length;de++){const Pe=tn(ae[de][0]),ke=lr(ae[de][1]);B.push(Pe,ke,0),de>0&&(ce+=U?(X*ke-Pe*ie)/2:Math.sqrt(Math.pow(Pe-X,2)+Math.pow(ke-ie,2))),X=Pe,ie=ke}const me=B.length-3;B[2]=1,Vt(B,0,me,j),B[me+2]=1,B.size=Math.abs(ce),B.start=0,B.end=B.size}function Ai(ae,B,j,U){for(let X=0;X<ae.length;X++){const ie=[];En(ae[X],ie,j,U),B.push(ie)}}function tn(ae){return ae/360+.5}function lr(ae){const B=Math.sin(ae*Math.PI/180),j=.5-.25*Math.log((1+B)/(1-B))/Math.PI;return j<0?0:j>1?1:j}function Pr(ae,B,j,U,X,ie,ce,me){if(U/=B,ie>=(j/=B)&&ce<U)return ae;if(ce<j||ie>=U)return null;const de=[];for(const Pe of ae){const ke=Pe.geometry;let Ce=Pe.type;const it=X===0?Pe.minX:Pe.minY,fe=X===0?Pe.maxX:Pe.maxY;if(it>=j&&fe<U){de.push(Pe);continue}if(fe<j||it>=U)continue;let _t=[];if(Ce==="Point"||Ce==="MultiPoint")Zr(ke,_t,j,U,X);else if(Ce==="LineString")ys(ke,_t,j,U,X,!1,me.lineMetrics);else if(Ce==="MultiLineString")le(ke,_t,j,U,X,!1);else if(Ce==="Polygon")le(ke,_t,j,U,X,!0);else if(Ce==="MultiPolygon")for(const At of ke){const ot=[];le(At,ot,j,U,X,!0),ot.length&&_t.push(ot)}if(_t.length){if(me.lineMetrics&&Ce==="LineString"){for(const At of _t)de.push(di(Pe.id,Ce,At,Pe.tags));continue}Ce!=="LineString"&&Ce!=="MultiLineString"||(_t.length===1?(Ce="LineString",_t=_t[0]):Ce="MultiLineString"),Ce!=="Point"&&Ce!=="MultiPoint"||(Ce=_t.length===3?"Point":"MultiPoint"),de.push(di(Pe.id,Ce,_t,Pe.tags))}}return de.length?de:null}function Zr(ae,B,j,U,X){for(let ie=0;ie<ae.length;ie+=3){const ce=ae[ie+X];ce>=j&&ce<=U&&Te(B,ae[ie],ae[ie+1],ae[ie+2])}}function ys(ae,B,j,U,X,ie,ce){let me=ne(ae);const de=X===0?ze:Ae;let Pe,ke,Ce=ae.start;for(let ot=0;ot<ae.length-3;ot+=3){const xt=ae[ot],oi=ae[ot+1],ji=ae[ot+2],Ni=ae[ot+3],Ii=ae[ot+4],Dt=X===0?xt:oi,Ut=X===0?Ni:Ii;let ki=!1;ce&&(Pe=Math.sqrt(Math.pow(xt-Ni,2)+Math.pow(oi-Ii,2))),Dt<j?Ut>j&&(ke=de(me,xt,oi,Ni,Ii,j),ce&&(me.start=Ce+Pe*ke)):Dt>U?Ut<U&&(ke=de(me,xt,oi,Ni,Ii,U),ce&&(me.start=Ce+Pe*ke)):Te(me,xt,oi,ji),Ut<j&&Dt>=j&&(ke=de(me,xt,oi,Ni,Ii,j),ki=!0),Ut>U&&Dt<=U&&(ke=de(me,xt,oi,Ni,Ii,U),ki=!0),!ie&&ki&&(ce&&(me.end=Ce+Pe*ke),B.push(me),me=ne(ae)),ce&&(Ce+=Pe)}let it=ae.length-3;const fe=ae[it],_t=ae[it+1],At=X===0?fe:_t;At>=j&&At<=U&&Te(me,fe,_t,ae[it+2]),it=me.length-3,ie&&it>=3&&(me[it]!==me[0]||me[it+1]!==me[1])&&Te(me,me[0],me[1],me[2]),me.length&&B.push(me)}function ne(ae){const B=[];return B.size=ae.size,B.start=ae.start,B.end=ae.end,B}function le(ae,B,j,U,X,ie){for(const ce of ae)ys(ce,B,j,U,X,ie,!1)}function Te(ae,B,j,U){ae.push(B,j,U)}function ze(ae,B,j,U,X,ie){const ce=(ie-B)/(U-B);return Te(ae,ie,j+(X-j)*ce,1),ce}function Ae(ae,B,j,U,X,ie){const ce=(ie-j)/(X-j);return Te(ae,B+(U-B)*ce,ie,1),ce}function Re(ae,B){const j=[];for(let U=0;U<ae.length;U++){const X=ae[U],ie=X.type;let ce;if(ie==="Point"||ie==="MultiPoint"||ie==="LineString")ce=qe(X.geometry,B);else if(ie==="MultiLineString"||ie==="Polygon"){ce=[];for(const me of X.geometry)ce.push(qe(me,B))}else if(ie==="MultiPolygon"){ce=[];for(const me of X.geometry){const de=[];for(const Pe of me)de.push(qe(Pe,B));ce.push(de)}}j.push(di(X.id,ie,ce,X.tags))}return j}function qe(ae,B){const j=[];j.size=ae.size,ae.start!==void 0&&(j.start=ae.start,j.end=ae.end);for(let U=0;U<ae.length;U+=3)j.push(ae[U]+B,ae[U+1],ae[U+2]);return j}function $e(ae,B){if(ae.transformed)return ae;const j=1<<ae.z,U=ae.x,X=ae.y;for(const ie of ae.features){const ce=ie.geometry,me=ie.type;if(ie.geometry=[],me===1)for(let de=0;de<ce.length;de+=2)ie.geometry.push(Ge(ce[de],ce[de+1],B,j,U,X));else for(let de=0;de<ce.length;de++){const Pe=[];for(let ke=0;ke<ce[de].length;ke+=2)Pe.push(Ge(ce[de][ke],ce[de][ke+1],B,j,U,X));ie.geometry.push(Pe)}}return ae.transformed=!0,ae}function Ge(ae,B,j,U,X,ie){return[Math.round(j*(ae*U-X)),Math.round(j*(B*U-ie))]}function De(ae,B,j,U,X){const ie=B===X.maxZoom?0:X.tolerance/((1<<B)*X.extent),ce={features:[],numPoints:0,numSimplified:0,numFeatures:ae.length,source:null,x:j,y:U,z:B,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const me of ae)ut(ce,me,ie,X);return ce}function ut(ae,B,j,U){const X=B.geometry,ie=B.type,ce=[];if(ae.minX=Math.min(ae.minX,B.minX),ae.minY=Math.min(ae.minY,B.minY),ae.maxX=Math.max(ae.maxX,B.maxX),ae.maxY=Math.max(ae.maxY,B.maxY),ie==="Point"||ie==="MultiPoint")for(let me=0;me<X.length;me+=3)ce.push(X[me],X[me+1]),ae.numPoints++,ae.numSimplified++;else if(ie==="LineString")Ke(ce,X,ae,j,!1,!1);else if(ie==="MultiLineString"||ie==="Polygon")for(let me=0;me<X.length;me++)Ke(ce,X[me],ae,j,ie==="Polygon",me===0);else if(ie==="MultiPolygon")for(let me=0;me<X.length;me++){const de=X[me];for(let Pe=0;Pe<de.length;Pe++)Ke(ce,de[Pe],ae,j,!0,Pe===0)}if(ce.length){let me=B.tags||null;if(ie==="LineString"&&U.lineMetrics){me={};for(const Pe in B.tags)me[Pe]=B.tags[Pe];me.mapbox_clip_start=X.start/X.size,me.mapbox_clip_end=X.end/X.size}const de={geometry:ce,type:ie==="Polygon"||ie==="MultiPolygon"?3:ie==="LineString"||ie==="MultiLineString"?2:1,tags:me};B.id!==null&&(de.id=B.id),ae.features.push(de)}}function Ke(ae,B,j,U,X,ie){const ce=U*U;if(U>0&&B.size<(X?ce:U))return void(j.numPoints+=B.length/3);const me=[];for(let de=0;de<B.length;de+=3)(U===0||B[de+2]>ce)&&(j.numSimplified++,me.push(B[de],B[de+1])),j.numPoints++;X&&function(de,Pe){let ke=0;for(let Ce=0,it=de.length,fe=it-2;Ce<it;fe=Ce,Ce+=2)ke+=(de[Ce]-de[fe])*(de[Ce+1]+de[fe+1]);if(ke>0===Pe)for(let Ce=0,it=de.length;Ce<it/2;Ce+=2){const fe=de[Ce],_t=de[Ce+1];de[Ce]=de[it-2-Ce],de[Ce+1]=de[it-1-Ce],de[it-2-Ce]=fe,de[it-1-Ce]=_t}}(me,ie),ae.push(me)}const lt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0};class mt{constructor(B,j){const U=(j=this.options=function(ie,ce){for(const me in ce)ie[me]=ce[me];return ie}(Object.create(lt),j)).debug;if(U&&console.time("preprocess data"),j.maxZoom<0||j.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(j.promoteId&&j.generateId)throw new Error("promoteId and generateId cannot be used together.");let X=function(ie,ce){const me=[];if(ie.type==="FeatureCollection")for(let de=0;de<ie.features.length;de++)Lr(me,ie.features[de],ce,de);else Lr(me,ie.type==="Feature"?ie:{geometry:ie},ce);return me}(B,j);this.tiles={},this.tileCoords=[],U&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",j.indexMaxZoom,j.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),X=function(ie,ce){const me=ce.buffer/ce.extent;let de=ie;const Pe=Pr(ie,1,-1-me,me,0,-1,2,ce),ke=Pr(ie,1,1-me,2+me,0,-1,2,ce);return(Pe||ke)&&(de=Pr(ie,1,-me,1+me,0,-1,2,ce)||[],Pe&&(de=Re(Pe,1).concat(de)),ke&&(de=de.concat(Re(ke,-1)))),de}(X,j),X.length&&this.splitTile(X,0,0,0),U&&(X.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(B,j,U,X,ie,ce,me){const de=[B,j,U,X],Pe=this.options,ke=Pe.debug;for(;de.length;){X=de.pop(),U=de.pop(),j=de.pop(),B=de.pop();const Ce=1<<j,it=Ct(j,U,X);let fe=this.tiles[it];if(!fe&&(ke>1&&console.time("creation"),fe=this.tiles[it]=De(B,j,U,X,Pe),this.tileCoords.push({z:j,x:U,y:X}),ke)){ke>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",j,U,X,fe.numFeatures,fe.numPoints,fe.numSimplified),console.timeEnd("creation"));const ki=`z${j}`;this.stats[ki]=(this.stats[ki]||0)+1,this.total++}if(fe.source=B,ie==null){if(j===Pe.indexMaxZoom||fe.numPoints<=Pe.indexMaxPoints)continue}else{if(j===Pe.maxZoom||j===ie)continue;if(ie!=null){const ki=ie-j;if(U!==ce>>ki||X!==me>>ki)continue}}if(fe.source=null,B.length===0)continue;ke>1&&console.time("clipping");const _t=.5*Pe.buffer/Pe.extent,At=.5-_t,ot=.5+_t,xt=1+_t;let oi=null,ji=null,Ni=null,Ii=null,Dt=Pr(B,Ce,U-_t,U+ot,0,fe.minX,fe.maxX,Pe),Ut=Pr(B,Ce,U+At,U+xt,0,fe.minX,fe.maxX,Pe);B=null,Dt&&(oi=Pr(Dt,Ce,X-_t,X+ot,1,fe.minY,fe.maxY,Pe),ji=Pr(Dt,Ce,X+At,X+xt,1,fe.minY,fe.maxY,Pe),Dt=null),Ut&&(Ni=Pr(Ut,Ce,X-_t,X+ot,1,fe.minY,fe.maxY,Pe),Ii=Pr(Ut,Ce,X+At,X+xt,1,fe.minY,fe.maxY,Pe),Ut=null),ke>1&&console.timeEnd("clipping"),de.push(oi||[],j+1,2*U,2*X),de.push(ji||[],j+1,2*U,2*X+1),de.push(Ni||[],j+1,2*U+1,2*X),de.push(Ii||[],j+1,2*U+1,2*X+1)}}getTile(B,j,U){B=+B,j=+j,U=+U;const X=this.options,{extent:ie,debug:ce}=X;if(B<0||B>24)return null;const me=1<<B,de=Ct(B,j=j+me&me-1,U);if(this.tiles[de])return $e(this.tiles[de],ie);ce>1&&console.log("drilling down to z%d-%d-%d",B,j,U);let Pe,ke=B,Ce=j,it=U;for(;!Pe&&ke>0;)ke--,Ce>>=1,it>>=1,Pe=this.tiles[Ct(ke,Ce,it)];return Pe&&Pe.source?(ce>1&&(console.log("found parent tile z%d-%d-%d",ke,Ce,it),console.time("drilling down")),this.splitTile(Pe.source,ke,Ce,it,B,j,U),ce>1&&console.timeEnd("drilling down"),this.tiles[de]?$e(this.tiles[de],ie):null):null}}function Ct(ae,B,j){return 32*((1<<ae)*j+B)+ae}class Zt extends ge{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(B,j){return T._(this,void 0,void 0,function*(){const U=B.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const X=this._geoJSONIndex.getTile(U.z,U.x,U.y);if(!X)return null;const ie=new ct(X.features,{version:2,extent:T.$});let ce=function(me){const de=new T.cM;return function(Pe,ke){for(const Ce in Pe.layers)ke.writeMessage(3,st,Pe.layers[Ce])}(me,de),de.finish()}(ie);return ce.byteOffset===0&&ce.byteLength===ce.buffer.byteLength||(ce=new Uint8Array(ce)),{vectorTile:ie,rawData:ce.buffer}})}loadData(B){return T._(this,void 0,void 0,function*(){var j;(j=this._pendingRequest)===null||j===void 0||j.abort();const U=!!(B&&B.request&&B.request.collectResourceTiming)&&new T.cN(B.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(B,this._pendingRequest);const X=yield this._pendingData;this._geoJSONIndex=B.cluster?new tr(function({superclusterOptions:ce,clusterProperties:me}){if(!me||!ce)return ce;const de={},Pe={},ke={accumulated:null,zoom:0},Ce={properties:null},it=Object.keys(me);for(const fe of it){const[_t,At]=me[fe],ot=T.cT(At),xt=T.cT(typeof _t=="string"?[_t,["accumulated"],["get",fe]]:_t);de[fe]=ot.value,Pe[fe]=xt.value}return ce.map=fe=>{Ce.properties=fe;const _t={};for(const At of it)_t[At]=de[At].evaluate(ke,Ce);return _t},ce.reduce=(fe,_t)=>{Ce.properties=_t;for(const At of it)ke.accumulated=fe[At],fe[At]=Pe[At].evaluate(ke,Ce)},ce}(B)).load(X.features):function(ce,me){return new mt(ce,me)}(X,B.geojsonVtOptions),this.loaded={};const ie={data:X};if(U){const ce=U.finish();ce&&(ie.resourceTiming={},ie.resourceTiming[B.source]=JSON.parse(JSON.stringify(ce)))}return ie}catch(X){if(delete this._pendingRequest,T.cy(X))return{abandoned:!0};throw X}})}getData(){return T._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(B){const j=this.loaded;return j&&j[B.uid]?super.reloadTile(B):this.loadTile(B)}loadAndProcessGeoJSON(B,j){return T._(this,void 0,void 0,function*(){let U=yield this.loadGeoJSON(B,j);if(delete this._pendingRequest,typeof U!="object")throw new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`);if(Je(U,!0),B.filter){const X=T.cT(B.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(X.result==="error")throw new Error(X.value.map(ce=>`${ce.key}: ${ce.message}`).join(", "));U={type:"FeatureCollection",features:U.features.filter(ce=>X.value.evaluate({zoom:0},ce))}}return U})}loadGeoJSON(B,j){return T._(this,void 0,void 0,function*(){const{promoteId:U}=B;if(B.request){const X=yield T.j(B.request,j);return this._dataUpdateable=T.cV(X.data,U)?T.cU(X.data,U):void 0,X.data}if(typeof B.data=="string")try{const X=JSON.parse(B.data);return this._dataUpdateable=T.cV(X,U)?T.cU(X,U):void 0,X}catch{throw new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`)}if(!B.dataDiff)throw new Error(`Input data given to '${B.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${B.source}`);return T.cW(this._dataUpdateable,B.dataDiff,U),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(B){return T._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(B){return this._geoJSONIndex.getClusterExpansionZoom(B.clusterId)}getClusterChildren(B){return this._geoJSONIndex.getChildren(B.clusterId)}getClusterLeaves(B){return this._geoJSONIndex.getLeaves(B.clusterId,B.limit,B.offset)}}class Gt{constructor(B){this.self=B,this.actor=new T.J(B),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(j,U)=>{if(this.externalWorkerSourceTypes[j])throw new Error(`Worker source with name "${j}" already registered.`);this.externalWorkerSourceTypes[j]=U},this.self.addProtocol=T.cA,this.self.removeProtocol=T.cB,this.self.registerRTLTextPlugin=j=>{T.cX.setMethods(j)},this.actor.registerMessageHandler("LDT",(j,U)=>this._getDEMWorkerSource(j,U.source).loadTile(U)),this.actor.registerMessageHandler("RDT",(j,U)=>T._(this,void 0,void 0,function*(){this._getDEMWorkerSource(j,U.source).removeTile(U)})),this.actor.registerMessageHandler("GCEZ",(j,U)=>T._(this,void 0,void 0,function*(){return this._getWorkerSource(j,U.type,U.source).getClusterExpansionZoom(U)})),this.actor.registerMessageHandler("GCC",(j,U)=>T._(this,void 0,void 0,function*(){return this._getWorkerSource(j,U.type,U.source).getClusterChildren(U)})),this.actor.registerMessageHandler("GCL",(j,U)=>T._(this,void 0,void 0,function*(){return this._getWorkerSource(j,U.type,U.source).getClusterLeaves(U)})),this.actor.registerMessageHandler("LD",(j,U)=>this._getWorkerSource(j,U.type,U.source).loadData(U)),this.actor.registerMessageHandler("GD",(j,U)=>this._getWorkerSource(j,U.type,U.source).getData()),this.actor.registerMessageHandler("LT",(j,U)=>this._getWorkerSource(j,U.type,U.source).loadTile(U)),this.actor.registerMessageHandler("RT",(j,U)=>this._getWorkerSource(j,U.type,U.source).reloadTile(U)),this.actor.registerMessageHandler("AT",(j,U)=>this._getWorkerSource(j,U.type,U.source).abortTile(U)),this.actor.registerMessageHandler("RMT",(j,U)=>this._getWorkerSource(j,U.type,U.source).removeTile(U)),this.actor.registerMessageHandler("RS",(j,U)=>T._(this,void 0,void 0,function*(){if(!this.workerSources[j]||!this.workerSources[j][U.type]||!this.workerSources[j][U.type][U.source])return;const X=this.workerSources[j][U.type][U.source];delete this.workerSources[j][U.type][U.source],X.removeSource!==void 0&&X.removeSource(U)})),this.actor.registerMessageHandler("RM",j=>T._(this,void 0,void 0,function*(){delete this.layerIndexes[j],delete this.availableImages[j],delete this.workerSources[j],delete this.demWorkerSources[j]})),this.actor.registerMessageHandler("SR",(j,U)=>T._(this,void 0,void 0,function*(){this.referrer=U})),this.actor.registerMessageHandler("SRPS",(j,U)=>this._syncRTLPluginState(j,U)),this.actor.registerMessageHandler("IS",(j,U)=>T._(this,void 0,void 0,function*(){this.self.importScripts(U)})),this.actor.registerMessageHandler("SI",(j,U)=>this._setImages(j,U)),this.actor.registerMessageHandler("UL",(j,U)=>T._(this,void 0,void 0,function*(){this._getLayerIndex(j).update(U.layers,U.removedIds)})),this.actor.registerMessageHandler("SL",(j,U)=>T._(this,void 0,void 0,function*(){this._getLayerIndex(j).replace(U)}))}_setImages(B,j){return T._(this,void 0,void 0,function*(){this.availableImages[B]=j;for(const U in this.workerSources[B]){const X=this.workerSources[B][U];for(const ie in X)X[ie].availableImages=j}})}_syncRTLPluginState(B,j){return T._(this,void 0,void 0,function*(){return yield T.cX.syncState(j,this.self.importScripts)})}_getAvailableImages(B){let j=this.availableImages[B];return j||(j=[]),j}_getLayerIndex(B){let j=this.layerIndexes[B];return j||(j=this.layerIndexes[B]=new a),j}_getWorkerSource(B,j,U){if(this.workerSources[B]||(this.workerSources[B]={}),this.workerSources[B][j]||(this.workerSources[B][j]={}),!this.workerSources[B][j][U]){const X={sendAsync:(ie,ce)=>(ie.targetMapId=B,this.actor.sendAsync(ie,ce))};switch(j){case"vector":this.workerSources[B][j][U]=new ge(X,this._getLayerIndex(B),this._getAvailableImages(B));break;case"geojson":this.workerSources[B][j][U]=new Zt(X,this._getLayerIndex(B),this._getAvailableImages(B));break;default:this.workerSources[B][j][U]=new this.externalWorkerSourceTypes[j](X,this._getLayerIndex(B),this._getAvailableImages(B))}}return this.workerSources[B][j][U]}_getDEMWorkerSource(B,j){return this.demWorkerSources[B]||(this.demWorkerSources[B]={}),this.demWorkerSources[B][j]||(this.demWorkerSources[B][j]=new Se),this.demWorkerSources[B][j]}}return T.i(self)&&(self.worker=new Gt(self)),Gt}),E("index",["exports","./shared"],function(T,a){var V="5.7.1";function ue(){var h=new a.A(4);return a.A!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h}let oe,ge;const Se={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(h,e,n){const o=requestAnimationFrame(d=>{c(),e(d)}),{unsubscribe:c}=a.s(h.signal,"abort",()=>{c(),cancelAnimationFrame(o),n(a.c())},!1)},frameAsync(h){return new Promise((e,n)=>{this.frame(h,e,n)})},getImageData(h,e=0){return this.getImageCanvasContext(h).getImageData(-e,-e,h.width+2*e,h.height+2*e)},getImageCanvasContext(h){const e=window.document.createElement("canvas"),n=e.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return e.width=h.width,e.height=h.height,n.drawImage(h,0,0,h.width,h.height),n},resolveURL:h=>(oe||(oe=document.createElement("a")),oe.href=h,oe.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(ge==null&&(ge=matchMedia("(prefers-reduced-motion: reduce)")),ge.matches)}};class Q{static testProp(e){if(!Q.docStyle)return e[0];for(let n=0;n<e.length;n++)if(e[n]in Q.docStyle)return e[n];return e[0]}static create(e,n,o){const c=window.document.createElement(e);return n!==void 0&&(c.className=n),o&&o.appendChild(c),c}static createNS(e,n){return window.document.createElementNS(e,n)}static disableDrag(){Q.docStyle&&Q.selectProp&&(Q.userSelect=Q.docStyle[Q.selectProp],Q.docStyle[Q.selectProp]="none")}static enableDrag(){Q.docStyle&&Q.selectProp&&(Q.docStyle[Q.selectProp]=Q.userSelect)}static setTransform(e,n){e.style[Q.transformProp]=n}static addEventListener(e,n,o,c={}){e.addEventListener(n,o,"passive"in c?c:c.capture)}static removeEventListener(e,n,o,c={}){e.removeEventListener(n,o,"passive"in c?c:c.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",Q.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",Q.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",Q.suppressClickInternal,!0)},0)}static getScale(e){const n=e.getBoundingClientRect();return{x:n.width/e.offsetWidth||1,y:n.height/e.offsetHeight||1,boundingClientRect:n}}static getPoint(e,n,o){const c=n.boundingClientRect;return new a.P((o.clientX-c.left)/n.x-e.clientLeft,(o.clientY-c.top)/n.y-e.clientTop)}static mousePos(e,n){const o=Q.getScale(e);return Q.getPoint(e,o,n)}static touchPos(e,n){const o=[],c=Q.getScale(e);for(let d=0;d<n.length;d++)o.push(Q.getPoint(e,c,n[d]));return o}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}static sanitize(e){const n=new DOMParser().parseFromString(e,"text/html").body||document.createElement("body"),o=n.querySelectorAll("script");for(const c of o)c.remove();return Q.clean(n),n.innerHTML}static isPossiblyDangerous(e,n){const o=n.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(e)||!o.includes("javascript:")&&!o.includes("data:"))||!!e.startsWith("on")||void 0}static clean(e){const n=e.children;for(const o of n)Q.removeAttributes(o),Q.clean(o)}static removeAttributes(e){for(const{name:n,value:o}of e.attributes)Q.isPossiblyDangerous(n,o)&&e.removeAttribute(n)}}Q.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,Q.selectProp=Q.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),Q.transformProp=Q.testProp(["transform","WebkitTransform"]);const He={supported:!1,testSupport:function(h){!Ye&&Je&&(ct?st(h):Qe=h)}};let Qe,Je,Ye=!1,ct=!1;function st(h){const e=h.createTexture();h.bindTexture(h.TEXTURE_2D,e);try{if(h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,Je),h.isContextLost())return;He.supported=!0}catch{}h.deleteTexture(e),Ye=!0}var We;typeof document<"u"&&(Je=document.createElement("img"),Je.onload=()=>{Qe&&st(Qe),Qe=null,ct=!0},Je.onerror=()=>{Ye=!0,Qe=null},Je.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(h){let e,n,o,c;h.resetRequestQueue=()=>{e=[],n=0,o=0,c={}},h.addThrottleControl=x=>{const P=o++;return c[P]=x,P},h.removeThrottleControl=x=>{delete c[x],g()},h.getImage=(x,P,C=!0)=>new Promise((k,A)=>{He.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),a.e(x,{type:"image"}),e.push({abortController:P,requestParameters:x,supportImageRefresh:C,state:"queued",onError:R=>{A(R)},onSuccess:R=>{k(R)}}),g()});const d=x=>a._(this,void 0,void 0,function*(){x.state="running";const{requestParameters:P,supportImageRefresh:C,onError:k,onSuccess:A,abortController:R}=x,O=C===!1&&!a.i(self)&&!a.g(P.url)&&(!P.headers||Object.keys(P.headers).reduce((q,W)=>q&&W==="accept",!0));n++;const Z=O?v(P,R):a.m(P,R);try{const q=yield Z;delete x.abortController,x.state="completed",q.data instanceof HTMLImageElement||a.b(q.data)?A(q):q.data&&A({data:yield(G=q.data,typeof createImageBitmap=="function"?a.f(G):a.h(G)),cacheControl:q.cacheControl,expires:q.expires})}catch(q){delete x.abortController,k(q)}finally{n--,g()}var G}),g=()=>{const x=(()=>{for(const P of Object.keys(c))if(c[P]())return!0;return!1})()?a.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:a.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let P=n;P<x&&e.length>0;P++){const C=e.shift();C.abortController.signal.aborted?P--:d(C)}},v=(x,P)=>new Promise((C,k)=>{const A=new Image,R=x.url,O=x.credentials;O&&O==="include"?A.crossOrigin="use-credentials":(O&&O==="same-origin"||!a.d(R))&&(A.crossOrigin="anonymous"),P.signal.addEventListener("abort",()=>{A.src="",k(a.c())}),A.fetchPriority="high",A.onload=()=>{A.onerror=A.onload=null,C({data:A})},A.onerror=()=>{A.onerror=A.onload=null,P.signal.aborted||k(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},A.src=R})}(We||(We={})),We.resetRequestQueue();class yt{constructor(e){this._transformRequestFn=e??null}transformRequest(e,n){return this._transformRequestFn&&this._transformRequestFn(e,n)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function Oi(h){const e=[];if(typeof h=="string")e.push({id:"default",url:h});else if(h&&h.length>0){const n=[];for(const{id:o,url:c}of h){const d=`${o}${c}`;n.indexOf(d)===-1&&(n.push(d),e.push({id:o,url:c}))}}return e}function mi(h,e,n){try{const o=new URL(h);return o.pathname+=`${e}${n}`,o.toString()}catch{throw new Error(`Invalid sprite URL "${h}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function Ft(h){const{userImage:e}=h;return!!(e&&e.render&&e.render())&&(h.data.replace(new Uint8Array(e.data.buffer)),!0)}class Nt extends a.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:n,promiseResolve:o}of this.requestors)o(this._getImagesForIds(n));this.requestors=[]}}getImage(e){const n=this.images[e];if(n&&!n.data&&n.spriteData){const o=n.spriteData;n.data=new a.R({width:o.width,height:o.height},o.context.getImageData(o.x,o.y,o.width,o.height).data),n.spriteData=null}return n}addImage(e,n){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,n)&&(this.images[e]=n)}_validate(e,n){let o=!0;const c=n.data||n.spriteData;return this._validateStretch(n.stretchX,c&&c.width)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchX" value`))),o=!1),this._validateStretch(n.stretchY,c&&c.height)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "stretchY" value`))),o=!1),this._validateContent(n.content,n)||(this.fire(new a.k(new Error(`Image "${e}" has invalid "content" value`))),o=!1),o}_validateStretch(e,n){if(!e)return!0;let o=0;for(const c of e){if(c[0]<o||c[1]<c[0]||n<c[1])return!1;o=c[1]}return!0}_validateContent(e,n){if(!e)return!0;if(e.length!==4)return!1;const o=n.spriteData,c=o&&o.width||n.data.width,d=o&&o.height||n.data.height;return!(e[0]<0||c<e[0]||e[1]<0||d<e[1]||e[2]<0||c<e[2]||e[3]<0||d<e[3]||e[2]<e[0]||e[3]<e[1])}updateImage(e,n,o=!0){const c=this.getImage(e);if(o&&(c.data.width!==n.data.width||c.data.height!==n.data.height))throw new Error(`size mismatch between old image (${c.data.width}x${c.data.height}) and new image (${n.data.width}x${n.data.height}).`);n.version=c.version+1,this.images[e]=n,this.updatedImages[e]=!0}removeImage(e){const n=this.images[e];delete this.images[e],delete this.patterns[e],n.userImage&&n.userImage.onRemove&&n.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e){return new Promise((n,o)=>{let c=!0;if(!this.isLoaded())for(const d of e)this.images[d]||(c=!1);this.isLoaded()||c?n(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:n})})}_getImagesForIds(e){const n={};for(const o of e){let c=this.getImage(o);c||(this.fire(new a.l("styleimagemissing",{id:o})),c=this.getImage(o)),c?n[o]={data:c.data.clone(),pixelRatio:c.pixelRatio,sdf:c.sdf,version:c.version,stretchX:c.stretchX,stretchY:c.stretchY,content:c.content,textFitWidth:c.textFitWidth,textFitHeight:c.textFitHeight,hasRenderCallback:!!(c.userImage&&c.userImage.render)}:a.w(`Image "${o}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:e,height:n}=this.atlasImage;return{width:e,height:n}}getPattern(e){const n=this.patterns[e],o=this.getImage(e);if(!o)return null;if(n&&n.position.version===o.version)return n.position;if(n)n.position.version=o.version;else{const c={w:o.data.width+2,h:o.data.height+2,x:0,y:0},d=new a.I(c,o);this.patterns[e]={bin:c,position:d}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const n=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.T(e,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const d in this.patterns)e.push(this.patterns[d].bin);const{w:n,h:o}=a.p(e),c=this.atlasImage;c.resize({width:n||1,height:o||1});for(const d in this.patterns){const{bin:g}=this.patterns[d],v=g.x+1,x=g.y+1,P=this.getImage(d).data,C=P.width,k=P.height;a.R.copy(P,c,{x:0,y:0},{x:v,y:x},{width:C,height:k}),a.R.copy(P,c,{x:0,y:k-1},{x:v,y:x-1},{width:C,height:1}),a.R.copy(P,c,{x:0,y:0},{x:v,y:x+k},{width:C,height:1}),a.R.copy(P,c,{x:C-1,y:0},{x:v-1,y:x},{width:1,height:k}),a.R.copy(P,c,{x:0,y:0},{x:v+C,y:x},{width:1,height:k})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const n of e){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const o=this.getImage(n);o||a.w(`Image with ID: "${n}" was not found`),Ft(o)&&this.updateImage(n,o)}}}const Xt=1e20;function Mi(h,e,n,o,c,d,g,v,x){for(let P=e;P<e+o;P++)Ci(h,n*d+P,d,c,g,v,x);for(let P=n;P<n+c;P++)Ci(h,P*d+e,1,o,g,v,x)}function Ci(h,e,n,o,c,d,g){d[0]=0,g[0]=-1e20,g[1]=Xt,c[0]=h[e];for(let v=1,x=0,P=0;v<o;v++){c[v]=h[e+v*n];const C=v*v;do{const k=d[x];P=(c[v]-c[k]+C-k*k)/(v-k)/2}while(P<=g[x]&&--x>-1);x++,d[x]=v,g[x]=P,g[x+1]=Xt}for(let v=0,x=0;v<o;v++){for(;g[x+1]<v;)x++;const P=d[x],C=v-P;h[e+v*n]=c[P]+C*C}}class tr{constructor(e,n,o){this.requestManager=e,this.localIdeographFontFamily=n,this.entries={},this.lang=o}setURL(e){this.url=e}getGlyphs(e){return a._(this,void 0,void 0,function*(){const n=[];for(const d in e)for(const g of e[d])n.push(this._getAndCacheGlyphsPromise(d,g));const o=yield Promise.all(n),c={};for(const{stack:d,id:g,glyph:v}of o)c[d]||(c[d]={}),c[d][g]=v&&{id:v.id,bitmap:v.bitmap.clone(),metrics:v.metrics};return c})}_getAndCacheGlyphsPromise(e,n){return a._(this,void 0,void 0,function*(){let o=this.entries[e];o||(o=this.entries[e]={glyphs:{},requests:{},ranges:{}});let c=o.glyphs[n];if(c!==void 0)return{stack:e,id:n,glyph:c};if(c=this._tinySDF(o,e,n),c)return o.glyphs[n]=c,{stack:e,id:n,glyph:c};const d=Math.floor(n/256);if(256*d>65535)throw new Error("glyphs > 65535 not supported");if(o.ranges[d])return{stack:e,id:n,glyph:c};if(!this.url)throw new Error("glyphsUrl is not set");if(!o.requests[d]){const v=tr.loadGlyphRange(e,d,this.url,this.requestManager);o.requests[d]=v}const g=yield o.requests[d];for(const v in g)this._doesCharSupportLocalGlyph(+v)||(o.glyphs[+v]=g[+v]);return o.ranges[d]=!0,{stack:e,id:n,glyph:g[n]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(new RegExp("\\p{Ideo}|\\p{sc=Hang}|\\p{sc=Hira}|\\p{sc=Kana}","u").test(String.fromCodePoint(e))||a.u["CJK Unified Ideographs"](e)||a.u["Hangul Syllables"](e)||a.u.Hiragana(e)||a.u.Katakana(e)||a.u["CJK Symbols and Punctuation"](e)||a.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,n,o){const c=this.localIdeographFontFamily;if(!c||!this._doesCharSupportLocalGlyph(o))return;let d=e.tinySDF;if(!d){let v="400";/bold/i.test(n)?v="900":/medium/i.test(n)?v="500":/light/i.test(n)&&(v="200"),d=e.tinySDF=new tr.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,lang:this.lang,fontFamily:c,fontWeight:v})}const g=d.draw(String.fromCharCode(o));return{id:o,bitmap:new a.q({width:g.width||60,height:g.height||60},g.data),metrics:{width:g.glyphWidth/2||24,height:g.glyphHeight/2||24,left:g.glyphLeft/2+.5||0,top:g.glyphTop/2-27.5||-8,advance:g.glyphAdvance/2||24,isDoubleResolution:!0}}}}tr.loadGlyphRange=function(h,e,n,o){return a._(this,void 0,void 0,function*(){const c=256*e,d=c+255,g=o.transformRequest(n.replace("{fontstack}",h).replace("{range}",`${c}-${d}`),"Glyphs"),v=yield a.n(g,new AbortController);if(!v||!v.data)throw new Error(`Could not load glyph range. range: ${e}, ${c}-${d}`);const x={};for(const P of a.o(v.data))x[P.id]=P;return x})},tr.TinySDF=class{constructor({fontSize:h=24,buffer:e=3,radius:n=8,cutoff:o=.25,fontFamily:c="sans-serif",fontWeight:d="normal",fontStyle:g="normal",lang:v=null}={}){this.buffer=e,this.cutoff=o,this.radius=n,this.lang=v;const x=this.size=h+4*e,P=this._createCanvas(x),C=this.ctx=P.getContext("2d",{willReadFrequently:!0});C.font=`${g} ${d} ${h}px ${c}`,C.textBaseline="alphabetic",C.textAlign="left",C.fillStyle="black",this.gridOuter=new Float64Array(x*x),this.gridInner=new Float64Array(x*x),this.f=new Float64Array(x),this.z=new Float64Array(x+1),this.v=new Uint16Array(x)}_createCanvas(h){const e=document.createElement("canvas");return e.width=e.height=h,e}draw(h){const{width:e,actualBoundingBoxAscent:n,actualBoundingBoxDescent:o,actualBoundingBoxLeft:c,actualBoundingBoxRight:d}=this.ctx.measureText(h),g=Math.ceil(n),v=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(d-c))),x=Math.min(this.size-this.buffer,g+Math.ceil(o)),P=v+2*this.buffer,C=x+2*this.buffer,k=Math.max(P*C,0),A=new Uint8ClampedArray(k),R={data:A,width:P,height:C,glyphWidth:v,glyphHeight:x,glyphTop:g,glyphLeft:0,glyphAdvance:e};if(v===0||x===0)return R;const{ctx:O,buffer:Z,gridInner:G,gridOuter:q}=this;this.lang&&(O.lang=this.lang),O.clearRect(Z,Z,v,x),O.fillText(h,Z,Z+g);const W=O.getImageData(Z,Z,v,x);q.fill(Xt,0,k),G.fill(0,0,k);for(let J=0;J<x;J++)for(let K=0;K<v;K++){const te=W.data[4*(J*v+K)+3]/255;if(te===0)continue;const se=(J+Z)*P+K+Z;if(te===1)q[se]=0,G[se]=Xt;else{const Y=.5-te;q[se]=Y>0?Y*Y:0,G[se]=Y<0?Y*Y:0}}Mi(q,0,0,P,C,P,this.f,this.v,this.z),Mi(G,Z,Z,v,x,P,this.f,this.v,this.z);for(let J=0;J<k;J++){const K=Math.sqrt(q[J])-Math.sqrt(G[J]);A[J]=Math.round(255-255*(K/this.radius+this.cutoff))}return R}};class en{constructor(){this.specification=a.v.light.position}possiblyEvaluate(e,n){return a.B(e.expression.evaluate(n))}interpolate(e,n,o){return{x:a.C.number(e.x,n.x,o),y:a.C.number(e.y,n.y,o),z:a.C.number(e.z,n.z,o)}}}let $r;class Jt extends a.E{constructor(e){super(),$r=$r||new a.r({anchor:new a.D(a.v.light.anchor),position:new en,color:new a.D(a.v.light.color),intensity:new a.D(a.v.light.intensity)}),this._transitionable=new a.t($r),this.setLight(e),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,n={}){if(!this._validate(a.x,e,n))for(const o in e){const c=e[o];o.endsWith("-transition")?this._transitionable.setTransition(o.slice(0,-11),c):this._transitionable.setValue(o,c)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o){return(!o||o.validate!==!1)&&a.y(this,e.call(a.z,{value:n,style:{glyphs:!0,sprite:!0},styleSpec:a.v}))}}const St=new a.r({"sky-color":new a.D(a.v.sky["sky-color"]),"horizon-color":new a.D(a.v.sky["horizon-color"]),"fog-color":new a.D(a.v.sky["fog-color"]),"fog-ground-blend":new a.D(a.v.sky["fog-ground-blend"]),"horizon-fog-blend":new a.D(a.v.sky["horizon-fog-blend"]),"sky-horizon-blend":new a.D(a.v.sky["sky-horizon-blend"]),"atmosphere-blend":new a.D(a.v.sky["atmosphere-blend"])});class Kt extends a.E{constructor(e){super(),this._transitionable=new a.t(St),this.setSky(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new a.F(0))}setSky(e,n={}){if(!this._validate(a.G,e,n)){e||(e={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const o in e){const c=e[o];o.endsWith("-transition")?this._transitionable.setTransition(o.slice(0,-11),c):this._transitionable.setValue(o,c)}}}getSky(){return this._transitionable.serialize()}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,n,o={}){return(o==null?void 0:o.validate)!==!1&&a.y(this,e.call(a.z,a.e({value:n,style:{glyphs:!0,sprite:!0},styleSpec:a.v})))}calculateFogBlendOpacity(e){return e<60?0:e<70?(e-60)/10:1}}class Vt{constructor(e,n){this.width=e,this.height=n,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(e,n){const o=e.join(",")+String(n);return this.dashEntry[o]||(this.dashEntry[o]=this.addDash(e,n)),this.dashEntry[o]}getDashRanges(e,n,o){const c=[];let d=e.length%2==1?-e[e.length-1]*o:0,g=e[0]*o,v=!0;c.push({left:d,right:g,isDash:v,zeroLength:e[0]===0});let x=e[0];for(let P=1;P<e.length;P++){v=!v;const C=e[P];d=x*o,x+=C,g=x*o,c.push({left:d,right:g,isDash:v,zeroLength:C===0})}return c}addRoundDash(e,n,o){const c=n/2;for(let d=-o;d<=o;d++){const g=this.width*(this.nextRow+o+d);let v=0,x=e[v];for(let P=0;P<this.width;P++){P/x.right>1&&(x=e[++v]);const C=Math.abs(P-x.left),k=Math.abs(P-x.right),A=Math.min(C,k);let R;const O=d/o*(c+1);if(x.isDash){const Z=c-Math.abs(O);R=Math.sqrt(A*A+Z*Z)}else R=c-Math.sqrt(A*A+O*O);this.data[g+P]=Math.max(0,Math.min(255,R+128))}}}addRegularDash(e){for(let v=e.length-1;v>=0;--v){const x=e[v],P=e[v+1];x.zeroLength?e.splice(v,1):P&&P.isDash===x.isDash&&(P.left=x.left,e.splice(v,1))}const n=e[0],o=e[e.length-1];n.isDash===o.isDash&&(n.left=o.left-this.width,o.right=n.right+this.width);const c=this.width*this.nextRow;let d=0,g=e[d];for(let v=0;v<this.width;v++){v/g.right>1&&(g=e[++d]);const x=Math.abs(v-g.left),P=Math.abs(v-g.right),C=Math.min(x,P);this.data[c+v]=Math.max(0,Math.min(255,(g.isDash?C:-C)+128))}}addDash(e,n){const o=n?7:0,c=2*o+1;if(this.nextRow+c>this.height)return a.w("LineAtlas out of space"),null;let d=0;for(let v=0;v<e.length;v++)d+=e[v];if(d!==0){const v=this.width/d,x=this.getDashRanges(e,this.width,v);n?this.addRoundDash(x,v,o):this.addRegularDash(x)}const g={y:(this.nextRow+o+.5)/this.height,height:2*o/this.height,width:d};return this.nextRow+=c,this.dirty=!0,g}bind(e){const n=e.gl;this.texture?(n.bindTexture(n.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,n.texSubImage2D(n.TEXTURE_2D,0,0,0,this.width,this.height,n.ALPHA,n.UNSIGNED_BYTE,this.data))):(this.texture=n.createTexture(),n.bindTexture(n.TEXTURE_2D,this.texture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.REPEAT),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texImage2D(n.TEXTURE_2D,0,n.ALPHA,this.width,this.height,0,n.ALPHA,n.UNSIGNED_BYTE,this.data))}}const Gr="maplibre_preloaded_worker_pool";class di{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<di.workerCount;)this.workers.push(new Worker(a.a.WORKER_URL));return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.numActive()===0&&(this.workers.forEach(n=>{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Gr]}numActive(){return Object.keys(this.active).length}}const Zi=Math.floor(Se.hardwareConcurrency/2);let Lr,xn;function En(){return Lr||(Lr=new di),Lr}di.workerCount=a.H(globalThis)?Math.max(Math.min(Zi,3),1):1;class Ai{constructor(e,n){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=n;const o=this.workerPool.acquire(n);for(let c=0;c<o.length;c++){const d=new a.J(o[c],n);d.name=`Worker ${c}`,this.actors.push(d)}if(!this.actors.length)throw new Error("No actors found")}broadcast(e,n){const o=[];for(const c of this.actors)o.push(c.sendAsync({type:e,data:n}));return Promise.all(o)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(e=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,n){for(const o of this.actors)o.registerMessageHandler(e,n)}}function tn(){return xn||(xn=new Ai(En(),a.K),xn.registerMessageHandler("GR",(h,e,n)=>a.m(e,n))),xn}function lr(h,e){const n=a.L();return a.M(n,n,[1,1,0]),a.N(n,n,[.5*h.width,.5*h.height,1]),h.calculatePosMatrix?a.O(n,n,h.calculatePosMatrix(e.toUnwrapped())):n}function Pr(h,e,n,o,c,d,g){var v;const x=function(A,R,O){if(A)for(const Z of A){const G=R[Z];if(G&&G.source===O&&G.type==="fill-extrusion")return!0}else for(const Z in R){const G=R[Z];if(G.source===O&&G.type==="fill-extrusion")return!0}return!1}((v=c==null?void 0:c.layers)!==null&&v!==void 0?v:null,e,h.id),P=d.maxPitchScaleFactor(),C=h.tilesIn(o,P,x);C.sort(Zr);const k=[];for(const A of C)k.push({wrappedTileID:A.tileID.wrapped().key,queryResults:A.tile.queryRenderedFeatures(e,n,h._state,A.queryGeometry,A.cameraQueryGeometry,A.scale,c,d,P,lr(h.transform,A.tileID),g?(R,O)=>g(A.tileID,R,O):void 0)});return function(A,R){for(const O in A)for(const Z of A[O])ys(Z,R);return A}(function(A){const R={},O={};for(const Z of A){const G=Z.queryResults,q=Z.wrappedTileID,W=O[q]=O[q]||{};for(const J in G){const K=G[J],te=W[J]=W[J]||{},se=R[J]=R[J]||[];for(const Y of K)te[Y.featureIndex]||(te[Y.featureIndex]=!0,se.push(Y))}}return R}(k),h)}function Zr(h,e){const n=h.tileID,o=e.tileID;return n.overscaledZ-o.overscaledZ||n.canonical.y-o.canonical.y||n.wrap-o.wrap||n.canonical.x-o.canonical.x}function ys(h,e){const n=h.feature,o=e.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=o}function ne(h,e,n){return a._(this,void 0,void 0,function*(){let o=h;if(h.url?o=(yield a.j(e.transformRequest(h.url,"Source"),n)).data:yield Se.frameAsync(n),!o)return null;const c=a.Q(a.e(o,h),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in o&&o.vector_layers&&(c.vectorLayerIds=o.vector_layers.map(d=>d.id)),c})}class le{constructor(e,n){e&&(n?this.setSouthWest(e).setNorthEast(n):Array.isArray(e)&&(e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1])))}setNorthEast(e){return this._ne=e instanceof a.S?new a.S(e.lng,e.lat):a.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof a.S?new a.S(e.lng,e.lat):a.S.convert(e),this}extend(e){const n=this._sw,o=this._ne;let c,d;if(e instanceof a.S)c=e,d=e;else{if(!(e instanceof le))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(le.convert(e)):this.extend(a.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(a.S.convert(e)):this;if(c=e._sw,d=e._ne,!c||!d)return this}return n||o?(n.lng=Math.min(c.lng,n.lng),n.lat=Math.min(c.lat,n.lat),o.lng=Math.max(d.lng,o.lng),o.lat=Math.max(d.lat,o.lat)):(this._sw=new a.S(c.lng,c.lat),this._ne=new a.S(d.lng,d.lat)),this}getCenter(){return new a.S((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new a.S(this.getWest(),this.getNorth())}getSouthEast(){return new a.S(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:n,lat:o}=a.S.convert(e);let c=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=o&&o<=this._ne.lat&&c}static convert(e){return e instanceof le?e:e&&new le(e)}static fromLngLat(e,n=0){const o=360*n/40075017,c=o/Math.cos(Math.PI/180*e.lat);return new le(new a.S(e.lng-c,e.lat-o),new a.S(e.lng+c,e.lat+o))}adjustAntiMeridian(){const e=new a.S(this._sw.lng,this._sw.lat),n=new a.S(this._ne.lng,this._ne.lat);return new le(e,e.lng>n.lng?new a.S(n.lng+360,n.lat):n)}}class Te{constructor(e,n,o){this.bounds=le.convert(this.validateBounds(e)),this.minzoom=n||0,this.maxzoom=o||24}validateBounds(e){return Array.isArray(e)&&e.length===4?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const n=Math.pow(2,e.z),o=Math.floor(a.V(this.bounds.getWest())*n),c=Math.floor(a.U(this.bounds.getNorth())*n),d=Math.ceil(a.V(this.bounds.getEast())*n),g=Math.ceil(a.U(this.bounds.getSouth())*n);return e.x>=o&&e.x<d&&e.y>=c&&e.y<g}}class ze extends a.E{constructor(e,n,o,c){if(super(),this.id=e,this.dispatcher=o,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.e(this,a.Q(n,["url","scheme","tileSize","promoteId"])),this._options=a.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}load(){return a._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const e=yield ne(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e&&(a.e(this,e),e.bounds&&(this.tileBounds=new Te(e.bounds,this.minzoom,this.maxzoom)),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.l("data",{dataType:"source",sourceDataType:"content"})))}catch(e){this._tileJSONRequest=null,this.fire(new a.k(e))}})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.abort(),e(),this.load()}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return a.e({},this._options)}loadTile(e){return a._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o={request:this.map._requestManager.transformRequest(n,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};o.request.collectResourceTiming=this._collectResourceTiming;let c="RT";if(e.actor&&e.state!=="expired"){if(e.state==="loading")return new Promise((d,g)=>{e.reloadPromise={resolve:d,reject:g}})}else e.actor=this.dispatcher.getActor(),c="LT";e.abortController=new AbortController;try{const d=yield e.actor.sendAsync({type:c,data:o},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,d)}catch(d){if(delete e.abortController,e.aborted)return;if(d&&d.status!==404)throw d;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,n){if(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),e.reloadPromise){const o=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(o.resolve).catch(o.reject)}}abortTile(e){return a._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return a._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class Ae extends a.E{constructor(e,n,o,c){super(),this.id=e,this.dispatcher=o,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.e({type:"raster"},n),a.e(this,a.Q(n,["url","scheme","tileSize"]))}load(){return a._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const n=yield ne(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,n&&(a.e(this,n),n.bounds&&(this.tileBounds=new Te(n.bounds,this.minzoom,this.maxzoom)),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(n){this._tileJSONRequest=null,this.fire(new a.k(n))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return a.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return a._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const o=yield We.getImage(this.map._requestManager.transformRequest(n,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(o&&o.data){this.map._refreshExpiredTiles&&(o.cacheControl||o.expires)&&e.setExpiryData({cacheControl:o.cacheControl,expires:o.expires});const c=this.map.painter.context,d=c.gl,g=o.data;e.texture=this.map.painter.getTileTexture(g.width),e.texture?e.texture.update(g,{useMipmap:!0}):(e.texture=new a.T(c,g,d.RGBA,{useMipmap:!0}),e.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(o){if(delete e.abortController,e.aborted)e.state="unloaded";else if(o)throw e.state="errored",o}})}abortTile(e){return a._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return a._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Re extends Ae{constructor(e,n,o,c){super(e,n,o,c),this.type="raster-dem",this.maxzoom=22,this._options=a.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(e){return a._(this,void 0,void 0,function*(){const n=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),o=this.map._requestManager.transformRequest(n,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const c=yield We.getImage(o,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(c&&c.data){const d=c.data;this.map._refreshExpiredTiles&&(c.cacheControl||c.expires)&&e.setExpiryData({cacheControl:c.cacheControl,expires:c.expires});const g=a.b(d)&&a.W()?d:yield this.readImageNow(d),v={type:this.type,uid:e.uid,source:this.id,rawImageData:g,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||e.state==="expired"){e.actor=this.dispatcher.getActor();const x=yield e.actor.sendAsync({type:"LDT",data:v});e.dem=x,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(c){if(delete e.abortController,e.aborted)e.state="unloaded";else if(c)throw e.state="errored",c}})}readImageNow(e){return a._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&a.X()){const n=e.width+2,o=e.height+2;try{return new a.R({width:n,height:o},yield a.Y(e,-1,-1,n,o))}catch{}}return Se.getImageData(e,1)})}_getNeighboringTiles(e){const n=e.canonical,o=Math.pow(2,n.z),c=(n.x-1+o)%o,d=n.x===0?e.wrap-1:e.wrap,g=(n.x+1+o)%o,v=n.x+1===o?e.wrap+1:e.wrap,x={};return x[new a.Z(e.overscaledZ,d,n.z,c,n.y).key]={backfilled:!1},x[new a.Z(e.overscaledZ,v,n.z,g,n.y).key]={backfilled:!1},n.y>0&&(x[new a.Z(e.overscaledZ,d,n.z,c,n.y-1).key]={backfilled:!1},x[new a.Z(e.overscaledZ,e.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},x[new a.Z(e.overscaledZ,v,n.z,g,n.y-1).key]={backfilled:!1}),n.y+1<o&&(x[new a.Z(e.overscaledZ,d,n.z,c,n.y+1).key]={backfilled:!1},x[new a.Z(e.overscaledZ,e.wrap,n.z,n.x,n.y+1).key]={backfilled:!1},x[new a.Z(e.overscaledZ,v,n.z,g,n.y+1).key]={backfilled:!1}),x}unloadTile(e){return a._(this,void 0,void 0,function*(){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded",e.actor&&(yield e.actor.sendAsync({type:"RDT",data:{type:this.type,uid:e.uid,source:this.id}}))})}}class qe extends a.E{constructor(e,n,o,c){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:n.data},this.actor=o.getActor(),this.setEventedParent(c),this._data=n.data,this._options=a.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId,n.clusterMaxZoom!==void 0&&this.maxzoom<=n.clusterMaxZoom&&a.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${n.clusterMaxZoom}".`),this.workerOptions=a.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:this._pixelsToTileUnits(n.buffer!==void 0?n.buffer:128),tolerance:this._pixelsToTileUnits(n.tolerance!==void 0?n.tolerance:.375),extent:a.$,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:this._getClusterMaxZoom(n.clusterMaxZoom),minPoints:Math.max(2,n.clusterMinPoints||2),extent:a.$,radius:this._pixelsToTileUnits(n.clusterRadius||50),log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}_pixelsToTileUnits(e){return e*(a.$/this.tileSize)}_getClusterMaxZoom(e){const n=e?Math.round(e):this.maxzoom-1;return Number.isInteger(e)||e===void 0||a.w(`Integer expected for option 'clusterMaxZoom': provided value "${e}" rounded to "${n}"`),n}load(){return a._(this,void 0,void 0,function*(){yield this._updateWorkerData()})}onAdd(e){this.map=e,this.load()}setData(e){return this._data=e,this._pendingWorkerUpdate={data:e},this._updateWorkerData(),this}updateData(e){return this._pendingWorkerUpdate.diff=a.a0(this._pendingWorkerUpdate.diff,e),this._updateWorkerData(),this}getData(){return a._(this,void 0,void 0,function*(){const e=a.e({type:this.type},this.workerOptions);return this.actor.sendAsync({type:"GD",data:e})})}getCoordinatesFromGeometry(e){return e.type==="GeometryCollection"?e.geometries.map(n=>n.coordinates).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return a._(this,void 0,void 0,function*(){const e=new le,n=yield this.getData();let o;switch(n.type){case"FeatureCollection":o=n.features.map(c=>this.getCoordinatesFromGeometry(c.geometry)).flat(1/0);break;case"Feature":o=this.getCoordinatesFromGeometry(n.geometry);break;default:o=this.getCoordinatesFromGeometry(n)}if(o.length==0)return e;for(let c=0;c<o.length-1;c+=2)e.extend([o[c],o[c+1]]);return e})}setClusterOptions(e){return this.workerOptions.cluster=e.cluster,e&&(e.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=this._pixelsToTileUnits(e.clusterRadius)),e.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=this._getClusterMaxZoom(e.clusterMaxZoom))),this._updateWorkerData(),this}getClusterExpansionZoom(e){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:e,source:this.id}})}getClusterChildren(e){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:e,source:this.id}})}getClusterLeaves(e,n,o){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:e,limit:n,offset:o}})}_updateWorkerData(){return a._(this,void 0,void 0,function*(){if(this._isUpdatingWorker)return;const{data:e,diff:n}=this._pendingWorkerUpdate;if(!e&&!n)return void a.w(`No data or diff provided to GeoJSONSource ${this.id}.`);const o=a.e({type:this.type},this.workerOptions);e?(typeof e=="string"?(o.request=this.map._requestManager.transformRequest(Se.resolveURL(e),"Source"),o.request.collectResourceTiming=this._collectResourceTiming):o.data=JSON.stringify(e),this._pendingWorkerUpdate.data=void 0):n&&(o.dataDiff=n,this._pendingWorkerUpdate.diff=void 0),this._isUpdatingWorker=!0,this.fire(new a.l("dataloading",{dataType:"source"}));try{const c=yield this.actor.sendAsync({type:"LD",data:o});if(this._isUpdatingWorker=!1,this._removed||c.abandoned)return void this.fire(new a.l("dataabort",{dataType:"source"}));this._data=c.data;let d=null;c.resourceTiming&&c.resourceTiming[this.id]&&(d=c.resourceTiming[this.id].slice(0));const g={dataType:"source"};this._collectResourceTiming&&d&&d.length>0&&a.e(g,{resourceTiming:d}),this.fire(new a.l("data",Object.assign(Object.assign({},g),{sourceDataType:"metadata"}))),this.fire(new a.l("data",Object.assign(Object.assign({},g),{sourceDataType:"content"})))}catch(c){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new a.l("dataabort",{dataType:"source"}));this.fire(new a.k(c))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}})}loaded(){return!this._isUpdatingWorker&&this._pendingWorkerUpdate.data===void 0&&this._pendingWorkerUpdate.diff===void 0}loadTile(e){return a._(this,void 0,void 0,function*(){const n=e.actor?"RT":"LT";e.actor=this.actor;const o={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const c=yield this.actor.sendAsync({type:n,data:o},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(c,this.map.painter,n==="RT")})}abortTile(e){return a._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return a._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return a.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class $e extends a.E{constructor(e,n,o,c){super(),this.flippedWindingOrder=!1,this.id=e,this.dispatcher=o,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=n}load(e){return a._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new a.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield We.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,e&&(this.coordinates=e),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new a.k(n))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const n=e.map(a.a1.fromLngLat);var o;return this.tileID=function(c){const d=a.a2.fromPoints(c),g=d.width(),v=d.height(),x=Math.max(g,v),P=Math.max(0,Math.floor(-Math.log(x)/Math.LN2)),C=Math.pow(2,P);return new a.a4(P,Math.floor((d.minX+d.maxX)/2*C),Math.floor((d.minY+d.maxY)/2*C))}(n),this.terrainTileRanges=this._getOverlappingTileRanges(n),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=n.map(c=>this.tileID.getTilePoint(c)._round()),this.flippedWindingOrder=((o=this.tileCoords)[1].x-o[0].x)*(o[2].y-o[0].y)-(o[1].y-o[0].y)*(o[2].x-o[0].x)<0,this.fire(new a.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const e=this.map.painter.context,n=e.gl;this.texture||(this.texture=new a.T(e,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const c in this.tiles){const d=this.tiles[c];d.state!=="loaded"&&(d.state="loaded",d.texture=this.texture,o=!0)}o&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return a._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:n,minY:o,maxX:c,maxY:d}=a.a2.fromPoints(e),g={};for(let v=0;v<=a.a3;v++){const x=Math.pow(2,v),P=Math.floor(n*x),C=Math.floor(o*x),k=Math.floor(c*x),A=Math.floor(d*x);g[v]={minTileX:P,minTileY:C,maxTileX:k,maxTileY:A}}return g}}class Ge extends $e{constructor(e,n,o,c){super(e,n,o,c),this.roundZoom=!0,this.type="video",this.options=n}load(){return a._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const n of e.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield a.a5(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new a.k(n))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const n=this.video.seekable;e<n.start(0)||e>n.end(0)?this.fire(new a.k(new a.a6(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const e=this.map.painter.context,n=e.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new a.T(e,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let o=!1;for(const c in this.tiles){const d=this.tiles[c];d.state!=="loaded"&&(d.state="loaded",d.texture=this.texture,o=!0)}o&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class De extends $e{constructor(e,n,o,c){super(e,n,o,c),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(g=>typeof g!="number"))||this.fire(new a.k(new a.a6(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.k(new a.a6(`sources.${e}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new a.k(new a.a6(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new a.k(new a.a6(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new a.k(new a.a6(`sources.${e}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return a._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,o=n.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.T(n,this.canvas,o.RGBA,{premultiply:!0});let c=!1;for(const d in this.tiles){const g=this.tiles[d];g.state!=="loaded"&&(g.state="loaded",g.texture=this.texture,c=!0)}c&&this.fire(new a.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const ut={},Ke=h=>{switch(h){case"geojson":return qe;case"image":return $e;case"raster":return Ae;case"raster-dem":return Re;case"vector":return ze;case"video":return Ge;case"canvas":return De}return ut[h]},lt="RTLPluginLoaded";class mt extends a.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=tn()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return a._(this,arguments,void 0,function*(n,o=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=Se.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!o)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return a._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new a.l(lt))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let Ct=null;function Zt(){return Ct||(Ct=new mt),Ct}class Gt{constructor(e,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=a.a7(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const n=e+this.timeAdded;n<this.fadeEndTime||(this.fadeEndTime=n)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,n,o){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(c,d){const g={};if(!d)return g;for(const v of c){const x=v.layerIds.map(P=>d.getLayer(P)).filter(Boolean);if(x.length!==0){v.layers=x,v.stateDependentLayerIds&&(v.stateDependentLayers=v.stateDependentLayerIds.map(P=>x.filter(C=>C.id===P)[0]));for(const P of x)g[P.id]=v}}return g}(e.buckets,n==null?void 0:n.style),this.hasSymbolBuckets=!1;for(const c in this.buckets){const d=this.buckets[c];if(d instanceof a.a9){if(this.hasSymbolBuckets=!0,!o)break;d.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const c in this.buckets){const d=this.buckets[c];if(d instanceof a.a9&&d.hasRTLText){this.hasRTLText=!0,Zt().lazyLoad();break}}this.queryPadding=0;for(const c in this.buckets){const d=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(c).queryRadius(d))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new a.a8}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const o in this.buckets){const c=this.buckets[o];c.uploadPending()&&c.upload(e)}const n=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new a.T(e,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new a.T(e,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,n,o,c,d,g,v,x,P,C,k){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:d,scale:g,tileSize:this.tileSize,pixelPosMatrix:C,transform:x,params:v,queryPadding:this.queryPadding*P,getElevation:k},e,n,o):{}}querySourceFeatures(e,n){const o=this.latestFeatureIndex;if(!o||!o.rawTileData)return;const c=o.loadVTLayers(),d=n&&n.sourceLayer?n.sourceLayer:"",g=c._geojsonTileLayer||c[d];if(!g)return;const v=a.aa(n&&n.filter),{z:x,x:P,y:C}=this.tileID.canonical,k={z:x,x:P,y:C};for(let A=0;A<g.length;A++){const R=g.feature(A);if(v.needGeometry){const G=a.ab(R,!0);if(!v.filter(new a.F(this.tileID.overscaledZ),G,this.tileID.canonical))continue}else if(!v.filter(new a.F(this.tileID.overscaledZ),R))continue;const O=o.getId(R,d),Z=new a.ac(R,x,P,C,O);Z.tile=k,e.push(Z)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const n=this.expirationTime;if(e.cacheControl){const o=a.ad(e.cacheControl);o["max-age"]&&(this.expirationTime=Date.now()+1e3*o["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const o=Date.now();let c=!1;if(this.expirationTime>o)c=!1;else if(n)if(this.expirationTime<n)c=!0;else{const d=this.expirationTime-n;d?this.expirationTime=o+Math.max(d,3e4):c=!0}else c=!0;c?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,n){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0)return;const o=this.latestFeatureIndex.loadVTLayers();for(const c in this.buckets){if(!n.style.hasLayer(c))continue;const d=this.buckets[c],g=d.layers[0].sourceLayer||"_geojsonTileLayer",v=o[g],x=e[g];if(!v||!x||Object.keys(x).length===0)continue;d.update(x,v,this.imageAtlas&&this.imageAtlas.patternPositions||{});const P=n&&n.style&&n.style.getLayer(c);P&&(this.queryPadding=Math.max(this.queryPadding,P.queryRadius(d)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Se.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Se.now()+e}setDependencies(e,n){const o={};for(const c of n)o[c]=!0;this.dependencies[e]=o}hasDependency(e,n){for(const o of e){const c=this.dependencies[o];if(c){for(const d of n)if(c[d])return!0}}return!1}}class ae{constructor(e,n){this.max=e,this.onRemove=n,this.reset()}reset(){for(const e in this.data)for(const n of this.data[e])n.timeout&&clearTimeout(n.timeout),this.onRemove(n.value);return this.data={},this.order=[],this}add(e,n,o){const c=e.wrapped().key;this.data[c]===void 0&&(this.data[c]=[]);const d={value:n,timeout:void 0};if(o!==void 0&&(d.timeout=setTimeout(()=>{this.remove(e,d)},o)),this.data[c].push(d),this.order.push(c),this.order.length>this.max){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const n=this.data[e].shift();return n.timeout&&clearTimeout(n.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),n.value}getByKey(e){const n=this.data[e];return n?n[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,n){if(!this.has(e))return this;const o=e.wrapped().key,c=n===void 0?0:this.data[o].indexOf(n),d=this.data[o][c];return this.data[o].splice(c,1),d.timeout&&clearTimeout(d.timeout),this.data[o].length===0&&delete this.data[o],this.onRemove(d.value),this.order.splice(this.order.indexOf(o),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(e){const n=[];for(const o in this.data)for(const c of this.data[o])e(c.value)||n.push(c);for(const o of n)this.remove(o.value.tileID,o)}}class B{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,n,o){const c=String(n);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][c]=this.stateChanges[e][c]||{},a.e(this.stateChanges[e][c],o),this.deletedStates[e]===null){this.deletedStates[e]={};for(const d in this.state[e])d!==c&&(this.deletedStates[e][d]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][c]===null){this.deletedStates[e][c]={};for(const d in this.state[e][c])o[d]||(this.deletedStates[e][c][d]=null)}else for(const d in o)this.deletedStates[e]&&this.deletedStates[e][c]&&this.deletedStates[e][c][d]===null&&delete this.deletedStates[e][c][d]}removeFeatureState(e,n,o){if(this.deletedStates[e]===null)return;const c=String(n);if(this.deletedStates[e]=this.deletedStates[e]||{},o&&n!==void 0)this.deletedStates[e][c]!==null&&(this.deletedStates[e][c]=this.deletedStates[e][c]||{},this.deletedStates[e][c][o]=null);else if(n!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][c])for(o in this.deletedStates[e][c]={},this.stateChanges[e][c])this.deletedStates[e][c][o]=null;else this.deletedStates[e][c]=null;else this.deletedStates[e]=null}getState(e,n){const o=String(n),c=a.e({},(this.state[e]||{})[o],(this.stateChanges[e]||{})[o]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const d=this.deletedStates[e][n];if(d===null)return{};for(const g in d)delete c[g]}return c}initializeTileState(e,n){e.setFeatureState(this.state,n)}coalesceChanges(e,n){const o={};for(const c in this.stateChanges){this.state[c]=this.state[c]||{};const d={};for(const g in this.stateChanges[c])this.state[c][g]||(this.state[c][g]={}),a.e(this.state[c][g],this.stateChanges[c][g]),d[g]=this.state[c][g];o[c]=d}for(const c in this.deletedStates){this.state[c]=this.state[c]||{};const d={};if(this.deletedStates[c]===null)for(const g in this.state[c])d[g]={},this.state[c][g]={};else for(const g in this.deletedStates[c]){if(this.deletedStates[c][g]===null)this.state[c][g]={};else for(const v of Object.keys(this.deletedStates[c][g]))delete this.state[c][g][v];d[g]=this.state[c][g]}o[c]=o[c]||{},a.e(o[c],d)}if(this.stateChanges={},this.deletedStates={},Object.keys(o).length!==0)for(const c in e)e[c].setFeatureState(o,n)}}const j=89.25;function U(h,e){const n=a.ah(e.lat,-a.ai,a.ai);return new a.P(a.V(e.lng)*h,a.U(n)*h)}function X(h,e){return new a.a1(e.x/h,e.y/h).toLngLat()}function ie(h){return h.cameraToCenterDistance*Math.min(.85*Math.tan(a.ae(90-h.pitch)),Math.tan(a.ae(j-h.pitch)))}function ce(h,e){const n=h.canonical,o=e/a.af(n.z),c=n.x+Math.pow(2,n.z)*h.wrap,d=a.ag(new Float64Array(16));return a.M(d,d,[c*o,n.y*o,0]),a.N(d,d,[o/a.$,o/a.$,1]),d}function me(h,e,n,o,c){const d=a.a1.fromLngLat(h,e),g=c*a.aj(1,h.lat),v=g*Math.cos(a.ae(n)),x=Math.sqrt(g*g-v*v),P=x*Math.sin(a.ae(-o)),C=x*Math.cos(a.ae(-o));return new a.a1(d.x+P,d.y+C,d.z+v)}function de(h,e,n){const o=e.intersectsFrustum(h);if(!n||o===0)return o;const c=e.intersectsPlane(n);return c===0?0:o===2&&c===2?2:1}function Pe(h,e,n){let o=0;const c=(n-e)/10;for(let d=0;d<10;d++)o+=c*Math.pow(Math.cos(e+(d+.5)/10*(n-e)),h);return o}function ke(h,e){return function(n,o,c,d,g){const v=2*((h-1)/a.ak(Math.cos(a.ae(j-g))/Math.cos(a.ae(j)))-1),x=Math.acos(c/d),P=2*Pe(v-1,0,a.ae(g/2)),C=Math.min(a.ae(j),x+a.ae(g/2)),k=Pe(v-1,Math.min(C,x-a.ae(g/2)),C),A=Math.atan(o/c),R=Math.hypot(o,c);let O=n;return O+=a.ak(d/R/Math.max(.5,Math.cos(a.ae(g/2)))),O+=v*a.ak(Math.cos(A))/2,O-=a.ak(Math.max(1,k/P/e))/2,O}}const Ce=ke(9.314,3);function it(h,e){const n=(e.roundZoom?Math.round:Math.floor)(h.zoom+a.ak(h.tileSize/e.tileSize));return Math.max(0,n)}function fe(h,e){const n=h.getCameraFrustum(),o=h.getClippingPlane(),c=h.screenPointToMercatorCoordinate(h.getCameraPoint()),d=a.a1.fromLngLat(h.center,h.elevation);c.z=d.z+Math.cos(h.pitchInRadians)*h.cameraToCenterDistance/h.worldSize;const g=h.getCoveringTilesDetailsProvider(),v=g.allowVariableZoom(h,e),x=it(h,e),P=e.minzoom||0,C=e.maxzoom!==void 0?e.maxzoom:h.maxZoom,k=Math.min(Math.max(0,x),C),A=Math.pow(2,k),R=[A*c.x,A*c.y,0],O=[A*d.x,A*d.y,0],Z=Math.hypot(d.x-c.x,d.y-c.y),G=Math.abs(d.z-c.z),q=Math.hypot(Z,G),W=te=>({zoom:0,x:0,y:0,wrap:te,fullyVisible:!1}),J=[],K=[];if(h.renderWorldCopies&&g.allowWorldCopies())for(let te=1;te<=3;te++)J.push(W(-te)),J.push(W(te));for(J.push(W(0));J.length>0;){const te=J.pop(),se=te.x,Y=te.y;let pe=te.fullyVisible;const be={x:se,y:Y,z:te.zoom},_e=g.getTileBoundingVolume(be,te.wrap,h.elevation,e);if(!pe){const Oe=de(n,_e,o);if(Oe===0)continue;pe=Oe===2}const ye=g.distanceToTile2d(c.x,c.y,be,_e);let xe=x;v&&(xe=(e.calculateTileZoom||Ce)(h.zoom+a.ak(h.tileSize/e.tileSize),ye,G,q,h.fov)),xe=(e.roundZoom?Math.round:Math.floor)(xe),xe=Math.max(0,xe);const Le=Math.min(xe,C);if(te.wrap=g.getWrap(d,be,te.wrap),te.zoom>=Le){if(te.zoom<P)continue;const Oe=k-te.zoom,Ie=R[0]-.5-(se<<Oe),et=R[1]-.5-(Y<<Oe),Tt=e.reparseOverscaled?Math.max(te.zoom,xe):te.zoom;K.push({tileID:new a.Z(te.zoom===C?Tt:te.zoom,te.wrap,te.zoom,se,Y),distanceSq:a.al([O[0]-.5-se,O[1]-.5-Y]),tileDistanceToCamera:Math.sqrt(Ie*Ie+et*et)})}else for(let Oe=0;Oe<4;Oe++)J.push({zoom:te.zoom+1,x:(se<<1)+Oe%2,y:(Y<<1)+(Oe>>1),wrap:te.wrap,fullyVisible:pe})}return K.sort((te,se)=>te.distanceSq-se.distanceSq).map(te=>te.tileID)}const _t=a.a2.fromPoints([new a.P(0,0),new a.P(a.$,a.$)]);class At extends a.E{constructor(e,n,o){super(),this.id=e,this.dispatcher=o,this.on("data",c=>this._dataHandler(c)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((c,d,g,v)=>{const x=new(Ke(d.type))(c,d,g,v);if(x.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${x.id}`);return x})(e,n,o,this),this._tiles={},this._cache=new ae(0,c=>this._unloadTile(c)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new B,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const n=this._tiles[e];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,n,o){return a._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,n,o)}catch(c){e.state="errored",c.status!==404?this._source.fire(new a.k(c,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new a.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const o=this._tiles[n];o.upload(e),o.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(ot).map(e=>e.key)}getRenderableIds(e){const n=[];for(const o in this._tiles)this._isIdRenderable(o,e)&&n.push(this._tiles[o]);return e?n.sort((o,c)=>{const d=o.tileID,g=c.tileID,v=new a.P(d.canonical.x,d.canonical.y)._rotate(-this.transform.bearingInRadians),x=new a.P(g.canonical.x,g.canonical.y)._rotate(-this.transform.bearingInRadians);return d.overscaledZ-g.overscaledZ||x.y-v.y||x.x-v.x}).map(o=>o.tileID.key):n.map(o=>o.tileID).sort(ot).map(o=>o.key)}hasRenderableParent(e){const n=this.findLoadedParent(e,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(e,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(n||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)e?this._reloadTile(n,"expired"):this._tiles[n].state!=="errored"&&this._reloadTile(n,"reloading")}}_reloadTile(e,n){return a._(this,void 0,void 0,function*(){const o=this._tiles[e];o&&(o.state!=="loading"&&(o.state=n),yield this._loadTile(o,e,n))})}_tileLoaded(e,n,o){e.timeAdded=Se.now(),o==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(n,e),this.getSource().type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new a.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const n=this.getRenderableIds();for(let c=0;c<n.length;c++){const d=n[c];if(e.neighboringTiles&&e.neighboringTiles[d]){const g=this.getTileByID(d);o(e,g),o(g,e)}}function o(c,d){c.needsHillshadePrepare=!0,c.needsTerrainPrepare=!0;let g=d.tileID.canonical.x-c.tileID.canonical.x;const v=d.tileID.canonical.y-c.tileID.canonical.y,x=Math.pow(2,c.tileID.canonical.z),P=d.tileID.key;g===0&&v===0||Math.abs(v)>1||(Math.abs(g)>1&&(Math.abs(g+x)===1?g+=x:Math.abs(g-x)===1&&(g-=x)),d.dem&&c.dem&&(c.dem.backfillBorder(d.dem,g,v),c.neighboringTiles&&c.neighboringTiles[P]&&(c.neighboringTiles[P].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,n,o,c){for(const d in this._tiles){let g=this._tiles[d];if(c[d]||!g.hasData()||g.tileID.overscaledZ<=n||g.tileID.overscaledZ>o)continue;let v=g.tileID;for(;g&&g.tileID.overscaledZ>n+1;){const P=g.tileID.scaledTo(g.tileID.overscaledZ-1);g=this._tiles[P.key],g&&g.hasData()&&(v=P)}let x=v;for(;x.overscaledZ>n;)if(x=x.scaledTo(x.overscaledZ-1),e[x.key]||e[x.canonical.key]){c[v.key]=v;break}}}findLoadedParent(e,n){if(e.key in this._loadedParentTiles){const o=this._loadedParentTiles[e.key];return o&&o.tileID.overscaledZ>=n?o:null}for(let o=e.overscaledZ-1;o>=n;o--){const c=e.scaledTo(o),d=this._getLoadedTile(c);if(d)return d}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const n=this._tiles[e.key];return n&&n.hasData()?n:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const n=Math.ceil(e.width/this._source.tileSize)+1,o=Math.ceil(e.height/this._source.tileSize)+1,c=Math.floor(n*o*(this._maxTileCacheZoomLevels===null?a.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),d=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(d)}handleWrapJump(e){const n=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,n){const o={};for(const c in this._tiles){const d=this._tiles[c];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+n),o[d.tileID.key]=d}this._tiles=o;for(const c in this._timers)clearTimeout(this._timers[c]),delete this._timers[c];for(const c in this._tiles)this._setTileReloadTimer(c,this._tiles[c])}}_updateCoveredAndRetainedTiles(e,n,o,c,d,g){const v={},x={},P=Object.keys(e),C=Se.now();for(const k of P){const A=e[k],R=this._tiles[k];if(!R||R.fadeEndTime!==0&&R.fadeEndTime<=C)continue;const O=this.findLoadedParent(A,n),Z=this.findLoadedSibling(A),G=O||Z||null;G&&(this._addTile(G.tileID),v[G.tileID.key]=G.tileID),x[k]=A}this._retainLoadedChildren(x,c,o,e);for(const k in v)e[k]||(this._coveredTiles[k]=!0,e[k]=v[k]);if(g){const k={},A={};for(const R of d)this._tiles[R.key].hasData()?k[R.key]=R:A[R.key]=R;for(const R in A){const O=A[R].children(this._source.maxzoom);this._tiles[O[0].key]&&this._tiles[O[1].key]&&this._tiles[O[2].key]&&this._tiles[O[3].key]&&(k[O[0].key]=e[O[0].key]=O[0],k[O[1].key]=e[O[1].key]=O[1],k[O[2].key]=e[O[2].key]=O[2],k[O[3].key]=e[O[3].key]=O[3],delete A[R])}for(const R in A){const O=A[R],Z=this.findLoadedParent(O,this._source.minzoom),G=this.findLoadedSibling(O),q=Z||G||null;if(q){k[q.tileID.key]=e[q.tileID.key]=q.tileID;for(const W in k)k[W].isChildOf(q.tileID)&&delete k[W]}}for(const R in this._tiles)k[R]||(this._coveredTiles[R]=!0)}}update(e,n){if(!this._sourceLoaded||this._paused)return;let o;this.transform=e,this.terrain=n,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?o=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(C=>new a.Z(C.canonical.z,C.wrap,C.canonical.z,C.canonical.x,C.canonical.y)):(o=fe(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(o=o.filter(C=>this._source.hasTile(C)))):o=[];const c=it(e,this._source),d=Math.max(c-At.maxOverzooming,this._source.minzoom),g=Math.max(c+At.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const C={};for(const k of o)if(k.canonical.z>this._source.minzoom){const A=k.scaledTo(k.canonical.z-1);C[A.key]=A;const R=k.scaledTo(Math.max(this._source.minzoom,Math.min(k.canonical.z,5)));C[R.key]=R}o=o.concat(Object.values(C))}const v=o.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,v&&this.fire(new a.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const x=this._updateRetainedTiles(o,c);xt(this._source.type)&&this._updateCoveredAndRetainedTiles(x,d,g,c,o,n);for(const C in x)this._tiles[C].clearFadeHold();const P=a.am(this._tiles,x);for(const C of P){const k=this._tiles[C];k.hasSymbolBuckets&&!k.holdingForFade()?k.setHoldDuration(this.map._fadeDuration):k.hasSymbolBuckets&&!k.symbolFadeFinished()||this._removeTile(C)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,n){var o;const c={},d={},g=Math.max(n-At.maxOverzooming,this._source.minzoom),v=Math.max(n+At.maxUnderzooming,this._source.minzoom),x={};for(const P of e){const C=this._addTile(P);c[P.key]=P,C.hasData()||n<this._source.maxzoom&&(x[P.key]=P)}this._retainLoadedChildren(x,n,v,c);for(const P of e){let C=this._tiles[P.key];if(C.hasData())continue;if(n+1>this._source.maxzoom){const A=P.children(this._source.maxzoom)[0],R=this.getTile(A);if(R&&R.hasData()){c[A.key]=A;continue}}else{const A=P.children(this._source.maxzoom);if(c[A[0].key]&&c[A[1].key]&&c[A[2].key]&&c[A[3].key])continue}let k=C.wasRequested();for(let A=P.overscaledZ-1;A>=g;--A){const R=P.scaledTo(A);if(d[R.key])break;if(d[R.key]=!0,C=this.getTile(R),!C&&k&&(C=this._addTile(R)),C){const O=C.hasData();if((O||!(!((o=this.map)===null||o===void 0)&&o.cancelPendingTileRequestsWhileZooming)||k)&&(c[R.key]=R),k=C.wasRequested(),O)break}}}return c}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const n=[];let o,c=this._tiles[e].tileID;for(;c.overscaledZ>0;){if(c.key in this._loadedParentTiles){o=this._loadedParentTiles[c.key];break}n.push(c.key);const d=c.scaledTo(c.overscaledZ-1);if(o=this._getLoadedTile(d),o)break;c=d}for(const d of n)this._loadedParentTiles[d]=o}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const n=this._tiles[e].tileID,o=this._getLoadedTile(n);this._loadedSiblingTiles[n.key]=o}}_addTile(e){let n=this._tiles[e.key];if(n)return n;n=this._cache.getAndRemove(e),n&&(this._setTileReloadTimer(e.key,n),n.tileID=e,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,n)));const o=n;return n||(n=new Gt(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(n,e.key,n.state)),n.uses++,this._tiles[e.key]=n,o||this._source.fire(new a.l("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(e,n){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const o=n.getExpiryTimeout();o&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},o))}refreshTiles(e){for(const n in this._tiles)(this._isIdRenderable(n)||this._tiles[n].state=="errored")&&e.some(o=>o.equals(this._tiles[n].tileID.canonical))&&this._reloadTile(n,"expired")}_removeTile(e){const n=this._tiles[e];n&&(n.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(e){const n=e.sourceDataType;e.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&e.dataType==="source"&&n==="content"&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,n,o){const c=[],d=this.transform;if(!d)return c;const g=d.getCoveringTilesDetailsProvider().allowWorldCopies(),v=o?d.getCameraQueryGeometry(e):e,x=R=>d.screenPointToMercatorCoordinate(R,this.terrain),P=this.transformBbox(e,x,!g),C=this.transformBbox(v,x,!g),k=this.getIds(),A=a.a2.fromPoints(C);for(let R=0;R<k.length;R++){const O=this._tiles[k[R]];if(O.holdingForFade())continue;const Z=g?[O.tileID]:[O.tileID.unwrapTo(-1),O.tileID.unwrapTo(0)],G=Math.pow(2,d.zoom-O.tileID.overscaledZ),q=n*O.queryPadding*a.$/O.tileSize/G;for(const W of Z){const J=A.map(K=>W.getTilePoint(new a.a1(K.x,K.y)));if(J.expandBy(q),J.intersects(_t)){const K=P.map(se=>W.getTilePoint(se)),te=C.map(se=>W.getTilePoint(se));c.push({tile:O,tileID:g?W:W.unwrapTo(0),queryGeometry:K,cameraQueryGeometry:te,scale:G})}}}return c}transformBbox(e,n,o){let c=e.map(n);if(o){const d=a.a2.fromPoints(e);d.shrinkBy(.001*Math.min(d.width(),d.height()));const g=d.map(n);a.a2.fromPoints(c).covers(g)||(c=c.map(v=>v.x>.5?new a.a1(v.x-1,v.y,v.z):v))}return c}getVisibleCoordinates(e){const n=this.getRenderableIds(e).map(o=>this._tiles[o].tileID);return this.transform&&this.transform.populateCache(n),n}hasTransition(){if(this._source.hasTransition())return!0;if(xt(this._source.type)){const e=Se.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=e)return!0}return!1}setFeatureState(e,n,o){this._state.updateState(e=e||"_geojsonTileLayer",n,o)}removeFeatureState(e,n,o){this._state.removeFeatureState(e=e||"_geojsonTileLayer",n,o)}getFeatureState(e,n){return this._state.getState(e=e||"_geojsonTileLayer",n)}setDependencies(e,n,o){const c=this._tiles[e];c&&c.setDependencies(n,o)}reloadTilesForDependencies(e,n){for(const o in this._tiles)this._tiles[o].hasDependency(e,n)&&this._reloadTile(o,"reloading");this._cache.filter(o=>!o.hasDependency(e,n))}}function ot(h,e){const n=Math.abs(2*h.wrap)-+(h.wrap<0),o=Math.abs(2*e.wrap)-+(e.wrap<0);return h.overscaledZ-e.overscaledZ||o-n||e.canonical.y-h.canonical.y||e.canonical.x-h.canonical.x}function xt(h){return h==="raster"||h==="image"||h==="video"}At.maxOverzooming=10,At.maxUnderzooming=3;class oi{constructor(e,n){this.reset(e,n)}reset(e,n){this.points=e||[],this._distances=[0];for(let o=1;o<this.points.length;o++)this._distances[o]=this._distances[o-1]+this.points[o].dist(this.points[o-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(n||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(e){if(this.points.length===1)return this.points[0];e=a.ah(e,0,1);let n=1,o=this._distances[n];const c=e*this.paddedLength+this.padding;for(;o<c&&n<this._distances.length;)o=this._distances[++n];const d=n-1,g=this._distances[d],v=o-g,x=v>0?(c-g)/v:0;return this.points[d].mult(1-x).add(this.points[n].mult(x))}}function ji(h,e){let n=!0;return h==="always"||h!=="never"&&e!=="never"||(n=!1),n}class Ni{constructor(e,n,o){const c=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(e/o),this.yCellCount=Math.ceil(n/o);for(let g=0;g<this.xCellCount*this.yCellCount;g++)c.push([]),d.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=n,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/n,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,n,o,c,d){this._forEachCell(n,o,c,d,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(n),this.bboxes.push(o),this.bboxes.push(c),this.bboxes.push(d)}insertCircle(e,n,o,c){this._forEachCell(n-c,o-c,n+c,o+c,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(n),this.circles.push(o),this.circles.push(c)}_insertBoxCell(e,n,o,c,d,g){this.boxCells[d].push(g)}_insertCircleCell(e,n,o,c,d,g){this.circleCells[d].push(g)}_query(e,n,o,c,d,g,v){if(o<0||e>this.width||c<0||n>this.height)return[];const x=[];if(e<=0&&n<=0&&this.width<=o&&this.height<=c){if(d)return[{key:null,x1:e,y1:n,x2:o,y2:c}];for(let P=0;P<this.boxKeys.length;P++)x.push({key:this.boxKeys[P],x1:this.bboxes[4*P],y1:this.bboxes[4*P+1],x2:this.bboxes[4*P+2],y2:this.bboxes[4*P+3]});for(let P=0;P<this.circleKeys.length;P++){const C=this.circles[3*P],k=this.circles[3*P+1],A=this.circles[3*P+2];x.push({key:this.circleKeys[P],x1:C-A,y1:k-A,x2:C+A,y2:k+A})}}else this._forEachCell(e,n,o,c,this._queryCell,x,{hitTest:d,overlapMode:g,seenUids:{box:{},circle:{}}},v);return x}query(e,n,o,c){return this._query(e,n,o,c,!1,null)}hitTest(e,n,o,c,d,g){return this._query(e,n,o,c,!0,d,g).length>0}hitTestCircle(e,n,o,c,d){const g=e-o,v=e+o,x=n-o,P=n+o;if(v<0||g>this.width||P<0||x>this.height)return!1;const C=[];return this._forEachCell(g,x,v,P,this._queryCellCircle,C,{hitTest:!0,overlapMode:c,circle:{x:e,y:n,radius:o},seenUids:{box:{},circle:{}}},d),C.length>0}_queryCell(e,n,o,c,d,g,v,x){const{seenUids:P,hitTest:C,overlapMode:k}=v,A=this.boxCells[d];if(A!==null){const O=this.bboxes;for(const Z of A)if(!P.box[Z]){P.box[Z]=!0;const G=4*Z,q=this.boxKeys[Z];if(e<=O[G+2]&&n<=O[G+3]&&o>=O[G+0]&&c>=O[G+1]&&(!x||x(q))&&(!C||!ji(k,q.overlapMode))&&(g.push({key:q,x1:O[G],y1:O[G+1],x2:O[G+2],y2:O[G+3]}),C))return!0}}const R=this.circleCells[d];if(R!==null){const O=this.circles;for(const Z of R)if(!P.circle[Z]){P.circle[Z]=!0;const G=3*Z,q=this.circleKeys[Z];if(this._circleAndRectCollide(O[G],O[G+1],O[G+2],e,n,o,c)&&(!x||x(q))&&(!C||!ji(k,q.overlapMode))){const W=O[G],J=O[G+1],K=O[G+2];if(g.push({key:q,x1:W-K,y1:J-K,x2:W+K,y2:J+K}),C)return!0}}}return!1}_queryCellCircle(e,n,o,c,d,g,v,x){const{circle:P,seenUids:C,overlapMode:k}=v,A=this.boxCells[d];if(A!==null){const O=this.bboxes;for(const Z of A)if(!C.box[Z]){C.box[Z]=!0;const G=4*Z,q=this.boxKeys[Z];if(this._circleAndRectCollide(P.x,P.y,P.radius,O[G+0],O[G+1],O[G+2],O[G+3])&&(!x||x(q))&&!ji(k,q.overlapMode))return g.push(!0),!0}}const R=this.circleCells[d];if(R!==null){const O=this.circles;for(const Z of R)if(!C.circle[Z]){C.circle[Z]=!0;const G=3*Z,q=this.circleKeys[Z];if(this._circlesCollide(O[G],O[G+1],O[G+2],P.x,P.y,P.radius)&&(!x||x(q))&&!ji(k,q.overlapMode))return g.push(!0),!0}}}_forEachCell(e,n,o,c,d,g,v,x){const P=this._convertToXCellCoord(e),C=this._convertToYCellCoord(n),k=this._convertToXCellCoord(o),A=this._convertToYCellCoord(c);for(let R=P;R<=k;R++)for(let O=C;O<=A;O++)if(d.call(this,e,n,o,c,this.xCellCount*O+R,g,v,x))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,n,o,c,d,g){const v=c-e,x=d-n,P=o+g;return P*P>v*v+x*x}_circleAndRectCollide(e,n,o,c,d,g,v){const x=(g-c)/2,P=Math.abs(e-(c+x));if(P>x+o)return!1;const C=(v-d)/2,k=Math.abs(n-(d+C));if(k>C+o)return!1;if(P<=x||k<=C)return!0;const A=P-x,R=k-C;return A*A+R*R<=o*o}}function Ii(h,e,n){const o=a.L();if(!h){const{vecSouth:k,vecEast:A}=Ut(e),R=ue();R[0]=A[0],R[1]=A[1],R[2]=k[0],R[3]=k[1],c=R,(C=(g=(d=R)[0])*(P=d[3])-(x=d[2])*(v=d[1]))&&(c[0]=P*(C=1/C),c[1]=-v*C,c[2]=-x*C,c[3]=g*C),o[0]=R[0],o[1]=R[1],o[4]=R[2],o[5]=R[3]}var c,d,g,v,x,P,C;return a.N(o,o,[1/n,1/n,1]),o}function Dt(h,e,n,o){if(h){const c=a.L();if(!e){const{vecSouth:d,vecEast:g}=Ut(n);c[0]=g[0],c[1]=g[1],c[4]=d[0],c[5]=d[1]}return a.N(c,c,[o,o,1]),c}return n.pixelsToClipSpaceMatrix}function Ut(h){const e=Math.cos(h.rollInRadians),n=Math.sin(h.rollInRadians),o=Math.cos(h.pitchInRadians),c=Math.cos(h.bearingInRadians),d=Math.sin(h.bearingInRadians),g=a.ar();g[0]=-c*o*n-d*e,g[1]=-d*o*n+c*e;const v=a.as(g);v<1e-9?a.at(g):a.au(g,g,1/v);const x=a.ar();x[0]=c*o*e-d*n,x[1]=d*o*e+c*n;const P=a.as(x);return P<1e-9?a.at(x):a.au(x,x,1/P),{vecEast:x,vecSouth:g}}function ki(h,e,n,o){let c;o?(c=[h,e,o(h,e),1],a.aw(c,c,n)):(c=[h,e,0,1],Xs(c,c,n));const d=c[3];return{point:new a.P(c[0]/d,c[1]/d),signedDistanceFromCamera:d,isOccluded:!1}}function Fe(h,e){return .5+h/e*.5}function cr(h,e){return h.x>=-e[0]&&h.x<=e[0]&&h.y>=-e[1]&&h.y<=e[1]}function gi(h,e,n,o,c,d,g,v,x,P,C,k,A){const R=n?h.textSizeData:h.iconSizeData,O=a.an(R,e.transform.zoom),Z=[256/e.width*2+1,256/e.height*2+1],G=n?h.text.dynamicLayoutVertexArray:h.icon.dynamicLayoutVertexArray;G.clear();const q=h.lineVertexArray,W=n?h.text.placedSymbolArray:h.icon.placedSymbolArray,J=e.transform.width/e.transform.height;let K=!1;for(let te=0;te<W.length;te++){const se=W.get(te);if(se.hidden||se.writingMode===a.ao.vertical&&!K){bn(se.numGlyphs,G);continue}K=!1;const Y=new a.P(se.anchorX,se.anchorY),pe={getElevation:A,pitchedLabelPlaneMatrix:o,lineVertexArray:q,pitchWithMap:d,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:Y,unwrappedTileID:x,width:P,height:C,translation:k},be=Xn(se.anchorX,se.anchorY,pe);if(!cr(be.point,Z)){bn(se.numGlyphs,G);continue}const _e=Fe(e.transform.cameraToCenterDistance,be.signedDistanceFromCamera),ye=a.ap(R,O,se),xe=d?ye*e.transform.getPitchedTextCorrection(se.anchorX,se.anchorY,x)/_e:ye*_e,Le=Ze({projectionContext:pe,pitchedLabelPlaneMatrixInverse:c,symbol:se,fontSize:xe,flip:!1,keepUpright:g,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:G,aspectRatio:J,rotateToLine:v});K=Le.useVertical,(Le.notEnoughRoom||K||Le.needsFlipping&&Ze({projectionContext:pe,pitchedLabelPlaneMatrixInverse:c,symbol:se,fontSize:xe,flip:!0,keepUpright:g,glyphOffsetArray:h.glyphOffsetArray,dynamicLayoutVertexArray:G,aspectRatio:J,rotateToLine:v}).notEnoughRoom)&&bn(se.numGlyphs,G)}n?h.text.dynamicLayoutVertexBuffer.updateData(G):h.icon.dynamicLayoutVertexBuffer.updateData(G)}function Wn(h,e,n,o,c,d,g,v){const x=d.glyphStartIndex+d.numGlyphs,P=d.lineStartIndex,C=d.lineStartIndex+d.lineLength,k=e.getoffsetX(d.glyphStartIndex),A=e.getoffsetX(x-1),R=Kn(h*k,n,o,c,d.segment,P,C,v,g);if(!R)return null;const O=Kn(h*A,n,o,c,d.segment,P,C,v,g);return O?v.projectionCache.anyProjectionOccluded?null:{first:R,last:O}:null}function Ws(h,e,n,o){return h===a.ao.horizontal&&Math.abs(n.y-e.y)>Math.abs(n.x-e.x)*o?{useVertical:!0}:(h===a.ao.vertical?e.y<n.y:e.x>n.x)?{needsFlipping:!0}:null}function Ze(h){const{projectionContext:e,pitchedLabelPlaneMatrixInverse:n,symbol:o,fontSize:c,flip:d,keepUpright:g,glyphOffsetArray:v,dynamicLayoutVertexArray:x,aspectRatio:P,rotateToLine:C}=h,k=c/24,A=o.lineOffsetX*k,R=o.lineOffsetY*k;let O;if(o.numGlyphs>1){const Z=o.glyphStartIndex+o.numGlyphs,G=o.lineStartIndex,q=o.lineStartIndex+o.lineLength,W=Wn(k,v,A,R,d,o,C,e);if(!W)return{notEnoughRoom:!0};const J=vs(W.first.point.x,W.first.point.y,e,n),K=vs(W.last.point.x,W.last.point.y,e,n);if(g&&!d){const te=Ws(o.writingMode,J,K,P);if(te)return te}O=[W.first];for(let te=o.glyphStartIndex+1;te<Z-1;te++){const se=Kn(k*v.getoffsetX(te),A,R,d,o.segment,G,q,e,C);if(!se)return{notEnoughRoom:!0};O.push(se)}O.push(W.last)}else{if(g&&!d){const G=ir(e.tileAnchorPoint.x,e.tileAnchorPoint.y,e).point,q=o.lineStartIndex+o.segment+1,W=new a.P(e.lineVertexArray.getx(q),e.lineVertexArray.gety(q)),J=ir(W.x,W.y,e),K=J.signedDistanceFromCamera>0?J.point:kt(e.tileAnchorPoint,W,G,1,e),te=vs(G.x,G.y,e,n),se=vs(K.x,K.y,e,n),Y=Ws(o.writingMode,te,se,P);if(Y)return Y}const Z=Kn(k*v.getoffsetX(o.glyphStartIndex),A,R,d,o.segment,o.lineStartIndex,o.lineStartIndex+o.lineLength,e,C);if(!Z||e.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};O=[Z]}for(const Z of O)a.av(x,Z.point,Z.angle);return{}}function kt(h,e,n,o,c){const d=h.add(h.sub(e)._unit()),g=ir(d.x,d.y,c).point,v=n.sub(g);return n.add(v._mult(o/v.mag()))}function Pt(h,e,n){const o=e.projectionCache;if(o.projections[h])return o.projections[h];const c=new a.P(e.lineVertexArray.getx(h),e.lineVertexArray.gety(h)),d=ir(c.x,c.y,e);if(d.signedDistanceFromCamera>0)return o.projections[h]=d.point,o.anyProjectionOccluded=o.anyProjectionOccluded||d.isOccluded,d.point;const g=h-n.direction;return kt(n.distanceFromAnchor===0?e.tileAnchorPoint:new a.P(e.lineVertexArray.getx(g),e.lineVertexArray.gety(g)),c,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,e)}function ir(h,e,n){const o=h+n.translation[0],c=e+n.translation[1];let d;return n.pitchWithMap?(d=ki(o,c,n.pitchedLabelPlaneMatrix,n.getElevation),d.isOccluded=!1):(d=n.transform.projectTileCoordinates(o,c,n.unwrappedTileID,n.getElevation),d.point.x=(.5*d.point.x+.5)*n.width,d.point.y=(.5*-d.point.y+.5)*n.height),d}function vs(h,e,n,o){if(n.pitchWithMap){const c=[h,e,0,1];return a.aw(c,c,o),n.transform.projectTileCoordinates(c[0]/c[3],c[1]/c[3],n.unwrappedTileID,n.getElevation).point}return{x:h/n.width*2-1,y:1-e/n.height*2}}function Xn(h,e,n){return n.transform.projectTileCoordinates(h,e,n.unwrappedTileID,n.getElevation)}function wt(h,e,n){return h._unit()._perp()._mult(e*n)}function Aa(h,e,n,o,c,d,g,v,x){if(v.projectionCache.offsets[h])return v.projectionCache.offsets[h];const P=n.add(e);if(h+x.direction<o||h+x.direction>=c)return v.projectionCache.offsets[h]=P,P;const C=Pt(h+x.direction,v,x),k=wt(C.sub(n),g,x.direction),A=n.add(k),R=C.add(k);return v.projectionCache.offsets[h]=a.ax(d,P,A,R)||P,v.projectionCache.offsets[h]}function Kn(h,e,n,o,c,d,g,v,x){const P=o?h-e:h+e;let C=P>0?1:-1,k=0;o&&(C*=-1,k=Math.PI),C<0&&(k+=Math.PI);let A,R=C>0?d+c:d+c+1;v.projectionCache.cachedAnchorPoint?A=v.projectionCache.cachedAnchorPoint:(A=ir(v.tileAnchorPoint.x,v.tileAnchorPoint.y,v).point,v.projectionCache.cachedAnchorPoint=A);let O,Z,G=A,q=A,W=0,J=0;const K=Math.abs(P),te=[];let se;for(;W+J<=K;){if(R+=C,R<d||R>=g)return null;W+=J,q=G,Z=O;const be={absOffsetX:K,direction:C,distanceFromAnchor:W,previousVertex:q};if(G=Pt(R,v,be),n===0)te.push(q),se=G.sub(q);else{let _e;const ye=G.sub(q);_e=ye.mag()===0?wt(Pt(R+C,v,be).sub(G),n,C):wt(ye,n,C),Z||(Z=q.add(_e)),O=Aa(R,_e,G,d,g,Z,n,v,be),te.push(Z),se=O.sub(Z)}J=se.mag()}const Y=se._mult((K-W)/J)._add(Z||q),pe=k+Math.atan2(G.y-q.y,G.x-q.x);return te.push(Y),{point:Y,angle:x?pe:0,path:te}}const ka=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function bn(h,e){for(let n=0;n<h;n++){const o=e.length;e.resize(o+4),e.float32.set(ka,3*o)}}function Xs(h,e,n){const o=e[0],c=e[1];return h[0]=n[0]*o+n[4]*c+n[12],h[1]=n[1]*o+n[5]*c+n[13],h[3]=n[3]*o+n[7]*c+n[15],h}const wi=100;class za{constructor(e,n=new Ni(e.width+200,e.height+200,25),o=new Ni(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=o,this.pitchFactor=Math.cos(e.pitch*Math.PI/180)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+wi,this.screenBottomBoundary=e.height+wi,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(e,n,o,c,d,g,v,x,P,C,k,A){const R=this.projectAndGetPerspectiveRatio(e.anchorPointX+x[0],e.anchorPointY+x[1],d,C,A),O=o*R.perspectiveRatio;let Z;if(g||v)Z=this._projectCollisionBox(e,O,c,d,g,v,x,R,C,k,A);else{const se=R.x+(k?k.x*O:0),Y=R.y+(k?k.y*O:0);Z={allPointsOccluded:!1,box:[se+e.x1*O,Y+e.y1*O,se+e.x2*O,Y+e.y2*O]}}const[G,q,W,J]=Z.box,K=g?Z.allPointsOccluded:R.isOccluded;let te=K;return te||(te=R.perspectiveRatio<this.perspectiveRatioCutoff),te||(te=!this.isInsideGrid(G,q,W,J)),te||n!=="always"&&this.grid.hitTest(G,q,W,J,n,P)?{box:[G,q,W,J],placeable:!1,offscreen:!1,occluded:K}:{box:[G,q,W,J],placeable:!0,offscreen:this.isOffscreen(G,q,W,J),occluded:K}}placeCollisionCircles(e,n,o,c,d,g,v,x,P,C,k,A,R,O){const Z=[],G=new a.P(n.anchorX,n.anchorY),q=this.getPerspectiveRatio(G.x,G.y,g,O),W=(P?d*this.transform.getPitchedTextCorrection(n.anchorX,n.anchorY,g)/q:d*q)/a.aB,J={getElevation:O,pitchedLabelPlaneMatrix:v,lineVertexArray:o,pitchWithMap:P,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:G,unwrappedTileID:g,width:this.transform.width,height:this.transform.height,translation:R},K=Wn(W,c,n.lineOffsetX*W,n.lineOffsetY*W,!1,n,!1,J);let te=!1,se=!1,Y=!0;if(K){const pe=.5*k*q+A,be=new a.P(-100,-100),_e=new a.P(this.screenRightBoundary,this.screenBottomBoundary),ye=new oi,xe=K.first,Le=K.last;let Oe=[];for(let Tt=xe.path.length-1;Tt>=1;Tt--)Oe.push(xe.path[Tt]);for(let Tt=1;Tt<Le.path.length;Tt++)Oe.push(Le.path[Tt]);const Ie=2.5*pe;if(P){const Tt=this.projectPathToScreenSpace(Oe,J);Oe=Tt.some(Wt=>Wt.signedDistanceFromCamera<=0)?[]:Tt.map(Wt=>Wt.point)}let et=[];if(Oe.length>0){const Tt=Oe[0].clone(),Wt=Oe[0].clone();for(let ei=1;ei<Oe.length;ei++)Tt.x=Math.min(Tt.x,Oe[ei].x),Tt.y=Math.min(Tt.y,Oe[ei].y),Wt.x=Math.max(Wt.x,Oe[ei].x),Wt.y=Math.max(Wt.y,Oe[ei].y);et=Tt.x>=be.x&&Wt.x<=_e.x&&Tt.y>=be.y&&Wt.y<=_e.y?[Oe]:Wt.x<be.x||Tt.x>_e.x||Wt.y<be.y||Tt.y>_e.y?[]:a.ay([Oe],be.x,be.y,_e.x,_e.y)}for(const Tt of et){ye.reset(Tt,.25*pe);let Wt=0;Wt=ye.length<=.5*pe?1:Math.ceil(ye.paddedLength/Ie)+1;for(let ei=0;ei<Wt;ei++){const Yt=ei/Math.max(Wt-1,1),pi=ye.lerp(Yt),yi=pi.x+wi,bt=pi.y+wi;Z.push(yi,bt,pe,0);const ti=yi-pe,Ri=bt-pe,Vi=yi+pe,Wi=bt+pe;if(Y=Y&&this.isOffscreen(ti,Ri,Vi,Wi),se=se||this.isInsideGrid(ti,Ri,Vi,Wi),e!=="always"&&this.grid.hitTestCircle(yi,bt,pe,e,C)&&(te=!0,!x))return{circles:[],offscreen:!1,collisionDetected:te}}}}return{circles:!x&&te||!se||q<this.perspectiveRatioCutoff?[]:Z,offscreen:Y,collisionDetected:te}}projectPathToScreenSpace(e,n){const o=function(c,d){const g=a.L();return a.aq(g,d.pitchedLabelPlaneMatrix),c.map(v=>{const x=ki(v.x,v.y,g,d.getElevation),P=d.transform.projectTileCoordinates(x.point.x,x.point.y,d.unwrappedTileID,d.getElevation);return P.point.x=(.5*P.point.x+.5)*d.width,P.point.y=(.5*-P.point.y+.5)*d.height,P})}(e,n);return function(c){let d=0,g=0,v=0,x=0;for(let P=0;P<c.length;P++)c[P].isOccluded?(v=P+1,x=0):(x++,x>g&&(g=x,d=v));return c.slice(d,d+g)}(o)}queryRenderedSymbols(e){if(e.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const n=[],o=new a.a2;for(const k of e){const A=new a.P(k.x+wi,k.y+wi);o.extend(A),n.push(A)}const{minX:c,minY:d,maxX:g,maxY:v}=o,x=this.grid.query(c,d,g,v).concat(this.ignoredGrid.query(c,d,g,v)),P={},C={};for(const k of x){const A=k.key;if(P[A.bucketInstanceId]===void 0&&(P[A.bucketInstanceId]={}),P[A.bucketInstanceId][A.featureIndex])continue;const R=[new a.P(k.x1,k.y1),new a.P(k.x2,k.y1),new a.P(k.x2,k.y2),new a.P(k.x1,k.y2)];a.az(n,R)&&(P[A.bucketInstanceId][A.featureIndex]=!0,C[A.bucketInstanceId]===void 0&&(C[A.bucketInstanceId]=[]),C[A.bucketInstanceId].push(A.featureIndex))}return C}insertCollisionBox(e,n,o,c,d,g){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:g,overlapMode:n},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,n,o,c,d,g){const v=o?this.ignoredGrid:this.grid,x={bucketInstanceId:c,featureIndex:d,collisionGroupID:g,overlapMode:n};for(let P=0;P<e.length;P+=4)v.insertCircle(x,e[P],e[P+1],e[P+2])}projectAndGetPerspectiveRatio(e,n,o,c,d){if(d){let g;c?(g=[e,n,c(e,n),1],a.aw(g,g,d)):(g=[e,n,0,1],Xs(g,g,d));const v=g[3];return{x:(g[0]/v+1)/2*this.transform.width+wi,y:(-g[1]/v+1)/2*this.transform.height+wi,perspectiveRatio:.5+this.transform.cameraToCenterDistance/v*.5,isOccluded:!1,signedDistanceFromCamera:v}}{const g=this.transform.projectTileCoordinates(e,n,o,c);return{x:(g.point.x+1)/2*this.transform.width+wi,y:(1-g.point.y)/2*this.transform.height+wi,perspectiveRatio:.5+this.transform.cameraToCenterDistance/g.signedDistanceFromCamera*.5,isOccluded:g.isOccluded,signedDistanceFromCamera:g.signedDistanceFromCamera}}}getPerspectiveRatio(e,n,o,c){const d=this.transform.projectTileCoordinates(e,n,o,c);return .5+this.transform.cameraToCenterDistance/d.signedDistanceFromCamera*.5}isOffscreen(e,n,o,c){return o<wi||e>=this.screenRightBoundary||c<wi||n>this.screenBottomBoundary}isInsideGrid(e,n,o,c){return o>=0&&e<this.gridRightBoundary&&c>=0&&n<this.gridBottomBoundary}getViewportMatrix(){const e=a.ag([]);return a.M(e,e,[-100,-100,0]),e}_projectCollisionBox(e,n,o,c,d,g,v,x,P,C,k){let A=1,R=0,O=0,Z=1;const G=e.anchorPointX+v[0],q=e.anchorPointY+v[1];if(g&&!d){const Oe=this.projectAndGetPerspectiveRatio(G+1,q,c,P,k),Ie=Oe.x-x.x,et=Math.atan((Oe.y-x.y)/Ie)+(Ie<0?Math.PI:0),Tt=Math.sin(et),Wt=Math.cos(et);A=Wt,R=Tt,O=-Tt,Z=Wt}else if(!g&&d){const Oe=Ut(this.transform);A=Oe.vecEast[0],R=Oe.vecEast[1],O=Oe.vecSouth[0],Z=Oe.vecSouth[1]}let W=x.x,J=x.y,K=n;d&&(W=G,J=q,K=Math.pow(2,-(this.transform.zoom-o.overscaledZ)),K*=this.transform.getPitchedTextCorrection(G,q,c),C||(K*=a.ah(.5+x.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),C&&(W+=A*C.x*K+O*C.y*K,J+=R*C.x*K+Z*C.y*K);const te=e.x1*K,se=e.x2*K,Y=(te+se)/2,pe=e.y1*K,be=e.y2*K,_e=(pe+be)/2,ye=[{offsetX:te,offsetY:pe},{offsetX:Y,offsetY:pe},{offsetX:se,offsetY:pe},{offsetX:se,offsetY:_e},{offsetX:se,offsetY:be},{offsetX:Y,offsetY:be},{offsetX:te,offsetY:be},{offsetX:te,offsetY:_e}];let xe=[];for(const{offsetX:Oe,offsetY:Ie}of ye)xe.push(new a.P(W+A*Oe+O*Ie,J+R*Oe+Z*Ie));let Le=!1;if(d){const Oe=xe.map(Ie=>this.projectAndGetPerspectiveRatio(Ie.x,Ie.y,c,P,k));Le=Oe.some(Ie=>!Ie.isOccluded),xe=Oe.map(Ie=>new a.P(Ie.x,Ie.y))}else Le=!0;return{box:a.aA(xe),allPointsOccluded:!Le}}}class Mr{constructor(e,n,o,c){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?n:-n))):c&&o?1:0,this.placed=o}isHidden(){return this.opacity===0&&!this.placed}}class ri{constructor(e,n,o,c,d){this.text=new Mr(e?e.text:null,n,o,d),this.icon=new Mr(e?e.icon:null,n,c,d)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Uu{constructor(e,n,o){this.text=e,this.icon=n,this.skipFade=o}}class Do{constructor(e,n,o,c,d){this.bucketInstanceId=e,this.featureIndex=n,this.sourceLayerIndex=o,this.bucketIndex=c,this.tileID=d}}class Kl{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={}}get(e){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[e]){const n=++this.maxGroupID;this.collisionGroups[e]={ID:n,predicate:o=>o.collisionGroupID===n}}return this.collisionGroups[e]}}function Yn(h,e,n,o,c){const{horizontalAlign:d,verticalAlign:g}=a.aH(h);return new a.P(-(d-.5)*e+o[0]*c,-(g-.5)*n+o[1]*c)}class Jn{constructor(e,n,o,c,d){this.transform=e.clone(),this.terrain=n,this.collisionIndex=new za(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new Kl(c),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const n=this.terrain;return n?(o,c)=>n.getElevation(e,o,c):null}getBucketParts(e,n,o,c){const d=o.getBucket(n),g=o.latestFeatureIndex;if(!d||!g||n.id!==d.layerIds[0])return;const v=o.collisionBoxArray,x=d.layers[0].layout,P=d.layers[0].paint,C=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),k=o.tileSize/a.$,A=o.tileID.toUnwrapped(),R=x.get("text-rotation-alignment")==="map",O=a.aC(o,1,this.transform.zoom),Z=a.aD(this.collisionIndex.transform,o,P.get("text-translate"),P.get("text-translate-anchor")),G=a.aD(this.collisionIndex.transform,o,P.get("icon-translate"),P.get("icon-translate-anchor")),q=Ii(R,this.transform,O);this.retainedQueryData[d.bucketInstanceId]=new Do(d.bucketInstanceId,g,d.sourceLayerIndex,d.index,o.tileID);const W={bucket:d,layout:x,translationText:Z,translationIcon:G,unwrappedTileID:A,pitchedLabelPlaneMatrix:q,scale:C,textPixelRatio:k,holdingForFade:o.holdingForFade(),collisionBoxArray:v,partiallyEvaluatedTextSize:a.an(d.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(d.sourceID)};if(c)for(const J of d.sortKeyRanges){const{sortKey:K,symbolInstanceStart:te,symbolInstanceEnd:se}=J;e.push({sortKey:K,symbolInstanceStart:te,symbolInstanceEnd:se,parameters:W})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:d.symbolInstances.length,parameters:W})}attemptAnchorPlacement(e,n,o,c,d,g,v,x,P,C,k,A,R,O,Z,G,q,W,J,K){const te=a.aE[e.textAnchor],se=[e.textOffset0,e.textOffset1],Y=Yn(te,o,c,se,d),pe=this.collisionIndex.placeCollisionBox(n,A,x,P,C,v,g,G,k.predicate,J,Y,K);if((!W||this.collisionIndex.placeCollisionBox(W,A,x,P,C,v,g,q,k.predicate,J,Y,K).placeable)&&pe.placeable){let be;if(this.prevPlacement&&this.prevPlacement.variableOffsets[R.crossTileID]&&this.prevPlacement.placements[R.crossTileID]&&this.prevPlacement.placements[R.crossTileID].text&&(be=this.prevPlacement.variableOffsets[R.crossTileID].anchor),R.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[R.crossTileID]={textOffset:se,width:o,height:c,anchor:te,textBoxScale:d,prevAnchor:be},this.markUsedJustification(O,te,R,Z),O.allowVerticalPlacement&&(this.markUsedOrientation(O,Z,R),this.placedOrientations[R.crossTileID]=Z),{shift:Y,placedGlyphBoxes:pe}}}placeLayerBucketPart(e,n,o){const{bucket:c,layout:d,translationText:g,translationIcon:v,unwrappedTileID:x,pitchedLabelPlaneMatrix:P,textPixelRatio:C,holdingForFade:k,collisionBoxArray:A,partiallyEvaluatedTextSize:R,collisionGroup:O}=e.parameters,Z=d.get("text-optional"),G=d.get("icon-optional"),q=a.aF(d,"text-overlap","text-allow-overlap"),W=q==="always",J=a.aF(d,"icon-overlap","icon-allow-overlap"),K=J==="always",te=d.get("text-rotation-alignment")==="map",se=d.get("text-pitch-alignment")==="map",Y=d.get("icon-text-fit")!=="none",pe=d.get("symbol-z-order")==="viewport-y",be=W&&(K||!c.hasIconData()||G),_e=K&&(W||!c.hasTextData()||Z);!c.collisionArrays&&A&&c.deserializeCollisionBoxes(A);const ye=this.retainedQueryData[c.bucketInstanceId].tileID,xe=this._getTerrainElevationFunc(ye),Le=this.transform.getFastPathSimpleProjectionMatrix(ye),Oe=(Ie,et,Tt)=>{var Wt,ei;if(n[Ie.crossTileID])return;if(k)return void(this.placements[Ie.crossTileID]=new Uu(!1,!1,!1));let Yt=!1,pi=!1,yi=!0,bt=null,ti={box:null,placeable:!1,offscreen:null,occluded:!1},Ri={placeable:!1},Vi=null,Wi=null,vr=null,hn=0,rs=0,ns=0;et.textFeatureIndex?hn=et.textFeatureIndex:Ie.useRuntimeCollisionCircles&&(hn=Ie.featureIndex),et.verticalTextFeatureIndex&&(rs=et.verticalTextFeatureIndex);const _o=et.textBox;if(_o){const Er=Di=>{let Ui=a.ao.horizontal;if(c.allowVerticalPlacement&&!Di&&this.prevPlacement){const Xr=this.prevPlacement.placedOrientations[Ie.crossTileID];Xr&&(this.placedOrientations[Ie.crossTileID]=Xr,Ui=Xr,this.markUsedOrientation(c,Ui,Ie))}return Ui},dn=(Di,Ui)=>{if(c.allowVerticalPlacement&&Ie.numVerticalGlyphVertices>0&&et.verticalTextBox){for(const Xr of c.writingModes)if(Xr===a.ao.vertical?(ti=Ui(),Ri=ti):ti=Di(),ti&&ti.placeable)break}else ti=Di()},xr=Ie.textAnchorOffsetStartIndex,ss=Ie.textAnchorOffsetEndIndex;if(ss===xr){const Di=(Ui,Xr)=>{const Li=this.collisionIndex.placeCollisionBox(Ui,q,C,ye,x,se,te,g,O.predicate,xe,void 0,Le);return Li&&Li.placeable&&(this.markUsedOrientation(c,Xr,Ie),this.placedOrientations[Ie.crossTileID]=Xr),Li};dn(()=>Di(_o,a.ao.horizontal),()=>{const Ui=et.verticalTextBox;return c.allowVerticalPlacement&&Ie.numVerticalGlyphVertices>0&&Ui?Di(Ui,a.ao.vertical):{box:null,offscreen:null}}),Er(ti&&ti.placeable)}else{let Di=a.aE[(ei=(Wt=this.prevPlacement)===null||Wt===void 0?void 0:Wt.variableOffsets[Ie.crossTileID])===null||ei===void 0?void 0:ei.anchor];const Ui=(Li,aa,vo)=>{const Dn=Li.x2-Li.x1,pn=Li.y2-Li.y1,os=Ie.textBoxScale,Dh=Y&&J==="never"?aa:null;let Or=null,Lh=q==="never"?1:2,$c="never";Di&&Lh++;for(let fl=0;fl<Lh;fl++){for(let ml=xr;ml<ss;ml++){const as=c.textAnchorOffsets.get(ml);if(Di&&as.textAnchor!==Di)continue;const Ln=this.attemptAnchorPlacement(as,Li,Dn,pn,os,te,se,C,ye,x,O,$c,Ie,c,vo,g,v,Dh,xe);if(Ln&&(Or=Ln.placedGlyphBoxes,Or&&Or.placeable))return Yt=!0,bt=Ln.shift,Or}Di?Di=null:$c=q}return o&&!Or&&(Or={box:this.collisionIndex.placeCollisionBox(_o,"always",C,ye,x,se,te,g,O.predicate,xe,void 0,Le).box,offscreen:!1,placeable:!1,occluded:!1}),Or};dn(()=>Ui(_o,et.iconBox,a.ao.horizontal),()=>{const Li=et.verticalTextBox;return c.allowVerticalPlacement&&(!ti||!ti.placeable)&&Ie.numVerticalGlyphVertices>0&&Li?Ui(Li,et.verticalIconBox,a.ao.vertical):{box:null,occluded:!0,offscreen:null}}),ti&&(Yt=ti.placeable,yi=ti.offscreen);const Xr=Er(ti&&ti.placeable);if(!Yt&&this.prevPlacement){const Li=this.prevPlacement.variableOffsets[Ie.crossTileID];Li&&(this.variableOffsets[Ie.crossTileID]=Li,this.markUsedJustification(c,Li.anchor,Ie,Xr))}}}if(Vi=ti,Yt=Vi&&Vi.placeable,yi=Vi&&Vi.offscreen,Ie.useRuntimeCollisionCircles){const Er=c.text.placedSymbolArray.get(Ie.centerJustifiedTextSymbolIndex),dn=a.ap(c.textSizeData,R,Er),xr=d.get("text-padding");Wi=this.collisionIndex.placeCollisionCircles(q,Er,c.lineVertexArray,c.glyphOffsetArray,dn,x,P,o,se,O.predicate,Ie.collisionCircleDiameter,xr,g,xe),Wi.circles.length&&Wi.collisionDetected&&!o&&a.w("Collisions detected, but collision boxes are not shown"),Yt=W||Wi.circles.length>0&&!Wi.collisionDetected,yi=yi&&Wi.offscreen}if(et.iconFeatureIndex&&(ns=et.iconFeatureIndex),et.iconBox){const Er=dn=>this.collisionIndex.placeCollisionBox(dn,J,C,ye,x,se,te,v,O.predicate,xe,Y&&bt?bt:void 0,Le);Ri&&Ri.placeable&&et.verticalIconBox?(vr=Er(et.verticalIconBox),pi=vr.placeable):(vr=Er(et.iconBox),pi=vr.placeable),yi=yi&&vr.offscreen}const yo=Z||Ie.numHorizontalGlyphVertices===0&&Ie.numVerticalGlyphVertices===0,Bs=G||Ie.numIconVertices===0;yo||Bs?Bs?yo||(pi=pi&&Yt):Yt=pi&&Yt:pi=Yt=pi&&Yt;const Os=pi&&vr.placeable;if(Yt&&Vi.placeable&&this.collisionIndex.insertCollisionBox(Vi.box,q,d.get("text-ignore-placement"),c.bucketInstanceId,Ri&&Ri.placeable&&rs?rs:hn,O.ID),Os&&this.collisionIndex.insertCollisionBox(vr.box,J,d.get("icon-ignore-placement"),c.bucketInstanceId,ns,O.ID),Wi&&Yt&&this.collisionIndex.insertCollisionCircles(Wi.circles,q,d.get("text-ignore-placement"),c.bucketInstanceId,hn,O.ID),o&&this.storeCollisionData(c.bucketInstanceId,Tt,et,Vi,vr,Wi),Ie.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");if(c.bucketInstanceId===0)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[Ie.crossTileID]=new Uu((Yt||be)&&!(Vi!=null&&Vi.occluded),(pi||_e)&&!(vr!=null&&vr.occluded),yi||c.justReloaded),n[Ie.crossTileID]=!0};if(pe){if(e.symbolInstanceStart!==0)throw new Error("bucket.bucketInstanceId should be 0");const Ie=c.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let et=Ie.length-1;et>=0;--et){const Tt=Ie[et];Oe(c.symbolInstances.get(Tt),c.collisionArrays[Tt],Tt)}}else for(let Ie=e.symbolInstanceStart;Ie<e.symbolInstanceEnd;Ie++)Oe(c.symbolInstances.get(Ie),c.collisionArrays[Ie],Ie);c.justReloaded=!1}storeCollisionData(e,n,o,c,d,g){if(o.textBox||o.iconBox){let v,x;this.collisionBoxArrays.has(e)?v=this.collisionBoxArrays.get(e):(v=new Map,this.collisionBoxArrays.set(e,v)),v.has(n)?x=v.get(n):(x={text:null,icon:null},v.set(n,x)),o.textBox&&(x.text=c.box),o.iconBox&&(x.icon=d.box)}if(g){let v=this.collisionCircleArrays[e];v===void 0&&(v=this.collisionCircleArrays[e]=[]);for(let x=0;x<g.circles.length;x+=4)v.push(g.circles[x+0]-wi),v.push(g.circles[x+1]-wi),v.push(g.circles[x+2]),v.push(g.collisionDetected?1:0)}}markUsedJustification(e,n,o,c){let d;d=c===a.ao.vertical?o.verticalPlacedTextSymbolIndex:{left:o.leftJustifiedTextSymbolIndex,center:o.centerJustifiedTextSymbolIndex,right:o.rightJustifiedTextSymbolIndex}[a.aG(n)];const g=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex,o.verticalPlacedTextSymbolIndex];for(const v of g)v>=0&&(e.text.placedSymbolArray.get(v).crossTileID=d>=0&&v!==d?0:o.crossTileID)}markUsedOrientation(e,n,o){const c=n===a.ao.horizontal||n===a.ao.horizontalOnly?n:0,d=n===a.ao.vertical?n:0,g=[o.leftJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.rightJustifiedTextSymbolIndex];for(const v of g)e.text.placedSymbolArray.get(v).placedOrientation=c;o.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(o.verticalPlacedTextSymbolIndex).placedOrientation=d)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let o=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const c=n?n.symbolFadeChange(e):1,d=n?n.opacities:{},g=n?n.variableOffsets:{},v=n?n.placedOrientations:{};for(const x in this.placements){const P=this.placements[x],C=d[x];C?(this.opacities[x]=new ri(C,c,P.text,P.icon),o=o||P.text!==C.text.placed||P.icon!==C.icon.placed):(this.opacities[x]=new ri(null,c,P.text,P.icon,P.skipFade),o=o||P.text||P.icon)}for(const x in d){const P=d[x];if(!this.opacities[x]){const C=new ri(P,c,!1,!1);C.isHidden()||(this.opacities[x]=C,o=o||P.text.placed||P.icon.placed)}}for(const x in g)this.variableOffsets[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.variableOffsets[x]=g[x]);for(const x in v)this.placedOrientations[x]||!this.opacities[x]||this.opacities[x].isHidden()||(this.placedOrientations[x]=v[x]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");o?this.lastPlacementChangeTime=e:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:e)}updateLayerOpacities(e,n){const o={};for(const c of n){const d=c.getBucket(e);d&&c.latestFeatureIndex&&e.id===d.layerIds[0]&&this.updateBucketOpacities(d,c.tileID,o,c.collisionBoxArray)}}updateBucketOpacities(e,n,o,c){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const d=e.layers[0],g=d.layout,v=new ri(null,0,!1,!1,!0),x=g.get("text-allow-overlap"),P=g.get("icon-allow-overlap"),C=d._unevaluatedLayout.hasValue("text-variable-anchor")||d._unevaluatedLayout.hasValue("text-variable-anchor-offset"),k=g.get("text-rotation-alignment")==="map",A=g.get("text-pitch-alignment")==="map",R=g.get("icon-text-fit")!=="none",O=new ri(null,0,x&&(P||!e.hasIconData()||g.get("icon-optional")),P&&(x||!e.hasTextData()||g.get("text-optional")),!0);!e.collisionArrays&&c&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(c);const Z=(q,W,J)=>{for(let K=0;K<W/4;K++)q.opacityVertexArray.emplaceBack(J);q.hasVisibleVertices=q.hasVisibleVertices||J!==Ys},G=this.collisionBoxArrays.get(e.bucketInstanceId);for(let q=0;q<e.symbolInstances.length;q++){const W=e.symbolInstances.get(q),{numHorizontalGlyphVertices:J,numVerticalGlyphVertices:K,crossTileID:te}=W;let se=this.opacities[te];o[te]?se=v:se||(se=O,this.opacities[te]=se),o[te]=!0;const Y=W.numIconVertices>0,pe=this.placedOrientations[W.crossTileID],be=pe===a.ao.vertical,_e=pe===a.ao.horizontal||pe===a.ao.horizontalOnly;if(J>0||K>0){const xe=Jl(se.text);Z(e.text,J,be?Ys:xe),Z(e.text,K,_e?Ys:xe);const Le=se.text.isHidden();[W.rightJustifiedTextSymbolIndex,W.centerJustifiedTextSymbolIndex,W.leftJustifiedTextSymbolIndex].forEach(et=>{et>=0&&(e.text.placedSymbolArray.get(et).hidden=Le||be?1:0)}),W.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(W.verticalPlacedTextSymbolIndex).hidden=Le||_e?1:0);const Oe=this.variableOffsets[W.crossTileID];Oe&&this.markUsedJustification(e,Oe.anchor,W,pe);const Ie=this.placedOrientations[W.crossTileID];Ie&&(this.markUsedJustification(e,"left",W,Ie),this.markUsedOrientation(e,Ie,W))}if(Y){const xe=Jl(se.icon),Le=!(R&&W.verticalPlacedIconSymbolIndex&&be);W.placedIconSymbolIndex>=0&&(Z(e.icon,W.numIconVertices,Le?xe:Ys),e.icon.placedSymbolArray.get(W.placedIconSymbolIndex).hidden=se.icon.isHidden()),W.verticalPlacedIconSymbolIndex>=0&&(Z(e.icon,W.numVerticalIconVertices,Le?Ys:xe),e.icon.placedSymbolArray.get(W.verticalPlacedIconSymbolIndex).hidden=se.icon.isHidden())}const ye=G&&G.has(q)?G.get(q):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const xe=e.collisionArrays[q];if(xe){let Le=new a.P(0,0);if(xe.textBox||xe.verticalTextBox){let Oe=!0;if(C){const Ie=this.variableOffsets[te];Ie?(Le=Yn(Ie.anchor,Ie.width,Ie.height,Ie.textOffset,Ie.textBoxScale),k&&Le._rotate(A?-this.transform.bearingInRadians:this.transform.bearingInRadians)):Oe=!1}if(xe.textBox||xe.verticalTextBox){let Ie;xe.textBox&&(Ie=be),xe.verticalTextBox&&(Ie=_e),Yl(e.textCollisionBox.collisionVertexArray,se.text.placed,!Oe||Ie,ye.text,Le.x,Le.y)}}if(xe.iconBox||xe.verticalIconBox){const Oe=!!(!_e&&xe.verticalIconBox);let Ie;xe.iconBox&&(Ie=Oe),xe.verticalIconBox&&(Ie=!Oe),Yl(e.iconCollisionBox.collisionVertexArray,se.icon.placed,Ie,ye.icon,R?Le.x:0,R?Le.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return this.fadeDuration===0?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,n){const o=this.zoomAtLastRecencyCheck===n?1-this.zoomAdjustment(n):1;return this.zoomAtLastRecencyCheck=n,this.commitTime+this.fadeDuration*o>e}setStale(){this.stale=!0}}function Yl(h,e,n,o,c,d){o&&o.length!==0||(o=[0,0,0,0]);const g=o[0]-wi,v=o[1]-wi,x=o[2]-wi,P=o[3]-wi;h.emplaceBack(e?1:0,n?1:0,c||0,d||0,g,v),h.emplaceBack(e?1:0,n?1:0,c||0,d||0,x,v),h.emplaceBack(e?1:0,n?1:0,c||0,d||0,x,P),h.emplaceBack(e?1:0,n?1:0,c||0,d||0,g,P)}const $u=Math.pow(2,25),Gu=Math.pow(2,24),Ks=Math.pow(2,17),Zu=Math.pow(2,16),Zd=Math.pow(2,9),qd=Math.pow(2,8),Hd=Math.pow(2,1);function Jl(h){if(h.opacity===0&&!h.placed)return 0;if(h.opacity===1&&h.placed)return 4294967295;const e=h.placed?1:0,n=Math.floor(127*h.opacity);return n*$u+e*Gu+n*Ks+e*Zu+n*Zd+e*qd+n*Hd+e}const Ys=0;class Ql{constructor(e){this._sortAcrossTiles=e.layout.get("symbol-z-order")!=="viewport-y"&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,n,o,c,d){const g=this._bucketParts;for(;this._currentTileIndex<e.length;)if(n.getBucketParts(g,c,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,d())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort((v,x)=>v.sortKey-x.sortKey));this._currentPartIndex<g.length;)if(n.placeLayerBucketPart(g[this._currentPartIndex],this._seenCrossTileIDs,o),this._currentPartIndex++,d())return!0;return!1}}class ec{constructor(e,n,o,c,d,g,v,x){this.placement=new Jn(e,n,g,v,x),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=c,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(e,n,o){const c=Se.now(),d=()=>!this._forceFullPlacement&&Se.now()-c>2;for(;this._currentPlacementIndex>=0;){const g=n[e[this._currentPlacementIndex]],v=this.placement.collisionIndex.transform.zoom;if(g.type==="symbol"&&(!g.minzoom||g.minzoom<=v)&&(!g.maxzoom||g.maxzoom>v)){if(this._inProgressLayer||(this._inProgressLayer=new Ql(g)),this._inProgressLayer.continuePlacement(o[g.source],this.placement,this._showCollisionBoxes,g,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Js=512/a.$/2;class tc{constructor(e,n,o){this.tileID=e,this.bucketInstanceId=o,this._symbolsByKey={};const c=new Map;for(let d=0;d<n.length;d++){const g=n.get(d),v=g.key,x=c.get(v);x?x.push(g):c.set(v,[g])}for(const[d,g]of c){const v={positions:g.map(x=>({x:Math.floor(x.anchorX*Js),y:Math.floor(x.anchorY*Js)})),crossTileIDs:g.map(x=>x.crossTileID)};if(v.positions.length>128){const x=new a.aI(v.positions.length,16,Uint16Array);for(const{x:P,y:C}of v.positions)x.add(P,C);x.finish(),delete v.positions,v.index=x}this._symbolsByKey[d]=v}}getScaledCoordinates(e,n){const{x:o,y:c,z:d}=this.tileID.canonical,{x:g,y:v,z:x}=n.canonical,P=Js/Math.pow(2,x-d),C=(v*a.$+e.anchorY)*P,k=c*a.$*Js;return{x:Math.floor((g*a.$+e.anchorX)*P-o*a.$*Js),y:Math.floor(C-k)}}findMatches(e,n,o){const c=this.tileID.canonical.z<n.canonical.z?1:Math.pow(2,this.tileID.canonical.z-n.canonical.z);for(let d=0;d<e.length;d++){const g=e.get(d);if(g.crossTileID)continue;const v=this._symbolsByKey[g.key];if(!v)continue;const x=this.getScaledCoordinates(g,n);if(v.index){const P=v.index.range(x.x-c,x.y-c,x.x+c,x.y+c).sort();for(const C of P){const k=v.crossTileIDs[C];if(!o[k]){o[k]=!0,g.crossTileID=k;break}}}else if(v.positions)for(let P=0;P<v.positions.length;P++){const C=v.positions[P],k=v.crossTileIDs[P];if(Math.abs(C.x-x.x)<=c&&Math.abs(C.y-x.y)<=c&&!o[k]){o[k]=!0,g.crossTileID=k;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map(({crossTileIDs:e})=>e)}}class ic{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Wd{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const n=Math.round((e-this.lng)/360);if(n!==0)for(const o in this.indexes){const c=this.indexes[o],d={};for(const g in c){const v=c[g];v.tileID=v.tileID.unwrapTo(v.tileID.wrap+n),d[v.tileID.key]=v}this.indexes[o]=d}this.lng=e}addBucket(e,n,o){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let d=0;d<n.symbolInstances.length;d++)n.symbolInstances.get(d).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const c=this.usedCrossTileIDs[e.overscaledZ];for(const d in this.indexes){const g=this.indexes[d];if(Number(d)>e.overscaledZ)for(const v in g){const x=g[v];x.tileID.isChildOf(e)&&x.findMatches(n.symbolInstances,e,c)}else{const v=g[e.scaledTo(Number(d)).key];v&&v.findMatches(n.symbolInstances,e,c)}}for(let d=0;d<n.symbolInstances.length;d++){const g=n.symbolInstances.get(d);g.crossTileID||(g.crossTileID=o.generate(),c[g.crossTileID]=!0)}return this.indexes[e.overscaledZ]===void 0&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new tc(e,n.symbolInstances,n.bucketInstanceId),!0}removeBucketCrossTileIDs(e,n){for(const o of n.getCrossTileIDsLists())for(const c of o)delete this.usedCrossTileIDs[e][c]}removeStaleBuckets(e){let n=!1;for(const o in this.indexes){const c=this.indexes[o];for(const d in c)e[c[d].bucketInstanceId]||(this.removeBucketCrossTileIDs(o,c[d]),delete c[d],n=!0)}return n}}class Qs{constructor(){this.layerIndexes={},this.crossTileIDs=new ic,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,n,o){let c=this.layerIndexes[e.id];c===void 0&&(c=this.layerIndexes[e.id]=new Wd);let d=!1;const g={};c.handleWrapJump(o);for(const v of n){const x=v.getBucket(e);x&&e.id===x.layerIds[0]&&(x.bucketInstanceId||(x.bucketInstanceId=++this.maxBucketInstanceId),c.addBucket(v.tileID,x,this.crossTileIDs)&&(d=!0),g[x.bucketInstanceId]=!0)}return c.removeStaleBuckets(g)&&(d=!0),d}pruneUnusedLayers(e){const n={};e.forEach(o=>{n[o]=!0});for(const o in this.layerIndexes)n[o]||delete this.layerIndexes[o]}}var Lo="void main() {fragColor=vec4(1.0);}";const rn={prelude:zt(`#ifdef GL_ES
29
+ precision mediump float;
30
+ #else
31
+ #if !defined(lowp)
32
+ #define lowp
33
+ #endif
34
+ #if !defined(mediump)
35
+ #define mediump
36
+ #endif
37
+ #if !defined(highp)
38
+ #define highp
39
+ #endif
40
+ #endif
41
+ out highp vec4 fragColor;`,`#ifdef GL_ES
42
+ precision highp float;
43
+ #else
44
+ #if !defined(lowp)
45
+ #define lowp
46
+ #endif
47
+ #if !defined(mediump)
48
+ #define mediump
49
+ #endif
50
+ #if !defined(highp)
51
+ #define highp
52
+ #endif
53
+ #endif
54
+ vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
55
+ );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c
56
+ );}
57
+ #ifdef TERRAIN3D
58
+ uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;
59
+ #endif
60
+ const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {
61
+ #ifdef TERRAIN3D
62
+ highp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));
63
+ #else
64
+ return 1.0;
65
+ #endif
66
+ }float calculate_visibility(vec4 pos) {
67
+ #ifdef TERRAIN3D
68
+ vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;
69
+ #else
70
+ return 1.0;
71
+ #endif
72
+ }float ele(vec2 pos) {
73
+ #ifdef TERRAIN3D
74
+ vec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;
75
+ #else
76
+ return 0.0;
77
+ #endif
78
+ }float get_elevation(vec2 pos) {
79
+ #ifdef TERRAIN3D
80
+ #ifdef GLOBE
81
+ if ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}
82
+ #endif
83
+ vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;
84
+ #else
85
+ return 0.0;
86
+ #endif
87
+ }const float PI=3.141592653589793;uniform mat4 u_projection_matrix;`),projectionMercator:zt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:zt("",`#define GLOBE_RADIUS 6371008.8
88
+ uniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos
89
+ );}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);
90
+ if (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len
91
+ );if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}`),background:zt(`uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;
92
+ #ifdef OVERDRAW_INSPECTOR
93
+ fragColor=vec4(1.0);
94
+ #endif
95
+ }`,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:zt(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;
96
+ #ifdef OVERDRAW_INSPECTOR
97
+ fragColor=vec4(1.0);
98
+ #endif
99
+ }`,"uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:zt(`in vec3 v_data;in float v_visibility;
100
+ #pragma mapbox: define highp vec4 color
101
+ #pragma mapbox: define mediump float radius
102
+ #pragma mapbox: define lowp float blur
103
+ #pragma mapbox: define lowp float opacity
104
+ #pragma mapbox: define highp vec4 stroke_color
105
+ #pragma mapbox: define mediump float stroke_width
106
+ #pragma mapbox: define lowp float stroke_opacity
107
+ void main() {
108
+ #pragma mapbox: initialize highp vec4 color
109
+ #pragma mapbox: initialize mediump float radius
110
+ #pragma mapbox: initialize lowp float blur
111
+ #pragma mapbox: initialize lowp float opacity
112
+ #pragma mapbox: initialize highp vec4 stroke_color
113
+ #pragma mapbox: initialize mediump float stroke_width
114
+ #pragma mapbox: initialize lowp float stroke_opacity
115
+ vec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}
116
+ #ifdef OVERDRAW_INSPECTOR
117
+ fragColor=vec4(1.0);
118
+ #endif
119
+ }`,`uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;
120
+ #pragma mapbox: define highp vec4 color
121
+ #pragma mapbox: define mediump float radius
122
+ #pragma mapbox: define lowp float blur
123
+ #pragma mapbox: define lowp float opacity
124
+ #pragma mapbox: define highp vec4 stroke_color
125
+ #pragma mapbox: define mediump float stroke_width
126
+ #pragma mapbox: define lowp float stroke_opacity
127
+ void main(void) {
128
+ #pragma mapbox: initialize highp vec4 color
129
+ #pragma mapbox: initialize mediump float radius
130
+ #pragma mapbox: initialize lowp float blur
131
+ #pragma mapbox: initialize lowp float opacity
132
+ #pragma mapbox: initialize highp vec4 stroke_color
133
+ #pragma mapbox: initialize mediump float stroke_width
134
+ #pragma mapbox: initialize lowp float stroke_opacity
135
+ vec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {
136
+ #ifdef GLOBE
137
+ vec3 center_vector=projectToSphere(circle_center);
138
+ #endif
139
+ float angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {
140
+ #ifdef GLOBE
141
+ vec4 projected_center=interpolateProjection(circle_center,center_vector,ele);
142
+ #else
143
+ vec4 projected_center=projectTileWithElevation(circle_center,ele);
144
+ #endif
145
+ corner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}
146
+ #ifdef GLOBE
147
+ vec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);
148
+ #else
149
+ gl_Position=projectTileWithElevation(corner_position,ele);
150
+ #endif
151
+ } else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:zt(Lo,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:zt(`uniform highp float u_intensity;in vec2 v_extrude;
152
+ #pragma mapbox: define highp float weight
153
+ #define GAUSS_COEF 0.3989422804014327
154
+ void main() {
155
+ #pragma mapbox: initialize highp float weight
156
+ float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);
157
+ #ifdef OVERDRAW_INSPECTOR
158
+ fragColor=vec4(1.0);
159
+ #endif
160
+ }`,`uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;
161
+ #pragma mapbox: define highp float weight
162
+ #pragma mapbox: define mediump float radius
163
+ const highp float ZERO=1.0/255.0/16.0;
164
+ #define GAUSS_COEF 0.3989422804014327
165
+ void main(void) {
166
+ #pragma mapbox: initialize highp float weight
167
+ #pragma mapbox: initialize mediump float radius
168
+ vec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);
169
+ #ifdef GLOBE
170
+ vec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);
171
+ #else
172
+ gl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));
173
+ #endif
174
+ }`),heatmapTexture:zt(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;
175
+ #ifdef OVERDRAW_INSPECTOR
176
+ fragColor=vec4(0.0);
177
+ #endif
178
+ }`,"uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:zt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:zt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:zt(`#ifdef GL_ES
179
+ precision highp float;
180
+ #endif
181
+ uniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else
182
+ {l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));
183
+ #ifdef OVERDRAW_INSPECTOR
184
+ fragColor=vec4(1.0);
185
+ #endif
186
+ }`,"uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:zt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:zt(Lo,`in vec2 a_pos;void main() {
187
+ #ifdef GLOBE
188
+ gl_Position=projectTileFor3D(a_pos,0.0);
189
+ #else
190
+ gl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);
191
+ #endif
192
+ }`),fill:zt(`#pragma mapbox: define highp vec4 color
193
+ #pragma mapbox: define lowp float opacity
194
+ void main() {
195
+ #pragma mapbox: initialize highp vec4 color
196
+ #pragma mapbox: initialize lowp float opacity
197
+ fragColor=color*opacity;
198
+ #ifdef OVERDRAW_INSPECTOR
199
+ fragColor=vec4(1.0);
200
+ #endif
201
+ }`,`uniform vec2 u_fill_translate;in vec2 a_pos;
202
+ #pragma mapbox: define highp vec4 color
203
+ #pragma mapbox: define lowp float opacity
204
+ void main() {
205
+ #pragma mapbox: initialize highp vec4 color
206
+ #pragma mapbox: initialize lowp float opacity
207
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}`),fillOutline:zt(`in vec2 v_pos;
208
+ #ifdef GLOBE
209
+ in float v_depth;
210
+ #endif
211
+ #pragma mapbox: define highp vec4 outline_color
212
+ #pragma mapbox: define lowp float opacity
213
+ void main() {
214
+ #pragma mapbox: initialize highp vec4 outline_color
215
+ #pragma mapbox: initialize lowp float opacity
216
+ float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);
217
+ #ifdef GLOBE
218
+ if (v_depth > 1.0) {discard;}
219
+ #endif
220
+ #ifdef OVERDRAW_INSPECTOR
221
+ fragColor=vec4(1.0);
222
+ #endif
223
+ }`,`uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;
224
+ #ifdef GLOBE
225
+ out float v_depth;
226
+ #endif
227
+ #pragma mapbox: define highp vec4 outline_color
228
+ #pragma mapbox: define lowp float opacity
229
+ void main() {
230
+ #pragma mapbox: initialize highp vec4 outline_color
231
+ #pragma mapbox: initialize lowp float opacity
232
+ gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
233
+ #ifdef GLOBE
234
+ v_depth=gl_Position.z/gl_Position.w;
235
+ #endif
236
+ }`),fillOutlinePattern:zt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;
237
+ #ifdef GLOBE
238
+ in float v_depth;
239
+ #endif
240
+ #pragma mapbox: define lowp float opacity
241
+ #pragma mapbox: define lowp vec4 pattern_from
242
+ #pragma mapbox: define lowp vec4 pattern_to
243
+ void main() {
244
+ #pragma mapbox: initialize lowp float opacity
245
+ #pragma mapbox: initialize mediump vec4 pattern_from
246
+ #pragma mapbox: initialize mediump vec4 pattern_to
247
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;
248
+ #ifdef GLOBE
249
+ if (v_depth > 1.0) {discard;}
250
+ #endif
251
+ #ifdef OVERDRAW_INSPECTOR
252
+ fragColor=vec4(1.0);
253
+ #endif
254
+ }`,`uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;
255
+ #ifdef GLOBE
256
+ out float v_depth;
257
+ #endif
258
+ #pragma mapbox: define lowp float opacity
259
+ #pragma mapbox: define lowp vec4 pattern_from
260
+ #pragma mapbox: define lowp vec4 pattern_to
261
+ #pragma mapbox: define lowp float pixel_ratio_from
262
+ #pragma mapbox: define lowp float pixel_ratio_to
263
+ void main() {
264
+ #pragma mapbox: initialize lowp float opacity
265
+ #pragma mapbox: initialize mediump vec4 pattern_from
266
+ #pragma mapbox: initialize mediump vec4 pattern_to
267
+ #pragma mapbox: initialize lowp float pixel_ratio_from
268
+ #pragma mapbox: initialize lowp float pixel_ratio_to
269
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
270
+ #ifdef GLOBE
271
+ v_depth=gl_Position.z/gl_Position.w;
272
+ #endif
273
+ }`),fillPattern:zt(`#ifdef GL_ES
274
+ precision highp float;
275
+ #endif
276
+ uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;
277
+ #pragma mapbox: define lowp float opacity
278
+ #pragma mapbox: define lowp vec4 pattern_from
279
+ #pragma mapbox: define lowp vec4 pattern_to
280
+ void main() {
281
+ #pragma mapbox: initialize lowp float opacity
282
+ #pragma mapbox: initialize mediump vec4 pattern_from
283
+ #pragma mapbox: initialize mediump vec4 pattern_to
284
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;
285
+ #ifdef OVERDRAW_INSPECTOR
286
+ fragColor=vec4(1.0);
287
+ #endif
288
+ }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;
289
+ #pragma mapbox: define lowp float opacity
290
+ #pragma mapbox: define lowp vec4 pattern_from
291
+ #pragma mapbox: define lowp vec4 pattern_to
292
+ #pragma mapbox: define lowp float pixel_ratio_from
293
+ #pragma mapbox: define lowp float pixel_ratio_to
294
+ void main() {
295
+ #pragma mapbox: initialize lowp float opacity
296
+ #pragma mapbox: initialize mediump vec4 pattern_from
297
+ #pragma mapbox: initialize mediump vec4 pattern_to
298
+ #pragma mapbox: initialize lowp float pixel_ratio_from
299
+ #pragma mapbox: initialize lowp float pixel_ratio_to
300
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:zt(`in vec4 v_color;void main() {fragColor=v_color;
301
+ #ifdef OVERDRAW_INSPECTOR
302
+ fragColor=vec4(1.0);
303
+ #endif
304
+ }`,`uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;
305
+ #ifdef TERRAIN3D
306
+ in vec2 a_centroid;
307
+ #endif
308
+ out vec4 v_color;
309
+ #pragma mapbox: define highp float base
310
+ #pragma mapbox: define highp float height
311
+ #pragma mapbox: define highp vec4 color
312
+ void main() {
313
+ #pragma mapbox: initialize highp float base
314
+ #pragma mapbox: initialize highp float height
315
+ #pragma mapbox: initialize highp vec4 color
316
+ vec3 normal=a_normal_ed.xyz;
317
+ #ifdef TERRAIN3D
318
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
319
+ #else
320
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
321
+ #endif
322
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
323
+ #ifdef GLOBE
324
+ vec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
325
+ #else
326
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
327
+ #endif
328
+ float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);
329
+ #ifdef GLOBE
330
+ mat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);
331
+ #endif
332
+ directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:zt(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;
333
+ #pragma mapbox: define lowp float base
334
+ #pragma mapbox: define lowp float height
335
+ #pragma mapbox: define lowp vec4 pattern_from
336
+ #pragma mapbox: define lowp vec4 pattern_to
337
+ #pragma mapbox: define lowp float pixel_ratio_from
338
+ #pragma mapbox: define lowp float pixel_ratio_to
339
+ void main() {
340
+ #pragma mapbox: initialize lowp float base
341
+ #pragma mapbox: initialize lowp float height
342
+ #pragma mapbox: initialize mediump vec4 pattern_from
343
+ #pragma mapbox: initialize mediump vec4 pattern_to
344
+ #pragma mapbox: initialize lowp float pixel_ratio_from
345
+ #pragma mapbox: initialize lowp float pixel_ratio_to
346
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;
347
+ #ifdef OVERDRAW_INSPECTOR
348
+ fragColor=vec4(1.0);
349
+ #endif
350
+ }`,`uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;
351
+ #ifdef TERRAIN3D
352
+ in vec2 a_centroid;
353
+ #endif
354
+ #ifdef GLOBE
355
+ out vec3 v_sphere_pos;
356
+ #endif
357
+ out vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;
358
+ #pragma mapbox: define lowp float base
359
+ #pragma mapbox: define lowp float height
360
+ #pragma mapbox: define lowp vec4 pattern_from
361
+ #pragma mapbox: define lowp vec4 pattern_to
362
+ #pragma mapbox: define lowp float pixel_ratio_from
363
+ #pragma mapbox: define lowp float pixel_ratio_to
364
+ void main() {
365
+ #pragma mapbox: initialize lowp float base
366
+ #pragma mapbox: initialize lowp float height
367
+ #pragma mapbox: initialize mediump vec4 pattern_from
368
+ #pragma mapbox: initialize mediump vec4 pattern_to
369
+ #pragma mapbox: initialize lowp float pixel_ratio_from
370
+ #pragma mapbox: initialize lowp float pixel_ratio_to
371
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;
372
+ #ifdef TERRAIN3D
373
+ float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);
374
+ #else
375
+ float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;
376
+ #endif
377
+ base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;
378
+ #ifdef GLOBE
379
+ vec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);
380
+ #else
381
+ gl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);
382
+ #endif
383
+ vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0
384
+ ? a_pos
385
+ : vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:zt(`#ifdef GL_ES
386
+ precision highp float;
387
+ #endif
388
+ uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);
389
+ #ifdef OVERDRAW_INSPECTOR
390
+ fragColor=vec4(1.0);
391
+ #endif
392
+ }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:zt(`uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];
393
+ #define PI 3.141592653589793
394
+ #define STANDARD 0
395
+ #define COMBINED 1
396
+ #define IGOR 2
397
+ #define MULTIDIRECTIONAL 3
398
+ #define BASIC 4
399
+ float get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else
400
+ {fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else
401
+ {fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}
402
+ #ifdef OVERDRAW_INSPECTOR
403
+ fragColor=vec4(1.0);
404
+ #endif
405
+ }`,"uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:zt(`uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;
406
+ #ifdef GLOBE
407
+ in float v_depth;
408
+ #endif
409
+ #pragma mapbox: define highp vec4 color
410
+ #pragma mapbox: define lowp float blur
411
+ #pragma mapbox: define lowp float opacity
412
+ void main() {
413
+ #pragma mapbox: initialize highp vec4 color
414
+ #pragma mapbox: initialize lowp float blur
415
+ #pragma mapbox: initialize lowp float opacity
416
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);
417
+ #ifdef GLOBE
418
+ if (v_depth > 1.0) {discard;}
419
+ #endif
420
+ #ifdef OVERDRAW_INSPECTOR
421
+ fragColor=vec4(1.0);
422
+ #endif
423
+ }`,`
424
+ #define scale 0.015873016
425
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;
426
+ #ifdef GLOBE
427
+ out float v_depth;
428
+ #endif
429
+ #pragma mapbox: define highp vec4 color
430
+ #pragma mapbox: define lowp float blur
431
+ #pragma mapbox: define lowp float opacity
432
+ #pragma mapbox: define mediump float gapwidth
433
+ #pragma mapbox: define lowp float offset
434
+ #pragma mapbox: define mediump float width
435
+ void main() {
436
+ #pragma mapbox: initialize highp vec4 color
437
+ #pragma mapbox: initialize lowp float blur
438
+ #pragma mapbox: initialize lowp float opacity
439
+ #pragma mapbox: initialize mediump float gapwidth
440
+ #pragma mapbox: initialize lowp float offset
441
+ #pragma mapbox: initialize mediump float width
442
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
443
+ #ifdef GLOBE
444
+ v_depth=gl_Position.z/gl_Position.w;
445
+ #endif
446
+ #ifdef TERRAIN3D
447
+ v_gamma_scale=1.0;
448
+ #else
449
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
450
+ #endif
451
+ v_width2=vec2(outset,inset);}`),lineGradient:zt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;
452
+ #ifdef GLOBE
453
+ in float v_depth;
454
+ #endif
455
+ #pragma mapbox: define lowp float blur
456
+ #pragma mapbox: define lowp float opacity
457
+ void main() {
458
+ #pragma mapbox: initialize lowp float blur
459
+ #pragma mapbox: initialize lowp float opacity
460
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);
461
+ #ifdef GLOBE
462
+ if (v_depth > 1.0) {discard;}
463
+ #endif
464
+ #ifdef OVERDRAW_INSPECTOR
465
+ fragColor=vec4(1.0);
466
+ #endif
467
+ }`,`
468
+ #define scale 0.015873016
469
+ in vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;
470
+ #ifdef GLOBE
471
+ out float v_depth;
472
+ #endif
473
+ #pragma mapbox: define lowp float blur
474
+ #pragma mapbox: define lowp float opacity
475
+ #pragma mapbox: define mediump float gapwidth
476
+ #pragma mapbox: define lowp float offset
477
+ #pragma mapbox: define mediump float width
478
+ void main() {
479
+ #pragma mapbox: initialize lowp float blur
480
+ #pragma mapbox: initialize lowp float opacity
481
+ #pragma mapbox: initialize mediump float gapwidth
482
+ #pragma mapbox: initialize lowp float offset
483
+ #pragma mapbox: initialize mediump float width
484
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
485
+ #ifdef GLOBE
486
+ v_depth=gl_Position.z/gl_Position.w;
487
+ #endif
488
+ #ifdef TERRAIN3D
489
+ v_gamma_scale=1.0;
490
+ #else
491
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
492
+ #endif
493
+ v_width2=vec2(outset,inset);}`),linePattern:zt(`#ifdef GL_ES
494
+ precision highp float;
495
+ #endif
496
+ uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;
497
+ #ifdef GLOBE
498
+ in float v_depth;
499
+ #endif
500
+ #pragma mapbox: define lowp vec4 pattern_from
501
+ #pragma mapbox: define lowp vec4 pattern_to
502
+ #pragma mapbox: define lowp float pixel_ratio_from
503
+ #pragma mapbox: define lowp float pixel_ratio_to
504
+ #pragma mapbox: define lowp float blur
505
+ #pragma mapbox: define lowp float opacity
506
+ void main() {
507
+ #pragma mapbox: initialize mediump vec4 pattern_from
508
+ #pragma mapbox: initialize mediump vec4 pattern_to
509
+ #pragma mapbox: initialize lowp float pixel_ratio_from
510
+ #pragma mapbox: initialize lowp float pixel_ratio_to
511
+ #pragma mapbox: initialize lowp float blur
512
+ #pragma mapbox: initialize lowp float opacity
513
+ vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;
514
+ #ifdef GLOBE
515
+ if (v_depth > 1.0) {discard;}
516
+ #endif
517
+ #ifdef OVERDRAW_INSPECTOR
518
+ fragColor=vec4(1.0);
519
+ #endif
520
+ }`,`
521
+ #define scale 0.015873016
522
+ #define LINE_DISTANCE_SCALE 2.0
523
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;
524
+ #ifdef GLOBE
525
+ out float v_depth;
526
+ #endif
527
+ #pragma mapbox: define lowp float blur
528
+ #pragma mapbox: define lowp float opacity
529
+ #pragma mapbox: define lowp float offset
530
+ #pragma mapbox: define mediump float gapwidth
531
+ #pragma mapbox: define mediump float width
532
+ #pragma mapbox: define lowp float floorwidth
533
+ #pragma mapbox: define lowp vec4 pattern_from
534
+ #pragma mapbox: define lowp vec4 pattern_to
535
+ #pragma mapbox: define lowp float pixel_ratio_from
536
+ #pragma mapbox: define lowp float pixel_ratio_to
537
+ void main() {
538
+ #pragma mapbox: initialize lowp float blur
539
+ #pragma mapbox: initialize lowp float opacity
540
+ #pragma mapbox: initialize lowp float offset
541
+ #pragma mapbox: initialize mediump float gapwidth
542
+ #pragma mapbox: initialize mediump float width
543
+ #pragma mapbox: initialize lowp float floorwidth
544
+ #pragma mapbox: initialize mediump vec4 pattern_from
545
+ #pragma mapbox: initialize mediump vec4 pattern_to
546
+ #pragma mapbox: initialize lowp float pixel_ratio_from
547
+ #pragma mapbox: initialize lowp float pixel_ratio_to
548
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
549
+ #ifdef GLOBE
550
+ v_depth=gl_Position.z/gl_Position.w;
551
+ #endif
552
+ #ifdef TERRAIN3D
553
+ v_gamma_scale=1.0;
554
+ #else
555
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
556
+ #endif
557
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:zt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;
558
+ #ifdef GLOBE
559
+ in float v_depth;
560
+ #endif
561
+ #pragma mapbox: define highp vec4 color
562
+ #pragma mapbox: define lowp float blur
563
+ #pragma mapbox: define lowp float opacity
564
+ #pragma mapbox: define mediump float width
565
+ #pragma mapbox: define lowp float floorwidth
566
+ void main() {
567
+ #pragma mapbox: initialize highp vec4 color
568
+ #pragma mapbox: initialize lowp float blur
569
+ #pragma mapbox: initialize lowp float opacity
570
+ #pragma mapbox: initialize mediump float width
571
+ #pragma mapbox: initialize lowp float floorwidth
572
+ float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);
573
+ #ifdef GLOBE
574
+ if (v_depth > 1.0) {discard;}
575
+ #endif
576
+ #ifdef OVERDRAW_INSPECTOR
577
+ fragColor=vec4(1.0);
578
+ #endif
579
+ }`,`
580
+ #define scale 0.015873016
581
+ #define LINE_DISTANCE_SCALE 2.0
582
+ in vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;
583
+ #ifdef GLOBE
584
+ out float v_depth;
585
+ #endif
586
+ #pragma mapbox: define highp vec4 color
587
+ #pragma mapbox: define lowp float blur
588
+ #pragma mapbox: define lowp float opacity
589
+ #pragma mapbox: define mediump float gapwidth
590
+ #pragma mapbox: define lowp float offset
591
+ #pragma mapbox: define mediump float width
592
+ #pragma mapbox: define lowp float floorwidth
593
+ void main() {
594
+ #pragma mapbox: initialize highp vec4 color
595
+ #pragma mapbox: initialize lowp float blur
596
+ #pragma mapbox: initialize lowp float opacity
597
+ #pragma mapbox: initialize mediump float gapwidth
598
+ #pragma mapbox: initialize lowp float offset
599
+ #pragma mapbox: initialize mediump float width
600
+ #pragma mapbox: initialize lowp float floorwidth
601
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;
602
+ #ifdef GLOBE
603
+ v_depth=gl_Position.z/gl_Position.w;
604
+ #endif
605
+ #ifdef TERRAIN3D
606
+ v_gamma_scale=1.0;
607
+ #else
608
+ float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
609
+ #endif
610
+ v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:zt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);
611
+ #ifdef OVERDRAW_INSPECTOR
612
+ fragColor=vec4(1.0);
613
+ #endif
614
+ }`,`uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;
615
+ #ifdef GLOBE
616
+ if (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}
617
+ #endif
618
+ v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}`),symbolIcon:zt(`uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;
619
+ #pragma mapbox: define lowp float opacity
620
+ void main() {
621
+ #pragma mapbox: initialize lowp float opacity
622
+ lowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;
623
+ #ifdef OVERDRAW_INSPECTOR
624
+ fragColor=vec4(1.0);
625
+ #endif
626
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;
627
+ #pragma mapbox: define lowp float opacity
628
+ void main() {
629
+ #pragma mapbox: initialize lowp float opacity
630
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
631
+ camera_to_anchor_distance/u_camera_to_center_distance :
632
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
633
+ #ifdef GLOBE
634
+ if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
635
+ #endif
636
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:zt(`#define SDF_PX 8.0
637
+ uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;
638
+ #pragma mapbox: define highp vec4 fill_color
639
+ #pragma mapbox: define highp vec4 halo_color
640
+ #pragma mapbox: define lowp float opacity
641
+ #pragma mapbox: define lowp float halo_width
642
+ #pragma mapbox: define lowp float halo_blur
643
+ void main() {
644
+ #pragma mapbox: initialize highp vec4 fill_color
645
+ #pragma mapbox: initialize highp vec4 halo_color
646
+ #pragma mapbox: initialize lowp float opacity
647
+ #pragma mapbox: initialize lowp float halo_width
648
+ #pragma mapbox: initialize lowp float halo_blur
649
+ float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);
650
+ #ifdef OVERDRAW_INSPECTOR
651
+ fragColor=vec4(1.0);
652
+ #endif
653
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;
654
+ #pragma mapbox: define highp vec4 fill_color
655
+ #pragma mapbox: define highp vec4 halo_color
656
+ #pragma mapbox: define lowp float opacity
657
+ #pragma mapbox: define lowp float halo_width
658
+ #pragma mapbox: define lowp float halo_blur
659
+ void main() {
660
+ #pragma mapbox: initialize highp vec4 fill_color
661
+ #pragma mapbox: initialize highp vec4 halo_color
662
+ #pragma mapbox: initialize lowp float opacity
663
+ #pragma mapbox: initialize lowp float halo_width
664
+ #pragma mapbox: initialize lowp float halo_blur
665
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
666
+ camera_to_anchor_distance/u_camera_to_center_distance :
667
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
668
+ #ifdef GLOBE
669
+ if(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
670
+ #endif
671
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:zt(`#define SDF_PX 8.0
672
+ #define SDF 1.0
673
+ #define ICON 0.0
674
+ uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;
675
+ #pragma mapbox: define highp vec4 fill_color
676
+ #pragma mapbox: define highp vec4 halo_color
677
+ #pragma mapbox: define lowp float opacity
678
+ #pragma mapbox: define lowp float halo_width
679
+ #pragma mapbox: define lowp float halo_blur
680
+ void main() {
681
+ #pragma mapbox: initialize highp vec4 fill_color
682
+ #pragma mapbox: initialize highp vec4 halo_color
683
+ #pragma mapbox: initialize lowp float opacity
684
+ #pragma mapbox: initialize lowp float halo_width
685
+ #pragma mapbox: initialize lowp float halo_blur
686
+ float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;
687
+ #ifdef OVERDRAW_INSPECTOR
688
+ fragColor=vec4(1.0);
689
+ #endif
690
+ return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);
691
+ #ifdef OVERDRAW_INSPECTOR
692
+ fragColor=vec4(1.0);
693
+ #endif
694
+ }`,`in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;
695
+ #pragma mapbox: define highp vec4 fill_color
696
+ #pragma mapbox: define highp vec4 halo_color
697
+ #pragma mapbox: define lowp float opacity
698
+ #pragma mapbox: define lowp float halo_width
699
+ #pragma mapbox: define lowp float halo_blur
700
+ void main() {
701
+ #pragma mapbox: initialize highp vec4 fill_color
702
+ #pragma mapbox: initialize highp vec4 halo_color
703
+ #pragma mapbox: initialize lowp float opacity
704
+ #pragma mapbox: initialize lowp float halo_width
705
+ #pragma mapbox: initialize lowp float halo_blur
706
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?
707
+ camera_to_anchor_distance/u_camera_to_center_distance :
708
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;
709
+ #ifdef GLOBE
710
+ if(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}
711
+ #endif
712
+ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:zt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:zt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:zt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:zt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:zt(`in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758
713
+ );color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,"in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:zt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function zt(h,e){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,o=e.match(/in ([\w]+) ([\w]+)/g),c=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),d=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=d?d.concat(c):c,v={};return{fragmentSource:h=h.replace(n,(x,P,C,k,A)=>(v[A]=!0,P==="define"?`
714
+ #ifndef HAS_UNIFORM_u_${A}
715
+ in ${C} ${k} ${A};
716
+ #else
717
+ uniform ${C} ${k} u_${A};
718
+ #endif
719
+ `:`
720
+ #ifdef HAS_UNIFORM_u_${A}
721
+ ${C} ${k} ${A} = u_${A};
722
+ #endif
723
+ `)),vertexSource:e=e.replace(n,(x,P,C,k,A)=>{const R=k==="float"?"vec2":"vec4",O=A.match(/color/)?"color":R;return v[A]?P==="define"?`
724
+ #ifndef HAS_UNIFORM_u_${A}
725
+ uniform lowp float u_${A}_t;
726
+ in ${C} ${R} a_${A};
727
+ out ${C} ${k} ${A};
728
+ #else
729
+ uniform ${C} ${k} u_${A};
730
+ #endif
731
+ `:O==="vec4"?`
732
+ #ifndef HAS_UNIFORM_u_${A}
733
+ ${A} = a_${A};
734
+ #else
735
+ ${C} ${k} ${A} = u_${A};
736
+ #endif
737
+ `:`
738
+ #ifndef HAS_UNIFORM_u_${A}
739
+ ${A} = unpack_mix_${O}(a_${A}, u_${A}_t);
740
+ #else
741
+ ${C} ${k} ${A} = u_${A};
742
+ #endif
743
+ `:P==="define"?`
744
+ #ifndef HAS_UNIFORM_u_${A}
745
+ uniform lowp float u_${A}_t;
746
+ in ${C} ${R} a_${A};
747
+ #else
748
+ uniform ${C} ${k} u_${A};
749
+ #endif
750
+ `:O==="vec4"?`
751
+ #ifndef HAS_UNIFORM_u_${A}
752
+ ${C} ${k} ${A} = a_${A};
753
+ #else
754
+ ${C} ${k} ${A} = u_${A};
755
+ #endif
756
+ `:`
757
+ #ifndef HAS_UNIFORM_u_${A}
758
+ ${C} ${k} ${A} = unpack_mix_${O}(a_${A}, u_${A}_t);
759
+ #else
760
+ ${C} ${k} ${A} = u_${A};
761
+ #endif
762
+ `}),staticAttributes:o,staticUniforms:g}}class xs{constructor(e,n,o){this.vertexBuffer=e,this.indexBuffer=n,this.segments=o}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Qn=a.aJ([{name:"a_pos",type:"Int16",components:2}]);const An="#define PROJECTION_MERCATOR",bs="mercator";class Rt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return bs}get shaderDefine(){return An}get shaderPreludeCode(){return rn.projectionMercator}get vertexShaderPreludeCode(){return rn.projectionMercator.vertexSource}get subdivisionGranularity(){return a.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,o,c,d){if(this._cachedMesh)return this._cachedMesh;const g=new a.aL;g.emplaceBack(0,0),g.emplaceBack(a.$,0),g.emplaceBack(0,a.$),g.emplaceBack(a.$,a.$);const v=e.createVertexBuffer(g,Qn.members),x=a.aM.simpleSegment(0,0,4,2),P=new a.aN;P.emplaceBack(1,0,2),P.emplaceBack(1,2,3);const C=e.createIndexBuffer(P);return this._cachedMesh=new xs(v,C,x),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class ws{constructor(e=0,n=0,o=0,c=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(o)||o<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=o,this.right=c}interpolate(e,n,o){return n.top!=null&&e.top!=null&&(this.top=a.C.number(e.top,n.top,o)),n.bottom!=null&&e.bottom!=null&&(this.bottom=a.C.number(e.bottom,n.bottom,o)),n.left!=null&&e.left!=null&&(this.left=a.C.number(e.left,n.left,o)),n.right!=null&&e.right!=null&&(this.right=a.C.number(e.right,n.right,o)),this}getCenter(e,n){const o=a.ah((this.left+e-this.right)/2,0,e),c=a.ah((this.top+n-this.bottom)/2,0,n);return new a.P(o,c)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new ws(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ra(h,e){if(!h.renderWorldCopies||h.lngRange)return;const n=e.lng-h.center.lng;e.lng+=n>180?-360:n<-180?360:0}function Da(h){return Math.max(0,Math.floor(h))}class mr{constructor(e,n,o,c,d,g){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=g===void 0||!!g,this._minZoom=n||0,this._maxZoom=o||22,this._minPitch=c??0,this._maxPitch=d??60,this.setMaxBounds(),this._width=0,this._height=0,this._center=new a.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Da(this._zoom),this._scale=a.af(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new ws,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,n,o){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Da(this._zoom),this._scale=a.af(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new ws(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!o&&e.autoCalculateNearFarZ,n&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const n=a.aO(e,-180,180)*Math.PI/180;var o,c,d,g,v,x,P,C,k;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=ue(),o=this._rotationMatrix,d=-this._bearingInRadians,g=(c=this._rotationMatrix)[0],v=c[1],x=c[2],P=c[3],C=Math.sin(d),k=Math.cos(d),o[0]=g*k+x*C,o[1]=v*k+P*C,o[2]=g*-C+x*k,o[3]=v*-C+P*k)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const n=a.ah(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const n=e/180*Math.PI;this._rollInRadians!==n&&(this._unmodified=!1,this._rollInRadians=n,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return a.aP(this._fovInRadians)}setFov(e){e=a.ah(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=a.ae(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const n=this.getConstrained(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=a.af(n),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,n){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=n,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,o){this._unmodified=!1,this._edgeInsets.interpolate(e,n,o),this._constrain(),this._calcMatrices()}resize(e,n,o=!0){this._width=e,this._height=n,o&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new le([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-a.ai,a.ai])}getConstrained(e,n){return this._callbacks.getConstrained(e,n)}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{const{minX:o,minY:c,maxX:d,maxY:g}=a.a2.fromPoints(n).extend(e);return[new a.P(o,c),new a.P(d,c),new a.P(d,g),new a.P(o,g),new a.P(o,c)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:o}=this.getConstrained(this.center,this.zoom);this.setCenter(n),this.setZoom(o),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=a.ag(new Float64Array(16));a.N(e,e,[this._width/2,-this._height/2,1]),a.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=a.ag(new Float64Array(16)),a.N(e,e,[1,-1,1]),a.M(e,e,[-1,-1,0]),a.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,o,c){const d=o!==void 0?o:this.bearing,g=c=c!==void 0?c:this.pitch,v=a.a1.fromLngLat(e,n),x=-Math.cos(a.ae(g)),P=Math.sin(a.ae(g)),C=P*Math.sin(a.ae(d)),k=-P*Math.cos(a.ae(d));let A=this.elevation;const R=n-A;let O;x*R>=0||Math.abs(x)<.1?(O=1e4,A=n+O*x):O=-R/x;let Z,G,q=a.aQ(1,v.y),W=0;do{if(W+=1,W>10)break;G=O/q,Z=new a.a1(v.x+C*G,v.y+k*G),q=1/Z.meterInMercatorCoordinateUnits()}while(Math.abs(O-G*q)>1e-12);return{center:Z.toLngLat(),elevation:A,zoom:a.ak(this.height/2/Math.tan(this.fovInRadians/2)/G/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const n=a.aj(1,this.center.lat)*this.worldSize,o=this.cameraToCenterDistance/n,c=a.a1.fromLngLat(this.center,this.elevation),d=me(this.center,this.elevation,this.pitch,this.bearing,o);this._elevation=e;const g=this.calculateCenterFromCameraLngLatAlt(d.toLngLat(),a.aQ(d.z,c.y),this.bearing,this.pitch);this._elevation=g.elevation,this._center=g.center,this.setZoom(g.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=a.aj(1,this.center.lat)*this.worldSize;return me(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const n=e.canonical.z>=0?1<<e.canonical.z:Math.pow(2,e.canonical.z);return[e.canonical.x/n,e.canonical.y/n,1/n/a.$,1/n/a.$]}}class qi{constructor(e,n){this.min=e,this.max=n,this.center=a.aR([],a.aS([],this.min,this.max),.5)}quadrant(e){const n=[e%2==0,e<2],o=a.aT(this.min),c=a.aT(this.max);for(let d=0;d<n.length;d++)o[d]=n[d]?this.min[d]:this.center[d],c[d]=n[d]?this.center[d]:this.max[d];return c[2]=this.max[2],new qi(o,c)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let n=!0;for(let o=0;o<e.planes.length;o++){const c=this.intersectsPlane(e.planes[o]);if(c===0)return 0;c===1&&(n=!1)}return n?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let n=e[3],o=e[3];for(let c=0;c<3;c++)e[c]>0?(n+=e[c]*this.min[c],o+=e[c]*this.max[c]):(o+=e[c]*this.min[c],n+=e[c]*this.max[c]);return n>=0?2:o<0?0:1}}class gr{distanceToTile2d(e,n,o,c){const d=c.distanceX([e,n]),g=c.distanceY([e,n]);return Math.hypot(d,g)}getWrap(e,n,o){return o}getTileBoundingVolume(e,n,o,c){var d,g;let v=0,x=0;if(c!=null&&c.terrain){const C=new a.Z(e.z,n,e.z,e.x,e.y),k=c.terrain.getMinMaxElevation(C);v=(d=k.minElevation)!==null&&d!==void 0?d:Math.min(0,o),x=(g=k.maxElevation)!==null&&g!==void 0?g:Math.max(0,o)}const P=1<<e.z;return new qi([n+e.x/P,e.y/P,v],[n+(e.x+1)/P,(e.y+1)/P,x])}allowVariableZoom(e,n){const o=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,c=a.ah(78.5-o/2,0,60);return!!n.terrain||e.pitch>c}allowWorldCopies(){return!0}prepareNextFrame(){}}class zi{constructor(e,n,o){this.points=e,this.planes=n,this.aabb=o}static fromInvProjectionMatrix(e,n=1,o=0,c,d){const g=d?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],v=Math.pow(2,o),x=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(A=>function(R,O,Z,G){const q=a.aw([],R,O),W=1/q[3]/Z*G;return a.aY(q,q,[W,W,1/q[3],W])}(A,e,n,v));c&&function(A,R,O,Z){const G=Z?4:0,q=Z?0:4;let W=0;const J=[],K=[];for(let Y=0;Y<4;Y++){const pe=a.aU([],A[Y+q],A[Y+G]),be=a.aZ(pe);a.aR(pe,pe,1/be),J.push(be),K.push(pe)}for(let Y=0;Y<4;Y++){const pe=a.a_(A[Y+G],K[Y],O);W=pe!==null&&pe>=0?Math.max(W,pe):Math.max(W,J[Y])}const te=function(Y,pe){const be=a.aU([],Y[pe[0]],Y[pe[1]]),_e=a.aU([],Y[pe[2]],Y[pe[1]]),ye=[0,0,0,0];return a.aV(ye,a.aW([],be,_e)),ye[3]=-a.aX(ye,Y[pe[0]]),ye}(A,R),se=function(Y,pe){const be=a.a$(Y),_e=a.b0([],Y,1/be),ye=a.aU([],pe,a.aR([],_e,a.aX(pe,_e))),xe=a.a$(ye);if(xe>0){const Le=Math.sqrt(1-_e[3]*_e[3]),Oe=a.aR([],_e,-_e[3]),Ie=a.aS([],Oe,a.aR([],ye,Le/xe));return a.b1(pe,Ie)}return null}(O,te);if(se!==null){const Y=se/a.aX(K[0],te);W=Math.min(W,Y)}for(let Y=0;Y<4;Y++){const pe=Math.min(W,J[Y]);A[Y+q]=[A[Y+G][0]+K[Y][0]*pe,A[Y+G][1]+K[Y][1]*pe,A[Y+G][2]+K[Y][2]*pe,1]}}(x,g[0],c,d);const P=g.map(A=>{const R=a.aU([],x[A[0]],x[A[1]]),O=a.aU([],x[A[2]],x[A[1]]),Z=a.aV([],a.aW([],R,O)),G=-a.aX(Z,x[A[1]]);return Z.concat(G)}),C=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],k=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const A of x)for(let R=0;R<3;R++)C[R]=Math.min(C[R],A[R]),k[R]=Math.max(k[R],A[R]);return new zi(x,P,new qi(C,k))}}class ni{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,o){return this._helper.interpolatePadding(e,n,o)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,o=!0){this._helper.resize(e,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,n){}constructor(e,n,o,c,d){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new mr({calcMatrices:()=>{this._calcMatrices()},getConstrained:(g,v)=>this.getConstrained(g,v)},e,n,o,c,d),this._coveringTilesDetailsProvider=new gr}clone(){const e=new ni;return e.apply(this),e}apply(e,n,o){this._helper.apply(e,n,o)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const n=[new a.b2(0,e)];if(this._helper._renderWorldCopies){const o=this.screenPointToMercatorCoordinate(new a.P(0,0)),c=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,0)),d=this.screenPointToMercatorCoordinate(new a.P(this._helper._width,this._helper._height)),g=this.screenPointToMercatorCoordinate(new a.P(0,this._helper._height)),v=Math.floor(Math.min(o.x,c.x,d.x,g.x)),x=Math.floor(Math.max(o.x,c.x,d.x,g.x)),P=1;for(let C=v-P;C<=x+P;C++)C!==0&&n.push(new a.b2(C,e))}return n}getCameraFrustum(){return zi.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const n=this.screenPointToLocation(this.centerPoint,e),o=e?e.getElevationForLngLatZoom(n,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(o)}setLocationAtPoint(e,n){const o=a.aj(this.elevation,this.center.lat),c=this.screenPointToMercatorCoordinateAtZ(n,o),d=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,o),g=a.a1.fromLngLat(e),v=new a.a1(g.x-(c.x-d.x),g.y-(c.y-d.y));this.setCenter(v==null?void 0:v.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(a.a1.fromLngLat(e),n.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(a.a1.fromLngLat(e))}screenPointToLocation(e,n){var o;return(o=this.screenPointToMercatorCoordinate(e,n))===null||o===void 0?void 0:o.toLngLat()}screenPointToMercatorCoordinate(e,n){if(n){const o=n.pointCoordinate(e);if(o!=null)return o}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){const o=n||0,c=[e.x,e.y,0,1],d=[e.x,e.y,1,1];a.aw(c,c,this._pixelMatrixInverse),a.aw(d,d,this._pixelMatrixInverse);const g=c[3],v=d[3],x=c[1]/g,P=d[1]/v,C=c[2]/g,k=d[2]/v,A=C===k?0:(o-C)/(k-C);return new a.a1(a.C.number(c[0]/g,d[0]/v,A)/this.worldSize,a.C.number(x,P,A)/this.worldSize,o)}coordinatePoint(e,n=0,o=this._pixelMatrix){const c=[e.x*this.worldSize,e.y*this.worldSize,n,1];return a.aw(c,c,o),new a.P(c[0]/c[3],c[1]/c[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ie(this));return new le().extend(this.screenPointToLocation(new a.P(0,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,e))).extend(this.screenPointToLocation(new a.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new a.P(0,this._helper._height)))}isPointOnMapSurface(e,n){return n?n.pointCoordinate(e)!=null:e.y>this.height/2-ie(this)}calculatePosMatrix(e,n=!1,o){var c;const d=(c=e.key)!==null&&c!==void 0?c:a.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),g=n?this._alignedPosMatrixCache:this._posMatrixCache;if(g.has(d)){const P=g.get(d);return o?P.f32:P.f64}const v=ce(e,this.worldSize);a.O(v,n?this._alignedProjMatrix:this._viewProjMatrix,v);const x={f64:v,f32:new Float32Array(v)};return g.set(d,x),o?x.f32:x.f64}calculateFogMatrix(e){const n=e.key,o=this._fogMatrixCacheF32;if(o.has(n))return o.get(n);const c=ce(e,this.worldSize);return a.O(c,this._fogMatrix,c),o.set(n,new Float32Array(c)),o.get(n)}getConstrained(e,n){n=a.ah(+n,this.minZoom,this.maxZoom);const o={center:new a.S(e.lng,e.lat),zoom:n};let c=this._helper._lngRange;!this._helper._renderWorldCopies&&c===null&&(c=[-179.9999999999,179.9999999999]);const d=this.tileSize*a.af(o.zoom);let g=0,v=d,x=0,P=d,C=0,k=0;const{x:A,y:R}=this.size;if(this._helper._latRange){const J=this._helper._latRange;g=a.U(J[1])*d,v=a.U(J[0])*d,v-g<R&&(C=R/(v-g))}c&&(x=a.aO(a.V(c[0])*d,0,d),P=a.aO(a.V(c[1])*d,0,d),P<x&&(P+=d),P-x<A&&(k=A/(P-x)));const{x:O,y:Z}=U(d,e);let G,q;const W=Math.max(k||0,C||0);if(W){const J=new a.P(k?(P+x)/2:O,C?(v+g)/2:Z);return o.center=X(d,J).wrap(),o.zoom+=a.ak(W),o}if(this._helper._latRange){const J=R/2;Z-J<g&&(q=g+J),Z+J>v&&(q=v-J)}if(c){const J=(x+P)/2;let K=O;this._helper._renderWorldCopies&&(K=a.aO(O,J-d/2,J+d/2));const te=A/2;K-te<x&&(G=x+te),K+te>P&&(G=P-te)}if(G!==void 0||q!==void 0){const J=new a.P(G??O,q??Z);o.center=X(d,J).wrap()}return o}calculateCenterFromCameraLngLatAlt(e,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,o,c)}_calculateNearFarZIfNeeded(e,n,o){if(!this._helper.autoCalculateNearFarZ)return;const c=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),d=e-c*this._helper._pixelPerMeter/Math.cos(n),g=c<0?d:e,v=Math.PI/2+this.pitchInRadians,x=a.ae(this.fov)*(Math.abs(Math.cos(a.ae(this.roll)))*this.height+Math.abs(Math.sin(a.ae(this.roll)))*this.width)/this.height*(.5+o.y/this.height),P=Math.sin(x)*g/Math.sin(a.ah(Math.PI-v-x,.01,Math.PI-.01)),C=ie(this),k=Math.atan(C/this._helper.cameraToCenterDistance),A=a.ae(.75),R=k>A?2*k*(.5+o.y/(2*C)):A,O=Math.sin(R)*g/Math.sin(a.ah(Math.PI-v-R,.01,Math.PI-.01)),Z=Math.min(P,O);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*Z+g),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,n=U(this.worldSize,this.center),o=n.x,c=n.y;this._helper._pixelPerMeter=a.aj(1,this.center.lat)*this.worldSize;const d=a.ae(Math.min(this.pitch,j)),g=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(d));let v;this._calculateNearFarZIfNeeded(g,d,e),v=new Float64Array(16),a.b4(v,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),a.aq(this._invProjMatrix,v),v[8]=2*-e.x/this._helper._width,v[9]=2*e.y/this._helper._height,this._projectionMatrix=a.b5(v),a.N(v,v,[1,-1,1]),a.M(v,v,[0,0,-this._helper.cameraToCenterDistance]),a.b6(v,v,-this.rollInRadians),a.b7(v,v,this.pitchInRadians),a.b6(v,v,-this.bearingInRadians),a.M(v,v,[-o,-c,0]),this._mercatorMatrix=a.N([],v,[this.worldSize,this.worldSize,this.worldSize]),a.N(v,v,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,v),a.M(v,v,[0,0,-this.elevation]),this._viewProjMatrix=v,this._invViewProjMatrix=a.aq([],v);const x=[0,0,-1,1];a.aw(x,x,this._invViewProjMatrix),this._cameraPosition=[x[0]/x[3],x[1]/x[3],x[2]/x[3]],this._fogMatrix=new Float64Array(16),a.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,g,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,a.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),a.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),a.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),a.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),a.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),a.M(this._fogMatrix,this._fogMatrix,[-o,-c,0]),a.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),a.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=a.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,v);const P=this._helper._width%2/2,C=this._helper._height%2/2,k=Math.cos(this.bearingInRadians),A=Math.sin(-this.bearingInRadians),R=o-Math.round(o)+k*P+A*C,O=c-Math.round(c)+k*C+A*P,Z=new Float64Array(v);if(a.M(Z,Z,[R>.5?R-1:R,O>.5?O-1:O,0]),this._alignedProjMatrix=Z,v=a.aq(new Float64Array(16),this._pixelMatrix),!v)throw new Error("failed to invert matrix");this._pixelMatrixInverse=v,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new a.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return a.aw(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=a.aj(1,this.center.lat)*this.worldSize;return me(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){const o=a.a1.fromLngLat(e),c=[o.x*this.worldSize,o.y*this.worldSize,n,1];return a.aw(c,c,this._viewProjMatrix),c[2]/c[3]}getProjectionData(e){const{overscaledTileID:n,aligned:o,applyTerrainMatrix:c}=e,d=this._helper.getMercatorTileCoordinates(n),g=n?this.calculatePosMatrix(n,o,!0):null;let v;return v=n&&n.terrainRttPosMatrix32f&&c?n.terrainRttPosMatrix32f:g||a.b8(),{mainMatrix:v,tileMercatorCoords:d,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:v}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,n,o){return 1}transformLightDirection(e){return a.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,n,o,c){const d=this.calculatePosMatrix(o);let g;c?(g=[e,n,c(e,n),1],a.aw(g,g,d)):(g=[e,n,0,1],Xs(g,g,d));const v=g[3];return{point:new a.P(g[0]/v,g[1]/v),signedDistanceFromCamera:v,isOccluded:!1}}populateCache(e){for(const n of e)this.calculatePosMatrix(n)}getMatrixForModel(e,n){const o=a.a1.fromLngLat(e,n),c=o.meterInMercatorCoordinateUnits(),d=a.b9();return a.M(d,d,[o.x,o.y,o.z]),a.b6(d,d,Math.PI),a.b7(d,d,Math.PI/2),a.N(d,d,[-c,c,c]),d}getProjectionDataForCustomLayer(e=!0){const n=new a.Z(0,0,0,0,0),o=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),c=ce(n,this.worldSize);a.O(c,this._viewProjMatrix,c),o.tileMercatorCoords=[0,0,1,1];const d=[a.$,a.$,this.worldSize/this._helper.pixelsPerMeter],g=a.ba();return a.N(g,c,d),o.fallbackMatrix=g,o.mainMatrix=g,o}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function qu(){a.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function _r(h){if(h.useSlerp)if(h.k<1){const e=a.bb(h.startEulerAngles.roll,h.startEulerAngles.pitch,h.startEulerAngles.bearing),n=a.bb(h.endEulerAngles.roll,h.endEulerAngles.pitch,h.endEulerAngles.bearing),o=new Float64Array(4);a.bc(o,e,n,h.k);const c=a.bd(o);h.tr.setRoll(c.roll),h.tr.setPitch(c.pitch),h.tr.setBearing(c.bearing)}else h.tr.setRoll(h.endEulerAngles.roll),h.tr.setPitch(h.endEulerAngles.pitch),h.tr.setBearing(h.endEulerAngles.bearing);else h.tr.setRoll(a.C.number(h.startEulerAngles.roll,h.endEulerAngles.roll,h.k)),h.tr.setPitch(a.C.number(h.startEulerAngles.pitch,h.endEulerAngles.pitch,h.k)),h.tr.setBearing(a.C.number(h.startEulerAngles.bearing,h.endEulerAngles.bearing,h.k))}function Fr(h,e,n,o,c){const d=c.padding,g=U(c.worldSize,n.getNorthWest()),v=U(c.worldSize,n.getNorthEast()),x=U(c.worldSize,n.getSouthEast()),P=U(c.worldSize,n.getSouthWest()),C=a.ae(-o),k=g.rotate(C),A=v.rotate(C),R=x.rotate(C),O=P.rotate(C),Z=new a.P(Math.max(k.x,A.x,O.x,R.x),Math.max(k.y,A.y,O.y,R.y)),G=new a.P(Math.min(k.x,A.x,O.x,R.x),Math.min(k.y,A.y,O.y,R.y)),q=Z.sub(G),W=(c.width-(d.left+d.right+e.left+e.right))/q.x,J=(c.height-(d.top+d.bottom+e.top+e.bottom))/q.y;if(J<0||W<0)return void qu();const K=Math.min(a.ak(c.scale*Math.min(W,J)),h.maxZoom),te=a.P.convert(h.offset),se=new a.P((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(a.ae(o)),Y=te.add(se).mult(c.scale/a.af(K));return{center:X(c.worldSize,g.add(x).div(2).sub(Y)),zoom:K,bearing:o}}class ur{get useGlobeControls(){return!1}handlePanInertia(e,n){const o=e.mag(),c=Math.abs(ie(n));return{easingOffset:e.mult(Math.min(.75*c/o,1)),easingCenter:n.center}}handleMapControlsRollPitchBearingZoom(e,n){e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta),e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta)}handleMapControlsPan(e,n,o){e.around.distSqr(n.centerPoint)<.01||n.setLocationAtPoint(o,e.around)}cameraForBoxAndBearing(e,n,o,c,d){return Fr(e,n,o,c,d)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom!==void 0?+n.zoom:e.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(a.S.convert(n.center))}handleEaseTo(e,n){const o=e.zoom,c=e.padding,d={roll:e.roll,pitch:e.pitch,bearing:e.bearing},g={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},v=n.zoom!==void 0,x=!e.isPaddingEqual(n.padding);let P=!1;const C=v?+n.zoom:e.zoom;let k=e.centerPoint.add(n.offsetAsPoint);const A=e.screenPointToLocation(k),{center:R,zoom:O}=e.getConstrained(a.S.convert(n.center||A),C??o);Ra(e,R);const Z=U(e.worldSize,A),G=U(e.worldSize,R).sub(Z),q=a.af(O-o);return P=O!==o,{easeFunc:W=>{if(P&&e.setZoom(a.C.number(o,O,W)),a.be(d,g)||_r({startEulerAngles:d,endEulerAngles:g,tr:e,k:W,useSlerp:d.roll!=g.roll}),x&&(e.interpolatePadding(c,n.padding,W),k=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{const J=a.af(e.zoom-o),K=O>o?Math.min(2,q):Math.max(.5,q),te=Math.pow(K,1-W),se=X(e.worldSize,Z.add(G.mult(W*te)).mult(J));e.setLocationAtPoint(e.renderWorldCopies?se.wrap():se,k)}},isZooming:P,elevationCenter:R}}handleFlyTo(e,n){const o=n.zoom!==void 0,c=e.zoom,d=e.getConstrained(a.S.convert(n.center||n.locationAtOffset),o?+n.zoom:c),g=d.center,v=d.zoom;Ra(e,g);const x=U(e.worldSize,n.locationAtOffset),P=U(e.worldSize,g).sub(x),C=P.mag(),k=a.af(v-c);let A;if(n.minZoom!==void 0){const R=Math.min(+n.minZoom,c,v),O=e.getConstrained(g,R).zoom;A=a.af(O-c)}return{easeFunc:(R,O,Z,G)=>{e.setZoom(R===1?v:c+a.ak(O));const q=R===1?g:X(e.worldSize,x.add(P.mult(Z)).mult(O));e.setLocationAtPoint(e.renderWorldCopies?q.wrap():q,G)},scaleOfZoom:k,targetCenter:g,scaleOfMinZoom:A,pixelPathLength:C}}}class ci{constructor(e,n,o){this.blendFunction=e,this.blendColor=n,this.mask=o}}ci.Replace=[1,0],ci.disabled=new ci(ci.Replace,a.bf.transparent,[!1,!1,!1,!1]),ci.unblended=new ci(ci.Replace,a.bf.transparent,[!0,!0,!0,!0]),ci.alphaBlended=new ci([1,771],a.bf.transparent,[!0,!0,!0,!0]);const Ts=2305;class pt{constructor(e,n,o){this.enable=e,this.mode=n,this.frontFace=o}}pt.disabled=new pt(!1,1029,Ts),pt.backCCW=new pt(!0,1029,Ts),pt.frontCCW=new pt(!0,1028,Ts);class vt{constructor(e,n,o){this.func=e,this.mask=n,this.range=o}}vt.ReadOnly=!1,vt.ReadWrite=!0,vt.disabled=new vt(519,vt.ReadOnly,[0,1]);const kn=7680;class $t{constructor(e,n,o,c,d,g){this.test=e,this.ref=n,this.mask=o,this.fail=c,this.depthFail=d,this.pass=g}}$t.disabled=new $t({func:519,mask:0},0,0,kn,kn,kn);const Br=new WeakMap;function wn(h){var e;if(Br.has(h))return Br.get(h);{const n=(e=h.getParameter(h.VERSION))===null||e===void 0?void 0:e.startsWith("WebGL 2.0");return Br.set(h,n),n}}class Tn{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const n=e.context,o=n.gl;this._texFormat=o.RGBA,this._texType=o.UNSIGNED_BYTE;const c=new a.aL;c.emplaceBack(-1,-1),c.emplaceBack(2,-1),c.emplaceBack(-1,2);const d=new a.aN;d.emplaceBack(0,1,2),this._fullscreenTriangle=new xs(n.createVertexBuffer(c,Qn.members),n.createIndexBuffer(d),a.aM.simpleSegment(0,0,c.length,d.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(o.TEXTURE1);const g=o.createTexture();o.bindTexture(o.TEXTURE_2D,g),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texImage2D(o.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(g),wn(o)&&(this._pbo=o.createBuffer(),o.bindBuffer(o.PIXEL_PACK_BUFFER,this._pbo),o.bufferData(o.PIXEL_PACK_BUFFER,4,o.STREAM_READ),o.bindBuffer(o.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,n){const o=this._updateCount;return this._readbackQueue?o>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():o>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,n),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,n=e.gl;e.activeTexture.set(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){const o=this._cachedRenderContext.context,c=o.gl;if(this._bindFramebuffer(),o.viewport.set([0,0,this._texWidth,this._texHeight]),o.clear({color:a.bf.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(o,c.TRIANGLES,vt.disabled,$t.disabled,ci.unblended,pt.disabled,((d,g)=>({u_input:d,u_output_expected:g}))(e,n),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&wn(c)){c.bindBuffer(c.PIXEL_PACK_BUFFER,this._pbo),c.readBuffer(c.COLOR_ATTACHMENT0),c.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const d=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);c.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:d}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&wn(e)){const n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return a.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Tn._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let n=0;return n+=e[0]/256,n+=e[1]/65536,n+=e[2]/16777216,e[3]<127&&(n=-n),n/128}}const La=a.$/128;function rc(h,e){const n=h.granularity!==void 0?Math.max(h.granularity,1):1,o=n+(h.generateBorders?2:0),c=n+(h.extendToNorthPole||h.generateBorders?1:0)+(h.extendToSouthPole||h.generateBorders?1:0),d=o+1,g=c+1,v=h.generateBorders?-1:0,x=h.generateBorders||h.extendToNorthPole?-1:0,P=n+(h.generateBorders?1:0),C=n+(h.generateBorders||h.extendToSouthPole?1:0),k=d*g,A=o*c*6,R=d*g>65536;if(R&&e==="16bit")throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const O=R||e==="32bit",Z=new Int16Array(2*k);let G=0;for(let J=x;J<=C;J++)for(let K=v;K<=P;K++){let te=K/n*a.$;K===-1&&(te=-La),K===n+1&&(te=a.$+La);let se=J/n*a.$;J===-1&&(se=h.extendToNorthPole?a.bh:-La),J===n+1&&(se=h.extendToSouthPole?a.bi:a.$+La),Z[G++]=te,Z[G++]=se}const q=O?new Uint32Array(A):new Uint16Array(A);let W=0;for(let J=0;J<c;J++)for(let K=0;K<o;K++){const te=K+1+J*d,se=K+(J+1)*d,Y=K+1+(J+1)*d;q[W++]=K+J*d,q[W++]=se,q[W++]=te,q[W++]=te,q[W++]=se,q[W++]=Y}return{vertices:Z.buffer.slice(0),indices:q.buffer.slice(0),uses32bitIndices:O}}const eo=new a.aK({fill:new a.bj(128,2),line:new a.bj(512,0),tile:new a.bj(128,32),stencil:new a.bj(128,1),circle:3});class Fo{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return rn.projectionGlobe}get vertexShaderPreludeCode(){return rn.projectionMercator.vertexSource}get subdivisionGranularity(){return eo}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||(this._errorMeasurement=new Tn(e));const n=a.U(this._errorQueryLatitudeDegrees),o=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,c=this._errorMeasurement.updateErrorLoop(n,o),d=Se.now();c!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=c,this._errorMeasurementLastChangeTime=d);const g=Math.min(Math.max((d-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=a.bk(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,a.bl(g))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?"b":""}${e.extendToNorthPole?"n":""}${e.extendToSouthPole?"s":""}`}getMeshFromTileID(e,n,o,c,d){const g=(d==="stencil"?eo.stencil:eo.tile).getGranularityForZoomLevel(n.z);return this._getMesh(e,{granularity:g,generateBorders:o,extendToNorthPole:n.y===0&&c,extendToSouthPole:n.y===(1<<n.z)-1&&c})}_getMesh(e,n){const o=this._getMeshKey(n);if(o in this._tileMeshCache)return this._tileMeshCache[o];const c=function(d,g){const v=rc(g,"16bit"),x=a.aL.deserialize({arrayBuffer:v.vertices,length:v.vertices.byteLength/2/2}),P=a.aN.deserialize({arrayBuffer:v.indices,length:v.indices.byteLength/2/3});return new xs(d.createVertexBuffer(x,Qn.members),d.createIndexBuffer(P),a.aM.simpleSegment(0,0,x.length,P.length))}(e,n);return this._tileMeshCache[o]=c,c}recalculate(e){}hasTransition(){const e=Se.now();let n=!1;return n=n||(e-this._errorMeasurementLastChangeTime)/1e3<.7,n=n||this._errorMeasurement&&this._errorMeasurement.awaitingQuery,n}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}const Fa=new a.r({type:new a.D(a.v.projection.type)});class Ba extends a.E{constructor(e){super(),this._transitionable=new a.t(Fa),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new a.F(0)),this._mercatorProjection=new Rt,this._verticalPerspectiveProjection=new Fo}get transitionState(){const e=this.properties.get("type");if(typeof e=="string"&&e==="mercator")return 0;if(typeof e=="string"&&e==="vertical-perspective")return 1;if(e instanceof a.bm){if(e.from==="vertical-perspective"&&e.to==="mercator")return 1-e.transition;if(e.from==="mercator"&&e.to==="vertical-perspective")return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,n,o,c,d){return this.currentProjection.getMeshFromTileID(e,n,o,c,d)}setProjection(e){this._transitionable.setValue("type",(e==null?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function Oa(h){const e=to(h.worldSize,h.center.lat);return 2*Math.PI*e}function nn(h,e,n,o,c){const d=1/(1<<c),g=e/a.$*d+o*d,v=a.bo((h/a.$*d+n*d)*Math.PI*2+Math.PI,2*Math.PI),x=2*Math.atan(Math.exp(Math.PI-g*Math.PI*2))-.5*Math.PI,P=Math.cos(x),C=new Float64Array(3);return C[0]=Math.sin(v)*P,C[1]=Math.sin(x),C[2]=Math.cos(v)*P,C}function Hi(h){return function(e,n){const o=Math.cos(n),c=new Float64Array(3);return c[0]=Math.sin(e)*o,c[1]=Math.sin(n),c[2]=Math.cos(e)*o,c}(h.lng*Math.PI/180,h.lat*Math.PI/180)}function to(h,e){return h/(2*Math.PI)/Math.cos(e*Math.PI/180)}function Bo(h){const e=Math.asin(h[1])/Math.PI*180,n=Math.sqrt(h[0]*h[0]+h[2]*h[2]);if(n>1e-6){const o=h[0]/n,c=Math.acos(h[2]/n),d=(o>0?c:-c)/Math.PI*180;return new a.S(a.aO(d,-180,180),e)}return new a.S(0,e)}function Ss(h){return Math.cos(h*Math.PI/180)}function Ti(h,e){const n=Ss(h),o=Ss(e);return a.ak(o/n)}function Hu(h,e){const n=h.rotate(e.bearingInRadians),o=e.zoom+Ti(e.center.lat,0),c=a.bk(1/Ss(e.center.lat),1/Ss(Math.min(Math.abs(e.center.lat),60)),a.bn(o,7,3,0,1)),d=360/Oa({worldSize:e.worldSize,center:{lat:e.center.lat}});return new a.S(e.center.lng-n.x*d*c,a.ah(e.center.lat+n.y*d,-a.ai,a.ai))}function Oo(h){const e=.5*h,n=Math.sin(e),o=Math.cos(e);return Math.log(n+o)-Math.log(o-n)}function nc(h,e,n,o){const c=h.lat+n*o;if(Math.abs(n)>1){const d=(Math.sign(h.lat+n)!==Math.sign(h.lat)?-Math.abs(h.lat):Math.abs(h.lat))*Math.PI/180,g=Math.abs(h.lat+n)*Math.PI/180,v=Oo(d+o*(g-d)),x=Oo(d),P=Oo(g);return new a.S(h.lng+e*((v-x)/(P-x)),c)}return new a.S(h.lng+e*o,c)}class Xd{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,n,o,c){const d=`${e.z}_${e.x}_${e.y}_${c!=null&&c.terrain?"t":""}`,g=this._cache.get(d);if(g)return g;const v=this._cachePrevious.get(d);if(v)return this._cache.set(d,v),v;const x=this._boundingVolumeFactory(e,n,o,c);return this._cache.set(d,x),this._hadAnyChanges=!0,x}}class io{constructor(e,n,o,c){this.min=o,this.max=c,this.points=e,this.planes=n}static fromAabb(e,n){const o=[];for(let c=0;c<8;c++)o.push([1&~c?e[0]:n[0],(c>>1&1)==1?n[1]:e[1],(c>>2&1)==1?n[2]:e[2]]);return new io(o,[[-1,0,0,n[0]],[1,0,0,-e[0]],[0,-1,0,n[1]],[0,1,0,-e[1]],[0,0,-1,n[2]],[0,0,1,-e[2]]],e,n)}static fromCenterSizeAngles(e,n,o){const c=a.br([],o[0],o[1],o[2]),d=a.bs([],[n[0],0,0],c),g=a.bs([],[0,n[1],0],c),v=a.bs([],[0,0,n[2]],c),x=[...e],P=[...e];for(let k=0;k<8;k++)for(let A=0;A<3;A++){const R=e[A]+d[A]*(1&~k?-1:1)+g[A]*((k>>1&1)==1?1:-1)+v[A]*((k>>2&1)==1?1:-1);x[A]=Math.min(x[A],R),P[A]=Math.max(P[A],R)}const C=[];for(let k=0;k<8;k++){const A=[...e];a.aS(A,A,a.aR([],d,1&~k?-1:1)),a.aS(A,A,a.aR([],g,(k>>1&1)==1?1:-1)),a.aS(A,A,a.aR([],v,(k>>2&1)==1?1:-1)),C.push(A)}return new io(C,[[...d,-a.aX(d,C[0])],[...g,-a.aX(g,C[0])],[...v,-a.aX(v,C[0])],[-d[0],-d[1],-d[2],-a.aX(d,C[7])],[-g[0],-g[1],-g[2],-a.aX(g,C[7])],[-v[0],-v[1],-v[2],-a.aX(v,C[7])]],x,P)}intersectsFrustum(e){let n=!0;const o=this.points.length,c=this.planes.length,d=e.planes.length,g=e.points.length;for(let v=0;v<d;v++){const x=e.planes[v];let P=0;for(let C=0;C<o;C++){const k=this.points[C];x[0]*k[0]+x[1]*k[1]+x[2]*k[2]+x[3]>=0&&P++}if(P===0)return 0;P<o&&(n=!1)}if(n)return 2;for(let v=0;v<c;v++){const x=this.planes[v];let P=0;for(let C=0;C<g;C++){const k=e.points[C];x[0]*k[0]+x[1]*k[1]+x[2]*k[2]+x[3]>=0&&P++}if(P===0)return 0}return 1}intersectsPlane(e){const n=this.points.length;let o=0;for(let c=0;c<n;c++){const d=this.points[c];e[0]*d[0]+e[1]*d[1]+e[2]*d[2]+e[3]>=0&&o++}return o===n?2:o===0?0:1}}function rr(h,e,n){const o=h-e;return o<0?-o:Math.max(0,o-n)}function jo(h,e,n,o,c){const d=h-n;let g;return g=d<0?Math.min(-d,1+d-c):d>1?Math.min(Math.max(d-c,0),1-d):0,Math.max(g,rr(e,o,c))}class Sn{constructor(){this._boundingVolumeCache=new Xd(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,n,o,c){const d=1<<o.z,g=1/d,v=o.x/d,x=o.y/d;let P=2;return P=Math.min(P,jo(e,n,v,x,g)),P=Math.min(P,jo(e,n,v+.5,-x-g,g)),P=Math.min(P,jo(e,n,v+.5,2-x-g,g)),P}getWrap(e,n,o){const c=1<<n.z,d=1/c,g=n.x/c,v=rr(e.x,g,d),x=rr(e.x,g-1,d),P=rr(e.x,g+1,d),C=Math.min(v,x,P);return C===P?1:C===x?-1:0}allowVariableZoom(e,n){return it(e,n)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,n,o,c){return this._boundingVolumeCache.getTileBoundingVolume(e,n,o,c)}_computeTileBoundingVolume(e,n,o,c){var d,g;let v=0,x=0;if(c!=null&&c.terrain){const P=new a.Z(e.z,n,e.z,e.x,e.y),C=c.terrain.getMinMaxElevation(P);v=(d=C.minElevation)!==null&&d!==void 0?d:Math.min(0,o),x=(g=C.maxElevation)!==null&&g!==void 0?g:Math.max(0,o)}if(v/=a.bu,x/=a.bu,v+=1,x+=1,e.z<=0)return io.fromAabb([-x,-x,-x],[x,x,x]);if(e.z===1)return io.fromAabb([e.x===0?-x:0,e.y===0?0:-x,-x],[e.x===0?0:x,e.y===0?x:0,x]);{const P=[nn(0,0,e.x,e.y,e.z),nn(a.$,0,e.x,e.y,e.z),nn(a.$,a.$,e.x,e.y,e.z),nn(0,a.$,e.x,e.y,e.z)],C=[];for(const ye of P)C.push(a.aR([],ye,x));if(x!==v)for(const ye of P)C.push(a.aR([],ye,v));e.y===0&&C.push([0,1,0]),e.y===(1<<e.z)-1&&C.push([0,-1,0]);const k=[1,1,1],A=[-1,-1,-1];for(const ye of C)for(let xe=0;xe<3;xe++)k[xe]=Math.min(k[xe],ye[xe]),A[xe]=Math.max(A[xe],ye[xe]);const R=nn(a.$/2,a.$/2,e.x,e.y,e.z),O=a.aW([],[0,1,0],R);a.aV(O,O);const Z=a.aW([],R,O);a.aV(Z,Z);const G=a.aW([],P[2],P[1]);a.aV(G,G);const q=a.aW([],P[0],P[3]);a.aV(q,q),C.push(a.aR([],R,x)),e.y>=(1<<e.z)/2&&C.push(a.aR([],nn(a.$/2,0,e.x,e.y,e.z),x)),e.y<(1<<e.z)/2&&C.push(a.aR([],nn(a.$/2,a.$,e.x,e.y,e.z),x));const W=No(R,C),J=No(Z,C),K=[-R[0],-R[1],-R[2],W.max],te=[R[0],R[1],R[2],-W.min],se=[-Z[0],-Z[1],-Z[2],J.max],Y=[Z[0],Z[1],Z[2],-J.min],pe=[...G,0],be=[...q,0],_e=[];return e.y===0?_e.push(a.bt(be,pe,K),a.bt(be,pe,te)):_e.push(a.bt(se,pe,K),a.bt(se,pe,te),a.bt(se,be,K),a.bt(se,be,te)),e.y===(1<<e.z)-1?_e.push(a.bt(be,pe,K),a.bt(be,pe,te)):_e.push(a.bt(Y,pe,K),a.bt(Y,pe,te),a.bt(Y,be,K),a.bt(Y,be,te)),new io(_e,[K,te,se,Y,pe,be],k,A)}}}function No(h,e){let n=1/0,o=-1/0;for(const c of e){const d=a.aX(h,c);n=Math.min(n,d),o=Math.max(o,d)}return{min:n,max:o}}class Vo{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,o){return this._helper.interpolatePadding(e,n,o)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n){this._helper.resize(e,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(){this._cachedClippingPlane=a.bv(),this._projectionMatrix=a.b9(),this._globeViewProjMatrix32f=a.b8(),this._globeViewProjMatrixNoCorrection=a.b9(),this._globeViewProjMatrixNoCorrectionInverted=a.b9(),this._globeProjMatrixInverted=a.b9(),this._cameraPosition=a.bp(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new mr({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,n)=>this.getConstrained(e,n)}),this._coveringTilesDetailsProvider=new Sn}clone(){const e=new Vo;return e.apply(this),e}apply(e,n){this._globeLatitudeErrorCorrectionRadians=n||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=a.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:n,applyGlobeMatrix:o}=e,c=this._helper.getMercatorTileCoordinates(n);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:c,clippingPlane:this._cachedClippingPlane,projectionTransition:o?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const n=this.pitchInRadians,o=this.cameraToCenterDistance/e,c=Math.sin(n)*o,d=Math.cos(n)*o+1,g=1/Math.sqrt(c*c+d*d)*1;let v=-c,x=d;const P=Math.sqrt(v*v+x*x);v/=P,x/=P;const C=[0,v,x];a.bw(C,C,[0,0,0],-this.bearingInRadians),a.bx(C,C,[0,0,0],-1*this.center.lat*Math.PI/180),a.by(C,C,[0,0,0],this.center.lng*Math.PI/180);const k=1/a.aZ(C);return a.aR(C,C,k),[...C,-g*k]}isLocationOccluded(e){return!this.isSurfacePointVisible(Hi(e))}transformLightDirection(e){const n=this._helper._center.lng*Math.PI/180,o=this._helper._center.lat*Math.PI/180,c=Math.cos(o),d=[Math.sin(n)*c,Math.sin(o),Math.cos(n)*c],g=[d[2],0,-d[0]],v=[0,0,0];a.aW(v,g,d),a.aV(g,g),a.aV(v,v);const x=[0,0,0];return a.aV(x,[g[0]*e[0]+v[0]*e[1]+d[0]*e[2],g[1]*e[0]+v[1]*e[1]+d[1]*e[2],g[2]*e[0]+v[2]*e[1]+d[2]*e[2]]),x}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,o){const c=function(v,x,P){const C=1/(1<<P.z);return new a.a1(v/a.$*C+P.x*C,x/a.$*C+P.y*C)}(e,n,o.canonical),d=(g=c.y,[a.bo(c.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-g*Math.PI*2))-.5*Math.PI]);var g;return this.getCircleRadiusCorrection()/Math.cos(d[1])}projectTileCoordinates(e,n,o,c){const d=o.canonical,g=nn(e,n,d.x,d.y,d.z),v=1+(c?c(e,n):0)/a.bu,x=[g[0]*v,g[1]*v,g[2]*v,1];a.aw(x,x,this._globeViewProjMatrixNoCorrection);const P=this._cachedClippingPlane,C=P[0]*g[0]+P[1]*g[1]+P[2]*g[2]+P[3]<0;return{point:new a.P(x[0]/x[3],x[1]/x[3]),signedDistanceFromCamera:x[3],isOccluded:C}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const e=to(this.worldSize,this.center.lat),n=a.ba(),o=a.ba();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),a.b4(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const c=this.centerOffset;n[8]=2*-c.x/this._helper._width,n[9]=2*c.y/this._helper._height,this._projectionMatrix=a.b5(n),this._globeProjMatrixInverted=a.ba(),a.aq(this._globeProjMatrixInverted,n),a.M(n,n,[0,0,-this.cameraToCenterDistance]),a.b6(n,n,this.rollInRadians),a.b7(n,n,-this.pitchInRadians),a.b6(n,n,this.bearingInRadians),a.M(n,n,[0,0,-e]);const d=a.bp();d[0]=e,d[1]=e,d[2]=e,a.b7(o,n,this.center.lat*Math.PI/180),a.bz(o,o,-this.center.lng*Math.PI/180),a.N(o,o,d),this._globeViewProjMatrixNoCorrection=o,a.b7(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),a.bz(n,n,-this.center.lng*Math.PI/180),a.N(n,n,d),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=a.ba(),a.aq(this._globeViewProjMatrixNoCorrectionInverted,o);const g=a.bp();this._cameraPosition=a.bp(),this._cameraPosition[2]=this.cameraToCenterDistance/e,a.bw(this._cameraPosition,this._cameraPosition,g,-this.rollInRadians),a.bx(this._cameraPosition,this._cameraPosition,g,this.pitchInRadians),a.bw(this._cameraPosition,this._cameraPosition,g,-this.bearingInRadians),a.aS(this._cameraPosition,this._cameraPosition,[0,0,1]),a.bx(this._cameraPosition,this._cameraPosition,g,-this.center.lat*Math.PI/180),a.by(this._cameraPosition,this._cameraPosition,g,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);const v=a.b5(this._globeViewProjMatrixNoCorrectionInverted);a.N(v,v,[1,1,-1]),this._cachedFrustum=zi.fromInvProjectionMatrix(v,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){a.w("calculateFogMatrix is not supported on globe projection.");const n=a.ba();return a.ag(n),n}getVisibleUnwrappedCoordinates(e){return[new a.b2(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&a.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;const o=Hi(e);a.aR(o,o,1+n/a.bu);const c=a.bv();return a.aw(c,[o[0],o[1],o[2],1],this._globeViewProjMatrixNoCorrection),c[2]/c[3]}populateCache(e){}getBounds(){const e=.5*this.width,n=.5*this.height,o=[new a.P(0,0),new a.P(e,0),new a.P(this.width,0),new a.P(this.width,n),new a.P(this.width,this.height),new a.P(e,this.height),new a.P(0,this.height),new a.P(0,n)],c=[];for(const k of o)c.push(this.unprojectScreenPoint(k));let d=0,g=0,v=0,x=0;const P=this.center;for(const k of c){const A=a.bA(P.lng,k.lng),R=a.bA(P.lat,k.lat);A<g&&(g=A),A>d&&(d=A),R<x&&(x=R),R>v&&(v=R)}const C=[P.lng+g,P.lat+x,P.lng+d,P.lat+v];return this.isSurfacePointOnScreen([0,1,0])&&(C[3]=90,C[0]=-180,C[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(C[1]=-90,C[0]=-180,C[2]=180),new le(C)}getConstrained(e,n){const o=a.ah(e.lat,-a.ai,a.ai),c=a.ah(+n,this.minZoom+Ti(0,o),this.maxZoom);return{center:new a.S(e.lng,o),zoom:c}}calculateCenterFromCameraLngLatAlt(e,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,o,c)}setLocationAtPoint(e,n){const o=Hi(this.unprojectScreenPoint(n)),c=Hi(e),d=a.bp();a.bB(d);const g=a.bp();a.by(g,o,d,-this.center.lng*Math.PI/180),a.bx(g,g,d,this.center.lat*Math.PI/180);const v=c[0]*c[0]+c[2]*c[2],x=g[0]*g[0];if(v<x)return;const P=Math.sqrt(v-x),C=-P,k=a.bC(c[0],c[2],g[0],P),A=a.bC(c[0],c[2],g[0],C),R=a.bp();a.by(R,c,d,-k);const O=a.bC(R[1],R[2],g[1],g[2]),Z=a.bp();a.by(Z,c,d,-A);const G=a.bC(Z[1],Z[2],g[1],g[2]),q=.5*Math.PI,W=O>=-q&&O<=q,J=G>=-q&&G<=q;let K,te;if(W&&J){const be=this.center.lng*Math.PI/180,_e=this.center.lat*Math.PI/180;a.bD(k,be)+a.bD(O,_e)<a.bD(A,be)+a.bD(G,_e)?(K=k,te=O):(K=A,te=G)}else if(W)K=k,te=O;else{if(!J)return;K=A,te=G}const se=K/Math.PI*180,Y=te/Math.PI*180,pe=this.center.lat;this.setCenter(new a.S(se,a.ah(Y,-90,90))),this.setZoom(this.zoom+Ti(pe,this.center.lat))}locationToScreenPoint(e,n){const o=Hi(e);if(n){const c=n.getElevationForLngLatZoom(e,this._helper._tileZoom);a.aR(o,o,1+c/a.bu)}return this._projectSurfacePointToScreen(o)}_projectSurfacePointToScreen(e){const n=a.bv();return a.aw(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new a.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){const o=n.pointCoordinate(e);if(o)return o}return a.a1.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,n){var o;return(o=this.screenPointToMercatorCoordinate(e,n))===null||o===void 0?void 0:o.toLngLat()}isPointOnMapSurface(e,n){const o=this._cameraPosition,c=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(o,c)}getRayDirectionFromPixel(e){const n=a.bv();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,a.aw(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];const o=a.bp();o[0]=n[0]-this._cameraPosition[0],o[1]=n[1]-this._cameraPosition[1],o[2]=n[2]-this._cameraPosition[2];const c=a.bp();return a.aV(c,o),c}isSurfacePointVisible(e){const n=this._cachedClippingPlane;return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const n=a.bv();return a.aw(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){const o=a.aX(e,n),c=a.bp(),d=a.bp();a.aR(d,n,o),a.aU(c,e,d);const g=1-a.aX(c,c);if(g<0)return null;const v=a.aX(e,e)-1,x=-o+(o<0?1:-1)*Math.sqrt(g),P=v/x,C=x;return{tMin:Math.min(P,C),tMax:Math.max(P,C)}}unprojectScreenPoint(e){const n=this._cameraPosition,o=this.getRayDirectionFromPixel(e),c=this.rayPlanetIntersection(n,o);if(c){const C=a.bp();a.aS(C,n,[o[0]*c.tMin,o[1]*c.tMin,o[2]*c.tMin]);const k=a.bp();return a.aV(k,C),Bo(k)}const d=this._cachedClippingPlane,g=d[0]*o[0]+d[1]*o[1]+d[2]*o[2],v=-a.b1(d,n)/g,x=a.bp();if(v>0)a.aS(x,n,[o[0]*v,o[1]*v,o[2]*v]);else{const C=a.bp();a.aS(C,n,[2*o[0],2*o[1],2*o[2]]);const k=a.b1(this._cachedClippingPlane,C);a.aU(x,C,[this._cachedClippingPlane[0]*k,this._cachedClippingPlane[1]*k,this._cachedClippingPlane[2]*k])}const P=function(C){const k=a.bp();return k[0]=C[0]*-C[3],k[1]=C[1]*-C[3],k[2]=C[2]*-C[3],{center:k,radius:Math.sqrt(1-C[3]*C[3])}}(d);return Bo(function(C,k,A){const R=a.bp();a.aU(R,A,C);const O=a.bp();return a.bq(O,C,R,k/a.a$(R)),O}(P.center,P.radius,x))}getMatrixForModel(e,n){const o=a.S.convert(e),c=1/a.bu,d=a.b9();return a.bz(d,d,o.lng/180*Math.PI),a.b7(d,d,-o.lat/180*Math.PI),a.M(d,d,[0,0,1+n/a.bu]),a.b7(d,d,.5*Math.PI),a.N(d,d,[c,c,c]),d}getProjectionDataForCustomLayer(e=!0){const n=this.getProjectionData({overscaledTileID:new a.Z(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class Uo{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,n,o){return this._helper.interpolatePadding(e,n,o)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,n,o=!0){this._helper.resize(e,n,o)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,n){this._helper.overrideNearFarZ(e,n)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,n){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=n,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new mr({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,n)=>this.getConstrained(e,n)}),this._globeness=1,this._mercatorTransform=new ni,this._verticalPerspectiveTransform=new Vo}clone(){const e=new Uo;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const n=this._mercatorTransform.getProjectionData(e),o=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?o.mainMatrix:n.mainMatrix,clippingPlane:o.clippingPlane,tileMercatorCoords:o.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:n.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return a.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return a.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,o){const c=this._mercatorTransform.getPitchedTextCorrection(e,n,o),d=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,o);return a.bk(c,d,this._globeness)}projectTileCoordinates(e,n,o,c){return this.currentTransform.projectTileCoordinates(e,n,o,c)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){return this.currentTransform.lngLatToCameraDepth(e,n)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,n){return this.currentTransform.getConstrained(e,n)}calculateCenterFromCameraLngLatAlt(e,n,o,c){return this._helper.calculateCenterFromCameraLngLatAlt(e,n,o,c)}setLocationAtPoint(e,n){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,n),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,n),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,n){return this.currentTransform.locationToScreenPoint(e,n)}screenPointToMercatorCoordinate(e,n){return this.currentTransform.screenPointToMercatorCoordinate(e,n)}screenPointToLocation(e,n){return this.currentTransform.screenPointToLocation(e,n)}isPointOnMapSurface(e,n){return this.currentTransform.isPointOnMapSurface(e,n)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,n){return this.currentTransform.getMatrixForModel(e,n)}getProjectionDataForCustomLayer(e=!0){const n=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return n;const o=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return o.fallbackMatrix=n.mainMatrix,o}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class hr{get useGlobeControls(){return!0}handlePanInertia(e,n){const o=Hu(e,n);return Math.abs(o.lng-n.center.lng)>180&&(o.lng=n.center.lng+179.5*Math.sign(o.lng-n.center.lng)),{easingCenter:o,easingOffset:new a.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){const o=e.around,c=n.screenPointToLocation(o);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);const d=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);const g=n.zoom-d;if(g===0)return;const v=a.bA(n.center.lng,c.lng),x=v/(Math.abs(v/180)+1),P=a.bA(n.center.lat,c.lat),C=n.getRayDirectionFromPixel(o),k=n.cameraPosition,A=-1*a.aX(k,C),R=a.bp();a.aS(R,k,[C[0]*A,C[1]*A,C[2]*A]);const O=a.aZ(R)-1,Z=Math.exp(.5*-Math.max(O-.3,0)),G=to(n.worldSize,n.center.lat)/Math.min(n.width,n.height),q=a.bn(G,.9,.5,1,.25),W=(1-a.af(-g))*Math.min(Z,q),J=n.center.lat,K=n.zoom,te=new a.S(n.center.lng+x*W,a.ah(n.center.lat+P*W,-a.ai,a.ai));n.setLocationAtPoint(c,o);const se=n.center,Y=a.bn(Math.abs(v),45,85,0,1),pe=a.bn(G,.75,.35,0,1),be=Math.pow(Math.max(Y,pe),.25),_e=a.bA(se.lng,te.lng),ye=a.bA(se.lat,te.lat);n.setCenter(new a.S(se.lng+_e*be,se.lat+ye*be).wrap()),n.setZoom(K+Ti(J,n.center.lat))}handleMapControlsPan(e,n,o){if(!e.panDelta)return;const c=n.center.lat,d=n.zoom;n.setCenter(Hu(e.panDelta,n).wrap()),n.setZoom(d+Ti(c,n.center.lat))}cameraForBoxAndBearing(e,n,o,c,d){const g=Fr(e,n,o,c,d),v=n.left/d.width*2-1,x=(d.width-n.right)/d.width*2-1,P=n.top/d.height*-2+1,C=(d.height-n.bottom)/d.height*-2+1,k=a.bA(o.getWest(),o.getEast())<0,A=k?o.getEast():o.getWest(),R=k?o.getWest():o.getEast(),O=Math.max(o.getNorth(),o.getSouth()),Z=Math.min(o.getNorth(),o.getSouth()),G=A+.5*a.bA(A,R),q=O+.5*a.bA(O,Z),W=d.clone();W.setCenter(g.center),W.setBearing(g.bearing),W.setPitch(0),W.setRoll(0),W.setZoom(g.zoom);const J=W.modelViewProjectionMatrix,K=[Hi(o.getNorthWest()),Hi(o.getNorthEast()),Hi(o.getSouthWest()),Hi(o.getSouthEast()),Hi(new a.S(R,q)),Hi(new a.S(A,q)),Hi(new a.S(G,O)),Hi(new a.S(G,Z))],te=Hi(g.center);let se=Number.POSITIVE_INFINITY;for(const Y of K)v<0&&(se=hr.getLesserNonNegativeNonNull(se,hr.solveVectorScale(Y,te,J,"x",v))),x>0&&(se=hr.getLesserNonNegativeNonNull(se,hr.solveVectorScale(Y,te,J,"x",x))),P>0&&(se=hr.getLesserNonNegativeNonNull(se,hr.solveVectorScale(Y,te,J,"y",P))),C<0&&(se=hr.getLesserNonNegativeNonNull(se,hr.solveVectorScale(Y,te,J,"y",C)));if(Number.isFinite(se)&&se!==0)return g.zoom=W.zoom+a.ak(se),g;qu()}handleJumpToCenterZoom(e,n){const o=e.center.lat,c=e.getConstrained(n.center?a.S.convert(n.center):e.center,e.zoom).center;e.setCenter(c.wrap());const d=n.zoom!==void 0?+n.zoom:e.zoom+Ti(o,c.lat);e.zoom!==d&&e.setZoom(d)}handleEaseTo(e,n){const o=e.zoom,c=e.center,d=e.padding,g={roll:e.roll,pitch:e.pitch,bearing:e.bearing},v={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},x=n.zoom!==void 0,P=!e.isPaddingEqual(n.padding);let C=!1;const k=n.center?a.S.convert(n.center):c,A=e.getConstrained(k,o).center;Ra(e,A);const R=e.clone();R.setCenter(A),R.setZoom(x?+n.zoom:o+Ti(c.lat,k.lat)),R.setBearing(n.bearing);const O=new a.P(a.ah(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),a.ah(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));R.setLocationAtPoint(A,O);const Z=(n.offset&&n.offsetAsPoint.mag())>0?R.center:A,G=x?+n.zoom:o+Ti(c.lat,Z.lat),q=o+Ti(c.lat,0),W=G+Ti(Z.lat,0),J=a.bA(c.lng,Z.lng),K=a.bA(c.lat,Z.lat),te=a.af(W-q);return C=G!==o,{easeFunc:se=>{if(a.be(g,v)||_r({startEulerAngles:g,endEulerAngles:v,tr:e,k:se,useSlerp:g.roll!=v.roll}),P&&e.interpolatePadding(d,n.padding,se),n.around)a.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(n.around,n.aroundPoint);else{const Y=W>q?Math.min(2,te):Math.max(.5,te),pe=Math.pow(Y,1-se),be=nc(c,J,K,se*pe);e.setCenter(be.wrap())}if(C){const Y=a.C.number(q,W,se)+Ti(0,e.center.lat);e.setZoom(Y)}},isZooming:C,elevationCenter:Z}}handleFlyTo(e,n){const o=n.zoom!==void 0,c=e.center,d=e.zoom,g=e.padding,v=!e.isPaddingEqual(n.padding),x=e.getConstrained(a.S.convert(n.center||n.locationAtOffset),d).center,P=o?+n.zoom:e.zoom+Ti(e.center.lat,x.lat),C=e.clone();C.setCenter(x),C.setZoom(P),C.setBearing(n.bearing);const k=new a.P(a.ah(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),a.ah(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));C.setLocationAtPoint(x,k);const A=C.center;Ra(e,A);const R=function(K,te,se){const Y=Hi(te),pe=Hi(se),be=a.aX(Y,pe),_e=Math.acos(be),ye=Oa(K);return _e/(2*Math.PI)*ye}(e,c,A),O=d+Ti(c.lat,0),Z=P+Ti(A.lat,0),G=a.af(Z-O);let q;if(typeof n.minZoom=="number"){const K=+n.minZoom+Ti(A.lat,0),te=Math.min(K,O,Z)+Ti(0,A.lat),se=e.getConstrained(A,te).zoom+Ti(A.lat,0);q=a.af(se-O)}const W=a.bA(c.lng,A.lng),J=a.bA(c.lat,A.lat);return{easeFunc:(K,te,se,Y)=>{const pe=nc(c,W,J,se);v&&e.interpolatePadding(g,n.padding,K);const be=K===1?A:pe;e.setCenter(be.wrap());const _e=O+a.ak(te);e.setZoom(K===1?P:_e+Ti(0,be.lat))},scaleOfZoom:G,targetCenter:A,scaleOfMinZoom:q,pixelPathLength:R}}static solveVectorScale(e,n,o,c,d){const g=c==="x"?[o[0],o[4],o[8],o[12]]:[o[1],o[5],o[9],o[13]],v=[o[3],o[7],o[11],o[15]],x=e[0]*g[0]+e[1]*g[1]+e[2]*g[2],P=e[0]*v[0]+e[1]*v[1]+e[2]*v[2],C=n[0]*g[0]+n[1]*g[1]+n[2]*g[2],k=n[0]*v[0]+n[1]*v[1]+n[2]*v[2];return C+d*P===x+d*k||v[3]*(x-C)+g[3]*(k-P)+x*k==C*P?null:(C+g[3]-d*k-d*v[3])/(C-x-d*k+d*P)}static getLesserNonNegativeNonNull(e,n){return n!==null&&n>=0&&n<e?n:e}}class Wu{constructor(e){this._globe=e,this._mercatorCameraHelper=new ur,this._verticalPerspectiveCameraHelper=new hr}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,n){return this.currentHelper.handlePanInertia(e,n)}handleMapControlsRollPitchBearingZoom(e,n){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,n)}handleMapControlsPan(e,n,o){this.currentHelper.handleMapControlsPan(e,n,o)}cameraForBoxAndBearing(e,n,o,c,d){return this.currentHelper.cameraForBoxAndBearing(e,n,o,c,d)}handleJumpToCenterZoom(e,n){this.currentHelper.handleJumpToCenterZoom(e,n)}handleEaseTo(e,n){return this.currentHelper.handleEaseTo(e,n)}handleFlyTo(e,n){return this.currentHelper.handleFlyTo(e,n)}}const ja=(h,e)=>a.y(h,e&&e.filter(n=>n.identifier!=="source.canvas")),Kd=a.bE();class sc extends a.E{constructor(e,n={}){var o,c;super(),this._rtlPluginLoaded=()=>{for(const g in this.sourceCaches){const v=this.sourceCaches[g].getSource().type;v!=="vector"&&v!=="geojson"||this.sourceCaches[g].reload()}},this.map=e,this.dispatcher=new Ai(En(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(g,v)=>this.getGlyphs(g,v)),this.dispatcher.registerMessageHandler("GI",(g,v)=>this.getImages(g,v)),this.imageManager=new Nt,this.imageManager.setEventedParent(this);const d=((o=e._container)===null||o===void 0?void 0:o.lang)||typeof document<"u"&&((c=document.documentElement)===null||c===void 0?void 0:c.lang)||void 0;this.glyphManager=new tr(e._requestManager,n.localIdeographFontFamily,d),this.lineAtlas=new Vt(256,512),this.crossTileSymbolIndex=new Qs,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new a.bF,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",a.bG()),Zt().on(lt,this._rtlPluginLoaded),this.on("data",g=>{if(g.dataType!=="source"||g.sourceDataType!=="metadata")return;const v=this.sourceCaches[g.sourceId];if(!v)return;const x=v.getSource();if(x&&x.vectorLayerIds)for(const P in this._layers){const C=this._layers[P];C.source===x.id&&this._validateLayer(C)}})}setGlobalStateProperty(e,n){var o,c,d;this._checkLoaded();const g=n===null?(d=(c=(o=this.stylesheet.state)===null||o===void 0?void 0:o[e])===null||c===void 0?void 0:c.default)!==null&&d!==void 0?d:null:n;if(a.bH(g,this._globalState[e]))return this;this._globalState[e]=g,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const n=[];for(const o in e)!a.bH(this._globalState[o],e[o].default)&&(n.push(o),this._globalState[o]=e[o].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;const n=new Set;for(const o in this._layers){const c=this._layers[o],d=c.getLayoutAffectingGlobalStateRefs(),g=c.getPaintAffectingGlobalStateRefs();for(const v of e)if(d.has(v)&&n.add(c.source),g.has(v))for(const{name:x,value:P}of g.get(v))this._updatePaintProperty(c,x,P)}for(const o in this.sourceCaches)n.has(o)&&(this._reloadSource(o),this._changed=!0)}loadURL(e,n={},o){this.fire(new a.l("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const c=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const d=this._loadStyleRequest;a.j(c,this._loadStyleRequest).then(g=>{this._loadStyleRequest=null,this._load(g.data,n,o)}).catch(g=>{this._loadStyleRequest=null,g&&!d.signal.aborted&&this.fire(new a.k(g))})}loadJSON(e,n={},o){this.fire(new a.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,Se.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(e,n,o)}).catch(()=>{})}loadEmpty(){this.fire(new a.l("dataloading",{dataType:"style"})),this._load(Kd,{validate:!1})}_load(e,n,o){var c,d;let g=n.transformStyle?n.transformStyle(o,e):e;if(!n.validate||!ja(this,a.z(g))){g=Object.assign({},g),this._loaded=!0,this.stylesheet=g;for(const v in g.sources)this.addSource(v,g.sources[v],{validate:!1});g.sprite?this._loadSprite(g.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(g.glyphs),this._createLayers(),this.light=new Jt(this.stylesheet.light),this._setProjectionInternal(((c=this.stylesheet.projection)===null||c===void 0?void 0:c.type)||"mercator"),this.sky=new Kt(this.stylesheet.sky),this.map.setTerrain((d=this.stylesheet.terrain)!==null&&d!==void 0?d:null),this.fire(new a.l("data",{dataType:"style"})),this.fire(new a.l("style.load"))}}_createLayers(){var e;const n=a.bI(this.stylesheet.layers);this.dispatcher.broadcast("SL",n),this._order=n.map(o=>o.id),this._layers={},this.setGlobalState((e=this.stylesheet.state)!==null&&e!==void 0?e:null),this._serializedLayers=null;for(const o of n){const c=a.bJ(o);c.setEventedParent(this,{layer:{id:o.id}}),c.setGlobalState(this._globalState),this._layers[o.id]=c}}_loadSprite(e,n=!1,o=void 0){let c;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(d,g,v,x){return a._(this,void 0,void 0,function*(){const P=Oi(d),C=v>1?"@2x":"",k={},A={};for(const{id:R,url:O}of P){const Z=g.transformRequest(mi(O,C,".json"),"SpriteJSON");k[R]=a.j(Z,x);const G=g.transformRequest(mi(O,C,".png"),"SpriteImage");A[R]=We.getImage(G,x)}return yield Promise.all([...Object.values(k),...Object.values(A)]),function(R,O){return a._(this,void 0,void 0,function*(){const Z={};for(const G in R){Z[G]={};const q=Se.getImageCanvasContext((yield O[G]).data),W=(yield R[G]).data;for(const J in W){const{width:K,height:te,x:se,y:Y,sdf:pe,pixelRatio:be,stretchX:_e,stretchY:ye,content:xe,textFitWidth:Le,textFitHeight:Oe}=W[J];Z[G][J]={data:null,pixelRatio:be,sdf:pe,stretchX:_e,stretchY:ye,content:xe,textFitWidth:Le,textFitHeight:Oe,spriteData:{width:K,height:te,x:se,y:Y,context:q}}}}return Z})}(k,A)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(d=>{if(this._spriteRequest=null,d)for(const g in d){this._spritesImagesIds[g]=[];const v=this._spritesImagesIds[g]?this._spritesImagesIds[g].filter(x=>!(x in d)):[];for(const x of v)this.imageManager.removeImage(x),this._changedImages[x]=!0;for(const x in d[g]){const P=g==="default"?x:`${g}:${x}`;this._spritesImagesIds[g].push(P),P in this.imageManager.images?this.imageManager.updateImage(P,d[g][x],!1):this.imageManager.addImage(P,d[g][x]),n&&(this._changedImages[P]=!0)}}}).catch(d=>{this._spriteRequest=null,c=d,this.fire(new a.k(c))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"})),o&&o(c)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}_validateLayer(e){const n=this.sourceCaches[e.source];if(!n)return;const o=e.sourceLayer;if(!o)return;const c=n.getSource();(c.type==="geojson"||c.vectorLayerIds&&c.vectorLayerIds.indexOf(o)===-1)&&this.fire(new a.k(new Error(`Source layer "${o}" does not exist on source "${c.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){const o=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?a.bK(o):o);const c=[];for(const d of e)if(o[d]){const g=n?a.bK(o[d]):o[d];c.push(g)}return c}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const n=Object.keys(this._layers);for(const o of n){const c=this._layers[o];c.type!=="custom"&&(e[o]=c.serialize())}return e}hasTransitions(){var e,n,o;if(!((e=this.light)===null||e===void 0)&&e.hasTransition()||!((n=this.sky)===null||n===void 0)&&n.hasTransition()||!((o=this.projection)===null||o===void 0)&&o.hasTransition())return!0;for(const c in this.sourceCaches)if(this.sourceCaches[c].hasTransition())return!0;for(const c in this._layers)if(this._layers[c].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const n=this._changed;if(n){const c=Object.keys(this._updatedLayers),d=Object.keys(this._removedLayers);(c.length||d.length)&&this._updateWorkerLayers(c,d);for(const g in this._updatedSources){const v=this._updatedSources[g];if(v==="reload")this._reloadSource(g);else{if(v!=="clear")throw new Error(`Invalid action ${v}`);this._clearSource(g)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const g in this._updatedPaintProps)this._layers[g].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const o={};for(const c in this.sourceCaches){const d=this.sourceCaches[c];o[c]=d.used,d.used=!1}for(const c of this._order){const d=this._layers[c];d.recalculate(e,this._availableImages),!d.isHidden(e.zoom)&&d.source&&(this.sourceCaches[d.source].used=!0)}for(const c in o){const d=this.sourceCaches[c];!!o[c]!=!!d.used&&d.fire(new a.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:c}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new a.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var o;this._checkLoaded();const c=this.serialize();if(e=n.transformStyle?n.transformStyle(c,e):e,((o=n.validate)===null||o===void 0||o)&&ja(this,a.z(e)))return!1;(e=a.bK(e)).layers=a.bI(e.layers);const d=a.bL(c,e),g=this._getOperationsToPerform(d);if(g.unimplemented.length>0)throw new Error(`Unimplemented: ${g.unimplemented.join(", ")}.`);if(g.operations.length===0)return!1;for(const v of g.operations)v();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const n=[],o=[];for(const c of e)switch(c.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,c.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,c.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,c.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,c.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,c.args));break;case"addSource":n.push(()=>this.addSource.apply(this,c.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,c.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,c.args));break;case"setLight":n.push(()=>this.setLight.apply(this,c.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,c.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,c.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,c.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,c.args));break;case"setSky":n.push(()=>this.setSky.apply(this,c.args));break;case"setProjection":this.setProjection.apply(this,c.args);break;case"setGlobalState":n.push(()=>this.setGlobalState.apply(this,c.args));break;case"setTransition":n.push(()=>{});break;default:o.push(c.command)}return{operations:n,unimplemented:o}}addImage(e,n){if(this.getImage(e))return this.fire(new a.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,n){this.imageManager.updateImage(e,n)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new a.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,o={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw new Error(`Source "${e}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(a.z.source,`sources.${e}`,n,null,o))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const c=this.sourceCaches[e]=new At(e,n,this.dispatcher);c.style=this,c.setEventedParent(this,()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:e})),c.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error("There is no source with this ID");for(const o in this._layers)if(this._layers[o].source===e)return this.fire(new a.k(new Error(`Source "${e}" cannot be removed while layer "${o}" is using it.`)));const n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new a.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,n){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw new Error(`There is no source with this ID=${e}`);const o=this.sourceCaches[e].getSource();if(o.type!=="geojson")throw new Error(`geojsonSource.type is ${o.type}, which is !== 'geojson`);o.setData(n),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,o={}){this._checkLoaded();const c=e.id;if(this.getLayer(c))return void this.fire(new a.k(new Error(`Layer "${c}" already exists on this map.`)));let d;if(e.type==="custom"){if(ja(this,a.bM(e)))return;d=a.bJ(e)}else{if("source"in e&&typeof e.source=="object"&&(this.addSource(c,e.source),e=a.bK(e),e=a.e(e,{source:c})),this._validate(a.z.layer,`layers.${c}`,e,{arrayIndex:-1},o))return;d=a.bJ(e),this._validateLayer(d),d.setEventedParent(this,{layer:{id:c}})}const g=n?this._order.indexOf(n):this._order.length;if(n&&g===-1)this.fire(new a.k(new Error(`Cannot add layer "${c}" before non-existing layer "${n}".`)));else{if(this._order.splice(g,0,c),this._layerOrderChanged=!0,this._layers[c]=d,this._removedLayers[c]&&d.source&&d.type!=="custom"){const v=this._removedLayers[c];delete this._removedLayers[c],v.type!==d.type?this._updatedSources[d.source]="clear":(this._updatedSources[d.source]="reload",this.sourceCaches[d.source].pause())}this._updateLayer(d),d.onAdd&&d.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new a.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;const o=this._order.indexOf(e);this._order.splice(o,1);const c=n?this._order.indexOf(n):this._order.length;n&&c===-1?this.fire(new a.k(new Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(c,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const n=this._layers[e];if(!n)return void this.fire(new a.k(new Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);const o=this._order.indexOf(e);this._order.splice(o,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,o){this._checkLoaded();const c=this.getLayer(e);c?c.minzoom===n&&c.maxzoom===o||(n!=null&&(c.minzoom=n),o!=null&&(c.maxzoom=o),this._updateLayer(c)):this.fire(new a.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,o={}){this._checkLoaded();const c=this.getLayer(e);if(c){if(!a.bH(c.filter,n))return n==null?(c.setFilter(void 0),void this._updateLayer(c)):void(this._validate(a.z.filter,`layers.${c.id}.filter`,n,null,o)||(c.setFilter(a.bK(n)),this._updateLayer(c)))}else this.fire(new a.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return a.bK(this.getLayer(e).filter)}setLayoutProperty(e,n,o,c={}){this._checkLoaded();const d=this.getLayer(e);d?a.bH(d.getLayoutProperty(n),o)||(d.setLayoutProperty(n,o,c),this._updateLayer(d)):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){const o=this.getLayer(e);if(o)return o.getLayoutProperty(n);this.fire(new a.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,o,c={}){this._checkLoaded();const d=this.getLayer(e);d?a.bH(d.getPaintProperty(n),o)||this._updatePaintProperty(d,n,o,c):this.fire(new a.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,n,o,c={}){e.setPaintProperty(n,o,c)&&this._updateLayer(e),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,n){return this.getLayer(e).getPaintProperty(n)}setFeatureState(e,n){this._checkLoaded();const o=e.source,c=e.sourceLayer,d=this.sourceCaches[o];if(d===void 0)return void this.fire(new a.k(new Error(`The source '${o}' does not exist in the map's style.`)));const g=d.getSource().type;g==="geojson"&&c?this.fire(new a.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):g!=="vector"||c?(e.id===void 0&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),d.setFeatureState(c,e.id,n)):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,n){this._checkLoaded();const o=e.source,c=this.sourceCaches[o];if(c===void 0)return void this.fire(new a.k(new Error(`The source '${o}' does not exist in the map's style.`)));const d=c.getSource().type,g=d==="vector"?e.sourceLayer:void 0;d!=="vector"||g?n&&typeof e.id!="string"&&typeof e.id!="number"?this.fire(new a.k(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(g,e.id,n):this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const n=e.source,o=e.sourceLayer,c=this.sourceCaches[n];if(c!==void 0)return c.getSource().type!=="vector"||o?(e.id===void 0&&this.fire(new a.k(new Error("The feature id parameter must be provided."))),c.getFeatureState(o,e.id)):void this.fire(new a.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new a.k(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return a.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=a.bN(this.sourceCaches,d=>d.serialize()),n=this._serializeByIds(this._order,!0),o=this.map.getTerrain()||void 0,c=this.stylesheet;return a.bO({version:c.version,name:c.name,metadata:c.metadata,light:c.light,sky:c.sky,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,projection:c.projection,sources:e,layers:n,terrain:o},d=>d!==void 0)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!=="raster"&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const n=g=>this._layers[g].type==="fill-extrusion",o={},c=[];for(let g=this._order.length-1;g>=0;g--){const v=this._order[g];if(n(v)){o[v]=g;for(const x of e){const P=x[v];if(P)for(const C of P)c.push(C)}}}c.sort((g,v)=>v.intersectionZ-g.intersectionZ);const d=[];for(let g=this._order.length-1;g>=0;g--){const v=this._order[g];if(n(v))for(let x=c.length-1;x>=0;x--){const P=c[x].feature;if(o[P.layer.id]<g)break;d.push(P),c.pop()}else for(const x of e){const P=x[v];if(P)for(const C of P)d.push(C.feature)}}return d}queryRenderedFeatures(e,n,o){n&&n.filter&&this._validate(a.z.filter,"queryRenderedFeatures.filter",n.filter,null,n);const c={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new a.k(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const P of n.layers){const C=this._layers[P];if(!C)return this.fire(new a.k(new Error(`The layer '${P}' does not exist in the map's style and cannot be queried for features.`))),[];c[C.source]=!0}}const d=[];n.availableImages=this._availableImages;const g=this._serializedAllLayers(),v=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,x=Object.assign(Object.assign({},n),{layers:v});for(const P in this.sourceCaches)n.layers&&!c[P]||d.push(Pr(this.sourceCaches[P],this._layers,g,e,x,o,this.map.terrain?(C,k,A)=>this.map.terrain.getElevation(C,k,A):void 0));return this.placement&&d.push(function(P,C,k,A,R,O,Z){const G={},q=O.queryRenderedSymbols(A),W=[];for(const J of Object.keys(q).map(Number))W.push(Z[J]);W.sort(Zr);for(const J of W){const K=J.featureIndex.lookupSymbolFeatures(q[J.bucketInstanceId],C,J.bucketIndex,J.sourceLayerIndex,R.filter,R.layers,R.availableImages,P);for(const te in K){const se=G[te]=G[te]||[],Y=K[te];Y.sort((pe,be)=>{const _e=J.featureSortOrder;if(_e){const ye=_e.indexOf(pe.featureIndex);return _e.indexOf(be.featureIndex)-ye}return be.featureIndex-pe.featureIndex});for(const pe of Y)se.push(pe)}}return function(J,K,te){for(const se in J)for(const Y of J[se])ys(Y,te[K[se].source]);return J}(G,P,k)}(this._layers,g,this.sourceCaches,e,x,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(d)}querySourceFeatures(e,n){n&&n.filter&&this._validate(a.z.filter,"querySourceFeatures.filter",n.filter,null,n);const o=this.sourceCaches[e];return o?function(c,d){const g=c.getRenderableIds().map(P=>c.getTileByID(P)),v=[],x={};for(let P=0;P<g.length;P++){const C=g[P],k=C.tileID.canonical.key;x[k]||(x[k]=!0,C.querySourceFeatures(v,d))}return v}(o,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const o=this.light.getLight();let c=!1;for(const g in e)if(!a.bH(e[g],o[g])){c=!0;break}if(!c)return;const d={now:Se.now(),transition:a.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(d)}getProjection(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){var e;return(e=this.stylesheet)===null||e===void 0?void 0:e.sky}setSky(e,n={}){this._checkLoaded();const o=this.getSky();let c=!1;if(!e&&!o)return;if(e&&!o)c=!0;else if(!e&&o)c=!0;else for(const g in e)if(!a.bH(e[g],o[g])){c=!0;break}if(!c)return;const d={now:Se.now(),transition:a.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(d)}_setProjectionInternal(e){const n=function(o){if(Array.isArray(o)){const c=new Ba({type:o});return{projection:c,transform:new Uo,cameraHelper:new Wu(c)}}switch(o){case"mercator":return{projection:new Rt,transform:new ni,cameraHelper:new ur};case"globe":{const c=new Ba({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:c,transform:new Uo,cameraHelper:new Wu(c)}}case"vertical-perspective":return{projection:new Fo,transform:new Vo,cameraHelper:new hr};default:return a.w(`Unknown projection name: ${o}. Falling back to mercator projection.`),{projection:new Rt,transform:new ni,cameraHelper:new ur}}}(e);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(const o in this.sourceCaches)this.sourceCaches[o].reload()}_validate(e,n,o,c,d={}){return(!d||d.validate!==!1)&&ja(this,e.call(a.z,a.e({key:n,style:this.serialize(),value:o,styleSpec:a.v},c)))}_remove(e=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),Zt().off(lt,this._rtlPluginLoaded);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const o=this.sourceCaches[n];o.setEventedParent(null),o.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(e)}_clearSource(e){this.sourceCaches[e].clearTiles()}_reloadSource(e){this.sourceCaches[e].resume(),this.sourceCaches[e].reload()}_updateSources(e){for(const n in this.sourceCaches)this.sourceCaches[n].update(e,this.map.terrain)}_generateCollisionBoxes(){for(const e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,n,o,c,d=!1){let g=!1,v=!1;const x={};for(const P of this._order){const C=this._layers[P];if(C.type!=="symbol")continue;if(!x[C.source]){const A=this.sourceCaches[C.source];x[C.source]=A.getRenderableIds(!0).map(R=>A.getTileByID(R)).sort((R,O)=>O.tileID.overscaledZ-R.tileID.overscaledZ||(R.tileID.isLessThan(O.tileID)?-1:1))}const k=this.crossTileSymbolIndex.addLayer(C,x[C.source],e.center.lng);g=g||k}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||o===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(Se.now(),e.zoom))&&(this.pauseablePlacement=new ec(e,this.map.terrain,this._order,d,n,o,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,x),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(Se.now()),v=!0),g&&this.pauseablePlacement.placement.setStale()),v||g)for(const P of this._order){const C=this._layers[P];C.type==="symbol"&&this.placement.updateLayerOpacities(C,x[C.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(Se.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return a._(this,void 0,void 0,function*(){const o=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const c=this.sourceCaches[n.source];return c&&c.setDependencies(n.tileID.key,n.type,n.icons),o})}getGlyphs(e,n){return a._(this,void 0,void 0,function*(){const o=yield this.glyphManager.getGlyphs(n.stacks),c=this.sourceCaches[n.source];return c&&c.setDependencies(n.tileID.key,n.type,[""]),o})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(a.z.glyphs,"glyphs",e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,o={},c){this._checkLoaded();const d=[{id:e,url:n}],g=[...Oi(this.stylesheet.sprite),...d];this._validate(a.z.sprite,"sprite",g,null,o)||(this.stylesheet.sprite=g,this._loadSprite(d,!0,c))}removeSprite(e){this._checkLoaded();const n=Oi(this.stylesheet.sprite);if(n.find(o=>o.id===e)){if(this._spritesImagesIds[e])for(const o of this._spritesImagesIds[e])this.imageManager.removeImage(o),this._changedImages[o]=!0;n.splice(n.findIndex(o=>o.id===e),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new a.l("data",{dataType:"style"}))}else this.fire(new a.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return Oi(this.stylesheet.sprite)}setSprite(e,n={},o){this._checkLoaded(),e&&this._validate(a.z.sprite,"sprite",e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,o):(this._unloadSprite(),o&&o(null)))}}var Yd=a.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Jd{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,o,c,d,g,v,x,P){this.context=e;let C=this.boundPaintVertexBuffers.length!==c.length;for(let k=0;!C&&k<c.length;k++)this.boundPaintVertexBuffers[k]!==c[k]&&(C=!0);!this.vao||this.boundProgram!==n||this.boundLayoutVertexBuffer!==o||C||this.boundIndexBuffer!==d||this.boundVertexOffset!==g||this.boundDynamicVertexBuffer!==v||this.boundDynamicVertexBuffer2!==x||this.boundDynamicVertexBuffer3!==P?this.freshBind(n,o,c,d,g,v,x,P):(e.bindVertexArray.set(this.vao),v&&v.bind(),d&&d.dynamicDraw&&d.bind(),x&&x.bind(),P&&P.bind())}freshBind(e,n,o,c,d,g,v,x){const P=e.numAttributes,C=this.context,k=C.gl;this.vao&&this.destroy(),this.vao=C.createVertexArray(),C.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=n,this.boundPaintVertexBuffers=o,this.boundIndexBuffer=c,this.boundVertexOffset=d,this.boundDynamicVertexBuffer=g,this.boundDynamicVertexBuffer2=v,this.boundDynamicVertexBuffer3=x,n.enableAttributes(k,e);for(const A of o)A.enableAttributes(k,e);g&&g.enableAttributes(k,e),v&&v.enableAttributes(k,e),x&&x.enableAttributes(k,e),n.bind(),n.setVertexAttribPointers(k,e,d);for(const A of o)A.bind(),A.setVertexAttribPointers(k,e,d);g&&(g.bind(),g.setVertexAttribPointers(k,e,d)),c&&c.bind(),v&&(v.bind(),v.setVertexAttribPointers(k,e,d)),x&&(x.bind(),x.setVertexAttribPointers(k,e,d)),C.currentNumAttributes=P}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Na=(h,e,n,o,c)=>({u_texture:0,u_ele_delta:h,u_fog_matrix:e,u_fog_color:n?n.properties.get("fog-color"):a.bf.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:c?0:n?n.calculateFogBlendOpacity(o):0,u_horizon_color:n?n.properties.get("horizon-color"):a.bf.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:c?1:0}),oc={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ps(h){const e=[];for(let n=0;n<h.length;n++){if(h[n]===null)continue;const o=h[n].split(" ");e.push(o.pop())}return e}class ac{constructor(e,n,o,c,d,g,v,x,P=[]){const C=e.gl;this.program=C.createProgram();const k=Ps(n.staticAttributes),A=o?o.getBinderAttributes():[],R=k.concat(A),O=rn.prelude.staticUniforms?Ps(rn.prelude.staticUniforms):[],Z=v.staticUniforms?Ps(v.staticUniforms):[],G=n.staticUniforms?Ps(n.staticUniforms):[],q=o?o.getBinderUniforms():[],W=O.concat(Z).concat(G).concat(q),J=[];for(const _e of W)J.indexOf(_e)<0&&J.push(_e);const K=o?o.defines():[];wn(C)&&K.unshift("#version 300 es"),d&&K.push("#define OVERDRAW_INSPECTOR;"),g&&K.push("#define TERRAIN3D;"),x&&K.push(x),P&&K.push(...P);let te=K.concat(rn.prelude.fragmentSource,v.fragmentSource,n.fragmentSource).join(`
763
+ `),se=K.concat(rn.prelude.vertexSource,v.vertexSource,n.vertexSource).join(`
764
+ `);wn(C)||(te=function(_e){return _e.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(te),se=function(_e){return _e.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(se));const Y=C.createShader(C.FRAGMENT_SHADER);if(C.isContextLost())return void(this.failedToCreate=!0);if(C.shaderSource(Y,te),C.compileShader(Y),!C.getShaderParameter(Y,C.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${C.getShaderInfoLog(Y)}`);C.attachShader(this.program,Y);const pe=C.createShader(C.VERTEX_SHADER);if(C.isContextLost())return void(this.failedToCreate=!0);if(C.shaderSource(pe,se),C.compileShader(pe),!C.getShaderParameter(pe,C.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${C.getShaderInfoLog(pe)}`);C.attachShader(this.program,pe),this.attributes={};const be={};this.numAttributes=R.length;for(let _e=0;_e<this.numAttributes;_e++)R[_e]&&(C.bindAttribLocation(this.program,_e,R[_e]),this.attributes[R[_e]]=_e);if(C.linkProgram(this.program),!C.getProgramParameter(this.program,C.LINK_STATUS))throw new Error(`Program failed to link: ${C.getProgramInfoLog(this.program)}`);C.deleteShader(pe),C.deleteShader(Y);for(let _e=0;_e<J.length;_e++){const ye=J[_e];if(ye&&!be[ye]){const xe=C.getUniformLocation(this.program,ye);xe&&(be[ye]=xe)}}this.fixedUniforms=c(e,be),this.terrainUniforms=((_e,ye)=>({u_depth:new a.bP(_e,ye.u_depth),u_terrain:new a.bP(_e,ye.u_terrain),u_terrain_dim:new a.bg(_e,ye.u_terrain_dim),u_terrain_matrix:new a.bR(_e,ye.u_terrain_matrix),u_terrain_unpack:new a.bS(_e,ye.u_terrain_unpack),u_terrain_exaggeration:new a.bg(_e,ye.u_terrain_exaggeration)}))(e,be),this.projectionUniforms=((_e,ye)=>({u_projection_matrix:new a.bR(_e,ye.u_projection_matrix),u_projection_tile_mercator_coords:new a.bS(_e,ye.u_projection_tile_mercator_coords),u_projection_clipping_plane:new a.bS(_e,ye.u_projection_clipping_plane),u_projection_transition:new a.bg(_e,ye.u_projection_transition),u_projection_fallback_matrix:new a.bR(_e,ye.u_projection_fallback_matrix)}))(e,be),this.binderUniforms=o?o.getUniforms(e,be):[]}draw(e,n,o,c,d,g,v,x,P,C,k,A,R,O,Z,G,q,W,J){const K=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(o),e.setStencilMode(c),e.setColorMode(d),e.setCullFace(g),x){e.activeTexture.set(K.TEXTURE2),K.bindTexture(K.TEXTURE_2D,x.depthTexture),e.activeTexture.set(K.TEXTURE3),K.bindTexture(K.TEXTURE_2D,x.texture);for(const se in this.terrainUniforms)this.terrainUniforms[se].set(x[se])}if(P)for(const se in P)this.projectionUniforms[oc[se]].set(P[se]);if(v)for(const se in this.fixedUniforms)this.fixedUniforms[se].set(v[se]);G&&G.setUniforms(e,this.binderUniforms,O,{zoom:Z});let te=0;switch(n){case K.LINES:te=2;break;case K.TRIANGLES:te=3;break;case K.LINE_STRIP:te=1}for(const se of R.get()){const Y=se.vaos||(se.vaos={});(Y[C]||(Y[C]=new Jd)).bind(e,this,k,G?G.getPaintVertexBuffers():[],A,se.vertexOffset,q,W,J),K.drawElements(n,se.primitiveLength*te,K.UNSIGNED_SHORT,se.primitiveOffset*te*2)}}}function Va(h,e,n){const o=1/a.aC(n,1,e.transform.tileZoom),c=Math.pow(2,n.tileID.overscaledZ),d=n.tileSize*Math.pow(2,e.transform.tileZoom)/c,g=d*(n.tileID.canonical.x+n.tileID.wrap*c),v=d*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[o,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[g>>16,v>>16],u_pixel_coord_lower:[65535&g,65535&v]}}const sn=(h,e,n,o)=>{const c=h.style.light,d=c.properties.get("position"),g=[d.x,d.y,d.z],v=a.bV();c.properties.get("anchor")==="viewport"&&a.bW(v,h.transform.bearingInRadians),a.bX(g,g,v);const x=h.transform.transformLightDirection(g),P=c.properties.get("color");return{u_lightpos:g,u_lightpos_globe:x,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[P.r,P.g,P.b],u_vertical_gradient:+e,u_opacity:n,u_fill_translate:o}},Qd=(h,e,n,o,c,d,g)=>a.e(sn(h,e,n,o),Va(d,h,g),{u_height_factor:-Math.pow(2,c.overscaledZ)/g.tileSize/8}),Ua=(h,e,n,o)=>a.e(Va(e,h,n),{u_fill_translate:o}),$o=(h,e)=>({u_world:h,u_fill_translate:e}),Go=(h,e,n,o,c)=>a.e(Ua(h,e,n,c),{u_world:o}),ep=(h,e,n,o,c)=>{const d=h.transform;let g,v,x=0;if(n.paint.get("circle-pitch-alignment")==="map"){const P=a.aC(e,1,d.zoom);g=!0,v=[P,P],x=P/(a.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*c}else g=!1,v=d.pixelsToGLUnits;return{u_camera_to_center_distance:d.cameraToCenterDistance,u_scale_with_map:+(n.paint.get("circle-pitch-scale")==="map"),u_pitch_with_map:+g,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:v,u_globe_extrude_scale:x,u_translate:o}},$a=h=>({u_pixel_extrude_scale:[1/h.width,1/h.height]}),tp=h=>({u_viewport_size:[h.width,h.height]}),Ms=(h,e=1)=>({u_color:h,u_overlay:0,u_overlay_scale:e}),Xu=(h,e,n,o)=>{const c=a.aC(h,1,e)/(a.$*Math.pow(2,h.tileID.overscaledZ))*2*Math.PI*o;return{u_extrude_scale:a.aC(h,1,e),u_intensity:n,u_globe_extrude_scale:c}},lc=(h,e,n,o)=>{const c=a.L();a.bY(c,0,h.width,h.height,0,0,1);const d=h.context.gl;return{u_matrix:c,u_world:[d.drawingBufferWidth,d.drawingBufferHeight],u_image:n,u_color_ramp:o,u_opacity:e.paint.get("heatmap-opacity")}},ip=(h,e,n)=>{const o=n.paint.get("hillshade-accent-color");let c;switch(n.paint.get("hillshade-method")){case"basic":c=4;break;case"combined":c=1;break;case"igor":c=2;break;case"multidirectional":c=3;break;default:c=0}const d=n.getIlluminationProperties();for(let g=0;g<d.directionRadians.length;g++)n.paint.get("hillshade-illumination-anchor")==="viewport"&&(d.directionRadians[g]+=h.transform.bearingInRadians);return{u_image:0,u_latrange:cc(0,e.tileID),u_exaggeration:n.paint.get("hillshade-exaggeration"),u_altitudes:d.altitudeRadians,u_azimuths:d.directionRadians,u_accent:o,u_method:c,u_highlights:d.highlightColor,u_shadows:d.shadowColor}},Ku=(h,e)=>{const n=e.stride,o=a.L();return a.bY(o,0,a.$,-a.$,0,0,1),a.M(o,o,[0,-a.$,0]),{u_matrix:o,u_image:1,u_dimension:[n,n],u_zoom:h.overscaledZ,u_unpack:e.getUnpackVector()}};function cc(h,e){const n=Math.pow(2,e.canonical.z),o=e.canonical.y;return[new a.a1(0,o/n).toLngLat().lat,new a.a1(0,(o+1)/n).toLngLat().lat]}const Yu=(h,e,n=0)=>({u_image:0,u_unpack:e.getUnpackVector(),u_dimension:[e.stride,e.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:h.paint.get("color-relief-opacity")}),Ga=(h,e,n,o)=>{const c=h.transform;return{u_translation:hc(h,e,n),u_ratio:o/a.aC(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},Ju=(h,e,n,o,c)=>a.e(Ga(h,e,n,o),{u_image:0,u_image_height:c}),Qu=(h,e,n,o,c)=>{const d=h.transform,g=uc(e,d);return{u_translation:hc(h,e,n),u_texsize:e.imageAtlasTexture.size,u_ratio:o/a.aC(e,1,d.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[g,c.fromScale,c.toScale],u_fade:c.t,u_units_to_pixels:[1/d.pixelsToGLUnits[0],1/d.pixelsToGLUnits[1]]}},Cs=(h,e,n,o,c,d)=>{const g=h.lineAtlas,v=uc(e,h.transform),x=n.layout.get("line-cap")==="round",P=g.getDash(c.from,x),C=g.getDash(c.to,x),k=P.width*d.fromScale,A=C.width*d.toScale;return a.e(Ga(h,e,n,o),{u_patternscale_a:[v/k,-P.height/2],u_patternscale_b:[v/A,-C.height/2],u_sdfgamma:g.width/(256*Math.min(k,A)*h.pixelRatio)/2,u_image:0,u_tex_y_a:P.y,u_tex_y_b:C.y,u_mix:d.t})};function uc(h,e){return 1/a.aC(h,1,e.tileZoom)}function hc(h,e,n){return a.aD(h.transform,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Zo=(h,e,n,o,c)=>{return{u_tl_parent:h,u_scale_parent:e,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(g=o.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(d=o.paint.get("raster-contrast"),d>0?1/(1-d):1+d),u_spin_weights:rp(o.paint.get("raster-hue-rotate")),u_coords_top:[c[0].x,c[0].y,c[1].x,c[1].y],u_coords_bottom:[c[3].x,c[3].y,c[2].x,c[2].y]};var d,g};function rp(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const qo=(h,e,n,o,c,d,g,v,x,P,C,k,A)=>{const R=g.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:R.cameraToCenterDistance,u_pitch:R.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:R.width/R.height,u_fade_change:g.options.fadeDuration?g.symbolFadeChange:1,u_label_plane_matrix:v,u_coord_matrix:x,u_is_text:+C,u_pitch_with_map:+o,u_is_along_line:c,u_is_variable_anchor:d,u_texsize:k,u_texture:0,u_translation:P,u_pitched_scale:A}},eh=(h,e,n,o,c,d,g,v,x,P,C,k,A,R)=>{const O=g.transform;return a.e(qo(h,e,n,o,c,d,g,v,x,P,C,k,R),{u_gamma_scale:o?Math.cos(O.pitch*Math.PI/180)*O.cameraToCenterDistance:1,u_device_pixel_ratio:g.pixelRatio,u_is_halo:1})},np=(h,e,n,o,c,d,g,v,x,P,C,k,A)=>a.e(eh(h,e,n,o,c,d,g,v,x,P,!0,C,0,A),{u_texsize_icon:k,u_texture_icon:1}),th=(h,e)=>({u_opacity:h,u_color:e}),ih=(h,e,n,o,c)=>a.e(function(d,g,v,x){const P=v.imageManager.getPattern(d.from.toString()),C=v.imageManager.getPattern(d.to.toString()),{width:k,height:A}=v.imageManager.getPixelSize(),R=Math.pow(2,x.tileID.overscaledZ),O=x.tileSize*Math.pow(2,v.transform.tileZoom)/R,Z=O*(x.tileID.canonical.x+x.tileID.wrap*R),G=O*x.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:P.tl,u_pattern_br_a:P.br,u_pattern_tl_b:C.tl,u_pattern_br_b:C.br,u_texsize:[k,A],u_mix:g.t,u_pattern_size_a:P.displaySize,u_pattern_size_b:C.displaySize,u_scale_a:g.fromScale,u_scale_b:g.toScale,u_tile_units_to_pixels:1/a.aC(x,1,v.transform.tileZoom),u_pixel_coord_upper:[Z>>16,G>>16],u_pixel_coord_lower:[65535&Z,65535&G]}}(n,c,e,o),{u_opacity:h}),dc=(h,e)=>{},pc={fillExtrusion:(h,e)=>({u_lightpos:new a.bT(h,e.u_lightpos),u_lightpos_globe:new a.bT(h,e.u_lightpos_globe),u_lightintensity:new a.bg(h,e.u_lightintensity),u_lightcolor:new a.bT(h,e.u_lightcolor),u_vertical_gradient:new a.bg(h,e.u_vertical_gradient),u_opacity:new a.bg(h,e.u_opacity),u_fill_translate:new a.bU(h,e.u_fill_translate)}),fillExtrusionPattern:(h,e)=>({u_lightpos:new a.bT(h,e.u_lightpos),u_lightpos_globe:new a.bT(h,e.u_lightpos_globe),u_lightintensity:new a.bg(h,e.u_lightintensity),u_lightcolor:new a.bT(h,e.u_lightcolor),u_vertical_gradient:new a.bg(h,e.u_vertical_gradient),u_height_factor:new a.bg(h,e.u_height_factor),u_opacity:new a.bg(h,e.u_opacity),u_fill_translate:new a.bU(h,e.u_fill_translate),u_image:new a.bP(h,e.u_image),u_texsize:new a.bU(h,e.u_texsize),u_pixel_coord_upper:new a.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(h,e.u_pixel_coord_lower),u_scale:new a.bT(h,e.u_scale),u_fade:new a.bg(h,e.u_fade)}),fill:(h,e)=>({u_fill_translate:new a.bU(h,e.u_fill_translate)}),fillPattern:(h,e)=>({u_image:new a.bP(h,e.u_image),u_texsize:new a.bU(h,e.u_texsize),u_pixel_coord_upper:new a.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(h,e.u_pixel_coord_lower),u_scale:new a.bT(h,e.u_scale),u_fade:new a.bg(h,e.u_fade),u_fill_translate:new a.bU(h,e.u_fill_translate)}),fillOutline:(h,e)=>({u_world:new a.bU(h,e.u_world),u_fill_translate:new a.bU(h,e.u_fill_translate)}),fillOutlinePattern:(h,e)=>({u_world:new a.bU(h,e.u_world),u_image:new a.bP(h,e.u_image),u_texsize:new a.bU(h,e.u_texsize),u_pixel_coord_upper:new a.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(h,e.u_pixel_coord_lower),u_scale:new a.bT(h,e.u_scale),u_fade:new a.bg(h,e.u_fade),u_fill_translate:new a.bU(h,e.u_fill_translate)}),circle:(h,e)=>({u_camera_to_center_distance:new a.bg(h,e.u_camera_to_center_distance),u_scale_with_map:new a.bP(h,e.u_scale_with_map),u_pitch_with_map:new a.bP(h,e.u_pitch_with_map),u_extrude_scale:new a.bU(h,e.u_extrude_scale),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_globe_extrude_scale:new a.bg(h,e.u_globe_extrude_scale),u_translate:new a.bU(h,e.u_translate)}),collisionBox:(h,e)=>({u_pixel_extrude_scale:new a.bU(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_viewport_size:new a.bU(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new a.bQ(h,e.u_color),u_overlay:new a.bP(h,e.u_overlay),u_overlay_scale:new a.bg(h,e.u_overlay_scale)}),depth:dc,clippingMask:dc,heatmap:(h,e)=>({u_extrude_scale:new a.bg(h,e.u_extrude_scale),u_intensity:new a.bg(h,e.u_intensity),u_globe_extrude_scale:new a.bg(h,e.u_globe_extrude_scale)}),heatmapTexture:(h,e)=>({u_matrix:new a.bR(h,e.u_matrix),u_world:new a.bU(h,e.u_world),u_image:new a.bP(h,e.u_image),u_color_ramp:new a.bP(h,e.u_color_ramp),u_opacity:new a.bg(h,e.u_opacity)}),hillshade:(h,e)=>({u_image:new a.bP(h,e.u_image),u_latrange:new a.bU(h,e.u_latrange),u_exaggeration:new a.bg(h,e.u_exaggeration),u_altitudes:new a.b_(h,e.u_altitudes),u_azimuths:new a.b_(h,e.u_azimuths),u_accent:new a.bQ(h,e.u_accent),u_method:new a.bP(h,e.u_method),u_shadows:new a.bZ(h,e.u_shadows),u_highlights:new a.bZ(h,e.u_highlights)}),hillshadePrepare:(h,e)=>({u_matrix:new a.bR(h,e.u_matrix),u_image:new a.bP(h,e.u_image),u_dimension:new a.bU(h,e.u_dimension),u_zoom:new a.bg(h,e.u_zoom),u_unpack:new a.bS(h,e.u_unpack)}),colorRelief:(h,e)=>({u_image:new a.bP(h,e.u_image),u_unpack:new a.bS(h,e.u_unpack),u_dimension:new a.bU(h,e.u_dimension),u_elevation_stops:new a.bP(h,e.u_elevation_stops),u_color_stops:new a.bP(h,e.u_color_stops),u_color_ramp_size:new a.bP(h,e.u_color_ramp_size),u_opacity:new a.bg(h,e.u_opacity)}),line:(h,e)=>({u_translation:new a.bU(h,e.u_translation),u_ratio:new a.bg(h,e.u_ratio),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new a.bU(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_translation:new a.bU(h,e.u_translation),u_ratio:new a.bg(h,e.u_ratio),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new a.bU(h,e.u_units_to_pixels),u_image:new a.bP(h,e.u_image),u_image_height:new a.bg(h,e.u_image_height)}),linePattern:(h,e)=>({u_translation:new a.bU(h,e.u_translation),u_texsize:new a.bU(h,e.u_texsize),u_ratio:new a.bg(h,e.u_ratio),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_image:new a.bP(h,e.u_image),u_units_to_pixels:new a.bU(h,e.u_units_to_pixels),u_scale:new a.bT(h,e.u_scale),u_fade:new a.bg(h,e.u_fade)}),lineSDF:(h,e)=>({u_translation:new a.bU(h,e.u_translation),u_ratio:new a.bg(h,e.u_ratio),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_units_to_pixels:new a.bU(h,e.u_units_to_pixels),u_patternscale_a:new a.bU(h,e.u_patternscale_a),u_patternscale_b:new a.bU(h,e.u_patternscale_b),u_sdfgamma:new a.bg(h,e.u_sdfgamma),u_image:new a.bP(h,e.u_image),u_tex_y_a:new a.bg(h,e.u_tex_y_a),u_tex_y_b:new a.bg(h,e.u_tex_y_b),u_mix:new a.bg(h,e.u_mix)}),raster:(h,e)=>({u_tl_parent:new a.bU(h,e.u_tl_parent),u_scale_parent:new a.bg(h,e.u_scale_parent),u_buffer_scale:new a.bg(h,e.u_buffer_scale),u_fade_t:new a.bg(h,e.u_fade_t),u_opacity:new a.bg(h,e.u_opacity),u_image0:new a.bP(h,e.u_image0),u_image1:new a.bP(h,e.u_image1),u_brightness_low:new a.bg(h,e.u_brightness_low),u_brightness_high:new a.bg(h,e.u_brightness_high),u_saturation_factor:new a.bg(h,e.u_saturation_factor),u_contrast_factor:new a.bg(h,e.u_contrast_factor),u_spin_weights:new a.bT(h,e.u_spin_weights),u_coords_top:new a.bS(h,e.u_coords_top),u_coords_bottom:new a.bS(h,e.u_coords_bottom)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new a.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bP(h,e.u_is_size_feature_constant),u_size_t:new a.bg(h,e.u_size_t),u_size:new a.bg(h,e.u_size),u_camera_to_center_distance:new a.bg(h,e.u_camera_to_center_distance),u_pitch:new a.bg(h,e.u_pitch),u_rotate_symbol:new a.bP(h,e.u_rotate_symbol),u_aspect_ratio:new a.bg(h,e.u_aspect_ratio),u_fade_change:new a.bg(h,e.u_fade_change),u_label_plane_matrix:new a.bR(h,e.u_label_plane_matrix),u_coord_matrix:new a.bR(h,e.u_coord_matrix),u_is_text:new a.bP(h,e.u_is_text),u_pitch_with_map:new a.bP(h,e.u_pitch_with_map),u_is_along_line:new a.bP(h,e.u_is_along_line),u_is_variable_anchor:new a.bP(h,e.u_is_variable_anchor),u_texsize:new a.bU(h,e.u_texsize),u_texture:new a.bP(h,e.u_texture),u_translation:new a.bU(h,e.u_translation),u_pitched_scale:new a.bg(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new a.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bP(h,e.u_is_size_feature_constant),u_size_t:new a.bg(h,e.u_size_t),u_size:new a.bg(h,e.u_size),u_camera_to_center_distance:new a.bg(h,e.u_camera_to_center_distance),u_pitch:new a.bg(h,e.u_pitch),u_rotate_symbol:new a.bP(h,e.u_rotate_symbol),u_aspect_ratio:new a.bg(h,e.u_aspect_ratio),u_fade_change:new a.bg(h,e.u_fade_change),u_label_plane_matrix:new a.bR(h,e.u_label_plane_matrix),u_coord_matrix:new a.bR(h,e.u_coord_matrix),u_is_text:new a.bP(h,e.u_is_text),u_pitch_with_map:new a.bP(h,e.u_pitch_with_map),u_is_along_line:new a.bP(h,e.u_is_along_line),u_is_variable_anchor:new a.bP(h,e.u_is_variable_anchor),u_texsize:new a.bU(h,e.u_texsize),u_texture:new a.bP(h,e.u_texture),u_gamma_scale:new a.bg(h,e.u_gamma_scale),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_is_halo:new a.bP(h,e.u_is_halo),u_translation:new a.bU(h,e.u_translation),u_pitched_scale:new a.bg(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new a.bP(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new a.bP(h,e.u_is_size_feature_constant),u_size_t:new a.bg(h,e.u_size_t),u_size:new a.bg(h,e.u_size),u_camera_to_center_distance:new a.bg(h,e.u_camera_to_center_distance),u_pitch:new a.bg(h,e.u_pitch),u_rotate_symbol:new a.bP(h,e.u_rotate_symbol),u_aspect_ratio:new a.bg(h,e.u_aspect_ratio),u_fade_change:new a.bg(h,e.u_fade_change),u_label_plane_matrix:new a.bR(h,e.u_label_plane_matrix),u_coord_matrix:new a.bR(h,e.u_coord_matrix),u_is_text:new a.bP(h,e.u_is_text),u_pitch_with_map:new a.bP(h,e.u_pitch_with_map),u_is_along_line:new a.bP(h,e.u_is_along_line),u_is_variable_anchor:new a.bP(h,e.u_is_variable_anchor),u_texsize:new a.bU(h,e.u_texsize),u_texsize_icon:new a.bU(h,e.u_texsize_icon),u_texture:new a.bP(h,e.u_texture),u_texture_icon:new a.bP(h,e.u_texture_icon),u_gamma_scale:new a.bg(h,e.u_gamma_scale),u_device_pixel_ratio:new a.bg(h,e.u_device_pixel_ratio),u_is_halo:new a.bP(h,e.u_is_halo),u_translation:new a.bU(h,e.u_translation),u_pitched_scale:new a.bg(h,e.u_pitched_scale)}),background:(h,e)=>({u_opacity:new a.bg(h,e.u_opacity),u_color:new a.bQ(h,e.u_color)}),backgroundPattern:(h,e)=>({u_opacity:new a.bg(h,e.u_opacity),u_image:new a.bP(h,e.u_image),u_pattern_tl_a:new a.bU(h,e.u_pattern_tl_a),u_pattern_br_a:new a.bU(h,e.u_pattern_br_a),u_pattern_tl_b:new a.bU(h,e.u_pattern_tl_b),u_pattern_br_b:new a.bU(h,e.u_pattern_br_b),u_texsize:new a.bU(h,e.u_texsize),u_mix:new a.bg(h,e.u_mix),u_pattern_size_a:new a.bU(h,e.u_pattern_size_a),u_pattern_size_b:new a.bU(h,e.u_pattern_size_b),u_scale_a:new a.bg(h,e.u_scale_a),u_scale_b:new a.bg(h,e.u_scale_b),u_pixel_coord_upper:new a.bU(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new a.bU(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new a.bg(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_texture:new a.bP(h,e.u_texture),u_ele_delta:new a.bg(h,e.u_ele_delta),u_fog_matrix:new a.bR(h,e.u_fog_matrix),u_fog_color:new a.bQ(h,e.u_fog_color),u_fog_ground_blend:new a.bg(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new a.bg(h,e.u_fog_ground_blend_opacity),u_horizon_color:new a.bQ(h,e.u_horizon_color),u_horizon_fog_blend:new a.bg(h,e.u_horizon_fog_blend),u_is_globe_mode:new a.bg(h,e.u_is_globe_mode)}),terrainDepth:(h,e)=>({u_ele_delta:new a.bg(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_texture:new a.bP(h,e.u_texture),u_terrain_coords_id:new a.bg(h,e.u_terrain_coords_id),u_ele_delta:new a.bg(h,e.u_ele_delta)}),projectionErrorMeasurement:(h,e)=>({u_input:new a.bg(h,e.u_input),u_output_expected:new a.bg(h,e.u_output_expected)}),atmosphere:(h,e)=>({u_sun_pos:new a.bT(h,e.u_sun_pos),u_atmosphere_blend:new a.bg(h,e.u_atmosphere_blend),u_globe_position:new a.bT(h,e.u_globe_position),u_globe_radius:new a.bg(h,e.u_globe_radius),u_inv_proj_matrix:new a.bR(h,e.u_inv_proj_matrix)}),sky:(h,e)=>({u_sky_color:new a.bQ(h,e.u_sky_color),u_horizon_color:new a.bQ(h,e.u_horizon_color),u_horizon:new a.bU(h,e.u_horizon),u_horizon_normal:new a.bU(h,e.u_horizon_normal),u_sky_horizon_blend:new a.bg(h,e.u_sky_horizon_blend),u_sky_blend:new a.bg(h,e.u_sky_blend)})};class rh{constructor(e,n,o){this.context=e;const c=e.gl;this.buffer=c.createBuffer(),this.dynamicDraw=!!o,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Za={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class zn{constructor(e,n,o,c){this.length=n.length,this.attributes=o,this.itemSize=n.bytesPerElement,this.dynamicDraw=c,this.context=e;const d=e.gl;this.buffer=d.createBuffer(),e.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let o=0;o<this.attributes.length;o++){const c=n.attributes[this.attributes[o].name];c!==void 0&&e.enableVertexAttribArray(c)}}setVertexAttribPointers(e,n,o){for(let c=0;c<this.attributes.length;c++){const d=this.attributes[c],g=n.attributes[d.name];g!==void 0&&e.vertexAttribPointer(g,d.components,e[Za[d.type]],!1,this.itemSize,d.offset+this.itemSize*(o||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class qt{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class fc extends qt{getDefault(){return a.bf.transparent}set(e){const n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class mc extends qt{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class nh extends qt{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class gc extends qt{getDefault(){return[!0,!0,!0,!0]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Is extends qt{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class _c extends qt{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class sp extends qt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const n=this.current;(e.func!==n.func||e.ref!==n.ref||e.mask!==n.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class op extends qt{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class ap extends qt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),this.current=e,this.dirty=!1}}class lp extends qt{getDefault(){return[0,1]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class sh extends qt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),this.current=e,this.dirty=!1}}class cp extends qt{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class oh extends qt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.BLEND):n.disable(n.BLEND),this.current=e,this.dirty=!1}}class qa extends qt{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class Ha extends qt{getDefault(){return a.bf.transparent}set(e){const n=this.current;(e.r!==n.r||e.g!==n.g||e.b!==n.b||e.a!==n.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Wa extends qt{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class yc extends qt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;e?n.enable(n.CULL_FACE):n.disable(n.CULL_FACE),this.current=e,this.dirty=!1}}class Es extends qt{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Ho extends qt{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class ro extends qt{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class qr extends qt{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class ah extends qt{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const n=this.current;(e[0]!==n[0]||e[1]!==n[1]||e[2]!==n[2]||e[3]!==n[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class lh extends qt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindFramebuffer(n.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class vc extends qt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindRenderbuffer(n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class As extends qt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindTexture(n.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Xa extends qt{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.bindBuffer(n.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ka extends qt{getDefault(){return null}set(e){const n=this.gl;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Wo extends qt{getDefault(){return null}set(e){var n;if(e===this.current&&!this.dirty)return;const o=this.gl;wn(o)?o.bindVertexArray(e):(n=o.getExtension("OES_vertex_array_object"))===null||n===void 0||n.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Ya extends qt{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class ch extends qt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class no extends qt{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const n=this.gl;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class es extends qt{constructor(e,n){super(e),this.context=e,this.parent=n}getDefault(){return null}}class uh extends es{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class xc extends es{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Lt extends es{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const n=this.gl;n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,e),this.current=e,this.dirty=!1}}const Xo="Framebuffer is not complete";class up{constructor(e,n,o,c,d){this.context=e,this.width=n,this.height=o;const g=e.gl,v=this.framebuffer=g.createFramebuffer();if(this.colorAttachment=new uh(e,v),c)this.depthAttachment=d?new Lt(e,v):new xc(e,v);else if(d)throw new Error("Stencil cannot be set without depth");if(g.checkFramebufferStatus(g.FRAMEBUFFER)!==g.FRAMEBUFFER_COMPLETE)throw new Error(Xo)}destroy(){const e=this.context.gl,n=this.colorAttachment.get();if(n&&e.deleteTexture(n),this.depthAttachment){const o=this.depthAttachment.get();o&&e.deleteRenderbuffer(o)}e.deleteFramebuffer(this.framebuffer)}}class hh{constructor(e){var n,o;if(this.gl=e,this.clearColor=new fc(this),this.clearDepth=new mc(this),this.clearStencil=new nh(this),this.colorMask=new gc(this),this.depthMask=new Is(this),this.stencilMask=new _c(this),this.stencilFunc=new sp(this),this.stencilOp=new op(this),this.stencilTest=new ap(this),this.depthRange=new lp(this),this.depthTest=new sh(this),this.depthFunc=new cp(this),this.blend=new oh(this),this.blendFunc=new qa(this),this.blendColor=new Ha(this),this.blendEquation=new Wa(this),this.cullFace=new yc(this),this.cullFaceSide=new Es(this),this.frontFace=new Ho(this),this.program=new ro(this),this.activeTexture=new qr(this),this.viewport=new ah(this),this.bindFramebuffer=new lh(this),this.bindRenderbuffer=new vc(this),this.bindTexture=new As(this),this.bindVertexBuffer=new Xa(this),this.bindElementBuffer=new Ka(this),this.bindVertexArray=new Wo(this),this.pixelStoreUnpack=new Ya(this),this.pixelStoreUnpackPremultiplyAlpha=new ch(this),this.pixelStoreUnpackFlipY=new no(this),this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),wn(e)){this.HALF_FLOAT=e.HALF_FLOAT;const c=e.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(n=e.RGBA16F)!==null&&n!==void 0?n:c==null?void 0:c.RGBA16F_EXT,this.RGB16F=(o=e.RGB16F)!==null&&o!==void 0?o:c==null?void 0:c.RGB16F_EXT,e.getExtension("EXT_color_buffer_float")}else{e.getExtension("EXT_color_buffer_half_float"),e.getExtension("OES_texture_half_float_linear");const c=e.getExtension("OES_texture_half_float");this.HALF_FLOAT=c==null?void 0:c.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,n){return new rh(this,e,n)}createVertexBuffer(e,n,o){return new zn(this,e,n,o)}createRenderbuffer(e,n,o){const c=this.gl,d=c.createRenderbuffer();return this.bindRenderbuffer.set(d),c.renderbufferStorage(c.RENDERBUFFER,e,n,o),this.bindRenderbuffer.set(null),d}createFramebuffer(e,n,o,c){return new up(this,e,n,o,c)}clear({color:e,depth:n,stencil:o}){const c=this.gl;let d=0;e&&(d|=c.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),n!==void 0&&(d|=c.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(n),this.depthMask.set(!0)),o!==void 0&&(d|=c.STENCIL_BUFFER_BIT,this.clearStencil.set(o),this.stencilMask.set(255)),c.clear(d)}setCullFace(e){e.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){a.bH(e.blendFunction,ci.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){var e;return wn(this.gl)?this.gl.createVertexArray():(e=this.gl.getExtension("OES_vertex_array_object"))===null||e===void 0?void 0:e.createVertexArrayOES()}deleteVertexArray(e){var n;return wn(this.gl)?this.gl.deleteVertexArray(e):(n=this.gl.getExtension("OES_vertex_array_object"))===null||n===void 0?void 0:n.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let ts;function dh(h,e,n,o,c){const d=h.context,g=h.transform,v=d.gl,x=h.useProgram("collisionBox"),P=[];let C=0,k=0;for(let q=0;q<o.length;q++){const W=o[q],J=e.getTile(W).getBucket(n);if(!J)continue;const K=c?J.textCollisionBox:J.iconCollisionBox,te=J.collisionCircleArray;te.length>0&&(P.push({circleArray:te,circleOffset:k,coord:W}),C+=te.length/4,k=C),K&&x.draw(d,v.LINES,vt.disabled,$t.disabled,h.colorModeForRenderPass(),pt.disabled,$a(h.transform),h.style.map.terrain&&h.style.map.terrain.getTerrainData(W),g.getProjectionData({overscaledTileID:W,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,K.layoutVertexBuffer,K.indexBuffer,K.segments,null,h.transform.zoom,null,null,K.collisionVertexBuffer)}if(!c||!P.length)return;const A=h.useProgram("collisionCircle"),R=new a.b$;R.resize(4*C),R._trim();let O=0;for(const q of P)for(let W=0;W<q.circleArray.length/4;W++){const J=4*W,K=q.circleArray[J+0],te=q.circleArray[J+1],se=q.circleArray[J+2],Y=q.circleArray[J+3];R.emplace(O++,K,te,se,Y,0),R.emplace(O++,K,te,se,Y,1),R.emplace(O++,K,te,se,Y,2),R.emplace(O++,K,te,se,Y,3)}(!ts||ts.length<2*C)&&(ts=function(q){const W=2*q,J=new a.c1;J.resize(W),J._trim();for(let K=0;K<W;K++){const te=6*K;J.uint16[te+0]=4*K+0,J.uint16[te+1]=4*K+1,J.uint16[te+2]=4*K+2,J.uint16[te+3]=4*K+2,J.uint16[te+4]=4*K+3,J.uint16[te+5]=4*K+0}return J}(C));const Z=d.createIndexBuffer(ts,!0),G=d.createVertexBuffer(R,a.c0.members,!0);for(const q of P){const W=tp(h.transform);A.draw(d,v.TRIANGLES,vt.disabled,$t.disabled,h.colorModeForRenderPass(),pt.disabled,W,h.style.map.terrain&&h.style.map.terrain.getTerrainData(q.coord),null,n.id,G,Z,a.aM.simpleSegment(0,2*q.circleOffset,q.circleArray.length,q.circleArray.length/2),null,h.transform.zoom,null,null,null)}G.destroy(),Z.destroy()}const hp=a.ag(new Float32Array(16));function ph(h,e,n,o,c,d){const{horizontalAlign:g,verticalAlign:v}=a.aH(h);return new a.P((-(g-.5)*e/c+o[0])*d,(-(v-.5)*n/c+o[1])*d)}function dp(h,e,n,o,c,d){const g=e.tileAnchorPoint.add(new a.P(e.translation[0],e.translation[1]));if(e.pitchWithMap){let v=o.mult(d);n||(v=v.rotate(-c));const x=g.add(v);return ki(x.x,x.y,e.pitchedLabelPlaneMatrix,e.getElevation).point}if(n){const v=ir(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(h),x=Math.atan(v.y/v.x)+(v.x<0?Math.PI:0);return h.add(o.rotate(x))}return h.add(o)}function bc(h,e,n,o,c,d,g,v,x,P,C,k){const A=h.text.placedSymbolArray,R=h.text.dynamicLayoutVertexArray,O=h.icon.dynamicLayoutVertexArray,Z={};R.clear();for(let G=0;G<A.length;G++){const q=A.get(G),W=q.hidden||!q.crossTileID||h.allowVerticalPlacement&&!q.placedOrientation?null:o[q.crossTileID];if(W){const J=new a.P(q.anchorX,q.anchorY),K={getElevation:k,width:c.width,height:c.height,pitchedLabelPlaneMatrix:d,pitchWithMap:n,transform:c,tileAnchorPoint:J,translation:P,unwrappedTileID:C},te=n?Xn(J.x,J.y,K):ir(J.x,J.y,K),se=Fe(c.cameraToCenterDistance,te.signedDistanceFromCamera);let Y=a.ap(h.textSizeData,v,q)*se/a.aB;n&&(Y*=h.tilePixelRatio/g);const{width:pe,height:be,anchor:_e,textOffset:ye,textBoxScale:xe}=W,Le=ph(_e,pe,be,ye,xe,Y),Oe=c.getPitchedTextCorrection(J.x+P[0],J.y+P[1],C),Ie=dp(te.point,K,e,Le,-c.bearingInRadians,Oe),et=h.allowVerticalPlacement&&q.placedOrientation===a.ao.vertical?Math.PI/2:0;for(let Tt=0;Tt<q.numGlyphs;Tt++)a.av(R,Ie,et);x&&q.associatedIconIndex>=0&&(Z[q.associatedIconIndex]={shiftedAnchor:Ie,angle:et})}else bn(q.numGlyphs,R)}if(x){O.clear();const G=h.icon.placedSymbolArray;for(let q=0;q<G.length;q++){const W=G.get(q);if(W.hidden)bn(W.numGlyphs,O);else{const J=Z[q];if(J)for(let K=0;K<W.numGlyphs;K++)a.av(O,J.shiftedAnchor,J.angle);else bn(W.numGlyphs,O)}}h.icon.dynamicLayoutVertexBuffer.updateData(O)}h.text.dynamicLayoutVertexBuffer.updateData(R)}function Ja(h,e,n){return n.iconsInText&&e?"symbolTextAndIcon":h?"symbolSDF":"symbolIcon"}function Ko(h,e,n,o,c,d,g,v,x,P,C,k,A){const R=h.context,O=R.gl,Z=h.transform,G=v==="map",q=x==="map",W=v!=="viewport"&&n.layout.get("symbol-placement")!=="point",J=G&&!q&&!W,K=!n.layout.get("symbol-sort-key").isConstant();let te=!1;const se=h.getDepthModeForSublayer(0,vt.ReadOnly),Y=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),pe=[],be=Z.getCircleRadiusCorrection();for(const _e of o){const ye=e.getTile(_e),xe=ye.getBucket(n);if(!xe)continue;const Le=c?xe.text:xe.icon;if(!Le||!Le.segments.get().length||!Le.hasVisibleVertices)continue;const Oe=Le.programConfigurations.get(n.id),Ie=c||xe.sdfIcons,et=c?xe.textSizeData:xe.iconSizeData,Tt=q||Z.pitch!==0,Wt=h.useProgram(Ja(Ie,c,xe),Oe),ei=a.an(et,Z.zoom),Yt=h.style.map.terrain&&h.style.map.terrain.getTerrainData(_e);let pi,yi,bt,ti,Ri=[0,0],Vi=null;if(c)yi=ye.glyphAtlasTexture,bt=O.LINEAR,pi=ye.glyphAtlasTexture.size,xe.iconsInText&&(Ri=ye.imageAtlasTexture.size,Vi=ye.imageAtlasTexture,ti=Tt||h.options.rotating||h.options.zooming||et.kind==="composite"||et.kind==="camera"?O.LINEAR:O.NEAREST);else{const Di=n.layout.get("icon-size").constantOr(0)!==1||xe.iconsNeedLinear;yi=ye.imageAtlasTexture,bt=Ie||h.options.rotating||h.options.zooming||Di||Tt?O.LINEAR:O.NEAREST,pi=ye.imageAtlasTexture.size}const Wi=a.aC(ye,1,h.transform.zoom),vr=Ii(G,h.transform,Wi),hn=a.L();a.aq(hn,vr);const rs=Dt(q,G,h.transform,Wi),ns=a.aD(Z,ye,d,g),_o=Z.getProjectionData({overscaledTileID:_e,applyGlobeMatrix:!A,applyTerrainMatrix:!0}),yo=Y&&xe.hasTextData(),Bs=n.layout.get("icon-text-fit")!=="none"&&yo&&xe.hasIconData();if(W){const Di=h.style.map.terrain?(Xr,Li)=>h.style.map.terrain.getElevation(_e,Xr,Li):null,Ui=n.layout.get("text-rotation-alignment")==="map";gi(xe,h,c,vr,hn,q,P,Ui,_e.toUnwrapped(),Z.width,Z.height,ns,Di)}const Os=c&&Y||Bs,Er=W||Os?hp:q?vr:h.transform.clipSpaceToPixelsMatrix,dn=Ie&&n.paint.get(c?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let xr;xr=Ie?xe.iconsInText?np(et.kind,ei,J,q,W,Os,h,Er,rs,ns,pi,Ri,be):eh(et.kind,ei,J,q,W,Os,h,Er,rs,ns,c,pi,0,be):qo(et.kind,ei,J,q,W,Os,h,Er,rs,ns,c,pi,be);const ss={program:Wt,buffers:Le,uniformValues:xr,projectionData:_o,atlasTexture:yi,atlasTextureIcon:Vi,atlasInterpolation:bt,atlasInterpolationIcon:ti,isSDF:Ie,hasHalo:dn};if(K&&xe.canOverlap){te=!0;const Di=Le.segments.get();for(const Ui of Di)pe.push({segments:new a.aM([Ui]),sortKey:Ui.sortKey,state:ss,terrainData:Yt})}else pe.push({segments:Le.segments,sortKey:0,state:ss,terrainData:Yt})}te&&pe.sort((_e,ye)=>_e.sortKey-ye.sortKey);for(const _e of pe){const ye=_e.state;if(R.activeTexture.set(O.TEXTURE0),ye.atlasTexture.bind(ye.atlasInterpolation,O.CLAMP_TO_EDGE),ye.atlasTextureIcon&&(R.activeTexture.set(O.TEXTURE1),ye.atlasTextureIcon&&ye.atlasTextureIcon.bind(ye.atlasInterpolationIcon,O.CLAMP_TO_EDGE)),ye.isSDF){const xe=ye.uniformValues;ye.hasHalo&&(xe.u_is_halo=1,Yo(ye.buffers,_e.segments,n,h,ye.program,se,C,k,xe,ye.projectionData,_e.terrainData)),xe.u_is_halo=0}Yo(ye.buffers,_e.segments,n,h,ye.program,se,C,k,ye.uniformValues,ye.projectionData,_e.terrainData)}}function Yo(h,e,n,o,c,d,g,v,x,P,C){const k=o.context;c.draw(k,k.gl.TRIANGLES,d,g,v,pt.backCCW,x,C,P,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,o.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function wc(h,e,n,o,c){const d=h.context,g=d.gl,v=$t.disabled,x=new ci([g.ONE,g.ONE],a.bf.transparent,[!0,!0,!0,!0]),P=e.getBucket(n);if(!P)return;const C=o.key;let k=n.heatmapFbos.get(C);k||(k=Jo(d,e.tileSize,e.tileSize),n.heatmapFbos.set(C,k)),d.bindFramebuffer.set(k.framebuffer),d.viewport.set([0,0,e.tileSize,e.tileSize]),d.clear({color:a.bf.transparent});const A=P.programConfigurations.get(n.id),R=h.useProgram("heatmap",A,!c),O=h.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),Z=h.style.map.terrain.getTerrainData(o);R.draw(d,g.TRIANGLES,vt.disabled,v,x,pt.disabled,Xu(e,h.transform.zoom,n.paint.get("heatmap-intensity"),1),Z,O,n.id,P.layoutVertexBuffer,P.indexBuffer,P.segments,n.paint,h.transform.zoom,A)}function fh(h,e,n,o,c){const d=h.context,g=d.gl,v=h.transform;d.setColorMode(h.colorModeForRenderPass());const x=Qo(d,e),P=n.key,C=e.heatmapFbos.get(P);if(!C)return;d.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,C.colorAttachment.get()),d.activeTexture.set(g.TEXTURE1),x.bind(g.LINEAR,g.CLAMP_TO_EDGE);const k=v.getProjectionData({overscaledTileID:n,applyTerrainMatrix:c,applyGlobeMatrix:!o});h.useProgram("heatmapTexture").draw(d,g.TRIANGLES,vt.disabled,$t.disabled,h.colorModeForRenderPass(),pt.disabled,lc(h,e,0,1),null,k,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,v.zoom),C.destroy(),e.heatmapFbos.delete(P)}function Jo(h,e,n){var o,c;const d=h.gl,g=d.createTexture();d.bindTexture(d.TEXTURE_2D,g),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.LINEAR);const v=(o=h.HALF_FLOAT)!==null&&o!==void 0?o:d.UNSIGNED_BYTE,x=(c=h.RGBA16F)!==null&&c!==void 0?c:d.RGBA;d.texImage2D(d.TEXTURE_2D,0,x,e,n,0,d.RGBA,v,null);const P=h.createFramebuffer(e,n,!1,!1);return P.colorAttachment.set(g),P}function Qo(h,e){return e.colorRampTexture||(e.colorRampTexture=new a.T(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function ea(h,e,n,o,c){if(!n||!o||!o.imageAtlas)return;const d=o.imageAtlas.patternPositions;let g=d[n.to.toString()],v=d[n.from.toString()];if(!g&&v&&(g=v),!v&&g&&(v=g),!g||!v){const x=c.getPaintProperty(e);g=d[x],v=d[x]}g&&v&&h.setConstantPatternPositions(g,v)}function Qa(h,e,n,o,c,d,g,v){const x=h.context.gl,P="fill-pattern",C=n.paint.get(P),k=C&&C.constantOr(1),A=n.getCrossfadeParameters();let R,O,Z,G,q;const W=h.transform,J=n.paint.get("fill-translate"),K=n.paint.get("fill-translate-anchor");g?(O=k&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",R=x.LINES):(O=k?"fillPattern":"fill",R=x.TRIANGLES);const te=C.constantOr(null);for(const se of o){const Y=e.getTile(se);if(k&&!Y.patternsLoaded())continue;const pe=Y.getBucket(n);if(!pe)continue;const be=pe.programConfigurations.get(n.id),_e=h.useProgram(O,be),ye=h.style.map.terrain&&h.style.map.terrain.getTerrainData(se);k&&(h.context.activeTexture.set(x.TEXTURE0),Y.imageAtlasTexture.bind(x.LINEAR,x.CLAMP_TO_EDGE),be.updatePaintBuffers(A)),ea(be,P,te,Y,n);const xe=W.getProjectionData({overscaledTileID:se,applyGlobeMatrix:!v,applyTerrainMatrix:!0}),Le=a.aD(W,Y,J,K);if(g){G=pe.indexBuffer2,q=pe.segments2;const Ie=[x.drawingBufferWidth,x.drawingBufferHeight];Z=O==="fillOutlinePattern"&&k?Go(h,A,Y,Ie,Le):$o(Ie,Le)}else G=pe.indexBuffer,q=pe.segments,Z=k?Ua(h,A,Y,Le):{u_fill_translate:Le};const Oe=h.stencilModeForClipping(se);_e.draw(h.context,R,c,Oe,d,pt.backCCW,Z,ye,xe,n.id,pe.layoutVertexBuffer,G,q,n.paint,h.transform.zoom,be)}}function Tc(h,e,n,o,c,d,g,v){const x=h.context,P=x.gl,C="fill-extrusion-pattern",k=n.paint.get(C),A=k.constantOr(1),R=n.getCrossfadeParameters(),O=n.paint.get("fill-extrusion-opacity"),Z=k.constantOr(null),G=h.transform;for(const q of o){const W=e.getTile(q),J=W.getBucket(n);if(!J)continue;const K=h.style.map.terrain&&h.style.map.terrain.getTerrainData(q),te=J.programConfigurations.get(n.id),se=h.useProgram(A?"fillExtrusionPattern":"fillExtrusion",te);A&&(h.context.activeTexture.set(P.TEXTURE0),W.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),te.updatePaintBuffers(R));const Y=G.getProjectionData({overscaledTileID:q,applyGlobeMatrix:!v,applyTerrainMatrix:!0});ea(te,C,Z,W,n);const pe=a.aD(G,W,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),be=n.paint.get("fill-extrusion-vertical-gradient"),_e=A?Qd(h,be,O,pe,q,R,W):sn(h,be,O,pe);se.draw(x,x.gl.TRIANGLES,c,d,g,pt.backCCW,_e,K,Y,n.id,J.layoutVertexBuffer,J.indexBuffer,J.segments,n.paint,h.transform.zoom,te,h.style.map.terrain&&J.centroidVertexBuffer)}}function ks(h,e,n,o,c,d,g,v,x){var P;const C=h.style.projection,k=h.context,A=h.transform,R=k.gl,O=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get("hillshade-highlight-color").values.length}`],Z=h.useProgram("hillshade",null,!1,O),G=!h.options.moving;for(const q of o){const W=e.getTile(q),J=W.fbo;if(!J)continue;const K=C.getMeshFromTileID(k,q.canonical,v,!0,"raster"),te=(P=h.style.map.terrain)===null||P===void 0?void 0:P.getTerrainData(q);k.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,J.colorAttachment.get());const se=A.getProjectionData({overscaledTileID:q,aligned:G,applyGlobeMatrix:!x,applyTerrainMatrix:!0});Z.draw(k,R.TRIANGLES,d,c[q.overscaledZ],g,pt.backCCW,ip(h,W,n),te,se,n.id,K.vertexBuffer,K.indexBuffer,K.segments)}}function Sc(h,e,n,o,c,d,g,v,x){var P;const C=h.style.projection,k=h.context,A=h.transform,R=k.gl,O=h.useProgram("colorRelief"),Z=!h.options.moving;let G=!0,q=0;for(const W of o){const J=e.getTile(W),K=J.dem;if(G){const _e=R.getParameter(R.MAX_TEXTURE_SIZE),{elevationTexture:ye,colorTexture:xe}=n.getColorRampTextures(k,_e,K.getUnpackVector());k.activeTexture.set(R.TEXTURE1),ye.bind(R.NEAREST,R.CLAMP_TO_EDGE),k.activeTexture.set(R.TEXTURE4),xe.bind(R.LINEAR,R.CLAMP_TO_EDGE),G=!1,q=ye.size[0]}if(!K||!K.data)continue;const te=K.stride,se=K.getPixels();if(k.activeTexture.set(R.TEXTURE0),k.pixelStoreUnpackPremultiplyAlpha.set(!1),J.demTexture=J.demTexture||h.getTileTexture(te),J.demTexture){const _e=J.demTexture;_e.update(se,{premultiply:!1}),_e.bind(R.LINEAR,R.CLAMP_TO_EDGE)}else J.demTexture=new a.T(k,se,R.RGBA,{premultiply:!1}),J.demTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE);const Y=C.getMeshFromTileID(k,W.canonical,v,!0,"raster"),pe=(P=h.style.map.terrain)===null||P===void 0?void 0:P.getTerrainData(W),be=A.getProjectionData({overscaledTileID:W,aligned:Z,applyGlobeMatrix:!x,applyTerrainMatrix:!0});O.draw(k,R.TRIANGLES,d,c[W.overscaledZ],g,pt.backCCW,Yu(n,J.dem,q),pe,be,n.id,Y.vertexBuffer,Y.indexBuffer,Y.segments)}}const el=[new a.P(0,0),new a.P(a.$,0),new a.P(a.$,a.$),new a.P(0,a.$)];function zs(h,e,n,o,c,d,g,v,x=!1,P=!1){const C=o[o.length-1].overscaledZ,k=h.context,A=k.gl,R=h.useProgram("raster"),O=h.transform,Z=h.style.projection,G=h.colorModeForRenderPass(),q=!h.options.moving;for(const W of o){const J=h.getDepthModeForSublayer(W.overscaledZ-C,n.paint.get("raster-opacity")===1?vt.ReadWrite:vt.ReadOnly,A.LESS),K=e.getTile(W);K.registerFadeDuration(n.paint.get("raster-fade-duration"));const te=e.findLoadedParent(W,0),se=e.findLoadedSibling(W),Y=Pc(K,te||se||null,e,n,h.transform,h.style.map.terrain);let pe,be;const _e=n.paint.get("raster-resampling")==="nearest"?A.NEAREST:A.LINEAR;k.activeTexture.set(A.TEXTURE0),K.texture.bind(_e,A.CLAMP_TO_EDGE,A.LINEAR_MIPMAP_NEAREST),k.activeTexture.set(A.TEXTURE1),te?(te.texture.bind(_e,A.CLAMP_TO_EDGE,A.LINEAR_MIPMAP_NEAREST),pe=Math.pow(2,te.tileID.overscaledZ-K.tileID.overscaledZ),be=[K.tileID.canonical.x*pe%1,K.tileID.canonical.y*pe%1]):K.texture.bind(_e,A.CLAMP_TO_EDGE,A.LINEAR_MIPMAP_NEAREST),K.texture.useMipmap&&k.extTextureFilterAnisotropic&&h.transform.pitch>20&&A.texParameterf(A.TEXTURE_2D,k.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,k.extTextureFilterAnisotropicMax);const ye=h.style.map.terrain&&h.style.map.terrain.getTerrainData(W),xe=O.getProjectionData({overscaledTileID:W,aligned:q,applyGlobeMatrix:!P,applyTerrainMatrix:!0}),Le=Zo(be||[0,0],pe||1,Y,n,v),Oe=Z.getMeshFromTileID(k,W.canonical,d,g,"raster");R.draw(k,A.TRIANGLES,J,c?c[W.overscaledZ]:$t.disabled,G,x?pt.frontCCW:pt.backCCW,Le,ye,xe,n.id,Oe.vertexBuffer,Oe.indexBuffer,Oe.segments)}}function Pc(h,e,n,o,c,d){const g=o.paint.get("raster-fade-duration");if(!d&&g>0){const v=Se.now(),x=(v-h.timeAdded)/g,P=e?(v-e.timeAdded)/g:-1,C=n.getSource(),k=it(c,{tileSize:C.tileSize,roundZoom:C.roundZoom}),A=!e||Math.abs(e.tileID.overscaledZ-k)>Math.abs(h.tileID.overscaledZ-k),R=A&&h.refreshedUponExpiration?1:a.ah(A?x:1-P,0,1);return h.refreshedUponExpiration&&x>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-R}:{opacity:R,mix:0}}return{opacity:1,mix:0}}const mh=new a.bf(1,0,0,1),gh=new a.bf(0,1,0,1),tl=new a.bf(0,0,1,1),Mc=new a.bf(1,0,1,1),pp=new a.bf(0,1,1,1);function Cc(h,e,n,o){Pn(h,0,e+n/2,h.transform.width,n,o)}function _i(h,e,n,o){Pn(h,e-n/2,0,n,h.transform.height,o)}function Pn(h,e,n,o,c,d){const g=h.context,v=g.gl;v.enable(v.SCISSOR_TEST),v.scissor(e*h.pixelRatio,n*h.pixelRatio,o*h.pixelRatio,c*h.pixelRatio),g.clear({color:d}),v.disable(v.SCISSOR_TEST)}function Hr(h,e,n){const o=h.context,c=o.gl,d=h.useProgram("debug"),g=vt.disabled,v=$t.disabled,x=h.colorModeForRenderPass(),P="$debug",C=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);o.activeTexture.set(c.TEXTURE0);const k=e.getTileByID(n.key).latestRawTileData,A=Math.floor((k&&k.byteLength||0)/1024),R=e.getTile(n).tileSize,O=512/Math.min(R,512)*(n.overscaledZ/h.transform.zoom)*.5;let Z=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(Z+=` => ${n.overscaledZ}`),function(q,W){q.initDebugOverlayCanvas();const J=q.debugOverlayCanvas,K=q.context.gl,te=q.debugOverlayCanvas.getContext("2d");te.clearRect(0,0,J.width,J.height),te.shadowColor="white",te.shadowBlur=2,te.lineWidth=1.5,te.strokeStyle="white",te.textBaseline="top",te.font="bold 36px Open Sans, sans-serif",te.fillText(W,5,5),te.strokeText(W,5,5),q.debugOverlayTexture.update(J),q.debugOverlayTexture.bind(K.LINEAR,K.CLAMP_TO_EDGE)}(h,`${Z} ${A}kB`);const G=h.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});d.draw(o,c.TRIANGLES,g,v,ci.alphaBlended,pt.disabled,Ms(a.bf.transparent,O),null,G,P,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),d.draw(o,c.LINE_STRIP,g,v,x,pt.disabled,Ms(a.bf.red),C,G,P,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function il(h,e,n,o){const{isRenderingGlobe:c}=o,d=h.context,g=d.gl,v=h.transform,x=h.colorModeForRenderPass(),P=h.getDepthModeFor3D(),C=h.useProgram("terrain");d.bindFramebuffer.set(null),d.viewport.set([0,0,h.width,h.height]);for(const k of n){const A=e.getTerrainMesh(k.tileID),R=h.renderToTexture.getTexture(k),O=e.getTerrainData(k.tileID);d.activeTexture.set(g.TEXTURE0),g.bindTexture(g.TEXTURE_2D,R.texture);const Z=e.getMeshFrameDelta(v.zoom),G=v.calculateFogMatrix(k.tileID.toUnwrapped()),q=Na(Z,G,h.style.sky,v.pitch,c),W=v.getProjectionData({overscaledTileID:k.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});C.draw(d,g.TRIANGLES,P,$t.disabled,x,pt.backCCW,q,O,W,"terrain",A.vertexBuffer,A.indexBuffer,A.segments)}}function ta(h,e){if(!e.mesh){const n=new a.aL;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const o=new a.aN;o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),e.mesh=new xs(h.createVertexBuffer(n,Qn.members),h.createIndexBuffer(o),a.aM.simpleSegment(0,0,n.length,o.length))}return e.mesh}class _h{constructor(e,n){this.context=new hh(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:a.ag(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=At.maxUnderzooming+At.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Qs}resize(e,n,o){if(this.width=Math.floor(e*o),this.height=Math.floor(n*o),this.pixelRatio=o,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style._order)this.style._layers[c].resize()}setup(){const e=this.context,n=new a.aL;n.emplaceBack(0,0),n.emplaceBack(a.$,0),n.emplaceBack(0,a.$),n.emplaceBack(a.$,a.$),this.tileExtentBuffer=e.createVertexBuffer(n,Qn.members),this.tileExtentSegments=a.aM.simpleSegment(0,0,4,2);const o=new a.aL;o.emplaceBack(0,0),o.emplaceBack(a.$,0),o.emplaceBack(0,a.$),o.emplaceBack(a.$,a.$),this.debugBuffer=e.createVertexBuffer(o,Qn.members),this.debugSegments=a.aM.simpleSegment(0,0,4,5);const c=new a.c6;c.emplaceBack(0,0,0,0),c.emplaceBack(a.$,0,a.$,0),c.emplaceBack(0,a.$,0,a.$),c.emplaceBack(a.$,a.$,a.$,a.$),this.rasterBoundsBuffer=e.createVertexBuffer(c,Yd.members),this.rasterBoundsSegments=a.aM.simpleSegment(0,0,4,2);const d=new a.aL;d.emplaceBack(0,0),d.emplaceBack(a.$,0),d.emplaceBack(0,a.$),d.emplaceBack(a.$,a.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(d,Qn.members),this.rasterBoundsSegmentsPosOnly=a.aM.simpleSegment(0,0,4,5);const g=new a.aL;g.emplaceBack(0,0),g.emplaceBack(1,0),g.emplaceBack(0,1),g.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(g,Qn.members),this.viewportSegments=a.aM.simpleSegment(0,0,4,2);const v=new a.c7;v.emplaceBack(0),v.emplaceBack(1),v.emplaceBack(3),v.emplaceBack(2),v.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(v);const x=new a.aN;x.emplaceBack(1,0,2),x.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(x);const P=this.context.gl;this.stencilClearMode=new $t({func:P.ALWAYS,mask:0},0,255,P.ZERO,P.ZERO,P.ZERO),this.tileExtentMesh=new xs(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const o=a.L();a.bY(o,0,this.width,this.height,0,0,1),a.N(o,o,[n.drawingBufferWidth,n.drawingBufferHeight,0]);const c={mainMatrix:o,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:o};this.useProgram("clippingMask",null,!0).draw(e,n.TRIANGLES,vt.disabled,this.stencilClearMode,ci.disabled,pt.disabled,null,null,c,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n,o){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source,this.nextStencilID+n.length>256&&this.clearStencil();const c=this.context;c.setColorMode(ci.disabled),c.setDepthMode(vt.disabled);const d={};for(const g of n)d[g.key]=this.nextStencilID++;this._renderTileMasks(d,n,o,!0),this._renderTileMasks(d,n,o,!1),this._tileClippingMaskIDs=d}_renderTileMasks(e,n,o,c){const d=this.context,g=d.gl,v=this.style.projection,x=this.transform,P=this.useProgram("clippingMask");for(const C of n){const k=e[C.key],A=this.style.map.terrain&&this.style.map.terrain.getTerrainData(C),R=v.getMeshFromTileID(this.context,C.canonical,c,!0,"stencil"),O=x.getProjectionData({overscaledTileID:C,applyGlobeMatrix:!o,applyTerrainMatrix:!0});P.draw(d,g.TRIANGLES,vt.disabled,new $t({func:g.ALWAYS,mask:0},k,255,g.KEEP,g.KEEP,g.REPLACE),ci.disabled,o?pt.disabled:pt.backCCW,null,A,O,"$clipping",R.vertexBuffer,R.indexBuffer,R.segments)}}_renderTilesDepthBuffer(){const e=this.context,n=e.gl,o=this.style.projection,c=this.transform,d=this.useProgram("depth"),g=this.getDepthModeFor3D(),v=fe(c,{tileSize:c.tileSize});for(const x of v){const P=this.style.map.terrain&&this.style.map.terrain.getTerrainData(x),C=o.getMeshFromTileID(this.context,x.canonical,!0,!0,"raster"),k=c.getProjectionData({overscaledTileID:x,applyGlobeMatrix:!0,applyTerrainMatrix:!0});d.draw(e,n.TRIANGLES,g,$t.disabled,ci.disabled,pt.backCCW,null,P,k,"$clipping",C.vertexBuffer,C.indexBuffer,C.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new $t({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new $t({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const n=this.context.gl,o=e.sort((g,v)=>v.overscaledZ-g.overscaledZ),c=o[o.length-1].overscaledZ,d=o[0].overscaledZ-c+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const g={};for(let v=0;v<d;v++)g[v+c]=new $t({func:n.GEQUAL,mask:255},v+this.nextStencilID,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID+=d,[g,o]}return[{[c]:$t.disabled},o]}stencilConfigForOverlapTwoPass(e){const n=this.context.gl,o=e.sort((g,v)=>v.overscaledZ-g.overscaledZ),c=o[o.length-1].overscaledZ,d=o[0].overscaledZ-c+1;if(this.clearStencil(),d>1){const g={},v={};for(let x=0;x<d;x++)g[x+c]=new $t({func:n.GREATER,mask:255},d+1+x,255,n.KEEP,n.KEEP,n.REPLACE),v[x+c]=new $t({func:n.GREATER,mask:255},1+x,255,n.KEEP,n.KEEP,n.REPLACE);return this.nextStencilID=2*d+1,[g,v,o]}return this.nextStencilID=3,[{[c]:new $t({func:n.GREATER,mask:255},2,255,n.KEEP,n.KEEP,n.REPLACE)},{[c]:new $t({func:n.GREATER,mask:255},1,255,n.KEEP,n.KEEP,n.REPLACE)},o]}colorModeForRenderPass(){const e=this.context.gl;return this._showOverdrawInspector?new ci([e.CONSTANT_COLOR,e.ONE],new a.bf(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?ci.unblended:ci.alphaBlended}getDepthModeForSublayer(e,n,o){if(!this.opaquePassEnabledForLayer())return vt.disabled;const c=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new vt(o||this.context.gl.LEQUAL,n,[c,c])}getDepthModeFor3D(){return new vt(this.context.gl.LEQUAL,vt.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var o,c;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(Se.now()),this.imageManager.beginFrame();const d=this.style._order,g=this.style.sourceCaches,v={},x={},P={},C={isRenderingToTexture:!1,isRenderingGlobe:((o=e.projection)===null||o===void 0?void 0:o.transitionState)>0};for(const A in g){const R=g[A];R.used&&R.prepare(this.context),v[A]=R.getVisibleCoordinates(!1),x[A]=v[A].slice().reverse(),P[A]=R.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let A=0;A<d.length;A++)if(this.style._layers[d[A]].is3D()){this.opaquePassCutoff=A;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const A of d){const R=this.style._layers[A];if(!R.hasOffscreenPass()||R.isHidden(this.transform.zoom))continue;const O=x[R.source];(R.type==="custom"||O.length)&&this.renderLayer(this,g[R.source],R,O,C)}if((c=this.style.projection)===null||c===void 0||c.updateGPUdependent({context:this.context,useProgram:A=>this.useProgram(A)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?a.bf.black:a.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(A,R){const O=A.context,Z=O.gl,G=((se,Y,pe)=>{const be=Math.cos(Y.rollInRadians),_e=Math.sin(Y.rollInRadians),ye=ie(Y),xe=Y.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:se.properties.get("sky-color"),u_horizon_color:se.properties.get("horizon-color"),u_horizon:[(Y.width/2-ye*_e)*pe,(Y.height/2+ye*be)*pe],u_horizon_normal:[-_e,be],u_sky_horizon_blend:se.properties.get("sky-horizon-blend")*Y.height/2*pe,u_sky_blend:xe}})(R,A.style.map.transform,A.pixelRatio),q=new vt(Z.LEQUAL,vt.ReadWrite,[0,1]),W=$t.disabled,J=A.colorModeForRenderPass(),K=A.useProgram("sky"),te=ta(O,R);K.draw(O,Z.TRIANGLES,q,W,J,pt.disabled,G,null,void 0,"sky",te.vertexBuffer,te.indexBuffer,te.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){const A=this.style._layers[d[this.currentLayer]],R=g[A.source],O=v[A.source];this._renderTileClippingMasks(A,O,!1),this.renderLayer(this,R,A,O,C)}this.renderPass="translucent";let k=!1;for(this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){const A=this.style._layers[d[this.currentLayer]],R=g[A.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(A,C))continue;this.opaquePassEnabledForLayer()||k||(k=!0,C.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const O=(A.type==="symbol"?P:x)[A.source];this._renderTileClippingMasks(A,v[A.source],!!this.renderToTexture),this.renderLayer(this,R,A,O,C)}if(C.isRenderingGlobe&&function(A,R,O){const Z=A.context,G=Z.gl,q=A.useProgram("atmosphere"),W=new vt(G.LEQUAL,vt.ReadOnly,[0,1]),J=A.transform,K=function(xe,Le){const Oe=xe.properties.get("position"),Ie=[-Oe.x,-Oe.y,-Oe.z],et=a.ag(new Float64Array(16));return xe.properties.get("anchor")==="map"&&(a.b6(et,et,Le.rollInRadians),a.b7(et,et,-Le.pitchInRadians),a.b6(et,et,Le.bearingInRadians),a.b7(et,et,Le.center.lat*Math.PI/180),a.bz(et,et,-Le.center.lng*Math.PI/180)),a.c5(Ie,Ie,et),Ie}(O,A.transform),te=J.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),se=R.properties.get("atmosphere-blend")*te.projectionTransition;if(se===0)return;const Y=to(J.worldSize,J.center.lat),pe=J.inverseProjectionMatrix,be=new Float64Array(4);be[3]=1,a.aw(be,be,J.modelViewProjectionMatrix),be[0]/=be[3],be[1]/=be[3],be[2]/=be[3],be[3]=1,a.aw(be,be,pe),be[0]/=be[3],be[1]/=be[3],be[2]/=be[3],be[3]=1;const _e=((xe,Le,Oe,Ie,et)=>({u_sun_pos:xe,u_atmosphere_blend:Le,u_globe_position:Oe,u_globe_radius:Ie,u_inv_proj_matrix:et}))(K,se,[be[0],be[1],be[2]],Y,pe),ye=ta(Z,R);q.draw(Z,G.TRIANGLES,W,$t.disabled,ci.alphaBlended,pt.disabled,_e,null,null,"atmosphere",ye.vertexBuffer,ye.indexBuffer,ye.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const A=function(R,O){let Z=null;const G=Object.values(R._layers).flatMap(K=>K.source&&!K.isHidden(O)?[R.sourceCaches[K.source]]:[]),q=G.filter(K=>K.getSource().type==="vector"),W=G.filter(K=>K.getSource().type!=="vector"),J=K=>{(!Z||Z.getSource().maxzoom<K.getSource().maxzoom)&&(Z=K)};return q.forEach(K=>J(K)),Z||W.forEach(K=>J(K)),Z}(this.style,this.transform.zoom);A&&function(R,O,Z){for(let G=0;G<Z.length;G++)Hr(R,O,Z[G])}(this,A,A.getVisibleCoordinates())}this.options.showPadding&&function(A){const R=A.transform.padding;Cc(A,A.transform.height-(R.top||0),3,mh),Cc(A,R.bottom||0,3,gh),_i(A,R.left||0,3,tl),_i(A,A.transform.width-(R.right||0),3,Mc);const O=A.transform.centerPoint;(function(Z,G,q,W){Pn(Z,G-1,q-10,2,20,W),Pn(Z,G-10,q-1,20,2,W)})(A,O.x,A.transform.height-O.y,pp)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;const n=this.terrainFacilitator.matrix,o=this.transform.modelViewProjectionMatrix;let c=this.terrainFacilitator.dirty;c||(c=e?!a.c8(n,o):!a.c9(n,o)),c||(c=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime)),c&&(a.ca(n,o),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(d,g){const v=d.context,x=v.gl,P=d.transform,C=ci.unblended,k=new vt(x.LEQUAL,vt.ReadWrite,[0,1]),A=g.sourceCache.getRenderableTiles(),R=d.useProgram("terrainDepth");v.bindFramebuffer.set(g.getFramebuffer("depth").framebuffer),v.viewport.set([0,0,d.width/devicePixelRatio,d.height/devicePixelRatio]),v.clear({color:a.bf.transparent,depth:1});for(const O of A){const Z=g.getTerrainMesh(O.tileID),G=g.getTerrainData(O.tileID),q=P.getProjectionData({overscaledTileID:O.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),W={u_ele_delta:g.getMeshFrameDelta(P.zoom)};R.draw(v,x.TRIANGLES,k,$t.disabled,C,pt.backCCW,W,G,q,"terrain",Z.vertexBuffer,Z.indexBuffer,Z.segments)}v.bindFramebuffer.set(null),v.viewport.set([0,0,d.width,d.height])}(this,this.style.map.terrain),function(d,g){const v=d.context,x=v.gl,P=d.transform,C=ci.unblended,k=new vt(x.LEQUAL,vt.ReadWrite,[0,1]),A=g.getCoordsTexture(),R=g.sourceCache.getRenderableTiles(),O=d.useProgram("terrainCoords");v.bindFramebuffer.set(g.getFramebuffer("coords").framebuffer),v.viewport.set([0,0,d.width/devicePixelRatio,d.height/devicePixelRatio]),v.clear({color:a.bf.transparent,depth:1}),g.coordsIndex=[];for(const Z of R){const G=g.getTerrainMesh(Z.tileID),q=g.getTerrainData(Z.tileID);v.activeTexture.set(x.TEXTURE0),x.bindTexture(x.TEXTURE_2D,A.texture);const W={u_terrain_coords_id:(255-g.coordsIndex.length)/255,u_texture:0,u_ele_delta:g.getMeshFrameDelta(P.zoom)},J=P.getProjectionData({overscaledTileID:Z.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});O.draw(v,x.TRIANGLES,k,$t.disabled,C,pt.backCCW,W,q,J,"terrain",G.vertexBuffer,G.indexBuffer,G.segments),g.coordsIndex.push(Z.tileID.key)}v.bindFramebuffer.set(null),v.viewport.set([0,0,d.width,d.height])}(this,this.style.map.terrain))}renderLayer(e,n,o,c,d){o.isHidden(this.transform.zoom)||(o.type==="background"||o.type==="custom"||(c||[]).length)&&(this.id=o.id,a.cb(o)?function(g,v,x,P,C,k){if(g.renderPass!=="translucent")return;const{isRenderingToTexture:A}=k,R=$t.disabled,O=g.colorModeForRenderPass();(x._unevaluatedLayout.hasValue("text-variable-anchor")||x._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(Z,G,q,W,J,K,te,se,Y){const pe=G.transform,be=G.style.map.terrain,_e=J==="map",ye=K==="map";for(const xe of Z){const Le=W.getTile(xe),Oe=Le.getBucket(q);if(!Oe||!Oe.text||!Oe.text.segments.get().length)continue;const Ie=a.an(Oe.textSizeData,pe.zoom),et=a.aC(Le,1,G.transform.zoom),Tt=Ii(_e,G.transform,et),Wt=q.layout.get("icon-text-fit")!=="none"&&Oe.hasIconData();if(Ie){const ei=Math.pow(2,pe.zoom-Le.tileID.overscaledZ),Yt=be?(pi,yi)=>be.getElevation(xe,pi,yi):null;bc(Oe,_e,ye,Y,pe,Tt,ei,Ie,Wt,a.aD(pe,Le,te,se),xe.toUnwrapped(),Yt)}}}(P,g,x,v,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),C),x.paint.get("icon-opacity").constantOr(1)!==0&&Ko(g,v,x,P,!1,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),x.layout.get("icon-rotation-alignment"),x.layout.get("icon-pitch-alignment"),x.layout.get("icon-keep-upright"),R,O,A),x.paint.get("text-opacity").constantOr(1)!==0&&Ko(g,v,x,P,!0,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),x.layout.get("text-keep-upright"),R,O,A),v.map.showCollisionBoxes&&(dh(g,v,x,P,!0),dh(g,v,x,P,!1))}(e,n,o,c,this.style.placement.variableOffsets,d):a.cc(o)?function(g,v,x,P,C){if(g.renderPass!=="translucent")return;const{isRenderingToTexture:k}=C,A=x.paint.get("circle-opacity"),R=x.paint.get("circle-stroke-width"),O=x.paint.get("circle-stroke-opacity"),Z=!x.layout.get("circle-sort-key").isConstant();if(A.constantOr(1)===0&&(R.constantOr(1)===0||O.constantOr(1)===0))return;const G=g.context,q=G.gl,W=g.transform,J=g.getDepthModeForSublayer(0,vt.ReadOnly),K=$t.disabled,te=g.colorModeForRenderPass(),se=[],Y=W.getCircleRadiusCorrection();for(let pe=0;pe<P.length;pe++){const be=P[pe],_e=v.getTile(be),ye=_e.getBucket(x);if(!ye)continue;const xe=x.paint.get("circle-translate"),Le=x.paint.get("circle-translate-anchor"),Oe=a.aD(W,_e,xe,Le),Ie=ye.programConfigurations.get(x.id),et=g.useProgram("circle",Ie),Tt=ye.layoutVertexBuffer,Wt=ye.indexBuffer,ei=g.style.map.terrain&&g.style.map.terrain.getTerrainData(be),Yt={programConfiguration:Ie,program:et,layoutVertexBuffer:Tt,indexBuffer:Wt,uniformValues:ep(g,_e,x,Oe,Y),terrainData:ei,projectionData:W.getProjectionData({overscaledTileID:be,applyGlobeMatrix:!k,applyTerrainMatrix:!0})};if(Z){const pi=ye.segments.get();for(const yi of pi)se.push({segments:new a.aM([yi]),sortKey:yi.sortKey,state:Yt})}else se.push({segments:ye.segments,sortKey:0,state:Yt})}Z&&se.sort((pe,be)=>pe.sortKey-be.sortKey);for(const pe of se){const{programConfiguration:be,program:_e,layoutVertexBuffer:ye,indexBuffer:xe,uniformValues:Le,terrainData:Oe,projectionData:Ie}=pe.state;_e.draw(G,q.TRIANGLES,J,K,te,pt.backCCW,Le,Oe,Ie,x.id,ye,xe,pe.segments,x.paint,g.transform.zoom,be)}}(e,n,o,c,d):a.cd(o)?function(g,v,x,P,C){if(x.paint.get("heatmap-opacity")===0)return;const k=g.context,{isRenderingToTexture:A,isRenderingGlobe:R}=C;if(g.style.map.terrain){for(const O of P){const Z=v.getTile(O);v.hasRenderableParent(O)||(g.renderPass==="offscreen"?wc(g,Z,x,O,R):g.renderPass==="translucent"&&fh(g,x,O,A,R))}k.viewport.set([0,0,g.width,g.height])}else g.renderPass==="offscreen"?function(O,Z,G,q){const W=O.context,J=W.gl,K=O.transform,te=$t.disabled,se=new ci([J.ONE,J.ONE],a.bf.transparent,[!0,!0,!0,!0]);(function(Y,pe,be){const _e=Y.gl;Y.activeTexture.set(_e.TEXTURE1),Y.viewport.set([0,0,pe.width/4,pe.height/4]);let ye=be.heatmapFbos.get(a.c2);ye?(_e.bindTexture(_e.TEXTURE_2D,ye.colorAttachment.get()),Y.bindFramebuffer.set(ye.framebuffer)):(ye=Jo(Y,pe.width/4,pe.height/4),be.heatmapFbos.set(a.c2,ye))})(W,O,G),W.clear({color:a.bf.transparent});for(let Y=0;Y<q.length;Y++){const pe=q[Y];if(Z.hasRenderableParent(pe))continue;const be=Z.getTile(pe),_e=be.getBucket(G);if(!_e)continue;const ye=_e.programConfigurations.get(G.id),xe=O.useProgram("heatmap",ye),Le=K.getProjectionData({overscaledTileID:pe,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),Oe=K.getCircleRadiusCorrection();xe.draw(W,J.TRIANGLES,vt.disabled,te,se,pt.backCCW,Xu(be,K.zoom,G.paint.get("heatmap-intensity"),Oe),null,Le,G.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,G.paint,K.zoom,ye)}W.viewport.set([0,0,O.width,O.height])}(g,v,x,P):g.renderPass==="translucent"&&function(O,Z){const G=O.context,q=G.gl;G.setColorMode(O.colorModeForRenderPass());const W=Z.heatmapFbos.get(a.c2);W&&(G.activeTexture.set(q.TEXTURE0),q.bindTexture(q.TEXTURE_2D,W.colorAttachment.get()),G.activeTexture.set(q.TEXTURE1),Qo(G,Z).bind(q.LINEAR,q.CLAMP_TO_EDGE),O.useProgram("heatmapTexture").draw(G,q.TRIANGLES,vt.disabled,$t.disabled,O.colorModeForRenderPass(),pt.disabled,lc(O,Z,0,1),null,null,Z.id,O.viewportBuffer,O.quadTriangleIndexBuffer,O.viewportSegments,Z.paint,O.transform.zoom))}(g,x)}(e,n,o,c,d):a.ce(o)?function(g,v,x,P,C){if(g.renderPass!=="translucent")return;const{isRenderingToTexture:k}=C,A=x.paint.get("line-opacity"),R=x.paint.get("line-width");if(A.constantOr(1)===0||R.constantOr(1)===0)return;const O=g.getDepthModeForSublayer(0,vt.ReadOnly),Z=g.colorModeForRenderPass(),G=x.paint.get("line-dasharray"),q=x.paint.get("line-pattern"),W=q.constantOr(1),J=x.paint.get("line-gradient"),K=x.getCrossfadeParameters(),te=W?"linePattern":G?"lineSDF":J?"lineGradient":"line",se=g.context,Y=se.gl,pe=g.transform;let be=!0;for(const _e of P){const ye=v.getTile(_e);if(W&&!ye.patternsLoaded())continue;const xe=ye.getBucket(x);if(!xe)continue;const Le=xe.programConfigurations.get(x.id),Oe=g.context.program.get(),Ie=g.useProgram(te,Le),et=be||Ie.program!==Oe,Tt=g.style.map.terrain&&g.style.map.terrain.getTerrainData(_e),Wt=q.constantOr(null);if(Wt&&ye.imageAtlas){const bt=ye.imageAtlas,ti=bt.patternPositions[Wt.to.toString()],Ri=bt.patternPositions[Wt.from.toString()];ti&&Ri&&Le.setConstantPatternPositions(ti,Ri)}const ei=pe.getProjectionData({overscaledTileID:_e,applyGlobeMatrix:!k,applyTerrainMatrix:!0}),Yt=pe.getPixelScale(),pi=W?Qu(g,ye,x,Yt,K):G?Cs(g,ye,x,Yt,G,K):J?Ju(g,ye,x,Yt,xe.lineClipsArray.length):Ga(g,ye,x,Yt);if(W)se.activeTexture.set(Y.TEXTURE0),ye.imageAtlasTexture.bind(Y.LINEAR,Y.CLAMP_TO_EDGE),Le.updatePaintBuffers(K);else if(G&&(et||g.lineAtlas.dirty))se.activeTexture.set(Y.TEXTURE0),g.lineAtlas.bind(se);else if(J){const bt=xe.gradients[x.id];let ti=bt.texture;if(x.gradientVersion!==bt.version){let Ri=256;if(x.stepInterpolant){const Vi=v.getSource().maxzoom,Wi=_e.canonical.z===Vi?Math.ceil(1<<g.transform.maxZoom-_e.canonical.z):1;Ri=a.ah(a.c3(xe.maxLineLength/a.$*1024*Wi),256,se.maxTextureSize)}bt.gradient=a.c4({expression:x.gradientExpression(),evaluationKey:"lineProgress",resolution:Ri,image:bt.gradient||void 0,clips:xe.lineClipsArray}),bt.texture?bt.texture.update(bt.gradient):bt.texture=new a.T(se,bt.gradient,Y.RGBA),bt.version=x.gradientVersion,ti=bt.texture}se.activeTexture.set(Y.TEXTURE0),ti.bind(x.stepInterpolant?Y.NEAREST:Y.LINEAR,Y.CLAMP_TO_EDGE)}const yi=g.stencilModeForClipping(_e);Ie.draw(se,Y.TRIANGLES,O,yi,Z,pt.disabled,pi,Tt,ei,x.id,xe.layoutVertexBuffer,xe.indexBuffer,xe.segments,x.paint,g.transform.zoom,Le,xe.layoutVertexBuffer2),be=!1}}(e,n,o,c,d):a.cf(o)?function(g,v,x,P,C){const k=x.paint.get("fill-color"),A=x.paint.get("fill-opacity");if(A.constantOr(1)===0)return;const{isRenderingToTexture:R}=C,O=g.colorModeForRenderPass(),Z=x.paint.get("fill-pattern"),G=g.opaquePassEnabledForLayer()&&!Z.constantOr(1)&&k.constantOr(a.bf.transparent).a===1&&A.constantOr(0)===1?"opaque":"translucent";if(g.renderPass===G){const q=g.getDepthModeForSublayer(1,g.renderPass==="opaque"?vt.ReadWrite:vt.ReadOnly);Qa(g,v,x,P,q,O,!1,R)}if(g.renderPass==="translucent"&&x.paint.get("fill-antialias")){const q=g.getDepthModeForSublayer(x.getPaintProperty("fill-outline-color")?2:0,vt.ReadOnly);Qa(g,v,x,P,q,O,!0,R)}}(e,n,o,c,d):a.cg(o)?function(g,v,x,P,C){const k=x.paint.get("fill-extrusion-opacity");if(k===0)return;const{isRenderingToTexture:A}=C;if(g.renderPass==="translucent"){const R=new vt(g.context.gl.LEQUAL,vt.ReadWrite,g.depthRangeFor3D);if(k!==1||x.paint.get("fill-extrusion-pattern").constantOr(1))Tc(g,v,x,P,R,$t.disabled,ci.disabled,A),Tc(g,v,x,P,R,g.stencilModeFor3D(),g.colorModeForRenderPass(),A);else{const O=g.colorModeForRenderPass();Tc(g,v,x,P,R,$t.disabled,O,A)}}}(e,n,o,c,d):a.ch(o)?function(g,v,x,P,C){if(g.renderPass!=="offscreen"&&g.renderPass!=="translucent")return;const{isRenderingToTexture:k}=C,A=g.context,R=g.style.projection.useSubdivision,O=g.getDepthModeForSublayer(0,vt.ReadOnly),Z=g.colorModeForRenderPass();if(g.renderPass==="offscreen")(function(G,q,W,J,K,te,se){const Y=G.context,pe=Y.gl;for(const be of W){const _e=q.getTile(be),ye=_e.dem;if(!ye||!ye.data||!_e.needsHillshadePrepare)continue;const xe=ye.dim,Le=ye.stride,Oe=ye.getPixels();if(Y.activeTexture.set(pe.TEXTURE1),Y.pixelStoreUnpackPremultiplyAlpha.set(!1),_e.demTexture=_e.demTexture||G.getTileTexture(Le),_e.demTexture){const et=_e.demTexture;et.update(Oe,{premultiply:!1}),et.bind(pe.NEAREST,pe.CLAMP_TO_EDGE)}else _e.demTexture=new a.T(Y,Oe,pe.RGBA,{premultiply:!1}),_e.demTexture.bind(pe.NEAREST,pe.CLAMP_TO_EDGE);Y.activeTexture.set(pe.TEXTURE0);let Ie=_e.fbo;if(!Ie){const et=new a.T(Y,{width:xe,height:xe,data:null},pe.RGBA);et.bind(pe.LINEAR,pe.CLAMP_TO_EDGE),Ie=_e.fbo=Y.createFramebuffer(xe,xe,!0,!1),Ie.colorAttachment.set(et.texture)}Y.bindFramebuffer.set(Ie.framebuffer),Y.viewport.set([0,0,xe,xe]),G.useProgram("hillshadePrepare").draw(Y,pe.TRIANGLES,K,te,se,pt.disabled,Ku(_e.tileID,ye),null,null,J.id,G.rasterBoundsBuffer,G.quadTriangleIndexBuffer,G.rasterBoundsSegments),_e.needsHillshadePrepare=!1}})(g,v,P,x,O,$t.disabled,Z),A.viewport.set([0,0,g.width,g.height]);else if(g.renderPass==="translucent")if(R){const[G,q,W]=g.stencilConfigForOverlapTwoPass(P);ks(g,v,x,W,G,O,Z,!1,k),ks(g,v,x,W,q,O,Z,!0,k)}else{const[G,q]=g.getStencilConfigForOverlapAndUpdateStencilID(P);ks(g,v,x,q,G,O,Z,!1,k)}}(e,n,o,c,d):a.ci(o)?function(g,v,x,P,C){if(g.renderPass!=="translucent"||!P.length)return;const{isRenderingToTexture:k}=C,A=g.style.projection.useSubdivision,R=g.getDepthModeForSublayer(0,vt.ReadOnly),O=g.colorModeForRenderPass();if(A){const[Z,G,q]=g.stencilConfigForOverlapTwoPass(P);Sc(g,v,x,q,Z,R,O,!1,k),Sc(g,v,x,q,G,R,O,!0,k)}else{const[Z,G]=g.getStencilConfigForOverlapAndUpdateStencilID(P);Sc(g,v,x,G,Z,R,O,!1,k)}}(e,n,o,c,d):a.cj(o)?function(g,v,x,P,C){if(g.renderPass!=="translucent"||x.paint.get("raster-opacity")===0||!P.length)return;const{isRenderingToTexture:k}=C,A=v.getSource(),R=g.style.projection.useSubdivision;if(A instanceof $e)zs(g,v,x,P,null,!1,!1,A.tileCoords,A.flippedWindingOrder,k);else if(R){const[O,Z,G]=g.stencilConfigForOverlapTwoPass(P);zs(g,v,x,G,O,!1,!0,el,!1,k),zs(g,v,x,G,Z,!0,!0,el,!1,k)}else{const[O,Z]=g.getStencilConfigForOverlapAndUpdateStencilID(P);zs(g,v,x,Z,O,!1,!0,el,!1,k)}}(e,n,o,c,d):a.ck(o)?function(g,v,x,P,C){const k=x.paint.get("background-color"),A=x.paint.get("background-opacity");if(A===0)return;const{isRenderingToTexture:R}=C,O=g.context,Z=O.gl,G=g.style.projection,q=g.transform,W=q.tileSize,J=x.paint.get("background-pattern");if(g.isPatternMissing(J))return;const K=!J&&k.a===1&&A===1&&g.opaquePassEnabledForLayer()?"opaque":"translucent";if(g.renderPass!==K)return;const te=$t.disabled,se=g.getDepthModeForSublayer(0,K==="opaque"?vt.ReadWrite:vt.ReadOnly),Y=g.colorModeForRenderPass(),pe=g.useProgram(J?"backgroundPattern":"background"),be=P||fe(q,{tileSize:W,terrain:g.style.map.terrain});J&&(O.activeTexture.set(Z.TEXTURE0),g.imageManager.bind(g.context));const _e=x.getCrossfadeParameters();for(const ye of be){const xe=q.getProjectionData({overscaledTileID:ye,applyGlobeMatrix:!R,applyTerrainMatrix:!0}),Le=J?ih(A,g,J,{tileID:ye,tileSize:W},_e):th(A,k),Oe=g.style.map.terrain&&g.style.map.terrain.getTerrainData(ye),Ie=G.getMeshFromTileID(O,ye.canonical,!1,!0,"raster");pe.draw(O,Z.TRIANGLES,se,te,Y,pt.backCCW,Le,Oe,xe,x.id,Ie.vertexBuffer,Ie.indexBuffer,Ie.segments)}}(e,0,o,c,d):a.cl(o)&&function(g,v,x,P){const{isRenderingGlobe:C}=P,k=g.context,A=x.implementation,R=g.style.projection,O=g.transform,Z=O.getProjectionDataForCustomLayer(C),G={farZ:O.farZ,nearZ:O.nearZ,fov:O.fov*Math.PI/180,modelViewProjectionMatrix:O.modelViewProjectionMatrix,projectionMatrix:O.projectionMatrix,shaderData:{variantName:R.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;
765
+ uniform mat4 u_projection_matrix;
766
+ ${R.shaderPreludeCode.vertexSource}`,define:R.shaderDefine},defaultProjectionData:Z},q=A.renderingMode?A.renderingMode:"2d";if(g.renderPass==="offscreen"){const W=A.prerender;W&&(g.setCustomLayerDefaults(),k.setColorMode(g.colorModeForRenderPass()),W.call(A,k.gl,G),k.setDirty(),g.setBaseState())}else if(g.renderPass==="translucent"){g.setCustomLayerDefaults(),k.setColorMode(g.colorModeForRenderPass()),k.setStencilMode($t.disabled);const W=q==="3d"?g.getDepthModeFor3D():g.getDepthModeForSublayer(0,vt.ReadOnly);k.setDepthMode(W),A.render(k.gl,G),k.setDirty(),g.setBaseState(),k.bindFramebuffer.set(null)}}(e,0,o,d))}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),o=this.imageManager.getPattern(e.to.toString());return!n||!o}useProgram(e,n,o=!1,c=[]){this.cache=this.cache||{};const d=!!this.style.map.terrain,g=this.style.projection,v=o?rn.projectionMercator:g.shaderPreludeCode,x=o?An:g.shaderDefine,P=e+(n?n.cacheKey:"")+`/${o?bs:g.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(d?"/terrain":"")+(c?`/${c.join("/")}`:"");return this.cache[P]||(this.cache[P]=new ac(this.context,rn[e],n,pc[e],this._showOverdrawInspector,d,v,x,c)),this.cache[P]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}function Rs(h,e){let n,o=!1,c=null,d=null;const g=()=>{c=null,o&&(h.apply(d,n),c=setTimeout(g,e),o=!1)};return(...v)=>(o=!0,d=this,n=v,c||g(),c)}class rl{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let o;return n.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(o=c)}),(o&&o[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(!this._isValidHash(n))return!1;const o=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:o,pitch:+(n[4]||0)}),!0},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const o=n.join("/");let c=o;c.split("&").length>0&&(c=c.split("&")[0]),this._hashName&&(c=`${this._hashName}=${o}`);let d=window.location.hash.replace(c,"");d.startsWith("#&")?d=d.slice(0,1)+d.slice(2):d==="#"&&(d="");let g=window.location.href.replace(/(#.+)?$/,d);g=g.replace("&&","&"),window.history.replaceState(window.history.state,null,g)},this._updateHash=Rs(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const n=this._map.getCenter(),o=Math.round(100*this._map.getZoom())/100,c=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,c),g=Math.round(n.lng*d)/d,v=Math.round(n.lat*d)/d,x=this._map.getBearing(),P=this._map.getPitch();let C="";if(C+=e?`/${g}/${v}/${o}`:`${o}/${v}/${g}`,(x||P)&&(C+="/"+Math.round(10*x)/10),P&&(C+=`/${Math.round(P)}`),this._hashName){const k=this._hashName;let A=!1;const R=window.location.hash.slice(1).split("&").map(O=>{const Z=O.split("=")[0];return Z===k?(A=!0,`${Z}=${C}`):O}).filter(O=>O);return A||R.push(`${k}=${C}`),`#${R.join("&")}`}return`#${C}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new a.S(+e[2],+e[1])}catch{return!1}const n=+e[0],o=+(e[3]||0),c=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&o>=-180&&o<=180&&c>=this._map.getMinPitch()&&c<=this._map.getMaxPitch()}}const Rn={linearity:.3,easing:a.cm(0,0,.3,1)},Ic=a.e({deceleration:2500,maxSpeed:1400},Rn),yh=a.e({deceleration:20,maxSpeed:1400},Rn),vh=a.e({deceleration:1e3,maxSpeed:360},Rn),xh=a.e({deceleration:1e3,maxSpeed:90},Rn),bh=a.e({deceleration:1e3,maxSpeed:360},Rn);class wh{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:Se.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=Se.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,roll:0,pan:new a.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)n.zoom+=d.zoomDelta||0,n.bearing+=d.bearingDelta||0,n.pitch+=d.pitchDelta||0,n.roll+=d.rollDelta||0,d.panDelta&&n.pan._add(d.panDelta),d.around&&(n.around=d.around),d.pinchAround&&(n.pinchAround=d.pinchAround);const o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(n.pan.mag()){const d=so(n.pan.mag(),o,a.e({},Ic,e||{})),g=n.pan.mult(d.amount/n.pan.mag()),v=this._map.cameraHelper.handlePanInertia(g,this._map.transform);c.center=v.easingCenter,c.offset=v.easingOffset,on(c,d)}if(n.zoom){const d=so(n.zoom,o,yh);c.zoom=this._map.transform.zoom+d.amount,on(c,d)}if(n.bearing){const d=so(n.bearing,o,vh);c.bearing=this._map.transform.bearing+a.ah(d.amount,-179,179),on(c,d)}if(n.pitch){const d=so(n.pitch,o,xh);c.pitch=this._map.transform.pitch+d.amount,on(c,d)}if(n.roll){const d=so(n.roll,o,bh);c.roll=this._map.transform.roll+a.ah(d.amount,-179,179),on(c,d)}if(c.zoom||c.bearing){const d=n.pinchAround===void 0?n.around:n.pinchAround;c.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),a.e(c,{noMoveStart:!0})}}function on(h,e){(!h.duration||h.duration<e.duration)&&(h.duration=e.duration,h.easing=e.easing)}function so(h,e,n){const{maxSpeed:o,linearity:c,deceleration:d}=n,g=a.ah(h*c/(e/1e3),-o,o),v=Math.abs(g)/(d*c);return{easing:n.easing,duration:1e3*v,amount:g*(v/2)}}class Cr extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o,c={}){o=o instanceof MouseEvent?o:new MouseEvent(e,o);const d=Q.mousePos(n.getCanvas(),o),g=n.unproject(d);super(e,a.e({point:d,lngLat:g,originalEvent:o},c)),this._defaultPrevented=!1,this.target=n}}class oo extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){const c=e==="touchend"?o.changedTouches:o.touches,d=Q.touchPos(n.getCanvasContainer(),c),g=d.map(x=>n.unproject(x)),v=d.reduce((x,P,C,k)=>x.add(P.div(k.length)),new a.P(0,0));super(e,{points:d,point:v,lngLats:g,lngLat:n.unproject(v),originalEvent:o}),this._defaultPrevented=!1}}class Ec extends a.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,o){super(e,{originalEvent:o}),this._defaultPrevented=!1}}class Th{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Ec(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new Cr(e.type,this._map,e))}mouseup(e){this._map.fire(new Cr(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new Cr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Cr(e.type,this._map,e))}mouseover(e){this._map.fire(new Cr(e.type,this._map,e))}mouseout(e){this._map.fire(new Cr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new oo(e.type,this._map,e))}touchmove(e){this._map.fire(new oo(e.type,this._map,e))}touchend(e){this._map.fire(new oo(e.type,this._map,e))}touchcancel(e){this._map.fire(new oo(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Sh{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Cr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Cr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Cr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ao{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(a.P.convert(e),this._map.terrain)}}class Ac{constructor(e,n){this._map=e,this._tr=new ao(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(Q.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const o=n;if(this._lastPos.equals(o)||!this._box&&o.dist(this._startPos)<this._clickTolerance)return;const c=this._startPos;this._lastPos=o,this._box||(this._box=Q.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",e));const d=Math.min(c.x,o.x),g=Math.max(c.x,o.x),v=Math.min(c.y,o.y),x=Math.max(c.y,o.y);Q.setTransform(this._box,`translate(${d}px,${v}px)`),this._box.style.width=g-d+"px",this._box.style.height=x-v+"px"}mouseupWindow(e,n){if(!this._active||e.button!==0)return;const o=this._startPos,c=n;if(this.reset(),Q.suppressClick(),o.x!==c.x||o.y!==c.y)return this._map.fire(new a.l("boxzoomend",{originalEvent:e})),{cameraAnimation:d=>d.fitScreenCoordinates(o,c,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(Q.remove(this._box),this._box=null),Q.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new a.l(e,{originalEvent:n}))}}function lo(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let o=0;o<h.length;o++)n[h[o].identifier]=e[o];return n}class Ph{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,o){(this.centroid||o.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),o.length===this.numTouches&&(this.centroid=function(c){const d=new a.P(0,0);for(const g of c)d._add(g);return d.div(c.length)}(n),this.touches=lo(o,n)))}touchmove(e,n,o){if(this.aborted||!this.centroid)return;const c=lo(o,n);for(const d in this.touches){const g=c[d];(!g||g.dist(this.touches[d])>30)&&(this.aborted=!0)}}touchend(e,n,o){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),o.length===0){const c=!this.aborted&&this.centroid;if(this.reset(),c)return c}}}class Ir{constructor(e){this.singleTap=new Ph(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,o){this.singleTap.touchstart(e,n,o)}touchmove(e,n,o){this.singleTap.touchmove(e,n,o)}touchend(e,n,o){const c=this.singleTap.touchend(e,n,o);if(c){const d=e.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(c)<30;if(d&&g||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class an{constructor(e){this._tr=new ao(e),this._zoomIn=new Ir({numTouches:1,numTaps:2}),this._zoomOut=new Ir({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,o){this._zoomIn.touchstart(e,n,o),this._zoomOut.touchstart(e,n,o)}touchmove(e,n,o){this._zoomIn.touchmove(e,n,o),this._zoomOut.touchmove(e,n,o)}touchend(e,n,o){const c=this._zoomIn.touchend(e,n,o),d=this._zoomOut.touchend(e,n,o),g=this._tr;return c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:v=>v.easeTo({duration:300,zoom:g.zoom+1,around:g.unproject(c)},{originalEvent:e})}):d?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:v=>v.easeTo({duration:300,zoom:g.zoom-1,around:g.unproject(d)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class co{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.rollDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(n)?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const o=this._lastPoint;if(!o)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const c=Array.isArray(n)?n[0]:n;return!this._moved&&c.dist(o)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=c,this._move(o,c))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&Q.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const ln=0,uo=2,fp={[ln]:1,[uo]:2};class ia{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){const n=Q.mouseButton(e);this._eventButton=n}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(n,o){const c=fp[o];return n.buttons===void 0||(n.buttons&c)!==c}(e,this._eventButton)}isValidEndEvent(e){return Q.mouseButton(e)===this._eventButton}}class mp{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class gp{constructor(e=new ia({checkCorrectEvent:()=>!0}),n=new mp){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=n}_executeRelevantHandler(e,n,o){return e instanceof MouseEvent?n(e):typeof TouchEvent<"u"&&e instanceof TouchEvent?o(e):void 0}startMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.startMove(n),n=>this.oneFingerTouchMoveStateManager.startMove(n))}endMove(e){this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.endMove(n),n=>this.oneFingerTouchMoveStateManager.endMove(n))}isValidStartEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidStartEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidStartEvent(n))}isValidMoveEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidMoveEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(n))}isValidEndEvent(e){return this._executeRelevantHandler(e,n=>this.mouseMoveStateManager.isValidEndEvent(n),n=>this.oneFingerTouchMoveStateManager.isValidEndEvent(n))}}const ra=h=>{h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}};class na{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new a.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,o){return this._calculateTransform(e,n,o)}touchmove(e,n,o){if(this._active){if(!this._shouldBePrevented(o.length))return e.preventDefault(),this._calculateTransform(e,n,o);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,o){this._calculateTransform(e,n,o),this._active&&this._shouldBePrevented(o.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,o){o.length>0&&(this._active=!0);const c=lo(o,n),d=new a.P(0,0),g=new a.P(0,0);let v=0;for(const P in c){const C=c[P],k=this._touches[P];k&&(d._add(C),g._add(C.sub(k)),v++,c[P]=C)}if(this._touches=c,this._shouldBePrevented(v)||!g.mag())return;const x=g.div(v);return this._sum._add(x),this._sum.mag()<this._clickTolerance?void 0:{around:d.div(v),panDelta:x}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class cn{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,n,o){this._firstTwoTouches||o.length<2||(this._firstTwoTouches=[o[0].identifier,o[1].identifier],this._start([n[0],n[1]]))}touchmove(e,n,o){if(!this._firstTwoTouches)return;e.preventDefault();const[c,d]=this._firstTwoTouches,g=Xe(o,n,c),v=Xe(o,n,d);if(!g||!v)return;const x=this._aroundCenter?null:g.add(v).div(2);return this._move([g,v],x,e)}touchend(e,n,o){if(!this._firstTwoTouches)return;const[c,d]=this._firstTwoTouches,g=Xe(o,n,c),v=Xe(o,n,d);g&&v||(this._active&&Q.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Xe(h,e,n){for(let o=0;o<h.length;o++)if(h[o].identifier===n)return e[o]}function kc(h,e){return Math.log(h/e)/Math.LN2}class nl extends cn{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,n){const o=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(kc(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:kc(this._distance,o),pinchAround:n}}}function zc(h,e){return 180*h.angleWith(e)/Math.PI}class ho extends cn{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,n,o){const c=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:zc(this._vector,c),pinchAround:n}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const n=25/(Math.PI*this._minDiameter)*360,o=zc(e,this._startVector);return Math.abs(o)<n}}function Ds(h){return Math.abs(h.y)>Math.abs(h.x)}class sl extends cn{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,o){super.touchstart(e,n,o),this._currentTouchCount=o.length}_start(e){this._lastPoints=e,Ds(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,o){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const c=e[0].sub(this._lastPoints[0]),d=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,d,o.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(c.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,o){if(this._valid!==void 0)return this._valid;const c=e.mag()>=2,d=n.mag()>=2;if(!c&&!d)return;if(!c||!d)return this._firstMove===void 0&&(this._firstMove=o),o-this._firstMove<100&&void 0;const g=e.y>0==n.y>0;return Ds(e)&&Ds(n)&&g}}const Bt={panStep:100,bearingStep:15,pitchStep:10};class ol{constructor(e){this._tr=new ao(e);const n=Bt;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,o=0,c=0,d=0,g=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?o=-1:(e.preventDefault(),d=-1);break;case 39:e.shiftKey?o=1:(e.preventDefault(),d=1);break;case 38:e.shiftKey?c=1:(e.preventDefault(),g=-1);break;case 40:e.shiftKey?c=-1:(e.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(o=0,c=0),{cameraAnimation:v=>{const x=this._tr;v.easeTo({duration:300,easeId:"keyboardHandler",easing:_p,zoom:n?Math.round(x.zoom)+n*(e.shiftKey?2:1):x.zoom,bearing:x.bearing+o*this._bearingStep,pitch:x.pitch+c*this._pitchStep,offset:[-d*this._panStep,-g*this._panStep],center:x.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function _p(h){return h*(2-h)}const al=4.000244140625,yp=1/450;class Mh{constructor(e,n){this._onTimeout=o=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)},this._map=e,this._tr=new ao(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=yp}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const o=Se.now(),c=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,n!==0&&n%al==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(c*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=Q.mousePos(this._map.getCanvas(),e),o=this._tr;this._aroundPoint=this._aroundCenter?o.transform.locationToScreenPoint(a.S.convert(o.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(typeof this._lastExpectedZoom=="number"){const v=e.zoom-this._lastExpectedZoom;typeof this._startZoom=="number"&&(this._startZoom+=v),typeof this._targetZoom=="number"&&(this._targetZoom+=v)}if(this._delta!==0){const v=this._type==="wheel"&&Math.abs(this._delta)>al?this._wheelZoomRate:this._defaultZoomRate;let x=2/(1+Math.exp(-Math.abs(this._delta*v)));this._delta<0&&x!==0&&(x=1/x);const P=typeof this._targetZoom!="number"?e.scale:a.af(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),a.ak(P*x)).zoom,this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom!="number"?e.zoom:this._targetZoom,o=this._startZoom,c=this._easing;let d,g=!1;if(this._type==="wheel"&&o&&c){const v=Se.now()-this._lastWheelEventTime,x=Math.min((v+5)/200,1),P=c(x);d=a.C.number(o,n,P),x<1?this._frameId||(this._frameId=!0):g=!0}else d=n,g=!0;return this._active=!0,g&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=d,{noInertia:!0,needsRenderFrame:!g,zoomDelta:d-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=a.co;if(this._prevEase){const o=this._prevEase,c=(Se.now()-o.start)/o.duration,d=o.easing(c+.01)-o.easing(c),g=.27/Math.sqrt(d*d+1e-4)*.01,v=Math.sqrt(.0729-g*g);n=a.cm(g,v,.25,1)}return this._prevEase={start:Se.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Rc{constructor(e,n){this._clickZoom=e,this._tapZoom=n}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Dc{constructor(e){this._tr=new ao(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:o=>{o.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ch{constructor(){this._tap=new Ir({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,o){if(!this._swipePoint)if(this._tapTime){const c=n[0],d=e.timeStamp-this._tapTime<500,g=this._tapPoint.dist(c)<30;d&&g?o.length>0&&(this._swipePoint=c,this._swipeTouch=o[0].identifier):this.reset()}else this._tap.touchstart(e,n,o)}touchmove(e,n,o){if(this._tapTime){if(this._swipePoint){if(o[0].identifier!==this._swipeTouch)return;const c=n[0],d=c.y-this._swipePoint.y;return this._swipePoint=c,e.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(e,n,o)}touchend(e,n,o){if(this._tapTime)this._swipePoint&&o.length===0&&this.reset();else{const c=this._tap.touchend(e,n,o);c&&(this._tapTime=e.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ih{constructor(e,n,o){this._el=e,this._mousePan=n,this._touchPan=o}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Lc{constructor(e,n,o,c){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=n,this._mousePitch=o,this._mouseRoll=c}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Eh{constructor(e,n,o,c){this._el=e,this._touchZoom=n,this._touchRotate=o,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Ah{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=Q.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const o=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),c=document.createElement("div");c.className="maplibregl-desktop-message",c.textContent=n,this._container.appendChild(c);const d=document.createElement("div");d.className="maplibregl-mobile-message",d.textContent=o,this._container.appendChild(d),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(Q.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new a.l("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const un=h=>h.zoom||h.drag||h.roll||h.pitch||h.rotate;class si extends a.l{}function po(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta||h.rollDelta}class Fc{constructor(e,n){this.handleWindowEvent=c=>{this.handleEvent(c,`${c.type}Window`)},this.handleEvent=(c,d)=>{if(c.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const g=c.type==="renderFrame"?void 0:c,v={needsRenderFrame:!1},x={},P={};for(const{handlerName:A,handler:R,allowed:O}of this._handlers){if(!R.isEnabled())continue;let Z;if(this._blockedByActive(P,O,A))R.reset();else if(R[d||c.type]){if(a.cp(c,d||c.type)){const G=Q.mousePos(this._map.getCanvas(),c);Z=R[d||c.type](c,G)}else if(a.cq(c,d||c.type)){const G=this._getMapTouches(c.touches),q=Q.touchPos(this._map.getCanvas(),G);Z=R[d||c.type](c,q,G)}else a.cr(d||c.type)||(Z=R[d||c.type](c));this.mergeHandlerResult(v,x,Z,A,g),Z&&Z.needsRenderFrame&&this._triggerRenderFrame()}(Z||R.isActive())&&(P[A]=R)}const C={};for(const A in this._previousActiveHandlers)P[A]||(C[A]=g);this._previousActiveHandlers=P,(Object.keys(C).length||po(v))&&(this._changes.push([v,x,C]),this._triggerRenderFrame()),(Object.keys(P).length||po(v))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:k}=v;k&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],k(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new wh(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const o=this._el;this._listeners=[[o,"touchstart",{passive:!0}],[o,"touchmove",{passive:!1}],[o,"touchend",void 0],[o,"touchcancel",void 0],[o,"mousedown",void 0],[o,"mousemove",void 0],[o,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[o,"mouseover",void 0],[o,"mouseout",void 0],[o,"dblclick",void 0],[o,"click",void 0],[o,"keydown",{capture:!1}],[o,"keyup",void 0],[o,"wheel",{passive:!1}],[o,"contextmenu",void 0],[window,"blur",void 0]];for(const[c,d,g]of this._listeners)Q.addEventListener(c,d,c===document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[e,n,o]of this._listeners)Q.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,o)}_addDefaultHandlers(e){const n=this._map,o=n.getCanvasContainer();this._add("mapEvent",new Th(n,e));const c=n.boxZoom=new Ac(n,e);this._add("boxZoom",c),e.interactive&&e.boxZoom&&c.enable();const d=n.cooperativeGestures=new Ah(n,e.cooperativeGestures);this._add("cooperativeGestures",d),e.cooperativeGestures&&d.enable();const g=new an(n),v=new Dc(n);n.doubleClickZoom=new Rc(v,g),this._add("tapZoom",g),this._add("clickZoom",v),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const x=new Ch;this._add("tapDragZoom",x);const P=n.touchPitch=new sl(n);this._add("touchPitch",P),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const C=()=>n.project(n.getCenter()),k=function({enable:K,clickTolerance:te,aroundCenter:se=!0,minPixelCenterThreshold:Y=100,rotateDegreesPerPixelMoved:pe=.8},be){const _e=new ia({checkCorrectEvent:ye=>Q.mouseButton(ye)===0&&ye.ctrlKey||Q.mouseButton(ye)===2&&!ye.ctrlKey});return new co({clickTolerance:te,move:(ye,xe)=>{const Le=be();if(se&&Math.abs(Le.y-ye.y)>Y)return{bearingDelta:a.cn(new a.P(ye.x,xe.y),xe,Le)};let Oe=(xe.x-ye.x)*pe;return se&&xe.y<Le.y&&(Oe=-Oe),{bearingDelta:Oe}},moveStateManager:_e,enable:K,assignEvents:ra})}(e,C),A=function({enable:K,clickTolerance:te,pitchDegreesPerPixelMoved:se=-.5}){const Y=new ia({checkCorrectEvent:pe=>Q.mouseButton(pe)===0&&pe.ctrlKey||Q.mouseButton(pe)===2});return new co({clickTolerance:te,move:(pe,be)=>({pitchDelta:(be.y-pe.y)*se}),moveStateManager:Y,enable:K,assignEvents:ra})}(e),R=function({enable:K,clickTolerance:te,rollDegreesPerPixelMoved:se=.3},Y){const pe=new ia({checkCorrectEvent:be=>Q.mouseButton(be)===2&&be.ctrlKey});return new co({clickTolerance:te,move:(be,_e)=>{const ye=Y();let xe=(_e.x-be.x)*se;return _e.y<ye.y&&(xe=-xe),{rollDelta:xe}},moveStateManager:pe,enable:K,assignEvents:ra})}(e,C);n.dragRotate=new Lc(e,k,A,R),this._add("mouseRotate",k,["mousePitch"]),this._add("mousePitch",A,["mouseRotate","mouseRoll"]),this._add("mouseRoll",R,["mousePitch"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const O=function({enable:K,clickTolerance:te}){const se=new ia({checkCorrectEvent:Y=>Q.mouseButton(Y)===0&&!Y.ctrlKey});return new co({clickTolerance:te,move:(Y,pe)=>({around:pe,panDelta:pe.sub(Y)}),activateOnStart:!0,moveStateManager:se,enable:K,assignEvents:ra})}(e),Z=new na(e,n);n.dragPan=new Ih(o,O,Z),this._add("mousePan",O),this._add("touchPan",Z,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const G=new ho,q=new nl;n.touchZoomRotate=new Eh(o,q,G,x),this._add("touchRotate",G,["touchPan","touchZoom"]),this._add("touchZoom",q,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const W=n.scrollZoom=new Mh(n,()=>this._triggerRenderFrame());this._add("scrollZoom",W,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const J=n.keyboard=new ol(n);this._add("keyboard",J),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Sh(n))}_add(e,n,o){this._handlers.push({handlerName:e,handler:n,allowed:o}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!un(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,o){for(const c in e)if(c!==o&&(!n||n.indexOf(c)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const o of e)this._el.contains(o.target)&&n.push(o);return n}mergeHandlerResult(e,n,o,c,d){if(!o)return;a.e(e,o);const g={handlerName:c,originalEvent:o.originalEvent||d};o.zoomDelta!==void 0&&(n.zoom=g),o.panDelta!==void 0&&(n.drag=g),o.rollDelta!==void 0&&(n.roll=g),o.pitchDelta!==void 0&&(n.pitch=g),o.bearingDelta!==void 0&&(n.rotate=g)}_applyChanges(){const e={},n={},o={};for(const[c,d,g]of this._changes)c.panDelta&&(e.panDelta=(e.panDelta||new a.P(0,0))._add(c.panDelta)),c.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+c.pitchDelta),c.rollDelta&&(e.rollDelta=(e.rollDelta||0)+c.rollDelta),c.around!==void 0&&(e.around=c.around),c.pinchAround!==void 0&&(e.pinchAround=c.pinchAround),c.noInertia&&(e.noInertia=c.noInertia),a.e(n,d),a.e(o,g);this._updateMapTransform(e,n,o),this._changes=[]}_updateMapTransform(e,n,o){const c=this._map,d=c._getTransformForUpdate(),g=c.terrain;if(!(po(e)||g&&this._terrainMovement))return this._fireEvents(n,o,!0);c._stop(!0);let{panDelta:v,zoomDelta:x,bearingDelta:P,pitchDelta:C,rollDelta:k,around:A,pinchAround:R}=e;R!==void 0&&(A=R),A=A||c.transform.centerPoint,g&&!d.isPointOnMapSurface(A)&&(A=d.centerPoint);const O={panDelta:v,zoomDelta:x,rollDelta:k,pitchDelta:C,bearingDelta:P,around:A};this._map.cameraHelper.useGlobeControls&&!d.isPointOnMapSurface(A)&&(A=d.centerPoint);const Z=A.distSqr(d.centerPoint)<.01?d.center:d.screenPointToLocation(v?A.sub(v):A);g?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(O,d),this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?d.setCenter(d.screenPointToLocation(d.centerPoint.sub(v))):this._map.cameraHelper.handleMapControlsPan(O,d,Z):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(O,d,Z))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(O,d),this._map.cameraHelper.handleMapControlsPan(O,d,Z)),c._applyUpdatedTransform(d),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,o,!0)}_fireEvents(e,n,o){const c=un(this._eventsInProgress),d=un(e),g={};for(const k in e){const{originalEvent:A}=e[k];this._eventsInProgress[k]||(g[`${k}start`]=A),this._eventsInProgress[k]=e[k]}!c&&d&&this._fireEvent("movestart",d.originalEvent);for(const k in g)this._fireEvent(k,g[k]);d&&this._fireEvent("move",d.originalEvent);for(const k in e){const{originalEvent:A}=e[k];this._fireEvent(k,A)}const v={};let x;for(const k in this._eventsInProgress){const{handlerName:A,originalEvent:R}=this._eventsInProgress[k];this._handlersById[A].isActive()||(delete this._eventsInProgress[k],x=n[A]||R,v[`${k}end`]=x)}for(const k in v)this._fireEvent(k,v[k]);const P=un(this._eventsInProgress),C=(c||d)&&!P;if(C&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const k=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&k.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(k)}if(o&&C){this._updatingCamera=!0;const k=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),A=R=>R!==0&&-this._bearingSnap<R&&R<this._bearingSnap;!k||!k.essential&&Se.prefersReducedMotion?(this._map.fire(new a.l("moveend",{originalEvent:x})),A(this._map.getBearing())&&this._map.resetNorth()):(A(k.bearing||this._map.getBearing())&&(k.bearing=0),k.freezeElevation=!0,this._map.easeTo(k,{originalEvent:x})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new a.l(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new si("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class kh extends a.E{constructor(e,n,o){super(),this._renderFrameCallback=()=>{const c=Math.min((Se.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(c)),c<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=o.bearingSnap,this.cameraHelper=n,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,n){e.apply(this.transform),this.transform=e,this.cameraHelper=n}getCenter(){return new a.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,n){return this.jumpTo({elevation:e},n),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,o){return e=a.P.convert(e).mult(-1),this.panTo(this.transform.center,a.e({offset:e},n),o)}panTo(e,n,o){return this.easeTo(a.e({center:e},n),o)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,o){return this.easeTo(a.e({zoom:e},n),o)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new a.l("movestart",n)).fire(new a.l("move",n)).fire(new a.l("moveend",n))),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,o){return this.easeTo(a.e({bearing:e},n),o)}resetNorth(e,n){return this.rotateTo(0,a.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(a.e({bearing:0,pitch:0,roll:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,n):this}getPitch(){return this.transform.pitch}setPitch(e,n){return this.jumpTo({pitch:e},n),this}getRoll(){return this.transform.roll}setRoll(e,n){return this.jumpTo({roll:e},n),this}cameraForBounds(e,n){e=le.convert(e).adjustAntiMeridian();const o=n&&n.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),o,n)}_cameraForBoxAndBearing(e,n,o,c){const d={top:0,bottom:0,right:0,left:0};if(typeof(c=a.e({padding:d,offset:[0,0],maxZoom:this.transform.maxZoom},c)).padding=="number"){const P=c.padding;c.padding={top:P,bottom:P,right:P,left:P}}const g=a.e(d,c.padding);c.padding=g;const v=this.transform,x=new le(e,n);return this.cameraHelper.cameraForBoxAndBearing(c,g,x,o,v)}fitBounds(e,n,o){return this._fitInternal(this.cameraForBounds(e,n),n,o)}fitScreenCoordinates(e,n,o,c,d){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(a.P.convert(e)),this.transform.screenPointToLocation(a.P.convert(n)),o,c),c,d)}_fitInternal(e,n,o){return e?(delete(n=a.e(e,n)).padding,n.linear?this.easeTo(n,o):this.flyTo(n,o)):this}jumpTo(e,n){this.stop();const o=this._getTransformForUpdate();let c=!1,d=!1,g=!1;const v=o.zoom;this.cameraHelper.handleJumpToCenterZoom(o,e);const x=o.zoom!==v;return"elevation"in e&&o.elevation!==+e.elevation&&o.setElevation(+e.elevation),"bearing"in e&&o.bearing!==+e.bearing&&(c=!0,o.setBearing(+e.bearing)),"pitch"in e&&o.pitch!==+e.pitch&&(d=!0,o.setPitch(+e.pitch)),"roll"in e&&o.roll!==+e.roll&&(g=!0,o.setRoll(+e.roll)),e.padding==null||o.isPaddingEqual(e.padding)||o.setPadding(e.padding),this._applyUpdatedTransform(o),this.fire(new a.l("movestart",n)).fire(new a.l("move",n)),x&&this.fire(new a.l("zoomstart",n)).fire(new a.l("zoom",n)).fire(new a.l("zoomend",n)),c&&this.fire(new a.l("rotatestart",n)).fire(new a.l("rotate",n)).fire(new a.l("rotateend",n)),d&&this.fire(new a.l("pitchstart",n)).fire(new a.l("pitch",n)).fire(new a.l("pitchend",n)),g&&this.fire(new a.l("rollstart",n)).fire(new a.l("roll",n)).fire(new a.l("rollend",n)),this.fire(new a.l("moveend",n))}calculateCameraOptionsFromTo(e,n,o,c=0){const d=a.a1.fromLngLat(e,n),g=a.a1.fromLngLat(o,c),v=g.x-d.x,x=g.y-d.y,P=g.z-d.z,C=Math.hypot(v,x,P);if(C===0)throw new Error("Can't calculate camera options with same From and To");const k=Math.hypot(v,x),A=a.ak(this.transform.cameraToCenterDistance/C/this.transform.tileSize),R=180*Math.atan2(v,-x)/Math.PI;let O=180*Math.acos(k/C)/Math.PI;return O=P<0?90-O:90+O,{center:g.toLngLat(),elevation:c,zoom:A,pitch:O,bearing:R}}calculateCameraOptionsFromCameraLngLatAltRotation(e,n,o,c,d){const g=this.transform.calculateCenterFromCameraLngLatAlt(e,n,o,c);return{center:g.center,elevation:g.elevation,zoom:g.zoom,bearing:o,pitch:c,roll:d}}easeTo(e,n){this._stop(!1,e.easeId),((e=a.e({offset:[0,0],duration:500,easing:a.co},e)).animate===!1||!e.essential&&Se.prefersReducedMotion)&&(e.duration=0);const o=this._getTransformForUpdate(),c=this.getBearing(),d=o.pitch,g=o.roll,v="bearing"in e?this._normalizeBearing(e.bearing,c):c,x="pitch"in e?+e.pitch:d,P="roll"in e?this._normalizeBearing(e.roll,g):g,C="padding"in e?e.padding:o.padding,k=a.P.convert(e.offset);let A,R;e.around&&(A=a.S.convert(e.around),R=o.locationToScreenPoint(A));const O={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},Z=this.cameraHelper.handleEaseTo(o,{bearing:v,pitch:x,roll:P,padding:C,around:A,aroundPoint:R,offsetAsPoint:k,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||c!==v,this._pitching=this._pitching||x!==d,this._rolling=this._rolling||P!==g,this._padding=!o.isPaddingEqual(C),this._zooming=this._zooming||Z.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,O),this.terrain&&this._prepareElevation(Z.elevationCenter),this._ease(G=>{Z.easeFunc(G),this.terrain&&!e.freezeElevation&&this._updateElevation(G),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},G=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,G)},e),this}_prepareEase(e,n,o={}){this._moving=!0,n||o.moving||this.fire(new a.l("movestart",e)),this._zooming&&!o.zooming&&this.fire(new a.l("zoomstart",e)),this._rotating&&!o.rotating&&this.fire(new a.l("rotatestart",e)),this._pitching&&!o.pitching&&this.fire(new a.l("pitchstart",e)),this._rolling&&!o.rolling&&this.fire(new a.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const o=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(o-(n-(o*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(a.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const n=e.getCameraLngLat(),o=e.getCameraAltitude(),c=this.terrain?this.terrain.getElevationForLngLatZoom(n,e.zoom):0;if(o<c){const d=this.calculateCameraOptionsFromTo(n,c,e.center,e.elevation);return{pitch:d.pitch,zoom:d.zoom}}return{}}_applyUpdatedTransform(e){const n=[];if(n.push(c=>this._elevateCameraIfInsideTerrain(c)),this.transformCameraUpdate&&n.push(c=>this.transformCameraUpdate(c)),!n.length)return;const o=e.clone();for(const c of n){const d=o.clone(),{center:g,zoom:v,roll:x,pitch:P,bearing:C,elevation:k}=c(d);g&&d.setCenter(g),k!==void 0&&d.setElevation(k),v!==void 0&&d.setZoom(v),x!==void 0&&d.setRoll(x),P!==void 0&&d.setPitch(P),C!==void 0&&d.setBearing(C),o.apply(d)}this.transform.apply(o)}_fireMoveEvents(e){this.fire(new a.l("move",e)),this._zooming&&this.fire(new a.l("zoom",e)),this._rotating&&this.fire(new a.l("rotate",e)),this._pitching&&this.fire(new a.l("pitch",e)),this._rolling&&this.fire(new a.l("roll",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const o=this._zooming,c=this._rotating,d=this._pitching,g=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,o&&this.fire(new a.l("zoomend",e)),c&&this.fire(new a.l("rotateend",e)),d&&this.fire(new a.l("pitchend",e)),g&&this.fire(new a.l("rollend",e)),this.fire(new a.l("moveend",e))}flyTo(e,n){if(!e.essential&&Se.prefersReducedMotion){const xe=a.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(xe,n)}this.stop(),e=a.e({offset:[0,0],speed:1.2,curve:1.42,easing:a.co},e);const o=this._getTransformForUpdate(),c=o.bearing,d=o.pitch,g=o.roll,v=o.padding,x="bearing"in e?this._normalizeBearing(e.bearing,c):c,P="pitch"in e?+e.pitch:d,C="roll"in e?this._normalizeBearing(e.roll,g):g,k="padding"in e?e.padding:o.padding,A=a.P.convert(e.offset);let R=o.centerPoint.add(A);const O=o.screenPointToLocation(R),Z=this.cameraHelper.handleFlyTo(o,{bearing:x,pitch:P,roll:C,padding:k,locationAtOffset:O,offsetAsPoint:A,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let G=e.curve;const q=Math.max(o.width,o.height),W=q/Z.scaleOfZoom,J=Z.pixelPathLength;typeof Z.scaleOfMinZoom=="number"&&(G=Math.sqrt(q/Z.scaleOfMinZoom/J*2));const K=G*G;function te(xe){const Le=(W*W-q*q+(xe?-1:1)*K*K*J*J)/(2*(xe?W:q)*K*J);return Math.log(Math.sqrt(Le*Le+1)-Le)}function se(xe){return(Math.exp(xe)-Math.exp(-xe))/2}function Y(xe){return(Math.exp(xe)+Math.exp(-xe))/2}const pe=te(!1);let be=function(xe){return Y(pe)/Y(pe+G*xe)},_e=function(xe){return q*((Y(pe)*(se(Le=pe+G*xe)/Y(Le))-se(pe))/K)/J;var Le},ye=(te(!0)-pe)/G;if(Math.abs(J)<2e-6||!isFinite(ye)){if(Math.abs(q-W)<1e-6)return this.easeTo(e,n);const xe=W<q?-1:1;ye=Math.abs(Math.log(W/q))/G,_e=()=>0,be=Le=>Math.exp(xe*G*Le)}return e.duration="duration"in e?+e.duration:1e3*ye/("screenSpeed"in e?+e.screenSpeed/G:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=c!==x,this._pitching=P!==d,this._rolling=C!==g,this._padding=!o.isPaddingEqual(k),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(Z.targetCenter),this._ease(xe=>{const Le=xe*ye,Oe=1/be(Le),Ie=_e(Le);this._rotating&&o.setBearing(a.C.number(c,x,xe)),this._pitching&&o.setPitch(a.C.number(d,P,xe)),this._rolling&&o.setRoll(a.C.number(g,C,xe)),this._padding&&(o.interpolatePadding(v,k,xe),R=o.centerPoint.add(A)),Z.easeFunc(xe,Oe,Ie,R),this.terrain&&!e.freezeElevation&&this._updateElevation(xe),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var o;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const c=this._onEaseEnd;delete this._onEaseEnd,c.call(this,n)}return e||(o=this.handlers)===null||o===void 0||o.stop(!1),this}_ease(e,n,o){o.animate===!1||o.duration===0?(e(1),n()):(this._easeStart=Se.now(),this._easeOptions=o,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=a.aO(e,-180,180);const o=Math.abs(e-n);return Math.abs(e-360-n)<o&&(e-=360),Math.abs(e+360-n)<o&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(a.S.convert(e),this.transform.tileZoom):null}}const Bc={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Oc{constructor(e=Bc){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=Q.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=Q.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=Q.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){Q.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,n){const o=this._map._getUIString(`AttributionControl.${n}`);e.title=o,e.setAttribute("aria-label",o)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(c=>typeof c!="string"?"":c)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const c=this._map.style.stylesheet;this.styleOwner=c.owner,this.styleId=c.id}const n=this._map.style.sourceCaches;for(const c in n){const d=n[c];if(d.used||d.usedForTerrain){const g=d.getSource();g.attribution&&e.indexOf(g.attribution)<0&&e.push(g.attribution)}}e=e.filter(c=>String(c).trim()),e.sort((c,d)=>c.length-d.length),e=e.filter((c,d)=>{for(let g=d+1;g<e.length;g++)if(e[g].indexOf(c)>=0)return!1;return!0});const o=e.join(" | ");o!==this._attribHTML&&(this._attribHTML=o,e.length?(this._innerContainer.innerHTML=Q.sanitize(o),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class zh{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const o=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&o.classList.add("maplibregl-compact"):o.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=Q.create("div","maplibregl-ctrl");const n=Q.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){Q.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Mn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,o=n?this._queue.concat(n):this._queue;for(const c of o)if(c.id===e)return void(c.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const o of n)if(!o.cancelled&&(o.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var ll=a.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class rt extends a.E{constructor(e){super(),this._lastTilesetChange=Se.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const o={};for(const c of fe(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))o[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.terrainRttPosMatrix32f=new Float64Array(16),a.bY(c.terrainRttPosMatrix32f,0,a.$,a.$,0,0,1),this._tiles[c.key]=new Gt(c,this.tileSize),this._lastTilesetChange=Se.now());for(const c in this._tiles)o[c]||delete this._tiles[c]}freeRtt(e){for(const n in this._tiles){const o=this._tiles[n];(!e||o.tileID.equals(e)||o.tileID.isChildOf(e)||e.isChildOf(o.tileID))&&(o.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,n){return n?this._getTerrainCoordsForTileRanges(e,n):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const n={};for(const o of this._renderableTilesKeys){const c=this._tiles[o].tileID,d=e.clone(),g=a.ba();if(c.canonical.equals(e.canonical))a.bY(g,0,a.$,a.$,0,0,1);else if(c.canonical.isChildOf(e.canonical)){const v=c.canonical.z-e.canonical.z,x=c.canonical.x-(c.canonical.x>>v<<v),P=c.canonical.y-(c.canonical.y>>v<<v),C=a.$>>v;a.bY(g,0,C,C,0,0,1),a.M(g,g,[-x*C,-P*C,0])}else{if(!e.canonical.isChildOf(c.canonical))continue;{const v=e.canonical.z-c.canonical.z,x=e.canonical.x-(e.canonical.x>>v<<v),P=e.canonical.y-(e.canonical.y>>v<<v),C=a.$>>v;a.bY(g,0,a.$,a.$,0,0,1),a.M(g,g,[x*C,P*C,0]),a.N(g,g,[1/2**v,1/2**v,0])}}d.terrainRttPosMatrix32f=new Float32Array(g),n[o]=d}return n}_getTerrainCoordsForTileRanges(e,n){const o={};for(const c of this._renderableTilesKeys){const d=this._tiles[c].tileID;if(!this._isWithinTileRanges(d,n))continue;const g=e.clone(),v=a.ba();if(d.canonical.z===e.canonical.z){const x=e.canonical.x-d.canonical.x,P=e.canonical.y-d.canonical.y;a.bY(v,0,a.$,a.$,0,0,1),a.M(v,v,[x*a.$,P*a.$,0])}else if(d.canonical.z>e.canonical.z){const x=d.canonical.z-e.canonical.z,P=d.canonical.x-(d.canonical.x>>x<<x),C=d.canonical.y-(d.canonical.y>>x<<x),k=e.canonical.x-(d.canonical.x>>x),A=e.canonical.y-(d.canonical.y>>x),R=a.$>>x;a.bY(v,0,R,R,0,0,1),a.M(v,v,[-P*R+k*a.$,-C*R+A*a.$,0])}else{const x=e.canonical.z-d.canonical.z,P=e.canonical.x-(e.canonical.x>>x<<x),C=e.canonical.y-(e.canonical.y>>x<<x),k=(e.canonical.x>>x)-d.canonical.x,A=(e.canonical.y>>x)-d.canonical.y,R=a.$<<x;a.bY(v,0,R,R,0,0,1),a.M(v,v,[P*a.$+k*R,C*a.$+A*R,0])}g.terrainRttPosMatrix32f=new Float32Array(v),o[c]=g}return o}getSourceTile(e,n){const o=this.sourceCache._source;let c=e.overscaledZ-this.deltaZoom;if(c>o.maxzoom&&(c=o.maxzoom),c<o.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(c).key);let d=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!d||!d.dem)&&n)for(;c>=o.minzoom&&(!d||!d.dem);)d=this.sourceCache.getTileByID(e.scaledTo(c--).key);return d}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,n){return n[e.canonical.z]&&e.canonical.x>=n[e.canonical.z].minTileX&&e.canonical.x<=n[e.canonical.z].maxTileX&&e.canonical.y>=n[e.canonical.z].minTileY&&e.canonical.y<=n[e.canonical.z].maxTileY}}class ht{constructor(e,n,o){this._meshCache={},this.painter=e,this.sourceCache=new rt(n),this.options=o,this.exaggeration=typeof o.exaggeration=="number"?o.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,o,c=a.$){var d;if(!(n>=0&&n<c&&o>=0&&o<c))return 0;const g=this.getTerrainData(e),v=(d=g.tile)===null||d===void 0?void 0:d.dem;if(!v)return 0;const x=a.cs([],[n/c*a.$,o/c*a.$],g.u_terrain_matrix),P=[x[0]*v.dim,x[1]*v.dim],C=Math.floor(P[0]),k=Math.floor(P[1]),A=P[0]-C,R=P[1]-k;return v.get(C,k)*(1-A)*(1-R)+v.get(C+1,k)*A*(1-R)+v.get(C,k+1)*(1-A)*R+v.get(C+1,k+1)*A*R}getElevationForLngLatZoom(e,n){if(!a.ct(n,e.wrap()))return 0;const{tileID:o,mercatorX:c,mercatorY:d}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(o,c%a.$,d%a.$,a.$)}getElevation(e,n,o,c=a.$){return this.getDEMElevation(e,n,o,c)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){const c=this.painter.context,d=new a.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new a.T(c,d,c.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new a.T(c,new a.R({width:1,height:1}),c.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=a.ag([])}const n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){const c=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new a.T(c,n.dem.getPixels(),c.gl.RGBA,{premultiply:!1}),n.demTexture.bind(c.gl.NEAREST,c.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}const o=n&&n+n.tileID.key+e.key;if(o&&!this._demMatrixCache[o]){const c=this.sourceCache.sourceCache._source.maxzoom;let d=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=c?d=e.canonical.z-c:a.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const g=e.canonical.x-(e.canonical.x>>d<<d),v=e.canonical.y-(e.canonical.y>>d<<d),x=a.cu(new Float64Array(16),[1/(a.$<<d),1/(a.$<<d),0]);a.M(x,x,[g*a.$,v*a.$,0]),this._demMatrixCache[e.key]={matrix:x,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:o?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){const n=this.painter,o=n.width/devicePixelRatio,c=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===o&&this._fbo.height===c||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new a.T(n.context,{width:o,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new a.T(n.context,{width:o,height:c,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(o,c,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,o,c))),this._fbo.colorAttachment.set(e==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let d=0,g=0;d<this._coordsTextureSize;d++)for(let v=0;v<this._coordsTextureSize;v++,g+=4)n[g+0]=255&v,n[g+1]=255&d,n[g+2]=v>>8<<4|d>>8,n[g+3]=0;const o=new a.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),c=new a.T(e,o,e.gl.RGBA,{premultiply:!1});return c.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),o=this.painter.context,c=o.gl,d=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),g=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),v=Math.round(this.painter.height/devicePixelRatio);o.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(d,v-g-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null);const x=n[0]+(n[2]>>4<<8),P=n[1]+((15&n[2])<<8),C=this.coordsIndex[255-n[3]],k=C&&this.sourceCache.getTileByID(C);if(!k)return null;const A=this._coordsTextureSize,R=(1<<k.tileID.canonical.z)*A;return new a.a1((k.tileID.canonical.x*A+x)/R+k.tileID.wrap,(k.tileID.canonical.y*A+P)/R,this.getElevation(k.tileID,x,P,A))}depthAtPoint(e){const n=new Uint8Array(4),o=this.painter.context,c=o.gl;return o.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),c.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),o.bindFramebuffer.set(null),(n[0]/16777216+n[1]/65536+n[2]/256+n[3])/256}getTerrainMesh(e){var n;const o=((n=this.painter.style.projection)===null||n===void 0?void 0:n.transitionState)>0,c=o&&e.canonical.y===0,d=o&&e.canonical.y===(1<<e.canonical.z)-1,g=`m_${c?"n":""}_${d?"s":""}`;if(this._meshCache[g])return this._meshCache[g];const v=this.painter.context,x=new a.cv,P=new a.aN,C=this.meshSize,k=a.$/C,A=C*C;for(let Y=0;Y<=C;Y++)for(let pe=0;pe<=C;pe++)x.emplaceBack(pe*k,Y*k,0);for(let Y=0;Y<A;Y+=C+1)for(let pe=0;pe<C;pe++)P.emplaceBack(pe+Y,C+pe+Y+1,C+pe+Y+2),P.emplaceBack(pe+Y,C+pe+Y+2,pe+Y+1);const R=x.length,O=R+(C+1),Z=(C+1)*C,G=c?a.bh:0,q=c?0:1,W=d?a.bi:a.$,J=d?0:1;for(let Y=0;Y<=C;Y++)x.emplaceBack(Y*k,G,q);for(let Y=0;Y<=C;Y++)x.emplaceBack(Y*k,W,J);for(let Y=0;Y<C;Y++)P.emplaceBack(Z+Y,O+Y,O+Y+1),P.emplaceBack(Z+Y,O+Y+1,Z+Y+1),P.emplaceBack(0+Y,R+Y+1,R+Y),P.emplaceBack(0+Y,0+Y+1,R+Y+1);const K=x.length,te=K+2*(C+1);for(const Y of[0,1])for(let pe=0;pe<=C;pe++)for(const be of[0,1])x.emplaceBack(Y*a.$,pe*k,be);for(let Y=0;Y<2*C;Y+=2)P.emplaceBack(K+Y,K+Y+1,K+Y+3),P.emplaceBack(K+Y,K+Y+3,K+Y+2),P.emplaceBack(te+Y,te+Y+3,te+Y+1),P.emplaceBack(te+Y,te+Y+2,te+Y+3);const se=new xs(v.createVertexBuffer(x,ll.members),v.createIndexBuffer(P),a.aM.simpleSegment(0,0,x.length,P.length));return this._meshCache[g]=se,se}getMeshFrameDelta(e){return 2*Math.PI*a.bu/Math.pow(2,Math.max(e,0))/5}getMinTileElevationForLngLatZoom(e,n){var o;const{tileID:c}=this._getOverscaledTileIDFromLngLatZoom(e,n);return(o=this.getMinMaxElevation(c).minElevation)!==null&&o!==void 0?o:0}getMinMaxElevation(e){const n=this.getTerrainData(e).tile,o={minElevation:null,maxElevation:null};return n&&n.dem&&(o.minElevation=n.dem.min*this.exaggeration,o.maxElevation=n.dem.max*this.exaggeration),o}_getOverscaledTileIDFromLngLatZoom(e,n){const o=a.a1.fromLngLat(e.wrap()),c=(1<<n)*a.$,d=o.x*c,g=o.y*c,v=Math.floor(d/a.$),x=Math.floor(g/a.$);return{tileID:new a.Z(n,0,n,v,x),mercatorX:d,mercatorY:g}}}class cl{constructor(e,n,o){this._context=e,this._size=n,this._tileSize=o,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),o=new a.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return o.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(o.texture),{id:e,fbo:n,texture:o,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(e=>!e.inUse)===!1}}const is={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class ul{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new cl(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(o=>!e._layers[o].isHidden(n)),this._coordsAscending={};for(const o in e.sourceCaches){this._coordsAscending[o]={};const c=e.sourceCaches[o].getVisibleCoordinates(),d=e.sourceCaches[o].getSource(),g=d instanceof $e?d.terrainTileRanges:null;for(const v of c){const x=this.terrain.sourceCache.getTerrainCoords(v,g);for(const P in x)this._coordsAscending[o][P]||(this._coordsAscending[o][P]=[]),this._coordsAscending[o][P].push(x[P])}}this._coordsAscendingStr={};for(const o of e._order){const c=e._layers[o],d=c.source;if(is[c.type]&&!this._coordsAscendingStr[d]){this._coordsAscendingStr[d]={};for(const g in this._coordsAscending[d])this._coordsAscendingStr[d][g]=this._coordsAscending[d][g].map(v=>v.key).sort().join()}}for(const o of this._renderableTiles)for(const c in this._coordsAscendingStr){const d=this._coordsAscendingStr[c][o.tileID.key];d&&d!==o.rttCoords[c]&&(o.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;const o=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),c=e.type,d=this.painter,g=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(is[c]&&(this._prevType&&is[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(e.id),!g))return!0;if(is[this._prevType]||is[c]&&g){this._prevType=c;const v=this._stacks.length-1,x=this._stacks[v]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(il(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[v]){const k=this.pool.getObjectForId(P.rtt[v].id);if(k.stamp===P.rtt[v].stamp){this.pool.useObject(k);continue}}const C=this.pool.getOrCreateFreeObject();this.pool.useObject(C),this.pool.stampObject(C),P.rtt[v]={id:C.id,stamp:C.stamp},d.context.bindFramebuffer.set(C.fbo.framebuffer),d.context.clear({color:a.bf.transparent,stencil:0}),d.currentStencilSource=void 0;for(let k=0;k<x.length;k++){const A=d.style._layers[x[k]],R=A.source?this._coordsAscending[A.source][P.tileID.key]:[P.tileID];d.context.viewport.set([0,0,C.fbo.width,C.fbo.height]),d._renderTileClippingMasks(A,R,!0),d.renderLayer(d,d.style.sourceCaches[A.source],A,R,o),A.source&&(P.rttCoords[A.source]=this._coordsAscendingStr[A.source][P.tileID.key])}}return il(this.painter,this.terrain,this._rttTiles,o),this._rttTiles=[],this.pool.freeAllObjects(),is[c]}return!1}}const yr={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Rh=V,Wr={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Bc,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:a.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},vp={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class sa{constructor(e,n,o=!1){this.mousedown=d=>{this.startMove(d,Q.mousePos(this.element,d)),Q.addEventListener(window,"mousemove",this.mousemove),Q.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=d=>{this.move(d,Q.mousePos(this.element,d))},this.mouseup=d=>{this._rotatePitchHandler.dragEnd(d),this.offTemp()},this.touchstart=d=>{d.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=Q.touchPos(this.element,d.targetTouches)[0],this.startMove(d,this._startPos),Q.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),Q.addEventListener(window,"touchend",this.touchend))},this.touchmove=d=>{d.targetTouches.length!==1?this.reset():(this._lastPos=Q.touchPos(this.element,d.targetTouches)[0],this.move(d,this._lastPos))},this.touchend=d=>{d.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n;const c=new gp;this._rotatePitchHandler=new co({clickTolerance:3,move:(d,g)=>{const v=n.getBoundingClientRect(),x=new a.P((v.bottom-v.top)/2,(v.right-v.left)/2);return{bearingDelta:a.cn(new a.P(d.x,g.y),g,x),pitchDelta:o?-.5*(g.y-d.y):void 0}},moveStateManager:c,enable:!0,assignEvents:()=>{}}),this.map=e,Q.addEventListener(n,"mousedown",this.mousedown),Q.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),Q.addEventListener(n,"touchcancel",this.reset)}startMove(e,n){this._rotatePitchHandler.dragStart(e,n),Q.disableDrag()}move(e,n){const o=this.map,{bearingDelta:c,pitchDelta:d}=this._rotatePitchHandler.dragMove(e,n)||{};c&&o.setBearing(o.getBearing()+c),d&&o.setPitch(o.getPitch()+d)}off(){const e=this.element;Q.removeEventListener(e,"mousedown",this.mousedown),Q.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),Q.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),Q.removeEventListener(window,"touchend",this.touchend),Q.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){Q.enableDrag(),Q.removeEventListener(window,"mousemove",this.mousemove),Q.removeEventListener(window,"mouseup",this.mouseup),Q.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),Q.removeEventListener(window,"touchend",this.touchend)}}let Qt;function Si(h,e,n,o=!1){if(o||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return h==null?void 0:h.wrap();const c=new a.S(h.lng,h.lat);if(h=new a.S(h.lng,h.lat),e){const d=new a.S(h.lng-360,h.lat),g=new a.S(h.lng+360,h.lat),v=n.locationToScreenPoint(h).distSqr(e);n.locationToScreenPoint(d).distSqr(e)<v?h=d:n.locationToScreenPoint(g).distSqr(e)<v&&(h=g)}for(;Math.abs(h.lng-n.center.lng)>180;){const d=n.locationToScreenPoint(h);if(d.x>=0&&d.y>=0&&d.x<=n.width&&d.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==c.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(h))?h:c}const hl={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function fo(h,e,n){const o=h.classList;for(const c in hl)o.remove(`maplibregl-${n}-anchor-${c}`);o.add(`maplibregl-${n}-anchor-${e}`)}class mo extends a.E{constructor(e){if(super(),this._onKeyPress=n=>{const o=n.code,c=n.charCode||n.keyCode;o!=="Space"&&o!=="Enter"&&c!==32&&c!==13||this.togglePopup()},this._onMapClick=n=>{const o=n.originalEvent.target,c=this._element;this._popup&&(o===c||c.contains(o))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=Si(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let d="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?d="rotateX(0deg)":this._pitchAlignment==="map"&&(d=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),Q.setTransform(this._element,`${hl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${d} ${c}`),Se.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const o=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=o}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new a.l("dragstart"))),this.fire(new a.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new a.l("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=a.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=Q.create("div");const n=Q.createNS("http://www.w3.org/2000/svg","svg"),o=41,c=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${o}px`),n.setAttributeNS(null,"width",`${c}px`),n.setAttributeNS(null,"viewBox",`0 0 ${c} ${o}`);const d=Q.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"stroke","none"),d.setAttributeNS(null,"stroke-width","1"),d.setAttributeNS(null,"fill","none"),d.setAttributeNS(null,"fill-rule","evenodd");const g=Q.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const v=Q.createNS("http://www.w3.org/2000/svg","g");v.setAttributeNS(null,"transform","translate(3.0, 29.0)"),v.setAttributeNS(null,"fill","#000000");const x=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const q of x){const W=Q.createNS("http://www.w3.org/2000/svg","ellipse");W.setAttributeNS(null,"opacity","0.04"),W.setAttributeNS(null,"cx","10.5"),W.setAttributeNS(null,"cy","5.80029008"),W.setAttributeNS(null,"rx",q.rx),W.setAttributeNS(null,"ry",q.ry),v.appendChild(W)}const P=Q.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"fill",this._color);const C=Q.createNS("http://www.w3.org/2000/svg","path");C.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),P.appendChild(C);const k=Q.createNS("http://www.w3.org/2000/svg","g");k.setAttributeNS(null,"opacity","0.25"),k.setAttributeNS(null,"fill","#000000");const A=Q.createNS("http://www.w3.org/2000/svg","path");A.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),k.appendChild(A);const R=Q.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"transform","translate(6.0, 7.0)"),R.setAttributeNS(null,"fill","#FFFFFF");const O=Q.createNS("http://www.w3.org/2000/svg","g");O.setAttributeNS(null,"transform","translate(8.0, 8.0)");const Z=Q.createNS("http://www.w3.org/2000/svg","circle");Z.setAttributeNS(null,"fill","#000000"),Z.setAttributeNS(null,"opacity","0.25"),Z.setAttributeNS(null,"cx","5.5"),Z.setAttributeNS(null,"cy","5.5"),Z.setAttributeNS(null,"r","5.4999962");const G=Q.createNS("http://www.w3.org/2000/svg","circle");G.setAttributeNS(null,"fill","#FFFFFF"),G.setAttributeNS(null,"cx","5.5"),G.setAttributeNS(null,"cy","5.5"),G.setAttributeNS(null,"r","5.4999962"),O.appendChild(Z),O.appendChild(G),g.appendChild(v),g.appendChild(P),g.appendChild(k),g.appendChild(R),g.appendChild(O),n.appendChild(g),n.setAttributeNS(null,"height",o*this._scale+"px"),n.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(n),this._offset=a.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),fo(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),Q.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=a.S.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const c=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[c,-1*(38.1-13.5+c)],"bottom-right":[-c,-1*(38.1-13.5+c)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,o;const c=(n=this._map)===null||n===void 0?void 0:n.terrain,d=this._map.transform.isLocationOccluded(this._lngLat);if(!c||d){const R=d?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==R&&(this._element.style.opacity=R))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const g=this._map,v=g.terrain.depthAtPoint(this._pos),x=g.terrain.getElevationForLngLatZoom(this._lngLat,g.transform.tileZoom);if(g.transform.lngLatToCameraDepth(this._lngLat,x)-v<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/g.transform.pixelsPerMeter,C=Math.sin(g.getPitch()*Math.PI/180)*P,k=g.terrain.depthAtPoint(new a.P(this._pos.x,this._pos.y-this._offset.y)),A=g.transform.lngLatToCameraDepth(this._lngLat,x+C)-k>.006;!((o=this._popup)===null||o===void 0)&&o.isOpen()&&A&&this._popup.remove(),this._element.style.opacity=A?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=a.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return(this._opacity===void 0||e===void 0&&n===void 0)&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const jc={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let go=0,Ls=!1;const oa={maxWidth:100,unit:"metric"};function dl(h,e,n){const o=n&&n.maxWidth||100,c=h._container.clientHeight/2,d=h._container.clientWidth/2,g=h.unproject([d-o/2,c]),v=h.unproject([d+o/2,c]),x=Math.round(h.project(v).x-h.project(g).x),P=Math.min(o,x,h._container.clientWidth),C=g.distanceTo(v);if(n&&n.unit==="imperial"){const k=3.2808*C;k>5280?Fs(e,P,k/5280,h._getUIString("ScaleControl.Miles")):Fs(e,P,k,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Fs(e,P,C/1852,h._getUIString("ScaleControl.NauticalMiles")):C>=1e3?Fs(e,P,C/1e3,h._getUIString("ScaleControl.Kilometers")):Fs(e,P,C,h._getUIString("ScaleControl.Meters"))}function Fs(h,e,n,o){const c=function(d){const g=Math.pow(10,`${Math.floor(d)}`.length-1);let v=d/g;return v=v>=10?10:v>=5?5:v>=3?3:v>=2?2:v>=1?1:function(x){const P=Math.pow(10,Math.ceil(-Math.log(x)/Math.LN10));return Math.round(x*P)/P}(v),g*v}(n);h.style.width=e*(c/n)+"px",h.innerHTML=`${c}&nbsp;${o}`}const Nc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},Vc=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function pl(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new a.P(0,0),top:new a.P(0,h),"top-left":new a.P(e,e),"top-right":new a.P(-e,e),bottom:new a.P(0,-h),"bottom-left":new a.P(e,-e),"bottom-right":new a.P(-e,-e),left:new a.P(h,0),right:new a.P(-h,0)}}if(h instanceof a.P||Array.isArray(h)){const e=a.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:a.P.convert(h.center||[0,0]),top:a.P.convert(h.top||[0,0]),"top-left":a.P.convert(h["top-left"]||[0,0]),"top-right":a.P.convert(h["top-right"]||[0,0]),bottom:a.P.convert(h.bottom||[0,0]),"bottom-left":a.P.convert(h["bottom-left"]||[0,0]),"bottom-right":a.P.convert(h["bottom-right"]||[0,0]),left:a.P.convert(h.left||[0,0]),right:a.P.convert(h.right||[0,0])}}return pl(new a.P(0,0))}const Uc=V;T.AJAXError=a.cz,T.Event=a.l,T.Evented=a.E,T.LngLat=a.S,T.MercatorCoordinate=a.a1,T.Point=a.P,T.addProtocol=a.cA,T.config=a.a,T.removeProtocol=a.cB,T.AttributionControl=Oc,T.BoxZoomHandler=Ac,T.CanvasSource=De,T.CooperativeGesturesHandler=Ah,T.DoubleClickZoomHandler=Rc,T.DragPanHandler=Ih,T.DragRotateHandler=Lc,T.EdgeInsets=ws,T.FullscreenControl=class extends a.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:a.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){Q.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=Q.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);Q.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new a.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new a.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},T.GeoJSONSource=qe,T.GeolocateControl=class extends a.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new a.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new a.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new a.S(e.coords.longitude,e.coords.latitude),o=e.coords.accuracy,c=this._map.getBearing(),d=a.e({bearing:c},this.options.fitBoundsOptions),g=le.fromLngLat(n,o);this._map.fitBounds(g,d,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new a.S(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ls)return;this.options.trackUserLocation&&this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new a.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=Q.create("button","maplibregl-ctrl-geolocate",this._container),Q.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){a.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Q.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new mo({element:this._dotElement}),this._circleElement=Q.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new mo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{const o=(n==null?void 0:n[0])instanceof ResizeObserverEntry;n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new a.l("trackuserlocationend")),this.fire(new a.l("userlocationlostfocus")))})}},this.options=a.e({},jc,h)}onAdd(h){return this._map=h,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return a._(this,arguments,void 0,function*(e=!1){if(Qt!==void 0&&!e)return Qt;if(window.navigator.permissions===void 0)return Qt=!!window.navigator.geolocation,Qt;try{Qt=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Qt=!!window.navigator.geolocation}return Qt})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),Q.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,go=0,Ls=!1}_isOutOfMapMaxBounds(h){const e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitude<e.getWest()||n.longitude>e.getEast()||n.latitude<e.getSouth()||n.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const h=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&h))return;const e=this._map.project(h),n=this._map.unproject([e.x+100,e.y]),o=h.distanceTo(n)/100,c=2*this._accuracy/o;this._circleElement.style.width=`${c.toFixed(2)}px`,this._circleElement.style.height=`${c.toFixed(2)}px`}trigger(){if(!this._setup)return a.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new a.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":go--,Ls=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new a.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.l("trackuserlocationstart")),this.fire(new a.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),go++,go>1?(h={maximumAge:6e5,timeout:0},Ls=!0):(h=this.options.positionOptions,Ls=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},T.GlobeControl=class{constructor(){this._toggleProjection=()=>{var h;const e=(h=this._map.getProjection())===null||h===void 0?void 0:h.type;this._map.setProjection(e!=="mercator"&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var h;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),((h=this._map.getProjection())===null||h===void 0?void 0:h.type)==="globe"?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(h){return this._map=h,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=Q.create("button","maplibregl-ctrl-globe",this._container),Q.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){Q.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},T.Hash=rl,T.ImageSource=$e,T.KeyboardHandler=ol,T.LngLatBounds=le,T.LogoControl=zh,T.Map=class extends kh{constructor(h){var e,n;a.cw.mark(a.cx.create);const o=Object.assign(Object.assign(Object.assign({},Wr),h),{canvasContextAttributes:Object.assign(Object.assign({},Wr.canvasContextAttributes),h.canvasContextAttributes)});if(o.minZoom!=null&&o.maxZoom!=null&&o.minZoom>o.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(o.minPitch!=null&&o.maxPitch!=null&&o.minPitch>o.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(o.minPitch!=null&&o.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(o.maxPitch!=null&&o.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const c=new ni,d=new ur;if(o.minZoom!==void 0&&c.setMinZoom(o.minZoom),o.maxZoom!==void 0&&c.setMaxZoom(o.maxZoom),o.minPitch!==void 0&&c.setMinPitch(o.minPitch),o.maxPitch!==void 0&&c.setMaxPitch(o.maxPitch),o.renderWorldCopies!==void 0&&c.setRenderWorldCopies(o.renderWorldCopies),super(c,d,{bearingSnap:o.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Mn,this._controls=[],this._mapId=a.a7(),this._contextLost=v=>{v.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new a.l("webglcontextlost",{originalEvent:v}))},this._contextRestored=v=>{this._setupPainter(),this.resize(),this._update(),this.fire(new a.l("webglcontextrestored",{originalEvent:v}))},this._onMapScroll=v=>{if(v.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=o.interactive,this._maxTileCacheSize=o.maxTileCacheSize,this._maxTileCacheZoomLevels=o.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},o.canvasContextAttributes),this._trackResize=o.trackResize===!0,this._bearingSnap=o.bearingSnap,this._centerClampedToGround=o.centerClampedToGround,this._refreshExpiredTiles=o.refreshExpiredTiles===!0,this._fadeDuration=o.fadeDuration,this._crossSourceCollisions=o.crossSourceCollisions===!0,this._collectResourceTiming=o.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},yr),o.locale),this._clickTolerance=o.clickTolerance,this._overridePixelRatio=o.pixelRatio,this._maxCanvasSize=o.maxCanvasSize,this.transformCameraUpdate=o.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=o.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=We.addThrottleControl(()=>this.isMoving()),this._requestManager=new yt(o.transformRequest),typeof o.container=="string"){if(this._container=document.getElementById(o.container),!this._container)throw new Error(`Container '${o.container}' not found.`)}else{if(!(o.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=o.container}if(o.maxBounds&&this.setMaxBounds(o.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let v=!1;const x=Rs(P=>{this._trackResize&&!this._removed&&(this.resize(P),this.redraw())},50);this._resizeObserver=new ResizeObserver(P=>{v?x(P):v=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Fc(this,o),this._hash=o.hash&&new rl(typeof o.hash=="string"&&o.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:o.center,elevation:o.elevation,zoom:o.zoom,bearing:o.bearing,pitch:o.pitch,roll:o.roll}),o.bounds&&(this.resize(),this.fitBounds(o.bounds,a.e({},o.fitBoundsOptions,{duration:0}))));const g=typeof o.style=="string"||((n=(e=o.style)===null||e===void 0?void 0:e.projection)===null||n===void 0?void 0:n.type)!=="globe";this.resize(null,g),this._localIdeographFontFamily=o.localIdeographFontFamily,this._validateStyle=o.validateStyle,o.style&&this.setStyle(o.style,{localIdeographFontFamily:o.localIdeographFontFamily}),o.attributionControl&&this.addControl(new Oc(typeof o.attributionControl=="boolean"?void 0:o.attributionControl)),o.maplibreLogo&&this.addControl(new zh,o.logoPosition),this.on("style.load",()=>{if(g||this._resizeTransform(),this.transform.unmodified){const v=a.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(v)}}),this.on("data",v=>{this._update(v.dataType==="style"),this.fire(new a.l(`${v.dataType}data`,v))}),this.on("dataloading",v=>{this.fire(new a.l(`${v.dataType}dataloading`,v))}),this.on("dataabort",v=>{this.fire(new a.l("sourcedataabort",v))})}_getMapId(){return this._mapId}setGlobalStateProperty(h,e){return this.style.setGlobalStateProperty(h,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new a.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const o=this._controlPositions[e];return e.indexOf("bottom")!==-1?o.insertBefore(n,o.firstChild):o.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new a.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}coveringTiles(h){return fe(this.transform,h)}calculateCameraOptionsFromTo(h,e,n,o){return o==null&&this.terrain&&(o=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,o)}resize(h,e=!0){const[n,o]=this._containerDimensions(),c=this._getClampedPixelRatio(n,o);if(this._resizeCanvas(n,o,c),this.painter.resize(n,o,c),this.painter.overLimit()){const g=this.painter.context.gl;this._maxCanvasSize=[g.drawingBufferWidth,g.drawingBufferHeight];const v=this._getClampedPixelRatio(n,o);this._resizeCanvas(n,o,v),this.painter.resize(n,o,v)}this._resizeTransform(e);const d=!this._moving;return d&&(this.stop(),this.fire(new a.l("movestart",h)).fire(new a.l("move",h))),this.fire(new a.l("resize",h)),d&&this.fire(new a.l("moveend",h)),this}_resizeTransform(h=!0){var e;const[n,o]=this._containerDimensions();this.transform.resize(n,o,h),(e=this._requestedCameraState)===null||e===void 0||e.resize(n,o,h)}_getClampedPixelRatio(h,e){const{0:n,1:o}=this._maxCanvasSize,c=this.getPixelRatio(),d=h*c,g=e*c;return Math.min(d>n?n/d:1,g>o?o/g:1)*c}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(le.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.setMinZoom(h),this._update(),this.getZoom()<h&&this.setZoom(h),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(h){if((h=h??22)>=this.transform.minZoom)return this.transform.setMaxZoom(h),this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.setMinPitch(h),this._update(),this.getPitch()<h&&this.setPitch(h),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(h){if((h=h??60)>180)throw new Error("maxPitch must be less than or equal to 180");if(h>=this.transform.minPitch)return this.transform.setMaxPitch(h),this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.setRenderWorldCopies(h),this._update()}project(h){return this.transform.locationToScreenPoint(a.S.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.screenPointToLocation(a.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:d=>{const g=e.filter(x=>this.getLayer(x)),v=g.length!==0?this.queryRenderedFeatures(d.point,{layers:g}):[];v.length?o||(o=!0,n.call(this,new Cr(h,this,d.originalEvent,{features:v}))):o=!1},mouseout:()=>{o=!1}}}}if(h==="mouseleave"||h==="mouseout"){let o=!1;return{layers:e,listener:n,delegates:{mousemove:g=>{const v=e.filter(x=>this.getLayer(x));(v.length!==0?this.queryRenderedFeatures(g.point,{layers:v}):[]).length?o=!0:o&&(o=!1,n.call(this,new Cr(h,this,g.originalEvent)))},mouseout:g=>{o&&(o=!1,n.call(this,new Cr(h,this,g.originalEvent)))}}}}{const o=c=>{const d=e.filter(v=>this.getLayer(v)),g=d.length!==0?this.queryRenderedFeatures(c.point,{layers:d}):[];g.length&&(c.features=g,n.call(this,c),delete c.features)};return{layers:e,listener:n,delegates:{[h]:o}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const o=this._delegatedListeners[h];for(let c=0;c<o.length;c++){const d=o[c];if(d.listener===n&&d.layers.length===e.length&&d.layers.every(g=>e.includes(g))){for(const g in d.delegates)this.off(g,d.delegates[g]);return void o.splice(c,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const o=typeof e=="string"?[e]:e,c=this._createDelegatedListener(h,o,n);this._saveDelegatedListener(h,c);for(const d in c.delegates)this.on(d,c.delegates[d]);return{unsubscribe:()=>{this._removeDelegatedListener(h,o,n)}}}once(h,e,n){if(n===void 0)return super.once(h,e);const o=typeof e=="string"?[e]:e,c=this._createDelegatedListener(h,o,n);for(const d in c.delegates){const g=c.delegates[d];c.delegates[d]=(...v)=>{this._removeDelegatedListener(h,o,n),g(...v)}}this._saveDelegatedListener(h,c);for(const d in c.delegates)this.once(d,c.delegates[d]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const o=h instanceof a.P||Array.isArray(h),c=o?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(o?{}:h)||{},c instanceof a.P||typeof c[0]=="number")n=[a.P.convert(c)];else{const d=a.P.convert(c[0]),g=a.P.convert(c[1]);n=[d,new a.P(g.x,d.y),g,new a.P(d.x,g.y),d]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=a.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){var n,o;if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const c=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new sc(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,c):this.style.loadJSON(h,e,c),this):((o=(n=this.style)===null||n===void 0?void 0:n.projection)===null||o===void 0||o.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new sc(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");a.j(n,new AbortController).then(o=>{this._updateDiff(o.data,e)}).catch(o=>{o&&this.fire(new a.k(o))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){a.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new a.k(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const o=this.style._layers[n];o.type==="hillshade"&&o.source===h.source&&a.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),o.type==="color-relief"&&o.source===h.source&&a.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new ht(this.painter,e,h),this.painter.renderToTexture=new ul(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=n=>{var o;n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),((o=n.source)===null||o===void 0?void 0:o.type)==="image"?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new a.l("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const o in n){const c=n[o];if(c.state!=="loaded"&&c.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}setSourceTileLodParams(h,e,n){if(n){const o=this.getSource(n);if(!o)throw new Error(`There is no source with ID "${n}", cannot set LOD parameters`);o.calculateTileZoom=ke(Math.max(1,h),Math.max(1,e))}else for(const o in this.style.sourceCaches)this.style.sourceCaches[o].getSource().calculateTileZoom=ke(Math.max(1,h),Math.max(1,e));return this._update(!0),this}refreshTiles(h,e){const n=this.style.sourceCaches[h];if(!n)throw new Error(`There is no source cache with ID "${h}", cannot refresh tile`);e===void 0?n.reload(!0):n.refreshTiles(e.map(o=>new a.a4(o.z,o.x,o.y)))}addImage(h,e,n={}){const{pixelRatio:o=1,sdf:c=!1,stretchX:d,stretchY:g,content:v,textFitWidth:x,textFitHeight:P}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||a.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new a.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:C,height:k,data:A}=e,R=e;return this.style.addImage(h,{data:new a.R({width:C,height:k},new Uint8Array(A)),pixelRatio:o,stretchX:d,stretchY:g,content:v,textFitWidth:x,textFitHeight:P,sdf:c,version:0,userImage:R}),R.onAdd&&R.onAdd(this,h),this}}{const{width:C,height:k,data:A}=Se.getImageData(e);this.style.addImage(h,{data:new a.R({width:C,height:k},A),pixelRatio:o,stretchX:d,stretchY:g,content:v,textFitWidth:x,textFitHeight:P,sdf:c,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new a.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=e instanceof HTMLImageElement||a.b(e)?Se.getImageData(e):e,{width:c,height:d,data:g}=o;if(c===void 0||d===void 0)return this.fire(new a.k(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(c!==n.data.width||d!==n.data.height)return this.fire(new a.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const v=!(e instanceof HTMLImageElement||a.b(e));return n.data.replace(g,v),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new a.k(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return We.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,o={}){return this.style.setPaintProperty(h,e,n,o),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,o={}){return this.style.setLayoutProperty(h,e,n,o),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,o=>{o||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(h,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=Q.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=Q.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),o=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],o);const c=this._controlContainer=Q.create("div","maplibregl-control-container",h),d=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(g=>{d[g]=Q.create("div",`maplibregl-ctrl-${g} `,c)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",o=>{e={requestedAttributes:h},o&&(e.statusMessage=o.statusMessage,e.type=o.type)},{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,h):this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h),!n){const o="Failed to initialize WebGL";throw e?(e.message=o,new Error(JSON.stringify(e))):new Error(o)}this.painter=new _h(n,this.transform),He.testSupport(n)}migrateProjection(h,e){super.migrateProjection(h,e),this.painter.transform=h,this.fire(new a.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){var e,n,o,c,d;const g=this._idleTriggered?this._fadeDuration:0,v=((e=this.style.projection)===null||e===void 0?void 0:e.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let x=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const k=this.transform.zoom,A=Se.now();this.style.zoomHistory.update(k,A);const R=new a.F(k,{now:A,fadeDuration:g,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),O=R.crossFadingFactor();O===1&&O===this._crossFadingFactor||(x=!0,this._crossFadingFactor=O),this.style.update(R)}const P=((n=this.style.projection)===null||n===void 0?void 0:n.transitionState)>0!==v;(o=this.style.projection)===null||o===void 0||o.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState((c=this.style.projection)===null||c===void 0?void 0:c.transitionState,(d=this.style.projection)===null||d===void 0?void 0:d.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||P)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,g,this._crossSourceCollisions,P),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:g,showPadding:this.showPadding}),this.fire(new a.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,a.cw.mark(a.cx.load),this.fire(new a.l("load"))),this.style&&(this.style.hasTransitions()||x)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const C=this._sourcesDirty||this._styleDirty||this._placementDirty;return C||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new a.l("idle")),!this._loaded||this._fullyLoaded||C||(this._fullyLoaded=!0,a.cw.mark(a.cx.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),We.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),Q.remove(this._canvasContainer),Q.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),a.cw.clearMetrics(),this._removed=!0,this.fire(new a.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,Se.frame(this._frameRequest,h=>{a.cw.frame(h),this._frameRequest=null;try{this._render(h)}catch(e){if(!a.cy(e)&&!function(n){return n.message===Xo}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Rh}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(h){return this._lazyInitEmptyStyle(),this.style.setProjection(h),this._update(!0)}},T.MapMouseEvent=Cr,T.MapTouchEvent=oo,T.MapWheelEvent=Ec,T.Marker=mo,T.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),o=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",o.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,n)=>{const o=this._map._getUIString(`NavigationControl.${n}`);e.title=o,e.setAttribute("aria-label",o)},this.options=a.e({},vp,h),this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),Q.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),Q.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=Q.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new sa(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){Q.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=Q.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},T.Popup=class extends a.E{constructor(h){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&Q.remove(this._content),this._container&&(Q.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new a.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=Q.create("div","maplibregl-popup",this._map.getContainer()),this._tip=Q.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const g of this.options.className.split(" "))this._container.classList.add(g);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Si(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const n=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let o=this.options.anchor;const c=pl(this.options.offset);if(!o){const g=this._container.offsetWidth,v=this._container.offsetHeight;let x;x=n.y+c.bottom.y<v?["top"]:n.y>this._map.transform.height-v?["bottom"]:[],n.x<g/2?x.push("left"):n.x>this._map.transform.width-g/2&&x.push("right"),o=x.length===0?"bottom":x.join("-")}let d=n.add(c[o]);this.options.subpixelPositioning||(d=d.round()),Q.setTransform(this._container,`${hl[o]} translate(${d.x}px,${d.y}px)`),fo(this._container,o,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=a.e(Object.create(Nc),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new a.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=a.S.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let o;for(n.innerHTML=h;o=n.firstChild,o;)e.appendChild(o);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=Q.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=Q.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(Vc);h&&h.focus()}},T.RasterDEMTileSource=Re,T.RasterTileSource=Ae,T.ScaleControl=class{constructor(h){this._onMove=()=>{dl(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,dl(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},oa),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){Q.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},T.ScrollZoomHandler=Mh,T.Style=sc,T.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=Q.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=Q.create("button","maplibregl-ctrl-terrain",this._container),Q.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){Q.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},T.TwoFingersTouchPitchHandler=sl,T.TwoFingersTouchRotateHandler=ho,T.TwoFingersTouchZoomHandler=nl,T.TwoFingersTouchZoomRotateHandler=Eh,T.VectorTileSource=ze,T.VideoSource=Ge,T.addSourceType=(h,e)=>a._(void 0,void 0,void 0,function*(){if(Ke(h))throw new Error(`A source type called "${h}" already exists.`);((n,o)=>{ut[n]=o})(h,e)}),T.clearPrewarmedResources=function(){const h=Lr;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(Gr),Lr=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},T.createTileMesh=rc,T.getMaxParallelImageRequests=function(){return a.a.MAX_PARALLEL_IMAGE_REQUESTS},T.getRTLTextPluginStatus=function(){return Zt().getRTLTextPluginStatus()},T.getVersion=function(){return Uc},T.getWorkerCount=function(){return di.workerCount},T.getWorkerUrl=function(){return a.a.WORKER_URL},T.importScriptInWorkers=function(h){return tn().broadcast("IS",h)},T.prewarm=function(){En().acquire(Gr)},T.setMaxParallelImageRequests=function(h){a.a.MAX_PARALLEL_IMAGE_REQUESTS=h},T.setRTLTextPlugin=function(h,e){return Zt().setRTLTextPlugin(h,e)},T.setWorkerCount=function(h){di.workerCount=h},T.setWorkerUrl=function(h){a.a.WORKER_URL=h}});var D=b;return D})}(Ou)),Ou.exports}var Ia=Nx();const Hn=zx("instance",()=>{const u=Kr(null),m=Kr(null),b=Kr(null),M=Kr(null),E=Kr([]),D=Kr(!1),T=Kr({}),a=Kr(null),V=Kr("overlays"),ue=Kr("marker"),oe=Kr(!1),ge=Io({text:"",inBounds:!0}),Se=(Je={})=>{u.value=new lg(Je)},Q=Sr(()=>{const Je={marker:{},line:{},shape:{}};return E.value.forEach(Ye=>{const ct=Ye.typeKey||"undefined";Je[Ye.featureType][ct]||(Je[Ye.featureType][ct]=[]),Je[Ye.featureType][ct].push(Ye)}),Je}),He=Sr(()=>{const Je=[];return E.value.forEach(Ye=>{ge.value.inBounds&&!Ye.inBounds(M.value)||ge.value.text!==""&&!layer.overlay.containsText(ge.value.text)||Je.includes(Ye)||Je.push(Ye)}),Je}),Qe=Sr(()=>{if(E.value.length===0)return null;const Je=new Ia.LngLatBounds;return E.value.forEach(Ye=>{Je.extend(Ye.getBounds())}),Je});return{config:u,mapReady:oe,container:m,panelOpen:D,overlays:E,overlaysByType:Q,map:b,mapBounds:M,layerFilters:ge,activeTileLayer:T,activeOverlay:a,activePanelKey:V,activeFeatureType:ue,init:Se,overlaysByType:Q,filteredOverlays:He,overlaysBounds:Qe}});var Qr=63710088e-1,Vx={centimeters:Qr*100,centimetres:Qr*100,degrees:360/(2*Math.PI),feet:Qr*3.28084,inches:Qr*39.37,kilometers:Qr/1e3,kilometres:Qr/1e3,meters:Qr,metres:Qr,miles:Qr/1609.344,millimeters:Qr*1e3,millimetres:Qr*1e3,nauticalmiles:Qr/1852,radians:1,yards:Qr*1.0936};function $d(u,m,b={}){const M={type:"Feature"};return(b.id===0||b.id)&&(M.id=b.id),b.bbox&&(M.bbox=b.bbox),M.properties=m||{},M.geometry=u,M}function Ux(u,m,b={}){if(u.length<2)throw new Error("coordinates must be an array of two or more positions");return $d({type:"LineString",coordinates:u},m,b)}function $x(u,m="kilometers"){const b=Vx[m];if(!b)throw new Error(m+" units is invalid");return u*b}function ju(u){return u%360*Math.PI/180}function ug(u){if(!u)throw new Error("coord is required");if(!Array.isArray(u)){if(u.type==="Feature"&&u.geometry!==null&&u.geometry.type==="Point")return[...u.geometry.coordinates];if(u.type==="Point")return[...u.coordinates]}if(Array.isArray(u)&&u.length>=2&&!Array.isArray(u[0])&&!Array.isArray(u[1]))return[...u];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Gx(u,m,b={}){var M=ug(u),E=ug(m),D=ju(E[1]-M[1]),T=ju(E[0]-M[0]),a=ju(M[1]),V=ju(E[1]),ue=Math.pow(Math.sin(D/2),2)+Math.pow(Math.sin(T/2),2)*Math.cos(a)*Math.cos(V);return $x(2*Math.atan2(Math.sqrt(ue),Math.sqrt(1-ue)),b.units)}function hg(u,m,b){if(u!==null)for(var M,E,D,T,a,V,ue,oe=0,ge=0,Se,Q=u.type,He=Q==="FeatureCollection",Qe=Q==="Feature",Je=He?u.features.length:1,Ye=0;Ye<Je;Ye++){ue=He?u.features[Ye].geometry:Qe?u.geometry:u,Se=ue?ue.type==="GeometryCollection":!1,a=Se?ue.geometries.length:1;for(var ct=0;ct<a;ct++){var st=0,We=0;if(T=Se?ue.geometries[ct]:ue,T!==null){V=T.coordinates;var yt=T.type;switch(oe=0,yt){case null:break;case"Point":if(m(V,ge,Ye,st,We)===!1)return!1;ge++,st++;break;case"LineString":case"MultiPoint":for(M=0;M<V.length;M++){if(m(V[M],ge,Ye,st,We)===!1)return!1;ge++,yt==="MultiPoint"&&st++}yt==="LineString"&&st++;break;case"Polygon":case"MultiLineString":for(M=0;M<V.length;M++){for(E=0;E<V[M].length-oe;E++){if(m(V[M][E],ge,Ye,st,We)===!1)return!1;ge++}yt==="MultiLineString"&&st++,yt==="Polygon"&&We++}yt==="Polygon"&&st++;break;case"MultiPolygon":for(M=0;M<V.length;M++){for(We=0,E=0;E<V[M].length;E++){for(D=0;D<V[M][E].length-oe;D++){if(m(V[M][E][D],ge,Ye,st,We)===!1)return!1;ge++}We++}st++}break;case"GeometryCollection":for(M=0;M<T.geometries.length;M++)if(hg(T.geometries[M],m)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Zx(u,m){var b,M,E,D,T,a,V,ue,oe,ge,Se=0,Q=u.type==="FeatureCollection",He=u.type==="Feature",Qe=Q?u.features.length:1;for(b=0;b<Qe;b++){for(a=Q?u.features[b].geometry:He?u.geometry:u,ue=Q?u.features[b].properties:He?u.properties:{},oe=Q?u.features[b].bbox:He?u.bbox:void 0,ge=Q?u.features[b].id:He?u.id:void 0,V=a?a.type==="GeometryCollection":!1,T=V?a.geometries.length:1,E=0;E<T;E++){if(D=V?a.geometries[E]:a,D===null){if(m(null,Se,ue,oe,ge)===!1)return!1;continue}switch(D.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(m(D,Se,ue,oe,ge)===!1)return!1;break}case"GeometryCollection":{for(M=0;M<D.geometries.length;M++)if(m(D.geometries[M],Se,ue,oe,ge)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}Se++}}function qx(u,m){Zx(u,function(b,M,E,D,T){var a=b===null?null:b.type;switch(a){case null:case"Point":case"LineString":case"Polygon":return m($d(b,E,{bbox:D,id:T}),M,0)===!1?!1:void 0}var V;switch(a){case"MultiPoint":V="Point";break;case"MultiLineString":V="LineString";break;case"MultiPolygon":V="Polygon";break}for(var ue=0;ue<b.coordinates.length;ue++){var oe=b.coordinates[ue],ge={type:V,coordinates:oe};if(m($d(ge,E),M,ue)===!1)return!1}})}function Hx(u,m){qx(u,function(b,M,E){var D=0;if(b.geometry){var T=b.geometry.type;if(!(T==="Point"||T==="MultiPoint")){var a,V=0,ue=0,oe=0;if(hg(b,function(ge,Se,Q,He,Qe){if(a===void 0||M>V||He>ue||Qe>oe){a=ge,V=M,ue=He,oe=Qe,D=0;return}var Je=Ux([a,ge],b.properties);if(m(Je,M,E,Qe,D)===!1)return!1;D++,a=ge})===!1)return!1}}})}function Wx(u,m,b){var M=b,E=!1;return Hx(u,function(D,T,a,V,ue){E===!1&&b===void 0?M=D:M=m(M,D,T,a,V,ue),E=!0}),M}function Xx(u,m={}){return Wx(u,(b,M)=>{const E=M.geometry.coordinates;return b+Gx(E[0],E[1],m)},0)}class Nu{constructor(m,b,M=null){if(!m||m.type!=="Feature")throw new Error("Valid GeoJSON Feature required");if(this.feature=m,M==null||typeof M!="string")throw new Error("Valid ID string required");if(this.id=M,!(b instanceof lg))throw new Error("Valid Config required");if(this.config=b,this.featureType=rg(this.feature)||null,this.feature.properties=this.feature.properties||{},this.title=this.feature.properties.title||"",this.description=this.feature.properties.description||"",this.images=Lx(this.feature),this.typeKey=this.getTypeKey()||null,this.type=this.config.getType(this.featureType,this.typeKey),!this.type){console.error(`Type not found for ${featureType} Type ${typeKey}`,m);return}}addTo(m){!m||!m.addLayer||(this.map=m,this.map.addSource(this.id,{type:"geojson",data:this.feature}),this.source=this.map.getSource(this.id),this instanceof Vu?(this.marker=this.toMarker(),this.marker.addTo(this.map)):(this.style=this.toStyle(),this.map.addLayer(this.style)),this.layer=this.map.getLayer(this.id),this.addEvents())}remove(){this.map&&(this instanceof Vu&&this.marker&&(this.marker.remove(),this.marker=null),this.map.getLayer(this.id)&&this.map.removeLayer(this.id),this.map.getSource(this.id)&&this.map.removeSource(this.id),this.map=null,this.source=null,this.layer=null,this.style=null)}toGeoJSON(){return this.feature}getTypeKey(){return!this.feature.properties.type||typeof this.feature.properties.type!="string"?null:this.feature.properties.type}hasImage(){return this.feature.properties.image_thumbnail_url||this.feature.properties.image_medium_url||this.feature.properties.image_large_url}getImage(m="thumbnail"){return this.images[m]}getTitle(){return this.title}getDescription(){return this.description}containsText(m=""){let b=0;return b+=this.type.getTitle().toString().toLowerCase().includes(m.toLowerCase()),b+=Object.values(this.feature.properties).some(M=>M.toString().toLowerCase().includes(m.toLowerCase())),b>0}zoomIn(){if(!this.map)return;const m=18;this.map.getZoom()<m&&this.map.flyTo({center:[this.feature.geometry.coordinates[0],this.feature.geometry.coordinates[1]],zoom:m,duration:1e3})}}class Vu extends Nu{constructor(m,b,M){super(m,b,M)}toMarker(){const m=document.createElement("div");m.className=this.type.iconData.className,m.innerHTML=this.type.iconData.html,m.style.width=`${this.type.iconData.iconSize[0]}px`,m.style.height=`${this.type.iconData.iconSize[1]}px`;const b=new Ia.Marker({element:m,offset:this.type.iconData.iconAnchor});return b.setLngLat(this.feature.geometry.coordinates),b}addEvents(){}hasElevationData(){return this.feature.geometry.coordinates.length===3}getElevationString(){if(!this.hasElevationData())return"";const m=this.config.getMapOption("units")==="metric"?"m":"ft";return"Elevation: "+Math.round(this.feature.geometry.coordinates[2]*10)/10+m}getBounds(){return new Ia.LngLatBounds([this.feature.geometry.coordinates[0],this.feature.geometry.coordinates[1]],[this.feature.geometry.coordinates[0],this.feature.geometry.coordinates[1]])}getCoordsString(){return"Lat,Lng: "+this.feature.geometry.coordinates[1].toFixed(6)+", "+this.feature.geometry.coordinates[0].toFixed(6)}addHighlight(){const m=this.marker.getElement(),b=m.querySelector(".waymark-marker-background");b&&(b.style.borderColor=Du),m.classList.add("waymark-active")}removeHighlight(){this.marker.getElement().classList.remove("waymark-active")}flyTo(){this.map.flyTo({center:[this.feature.geometry.coordinates[0],this.feature.geometry.coordinates[1]],...Rx})}inBounds(m){return m.contains({lng:this.feature.geometry.coordinates[0],lat:this.feature.geometry.coordinates[1]})}}class Kx extends Nu{constructor(m,b,M){super(m,b,M)}toStyle(){return{id:this.id,type:"line",source:this.id,layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":this.type.getPrimaryColour(),"line-width":parseFloat(this.type.data.line_weight)}}}addEvents(){this.map.on("mouseenter",this.id,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",this.id,()=>{this.map.getCanvas().style.cursor=""})}getLengthString(){let m="";m+="Length: ";const b=Xx(this.feature,{units:this.config.getMapOption("units")==="metric"?"kilometers":"miles"});return m+=Math.round(b*100)/100,m+=this.config.getMapOption("units")==="metric"?"km":"mi",m}hasElevationData(){if(this.feature.geometry.type=="MultiLineString"){for(var m in this.feature.geometry.coordinates)for(var b in this.feature.geometry.coordinates[m])if(this.feature.geometry.coordinates[m][b].length==3)return!0}else for(var b in this.feature.geometry.coordinates)if(this.feature.geometry.coordinates[b].length==3)return!0;return!1}getElevationString(){if(!this.hasElevationData())return"";const m=this.config.getMapOption("units")==="metric"?"m":"ft",b=this.feature.geometry.coordinates;let M=0,E=0,D=b[0][2],T=b[0][2];for(let a=1;a<b.length;a++){const V=b[a][2]-b[a-1][2];V>0?M+=V:E-=V,D=Math.max(D,b[a][2]),T=Math.min(T,b[a][2])}return this.config.getMapOption("units")==="imperial"&&(M*=3.28084,E*=3.28084,D*=3.28084,T*=3.28084),"Elevation Gain: "+Math.round(M*10)/10+m+", Loss: "+Math.round(E*10)/10+m+", Max: "+Math.round(D*10)/10+m+", Min: "+Math.round(T*10)/10+m}getBounds(){const m=this.feature.geometry.coordinates;return m.reduce((b,M)=>b.extend(M),new Ia.LngLatBounds(m[0],m[0]))}getCoordsString(){const b=this.getBounds().getCenter();return"Centre Lat,Lng: "+b.lat.toFixed(6)+", "+b.lng.toFixed(6)}addHighlight(){this.map.setPaintProperty(this.id,"line-color",Du),this.map.setPaintProperty(this.id,"line-dasharray",[2,4])}removeHighlight(){this.map.setPaintProperty(this.id,"line-color",this.type.getPrimaryColour()),this.map.setPaintProperty(this.id,"line-dasharray",null)}flyTo(){const m=this.getBounds();this.map.fitBounds(m,Nd)}inBounds(m){return this.feature.geometry.coordinates.some(M=>m.contains({lng:M[0],lat:M[1]}))}}class Yx extends Nu{constructor(m,b,M){super(m,b,M)}toStyle(){return{id:this.id,type:"fill",source:this.id,layout:{},paint:{"fill-color":this.type.data.shape_colour||"#000000","fill-opacity":parseFloat(this.type.data.fill_opacity)||.5,"fill-outline-color":this.type.data.shape_colour||"#000000"}}}addEvents(){this.map.on("mouseenter",this.id,()=>{this.map.getCanvas().style.cursor="pointer"}),this.map.on("mouseleave",this.id,()=>{this.map.getCanvas().style.cursor=""})}hasElevationData(){if(this.feature.geometry.type=="MultiPolygon"){for(var m in this.feature.geometry.coordinates)for(var b in this.feature.geometry.coordinates[m])for(var M in this.feature.geometry.coordinates[m][b])if(this.feature.geometry.coordinates[m][b][M].length==3)return!0}else for(var b in this.feature.geometry.coordinates)for(var M in this.feature.geometry.coordinates[b])if(this.feature.geometry.coordinates[b][M].length==3)return!0;return!1}getElevationString(){return this.hasElevationData()?(this.config.getMapOption("units"),"Elevation data available"):""}getBounds(){const m=this.feature.geometry.coordinates[0];return m.reduce((b,M)=>b.extend(M),new Ia.LngLatBounds(m[0],m[0]))}getCoordsString(){const b=this.getBounds().getCenter();return"Centre Lat,Lng: "+b.lat.toFixed(6)+", "+b.lng.toFixed(6)}addHighlight(){this.map.setPaintProperty(this.id,"fill-color",Du),this.map.setPaintProperty(this.id,"fill-opacity",.5),this.map.setPaintProperty(this.id,"fill-outline-color",Du)}removeHighlight(){this.map.setPaintProperty(this.id,"fill-color",this.type.getPrimaryColour())}flyTo(){const m=this.getBounds();this.map.fitBounds(m,Nd)}inBounds(m){return this.feature.geometry.coordinates[0].some(M=>m.contains({lng:M[0],lat:M[1]}))}}function Ea(){const{config:u,map:m,mapReady:b,mapBounds:M,overlays:E,overlaysBounds:D,activeOverlay:T,activeFeatureType:a,panelOpen:V,activePanelKey:ue,activeTileLayer:oe}=qn(Hn()),ge=()=>{const Je={...u.value.mapLibreOptions,container:`${u.value.getMapOption("div_id")}-map`};m.value=new Ia.Map(Je),m.value.on("load",()=>{u.value.getTileLayers().forEach(Ye=>{oe.value.id||(oe.value=Ye),Ye.addTo(m.value,Ye===oe.value)}),b.value=!0,M.value=m.value.getBounds()}),m.value.on("click",Ye=>{const ct=[[Ye.point.x-10,Ye.point.y-10],[Ye.point.x+10,Ye.point.y+10]],st=m.value.queryRenderedFeatures(ct,{layers:E.value.filter(We=>We.featureType!=="marker").map(We=>We.id)});if(st.length){const We=E.value.find(yt=>yt.id===st[0].layer.id);We&&Qe(We)}else Qe()}),m.value.on("moveend",()=>{M.value=m.value.getBounds()})},Se=Je=>{if(Je&&Array.isArray(Je.features)){if(console.log("Adding GeoJSON to Map",Je),!b.value){m.value.on("load",()=>{Se(Je)});return}Je.features.forEach(Ye=>{const ct=rg(Ye);if(!ct||!ig.includes(ct)){console.warn("Feature Type not recognised or supported - skipping",Ye);return}const st=`overlay-${E.value.length}`,We=(()=>{switch(ct){case"marker":return new Vu(Ye,u.value,st);case"line":return new Kx(Ye,u.value,st);case"shape":return new Yx(Ye,u.value,st)}})();E.value=[...E.value,We],We.addTo(m.value),We instanceof Vu&&We.marker.getElement().addEventListener("click",yt=>{yt.stopPropagation(),Qe(We)})}),console.log("Overlays added to map",D.value),m.value.fitBounds(D.value,Nd)}},Q=()=>{E.value.forEach(Je=>{Je.remove()}),E.value=[],T.value=null},He=()=>{const Je={type:"FeatureCollection",features:[]};return E.value.forEach(Ye=>{Je.features.push(Ye.toGeoJSON())}),Je},Qe=(Je=null)=>{if(!Je){T.value&&T.value.removeHighlight(),T.value=null;return}if(T.value){if(T.value===Je){switch(Je.featureType){case"marker":Je.zoomIn();break}return}T.value.removeHighlight(),T.value=null}a.value=Je.featureType,ue.value="overlays",V.value=!0,T.value=Je,Je.flyTo(),Je.addHighlight()};return{init:ge,loadGeoJSON:Se,clearGeoJSON:Q,toGeoJSON:He,setActiveOverlay:Qe}}const Jx=["id"],Qx={__name:"Map",setup(u){const{config:m}=qn(Hn()),{init:b}=Ea();return xd(()=>{b()}),(M,E)=>(jt(),li("div",{class:"map",id:`${dt(m).getMapOption("div_id")}-map`,style:{height:"100%"}},null,8,Jx))}};function e0(){const{panelOpen:u,activePanelKey:m,overlays:b}=qn(Hn()),M=Kr(null),E=ge=>{M.value=ge},D=Sr(()=>b.value.length>0);return{setUIContainer:E,isActivePanel:ge=>u.value&&m.value===ge,showPanel:ge=>m.value===ge&&u.value,togglePanel:()=>{u.value=!u.value},setActivePanel:(ge="overlays")=>{m.value=ge,u.value=!0},getActivePanelKey:()=>m.value,mapHasOverlays:D}}const t0={class:"preview"},i0={key:0,class:"marker"},r0=["innerHTML"],n0={key:1,class:"line"},s0={key:2,class:"shape"},o0={width:"100%",height:"100%",viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg"},a0=["fill"],dg={__name:"Preview",props:{type:{type:Fu,required:!0}},setup(u){return(m,b)=>(jt(),li("div",t0,[u.type instanceof dt(Bu)?(jt(),li("div",i0,[Et("div",{class:Vn(["waymark-marker",u.type.iconData.className]),innerHTML:u.type.iconData.html,style:Po(`width:${u.type.iconData.iconSize[0]}px;height:${u.type.iconData.iconSize[1]}px`)},null,14,r0)])):u.type instanceof dt(Vd)?(jt(),li("div",n0,[Et("div",{class:"inner",style:Po(`background-color:${u.type.getPrimaryColour()};height:${u.type.getLineWeight()}px`)},null,4)])):u.type instanceof dt(Ud)?(jt(),li("div",s0,[(jt(),li("svg",o0,[Et("circle",{cx:"50",cy:"50",r:"40",fill:u.type.getPrimaryColour()},null,8,a0)]))])):Ur("",!0)]))}},In={__name:"Button",props:{icon:{type:String,default:""},active:{type:Boolean,default:!1}},setup(u){const m=b=>{let M="";switch(!0){case b.startsWith("fa-"):M+=`fa ${b} `;break;case b.startsWith("ion-"):M+=`ion ${b} `;break}return M.trim()};return(b,M)=>(jt(),li("div",{class:Vn(["button",u.active?"active":""])},[u.icon?(jt(!0),li(er,{key:0},wa(u.icon.split(" "),(E,D)=>(jt(),li("i",{class:Vn(`${m(E)}`)},null,2))),256)):Ur("",!0),nv(b.$slots,"default")],2))}},l0={key:0,class:"active-layer"},c0={class:"layer-top"},u0={class:"type"},h0={class:"title"},d0={class:"layer-content"},p0={key:0,class:"image"},f0=["src"],m0={class:"stats"},g0={class:"coordinates"},_0=["innerHTML"],y0={key:1,class:"elevation"},v0=["innerHTML"],x0={__name:"Active",setup(u){const{activeOverlay:m}=qn(Hn()),{setActiveOverlay:b}=Ea();return(M,E)=>dt(m)?(jt(),li("div",l0,[Et("div",c0,[Et("div",u0,[Pi(dg,{type:dt(m).type},null,8,["type"])]),Et("div",h0,$s(dt(m).getTitle()),1),Pi(In,{icon:"ion-close",onClick:E[0]||(E[0]=D=>dt(b)(null))})]),Et("div",d0,[dt(m).hasImage()?(jt(),li("div",p0,[dt(m).images.thumbnail?(jt(),li("img",{key:0,src:dt(m).images.thumbnail},null,8,f0)):Ur("",!0)])):Ur("",!0),Et("div",m0,[Et("div",g0,$s(dt(m).getCoordsString()),1),dt(m).featureType==="line"?(jt(),li("div",{key:0,class:"length",innerHTML:dt(m).getLengthString()},null,8,_0)):Ur("",!0),dt(m).hasElevationData()?(jt(),li("div",y0,$s(dt(m).getElevationString()),1)):Ur("",!0)]),dt(m).getDescription()?(jt(),li("div",{key:1,class:"description",innerHTML:dt(m).getDescription()},null,8,v0)):Ur("",!0)])])):Ur("",!0)}},b0={class:"image"},w0=["alt","src"],T0={class:"title",colspan:"2"},S0={class:"content"},P0={class:"action visible"},M0={__name:"Overlay",props:{overlay:Nu},setup(u){const{setActiveOverlay:m}=Ea(),b=Hn(),{map:M,activeOverlay:E,filteredOverlays:D}=qn(b),T=u;let a=Io(!0);const V=Sr(()=>E.value===T.overlay),ue=Sr(()=>D.value.includes(T.overlay)),oe=()=>{a.value=!a.value,V.value&&(removeLayerHighlight(E.value),E.value=null),M.value.removeLayer(T.overlay),a.value&&M.value.addLayer(T.overlay)},ge=Sr(()=>{if(V.value)switch(T.overlay.featureType){case"marker":return`color: ${T.overlay.type.getIconColour()};background-color: ${T.overlay.type.getPrimaryColour()};`;case"line":return`background-color: ${T.overlay.type.getPrimaryColour()};`;case"shape":return`background-color: ${T.overlay.type.getPrimaryColour()};`}}),Se=Sr(()=>{let He=T.overlay.featureType;return V.value&&(He+=" active "),ue.value||(He+=" hidden "),He}),Q=Kf("row");return Ta(E,He=>{He==T.overlay&&Q.value.scrollIntoView({behavior:"smooth",block:"center"})}),(He,Qe)=>(jt(),li("tr",{ref_key:"row",ref:Q,class:Vn(["overlay",Se.value]),onClick:Qe[1]||(Qe[1]=Je=>dt(m)(u.overlay)),style:Po(ge.value)},[Et("td",b0,[u.overlay.hasImage()?(jt(),li("img",{key:0,alt:u.overlay.getTitle(),src:u.overlay.getImage("thumbnail")},null,8,w0)):Ur("",!0)]),Et("td",T0,[Et("div",S0,$s(u.overlay.getTitle()),1)]),Et("td",P0,[Pi(In,{icon:dt(ag)(dt(a)),onClick:Qe[0]||(Qe[0]=Fd(Je=>oe(),["stop"]))},null,8,["icon"])])],6))}},C0={class:"icon"},I0={class:"title"},E0={class:"content"},A0={class:"action expand"},k0={class:"count"},z0={class:"action visible"},Gd={__name:"Type",props:{featureType:String,typeKey:String,overlays:Array},setup(u){const{map:m,filteredOverlays:b,config:M}=qn(Hn()),E=u;let D=Io(!0),T=Io(!0);const a=Sr(()=>{let Q=0;return E.overlays.forEach(He=>{b.value.includes(He)&&Q++}),Q}),V=()=>{T.value=!T.value,T.value||(D.value=!1),E.layerGroup.eachLayer(Q=>{m.value.removeLayer(Q),T.value&&m.value.addLayer(Q)})},ue=M.value.getType(E.featureType,E.typeKey),oe=()=>{let Q="";switch(E.featureType){case"marker":Q+=`color:${ue.getIconColour()};`,Q+=`border-color:${ue.getIconColour()};`,Q+=`background-color:${ue.getPrimaryColour()};`;break;case"line":Q+=`border-color:${ue.getPrimaryColour()};`,Q+=`background-color:${ue.getPrimaryColour()};`;break}return Q},ge=()=>{D.value=!D.value},Se=()=>{let Q="";return Q+=` ${E.featureType}`,Q+=` ${E.typeKey}`,a.value||(Q+=" hidden"),Q};return(Q,He)=>(jt(),li(er,null,[Et("tr",{class:Vn(["heading",Se()]),style:Po(oe()),onClick:He[1]||(He[1]=Fd(Qe=>ge(),["stop"]))},[Et("td",C0,[Pi(dg,{type:dt(ue)},null,8,["type"])]),Et("td",I0,[Et("div",E0,$s(dt(ue).getTitle()),1)]),Et("td",A0,[Pi(In,{icon:dt(Bx)(dt(D))},{default:jl(()=>[Et("span",k0,$s(a.value),1)]),_:1},8,["icon"])]),Et("td",z0,[Pi(In,{icon:dt(ag)(dt(T)),onClick:He[0]||(He[0]=Fd(Qe=>V(),["stop"]))},null,8,["icon"])])],6),(jt(!0),li(er,null,wa(u.overlays,Qe=>Ao((jt(),vn(M0,{overlay:Qe},null,8,["overlay"])),[[Pa,dt(D)]])),256))],64))}},R0={class:"panel overlay"},D0={class:"panel-top"},L0={class:"feature-nav"},F0=["innerHTML"],B0=["innerHTML"],O0=["innerHTML"],j0={class:"panel-content"},N0={class:"marker-types type-list"},V0={class:"line-types type-list"},U0={class:"shape-types type-list"},$0={__name:"Overlays",setup(u){const{layerFilters:m,overlaysByType:b,activeFeatureType:M,filteredOverlays:E}=qn(Hn()),D=Sr(()=>E.value.filter(V=>V.featureType==="marker").length),T=Sr(()=>E.value.filter(V=>V.featureType==="line").length),a=Sr(()=>E.value.filter(V=>V.featureType==="shape").length);return(V,ue)=>(jt(),li("div",R0,[Et("header",D0,[Pi(x0),Et("nav",L0,[D.value?(jt(),vn(In,{key:0,class:"marker",icon:"ion-ios-location",onClick:ue[0]||(ue[0]=oe=>M.value="marker"),active:dt(M)==="marker"},{default:jl(()=>[Et("span",{class:"count",innerHTML:D.value},null,8,F0)]),_:1},8,["active"])):Ur("",!0),T.value?(jt(),vn(In,{key:1,class:"line",icon:"ion-arrow-graph-up-right",onClick:ue[1]||(ue[1]=oe=>M.value="line"),active:dt(M)==="line"},{default:jl(()=>[Et("span",{class:"count",innerHTML:T.value},null,8,B0)]),_:1},8,["active"])):Ur("",!0),a.value?(jt(),vn(In,{key:2,class:"shape",icon:"ion-android-checkbox-outline-blank",onClick:ue[2]||(ue[2]=oe=>M.value="shape"),active:dt(M)==="shape"},{default:jl(()=>[Et("span",{class:"count",innerHTML:a.value},null,8,O0)]),_:1},8,["active"])):Ur("",!0),Pi(In,{icon:"ion-android-expand",onClick:ue[3]||(ue[3]=oe=>dt(m).inBounds=!dt(m).inBounds),active:dt(m).inBounds},null,8,["active"]),Ao(Et("input",{type:"search",placeholder:"Search","onUpdate:modelValue":ue[4]||(ue[4]=oe=>dt(m).text=oe)},null,512),[[yx,dt(m).text]])])]),Et("div",j0,[Ao(Et("table",N0,[(jt(!0),li(er,null,wa(Object.keys(dt(b).marker),oe=>(jt(),vn(Gd,{key:oe,featureType:"marker",overlays:dt(b).marker[oe],typeKey:oe},null,8,["overlays","typeKey"]))),128))],512),[[Pa,dt(M)==="marker"]]),Ao(Et("table",V0,[(jt(!0),li(er,null,wa(Object.keys(dt(b).line),oe=>(jt(),vn(Gd,{key:oe,featureType:"line",overlays:dt(b).line[oe],typeKey:oe},null,8,["overlays","typeKey"]))),128))],512),[[Pa,dt(M)==="line"]]),Ao(Et("table",U0,[(jt(!0),li(er,null,wa(Object.keys(dt(b).shape),oe=>(jt(),vn(Gd,{key:oe,featureType:"shape",overlays:dt(b).shape[oe],typeKey:oe},null,8,["overlays","typeKey"]))),128))],512),[[Pa,dt(M)==="shape"]])])]))}},G0={class:"panel basemaps"},Z0={class:"list"},q0=["onClick"],H0=["src","alt"],W0={class:"info"},X0=["innerHTML"],K0={__name:"Basemaps",setup(u){const{config:m,map:b,activeTileLayer:M}=qn(Hn()),E=a=>{const V=a.data.layer_url,ue=(Je,Ye)=>Math.floor((Je+180)/360*Math.pow(2,Ye)),oe=(Je,Ye)=>Math.floor((1-Math.log(Math.tan(Je*Math.PI/180)+1/Math.cos(Je*Math.PI/180))/Math.PI)/2*Math.pow(2,Ye)),ge=parseInt(b.value.getZoom()),Se=b.value.getCenter().lat,Q=b.value.getCenter().lng,He=ue(Q,ge),Qe=oe(Se,ge);return V.replace("{z}",ge).replace("{x}",He).replace("{y}",Qe)},D=a=>{M.value=a,b.value.getStyle().layers.forEach(V=>{V.type==="raster"&&(b.value.setLayoutProperty(V.id,"visibility","none"),a.id==V.id&&b.value.setLayoutProperty(V.id,"visibility","visible"))})},T=m.value.getTileLayers();return(a,V)=>(jt(),li("div",G0,[V[0]||(V[0]=Et("h3",null,"Basemaps",-1)),Et("div",Z0,[(jt(!0),li(er,null,wa(dt(T),(ue,oe)=>(jt(),li("div",{class:Vn(["list-item",{active:dt(M)===ue}]),key:oe,onClick:ge=>D(ue)},[Et("img",{src:E(ue),alt:ue.data.layer_name,width:"160",height:"160"},null,8,H0),Et("div",W0,[Et("h4",null,$s(ue.data.layer_name),1),Et("p",{innerHTML:ue.data.layer_attribution},null,8,X0)])],10,q0))),128))])]))}},Y0={class:"panels-nav"},J0={class:"nav-item nav-overlays"},Q0={class:"nav-item nav-info"},eb={class:"nav-item nav-basemaps"},tb={class:"panels-content"},ib={__name:"UI",setup(u){const{showPanel:m,togglePanel:b,setActivePanel:M,isActivePanel:E,getActivePanelKey:D,setUIContainer:T,mapHasOverlays:a}=e0(),V=(oe="overlays")=>{oe===D()?b():M(oe)},ue=Kf("container");return xd(()=>{T(ue.value)}),(oe,ge)=>(jt(),li("div",{class:"ui",ref_key:"container",ref:ue},[Et("nav",Y0,[Et("div",J0,[dt(a)?(jt(),vn(In,{key:0,icon:"fa-navicon",onClick:ge[0]||(ge[0]=Se=>V("overlays")),active:dt(E)("overlays")},null,8,["active"])):Ur("",!0)]),Et("div",Q0,[Pi(In,{icon:"fa-info",onClick:ge[1]||(ge[1]=Se=>V("info")),active:dt(E)("info")},null,8,["active"])]),Et("div",eb,[Pi(In,{icon:"fa-map",onClick:ge[2]||(ge[2]=Se=>V("basemaps")),active:dt(E)("basemaps")},null,8,["active"])])]),Et("div",tb,[Ao(Pi($0,null,null,512),[[Pa,dt(a)&&dt(m)("overlays")]]),Ao(Pi(K0,null,null,512),[[Pa,dt(m)("basemaps")]])])],512))}},rb=["id"],nb={__name:"Instance",props:{map_options:{type:Object,default:()=>({})},viewer_options:{type:Object,default:()=>({})}},setup(u){const m=Hn(),{mapReady:b,config:M,container:E,panelOpen:D,activeOverlay:T}=qn(m),a=u;m.init(a),E.value=document.getElementById(`${M.value.getMapOption("div_id")}`);const V=Sr(()=>{let ue=[""];return D.value?ue.push("panel-open"):ue.push("panel-closed"),E.value.clientWidth>E.value.clientHeight?ue.push("orientation-landscape"):ue.push("orientation-portrait"),E.value.clientWidth<=375&&ue.push("display-narrow"),T.value&&ue.push("has-active-layer"),ue.join(" ")});return(ue,oe)=>(jt(),li("div",{ref_key:"container",ref:E,class:Vn(`instance ${V.value}`),id:`${dt(M).map_options.div_id}-instance`},[Pi(Qx),dt(b)?(jt(),vn(ib,{key:0})):Ur("",!0)],10,rb))}};function sb(){return{createInstance:m=>{if(typeof m.map_options.div_id>"u"){console.error("No Container ID provided for Waymark instance.");return}const b=Tx(nb,m),M=Mx();return b.use(M),b.mount("#"+m.map_options.div_id),{store:qn(Hn()),loadGeoJSON:Ea().loadGeoJSON,toGeoJSON:Ea().toGeoJSON,clearGeoJSON:Ea().clearGeoJSON}}}}document.body.classList.add("app"),console.clear();const{createInstance:ob}=sb(),pg=["waymark","af-ccc","lemiecime-it","via-ardeche"];function fg(){return pg[Math.floor(Math.random()*pg.length)]}init(async()=>{var u,m,b;{let M=fg();const E=document.createElement("div");E.id="dev-waymark-app",E.className="test-wrap",document.body.appendChild(E);let D=await fetch(`./data/${M}/devConfig.json`).then(ge=>ge.json());D=Object.assign(D,{div_id:E.id,units:"metric",maplibre_options:{}});const T=await fetch(`./data/${M}/devData.json`).then(ge=>ge.json()),{store:a,loadGeoJSON:V,clearGeoJSON:ue,toGeoJSON:oe}=ob({map_options:D});V(T),Ta(a.activeOverlay,ge=>{console.log("Active Overlay Changed:",ge)}),(u=document.querySelector("button#clear"))==null||u.addEventListener("click",()=>{ue()}),(m=document.querySelector("button#import"))==null||m.addEventListener("click",async()=>{M=fg();const ge=await fetch(`./data/${M}/devData.json`).then(Se=>Se.json());V(ge)}),(b=document.querySelector("button#export"))==null||b.addEventListener("click",()=>{const ge=JSON.stringify(oe(),null,2);console.log("Exported GeoJSON:",ge);const Se=new Blob([ge],{type:"application/json"}),Q=URL.createObjectURL(Se),He=document.createElement("a");He.href=Q,He.download="waymark-export.geojson",He.click(),URL.revokeObjectURL(Q)})}}),init()});